pandorga 1.3.11 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,295 @@
1
+ var Tg=Object.defineProperty;var Ag=(t,e,n)=>e in t?Tg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ce=(t,e,n)=>Ag(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const Eg="modulepreload",Ng=function(t){return"/studio/"+t},Tc={},Og=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),a=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=s(n.map(c=>{if(c=Ng(c),c in Tc)return;Tc[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":Eg,u||(p.as="script"),p.crossOrigin="",p.href=c,a&&p.setAttribute("nonce",a),document.head.appendChild(p),u)return new Promise((h,g)=>{p.addEventListener("load",h),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return i.then(s=>{for(const l of s||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})};function Lg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pe={},$i={},Wt={},Ac;function mi(){if(Ac)return Wt;Ac=1;function t(s){return typeof s>"u"||s===null}function e(s){return typeof s=="object"&&s!==null}function n(s){return Array.isArray(s)?s:t(s)?[]:[s]}function r(s,l){if(l){const a=Object.keys(l);for(let c=0,u=a.length;c<u;c+=1){const d=a[c];s[d]=l[d]}}return s}function i(s,l){let a="";for(let c=0;c<l;c+=1)a+=s;return a}function o(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return Wt.isNothing=t,Wt.isObject=e,Wt.toArray=n,Wt.repeat=i,Wt.isNegativeZero=o,Wt.extend=r,Wt}var Bs,Ec;function gi(){if(Ec)return Bs;Ec=1;function t(n,r){let i="";const o=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(i+='in "'+n.mark.name+'" '),i+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(i+=`
2
+
3
+ `+n.mark.snippet),o+" "+i):o}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Bs=e,Bs}var _s,Nc;function Ig(){if(Nc)return _s;Nc=1;const t=mi();function e(i,o,s,l,a){let c="",u="";const d=Math.floor(a/2)-1;return l-o>d&&(c=" ... ",o=l-d+c.length),s-l>d&&(u=" ...",s=l+d-u.length),{str:c+i.slice(o,s).replace(/\t/g,"→")+u,pos:l-o+c.length}}function n(i,o){return t.repeat(" ",o-i.length)+i}function r(i,o){if(o=Object.create(o||null),!i.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const s=/\r?\n|\r|\0/g,l=[0],a=[];let c,u=-1;for(;c=s.exec(i.buffer);)a.push(c.index),l.push(c.index+c[0].length),i.position<=c.index&&u<0&&(u=l.length-2);u<0&&(u=l.length-1);let d="";const p=Math.min(i.line+o.linesAfter,a.length).toString().length,h=o.maxLength-(o.indent+p+3);for(let b=1;b<=o.linesBefore&&!(u-b<0);b++){const x=e(i.buffer,l[u-b],a[u-b],i.position-(l[u]-l[u-b]),h);d=t.repeat(" ",o.indent)+n((i.line-b+1).toString(),p)+" | "+x.str+`
4
+ `+d}const g=e(i.buffer,l[u],a[u],i.position,h);d+=t.repeat(" ",o.indent)+n((i.line+1).toString(),p)+" | "+g.str+`
5
+ `,d+=t.repeat("-",o.indent+p+3+g.pos)+`^
6
+ `;for(let b=1;b<=o.linesAfter&&!(u+b>=a.length);b++){const x=e(i.buffer,l[u+b],a[u+b],i.position-(l[u]-l[u+b]),h);d+=t.repeat(" ",o.indent)+n((i.line+b+1).toString(),p)+" | "+x.str+`
7
+ `}return d.replace(/\n$/,"")}return _s=r,_s}var zs,Oc;function We(){if(Oc)return zs;Oc=1;const t=gi(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const s={};return o!==null&&Object.keys(o).forEach(function(l){o[l].forEach(function(a){s[String(a)]=l})}),s}function i(o,s){if(s=s||{},Object.keys(s).forEach(function(l){if(e.indexOf(l)===-1)throw new t('Unknown option "'+l+'" is met in definition of "'+o+'" YAML type.')}),this.options=s,this.tag=o,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(l){return l},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=r(s.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return zs=i,zs}var Fs,Lc;function cf(){if(Lc)return Fs;Lc=1;const t=gi(),e=We();function n(o,s){const l=[];return o[s].forEach(function(a){let c=l.length;l.forEach(function(u,d){u.tag===a.tag&&u.kind===a.kind&&u.multi===a.multi&&(c=d)}),l[c]=a}),l}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function s(l){l.multi?(o.multi[l.kind].push(l),o.multi.fallback.push(l)):o[l.kind][l.tag]=o.fallback[l.tag]=l}for(let l=0,a=arguments.length;l<a;l+=1)arguments[l].forEach(s);return o}function i(o){return this.extend(o)}return i.prototype.extend=function(s){let l=[],a=[];if(s instanceof e)a.push(s);else if(Array.isArray(s))a=a.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(l=l.concat(s.implicit)),s.explicit&&(a=a.concat(s.explicit));else throw new t("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");l.forEach(function(u){if(!(u instanceof e))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(u.loadKind&&u.loadKind!=="scalar")throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(u.multi)throw new t("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),a.forEach(function(u){if(!(u instanceof e))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.")});const c=Object.create(i.prototype);return c.implicit=(this.implicit||[]).concat(l),c.explicit=(this.explicit||[]).concat(a),c.compiledImplicit=n(c,"implicit"),c.compiledExplicit=n(c,"explicit"),c.compiledTypeMap=r(c.compiledImplicit,c.compiledExplicit),c},Fs=i,Fs}var Hs,Ic;function uf(){if(Ic)return Hs;Ic=1;const t=We();return Hs=new t("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Hs}var js,Rc;function df(){if(Rc)return js;Rc=1;const t=We();return js=new t("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),js}var Vs,Dc;function ff(){if(Dc)return Vs;Dc=1;const t=We();return Vs=new t("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Vs}var Us,Pc;function pf(){if(Pc)return Us;Pc=1;const t=cf();return Us=new t({explicit:[uf(),df(),ff()]}),Us}var qs,$c;function hf(){if($c)return qs;$c=1;const t=We();function e(i){if(i===null)return!0;const o=i.length;return o===1&&i==="~"||o===4&&(i==="null"||i==="Null"||i==="NULL")}function n(){return null}function r(i){return i===null}return qs=new t("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),qs}var Ws,Bc;function mf(){if(Bc)return Ws;Bc=1;const t=We();function e(i){if(i===null)return!1;const o=i.length;return o===4&&(i==="true"||i==="True"||i==="TRUE")||o===5&&(i==="false"||i==="False"||i==="FALSE")}function n(i){return i==="true"||i==="True"||i==="TRUE"}function r(i){return Object.prototype.toString.call(i)==="[object Boolean]"}return Ws=new t("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{lowercase:function(i){return i?"true":"false"},uppercase:function(i){return i?"TRUE":"FALSE"},camelcase:function(i){return i?"True":"False"}},defaultStyle:"lowercase"}),Ws}var Ks,_c;function gf(){if(_c)return Ks;_c=1;const t=mi(),e=We();function n(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function r(c){return c>=48&&c<=55}function i(c){return c>=48&&c<=57}function o(c){if(c===null)return!1;const u=c.length;let d=0,p=!1;if(!u)return!1;let h=c[d];if((h==="-"||h==="+")&&(h=c[++d]),h==="0"){if(d+1===u)return!0;if(h=c[++d],h==="b"){for(d++;d<u;d++){if(h=c[d],h!=="0"&&h!=="1")return!1;p=!0}return p&&isFinite(s(c))}if(h==="x"){for(d++;d<u;d++){if(!n(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}if(h==="o"){for(d++;d<u;d++){if(!r(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}}for(;d<u;d++){if(!i(c.charCodeAt(d)))return!1;p=!0}return p?isFinite(s(c)):!1}function s(c){let u=c,d=1,p=u[0];if((p==="-"||p==="+")&&(p==="-"&&(d=-1),u=u.slice(1),p=u[0]),u==="0")return 0;if(p==="0"){if(u[1]==="b")return d*parseInt(u.slice(2),2);if(u[1]==="x")return d*parseInt(u.slice(2),16);if(u[1]==="o")return d*parseInt(u.slice(2),8)}return d*parseInt(u,10)}function l(c){return s(c)}function a(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!t.isNegativeZero(c)}return Ks=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:o,construct:l,predicate:a,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ks}var Ys,zc;function yf(){if(zc)return Ys;zc=1;const t=mi(),e=We(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function i(c){return c===null||!n.test(c)?!1:isFinite(parseFloat(c,10))?!0:r.test(c)}function o(c){let u=c.toLowerCase();const d=u[0]==="-"?-1:1;return"+-".indexOf(u[0])>=0&&(u=u.slice(1)),u===".inf"?d===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:u===".nan"?NaN:d*parseFloat(u,10)}const s=/^[-+]?[0-9]+e/;function l(c,u){if(isNaN(c))switch(u){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(u){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(u){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(c))return"-0.0";const d=c.toString(10);return s.test(d)?d.replace("e",".e"):d}function a(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||t.isNegativeZero(c))}return Ys=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:i,construct:o,predicate:a,represent:l,defaultStyle:"lowercase"}),Ys}var Js,Fc;function bf(){return Fc||(Fc=1,Js=pf().extend({implicit:[hf(),mf(),gf(),yf()]})),Js}var Gs,Hc;function kf(){return Hc||(Hc=1,Gs=bf()),Gs}var Xs,jc;function xf(){if(jc)return Xs;jc=1;const t=We(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(s){return s===null?!1:e.exec(s)!==null||n.exec(s)!==null}function i(s){let l=0,a=null,c=e.exec(s);if(c===null&&(c=n.exec(s)),c===null)throw new Error("Date resolve error");const u=+c[1],d=+c[2]-1,p=+c[3];if(!c[4])return new Date(Date.UTC(u,d,p));const h=+c[4],g=+c[5],b=+c[6];if(c[7]){for(l=c[7].slice(0,3);l.length<3;)l+="0";l=+l}if(c[9]){const w=+c[10],T=+(c[11]||0);a=(w*60+T)*6e4,c[9]==="-"&&(a=-a)}const x=new Date(Date.UTC(u,d,p,h,g,b,l));return a&&x.setTime(x.getTime()-a),x}function o(s){return s.toISOString()}return Xs=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:i,instanceOf:Date,represent:o}),Xs}var Zs,Vc;function Sf(){if(Vc)return Zs;Vc=1;const t=We();function e(n){return n==="<<"||n===null}return Zs=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Zs}var Qs,Uc;function wf(){if(Uc)return Qs;Uc=1;const t=We(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
8
+ \r`;function n(s){if(s===null)return!1;let l=0;const a=s.length,c=e;for(let u=0;u<a;u++){const d=c.indexOf(s.charAt(u));if(!(d>64)){if(d<0)return!1;l+=6}}return l%8===0}function r(s){const l=s.replace(/[\r\n=]/g,""),a=l.length,c=e;let u=0;const d=[];for(let h=0;h<a;h++)h%4===0&&h&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(l.charAt(h));const p=a%4*6;return p===0?(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)):p===18?(d.push(u>>10&255),d.push(u>>2&255)):p===12&&d.push(u>>4&255),new Uint8Array(d)}function i(s){let l="",a=0;const c=s.length,u=e;for(let p=0;p<c;p++)p%3===0&&p&&(l+=u[a>>18&63],l+=u[a>>12&63],l+=u[a>>6&63],l+=u[a&63]),a=(a<<8)+s[p];const d=c%3;return d===0?(l+=u[a>>18&63],l+=u[a>>12&63],l+=u[a>>6&63],l+=u[a&63]):d===2?(l+=u[a>>10&63],l+=u[a>>4&63],l+=u[a<<2&63],l+=u[64]):d===1&&(l+=u[a>>2&63],l+=u[a<<4&63],l+=u[64],l+=u[64]),l}function o(s){return Object.prototype.toString.call(s)==="[object Uint8Array]"}return Qs=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:i}),Qs}var el,qc;function Cf(){if(qc)return el;qc=1;const t=We(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const s={},l=o;for(let a=0,c=l.length;a<c;a+=1){const u=l[a];let d=!1;if(n.call(u)!=="[object Object]")return!1;let p;for(p in u)if(e.call(u,p))if(!d)d=!0;else return!1;if(!d||e.call(s,p))return!1;Object.defineProperty(s,p,{value:!0})}return!0}function i(o){return o!==null?o:[]}return el=new t("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:i}),el}var tl,Wc;function vf(){if(Wc)return tl;Wc=1;const t=We(),e=Object.prototype.toString;function n(i){if(i===null)return!0;const o=i,s=new Array(o.length);for(let l=0,a=o.length;l<a;l+=1){const c=o[l];if(e.call(c)!=="[object Object]")return!1;const u=Object.keys(c);if(u.length!==1)return!1;s[l]=[u[0],c[u[0]]]}return!0}function r(i){if(i===null)return[];const o=i,s=new Array(o.length);for(let l=0,a=o.length;l<a;l+=1){const c=o[l],u=Object.keys(c);s[l]=[u[0],c[u[0]]]}return s}return tl=new t("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),tl}var nl,Kc;function Mf(){if(Kc)return nl;Kc=1;const t=We(),e=Object.prototype.hasOwnProperty;function n(i){if(i===null)return!0;const o=i;for(const s in o)if(e.call(o,s)&&o[s]!==null)return!1;return!0}function r(i){return i!==null?i:{}}return nl=new t("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),nl}var rl,Yc;function Ta(){return Yc||(Yc=1,rl=kf().extend({implicit:[xf(),Sf()],explicit:[wf(),Cf(),vf(),Mf()]})),rl}var Jc;function Rg(){if(Jc)return $i;Jc=1;const t=mi(),e=gi(),n=Ig(),r=Ta(),i=Object.prototype.hasOwnProperty,o=1,s=2,l=3,a=4,c=1,u=2,d=3,p=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,h=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,b=/^(?:!|!!|![0-9A-Za-z-]+!)$/,x=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function w(f){return Object.prototype.toString.call(f)}function T(f){return f===10||f===13}function R(f){return f===9||f===32}function $(f){return f===9||f===32||f===10||f===13}function Y(f){return f===44||f===91||f===93||f===123||f===125}function ne(f){if(f>=48&&f<=57)return f-48;const S=f|32;return S>=97&&S<=102?S-97+10:-1}function j(f){return f===120?2:f===117?4:f===85?8:0}function ee(f){return f>=48&&f<=57?f-48:-1}function te(f){switch(f){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
9
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function ye(f){return f<=65535?String.fromCharCode(f):String.fromCharCode((f-65536>>10)+55296,(f-65536&1023)+56320)}function Me(f,S,E){S==="__proto__"?Object.defineProperty(f,S,{configurable:!0,enumerable:!0,writable:!0,value:E}):f[S]=E}const tt=new Array(256),Ee=new Array(256);for(let f=0;f<256;f++)tt[f]=te(f)?1:0,Ee[f]=te(f);function le(f,S){this.input=f,this.filename=S.filename||null,this.schema=S.schema||r,this.onWarning=S.onWarning||null,this.legacy=S.legacy||!1,this.json=S.json||!1,this.listener=S.listener||null,this.maxDepth=typeof S.maxDepth=="number"?S.maxDepth:100,this.maxTotalMergeKeys=typeof S.maxTotalMergeKeys=="number"?S.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=f.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function De(f,S){const E={name:f.filename,buffer:f.input.slice(0,-1),position:f.position,line:f.line,column:f.position-f.lineStart};return E.snippet=n(E),new e(S,E)}function z(f,S){throw De(f,S)}function Hn(f,S){f.onWarning&&f.onWarning.call(null,De(f,S))}function Mt(f,S,E){const N=f.anchorMapTransactions;if(N.length!==0){const M=N[N.length-1];i.call(M,S)||(M[S]={existed:i.call(f.anchorMap,S),value:f.anchorMap[S]})}f.anchorMap[S]=E}function Ls(f){f.anchorMapTransactions.push(Object.create(null))}function yn(f){const S=f.anchorMapTransactions.pop(),E=f.anchorMapTransactions;if(E.length===0)return;const N=E[E.length-1],M=Object.keys(S);for(let y=0,C=M.length;y<C;y+=1){const v=M[y];i.call(N,v)||(N[v]=S[v])}}function Is(f){const S=f.anchorMapTransactions.pop(),E=Object.keys(S);for(let N=E.length-1;N>=0;N-=1){const M=S[E[N]];M.existed?f.anchorMap[E[N]]=M.value:delete f.anchorMap[E[N]]}}function yr(f){return{position:f.position,line:f.line,lineStart:f.lineStart,lineIndent:f.lineIndent,firstTabInLine:f.firstTabInLine,tag:f.tag,anchor:f.anchor,kind:f.kind,result:f.result}}function jn(f,S){f.position=S.position,f.line=S.line,f.lineStart=S.lineStart,f.lineIndent=S.lineIndent,f.firstTabInLine=S.firstTabInLine,f.tag=S.tag,f.anchor=S.anchor,f.kind=S.kind,f.result=S.result}const Ai={YAML:function(S,E,N){S.version!==null&&z(S,"duplication of %YAML directive"),N.length!==1&&z(S,"YAML directive accepts exactly one argument");const M=/^([0-9]+)\.([0-9]+)$/.exec(N[0]);M===null&&z(S,"ill-formed argument of the YAML directive");const y=parseInt(M[1],10),C=parseInt(M[2],10);y!==1&&z(S,"unacceptable YAML version of the document"),S.version=N[0],S.checkLineBreaks=C<2,C!==1&&C!==2&&Hn(S,"unsupported YAML version of the document")},TAG:function(S,E,N){let M;N.length!==2&&z(S,"TAG directive accepts exactly two arguments");const y=N[0];M=N[1],b.test(y)||z(S,"ill-formed tag handle (first argument) of the TAG directive"),i.call(S.tagMap,y)&&z(S,'there is a previously declared suffix for "'+y+'" tag handle'),x.test(M)||z(S,"ill-formed tag prefix (second argument) of the TAG directive");try{M=decodeURIComponent(M)}catch{z(S,"tag prefix is malformed: "+M)}S.tagMap[y]=M}};function Xe(f,S,E,N){if(S<E){const M=f.input.slice(S,E);if(N)for(let y=0,C=M.length;y<C;y+=1){const v=M.charCodeAt(y);v===9||v>=32&&v<=1114111||z(f,"expected valid JSON character")}else p.test(M)&&z(f,"the stream contains non-printable characters");f.result+=M}}function jt(f){f.totalMergeKeys++,f.maxTotalMergeKeys!==-1&&f.totalMergeKeys>f.maxTotalMergeKeys&&z(f,"merge keys exceeded maxTotalMergeKeys ("+f.maxTotalMergeKeys+")")}function br(f,S,E,N){t.isObject(E)||z(f,"cannot merge mappings; the provided source object is unacceptable"),jt(f);const M=Object.keys(E);for(let y=0,C=M.length;y<C;y+=1){const v=M[y];jt(f),i.call(S,v)||(Me(S,v,E[v]),N[v]=!0)}}function Tt(f,S,E,N,M,y,C,v,O){if(Array.isArray(M)){M=Array.prototype.slice.call(M);for(let I=0,D=M.length;I<D;I+=1)Array.isArray(M[I])&&z(f,"nested arrays are not supported inside keys"),typeof M=="object"&&w(M[I])==="[object Object]"&&(M[I]="[object Object]")}if(typeof M=="object"&&w(M)==="[object Object]"&&(M="[object Object]"),M=String(M),S===null&&(S={}),N==="tag:yaml.org,2002:merge")if(Array.isArray(y)){y.length>100&&z(f,"abnormal merge sequence size");for(let I=0,D=y.length;I<D;I+=1)br(f,S,y[I],E)}else br(f,S,y,E);else!f.json&&!i.call(E,M)&&i.call(S,M)&&(f.line=C||f.line,f.lineStart=v||f.lineStart,f.position=O||f.position,z(f,"duplicated mapping key")),Me(S,M,y),delete E[M];return S}function kr(f){const S=f.input.charCodeAt(f.position);S===10?f.position++:S===13?(f.position++,f.input.charCodeAt(f.position)===10&&f.position++):z(f,"a line break is expected"),f.line+=1,f.lineStart=f.position,f.firstTabInLine=-1}function pe(f,S,E){let N=0,M=f.input.charCodeAt(f.position);for(;M!==0;){for(;R(M);)M===9&&f.firstTabInLine===-1&&(f.firstTabInLine=f.position),M=f.input.charCodeAt(++f.position);if(S&&M===35)do M=f.input.charCodeAt(++f.position);while(M!==10&&M!==13&&M!==0);if(T(M))for(kr(f),M=f.input.charCodeAt(f.position),N++,f.lineIndent=0;M===32;)f.lineIndent++,M=f.input.charCodeAt(++f.position);else break}return E!==-1&&N!==0&&f.lineIndent<E&&Hn(f,"deficient indentation"),N}function pt(f){let S=f.position,E=f.input.charCodeAt(S);return!!((E===45||E===46)&&E===f.input.charCodeAt(S+1)&&E===f.input.charCodeAt(S+2)&&(S+=3,E=f.input.charCodeAt(S),E===0||$(E)))}function Vn(f,S){S===1?f.result+=" ":S>1&&(f.result+=t.repeat(`
10
+ `,S-1))}function Ei(f,S,E){let N,M,y,C,v,O;const I=f.kind,D=f.result;let A=f.input.charCodeAt(f.position);if($(A)||Y(A)||A===35||A===38||A===42||A===33||A===124||A===62||A===39||A===34||A===37||A===64||A===96)return!1;if(A===63||A===45){const B=f.input.charCodeAt(f.position+1);if($(B)||E&&Y(B))return!1}for(f.kind="scalar",f.result="",N=M=f.position,y=!1;A!==0;){if(A===58){const B=f.input.charCodeAt(f.position+1);if($(B)||E&&Y(B))break}else if(A===35){const B=f.input.charCodeAt(f.position-1);if($(B))break}else{if(f.position===f.lineStart&&pt(f)||E&&Y(A))break;if(T(A))if(C=f.line,v=f.lineStart,O=f.lineIndent,pe(f,!1,-1),f.lineIndent>=S){y=!0,A=f.input.charCodeAt(f.position);continue}else{f.position=M,f.line=C,f.lineStart=v,f.lineIndent=O;break}}y&&(Xe(f,N,M,!1),Vn(f,f.line-C),N=M=f.position,y=!1),R(A)||(M=f.position+1),A=f.input.charCodeAt(++f.position)}return Xe(f,N,M,!1),f.result?!0:(f.kind=I,f.result=D,!1)}function xr(f,S){let E,N,M=f.input.charCodeAt(f.position);if(M!==39)return!1;for(f.kind="scalar",f.result="",f.position++,E=N=f.position;(M=f.input.charCodeAt(f.position))!==0;)if(M===39)if(Xe(f,E,f.position,!0),M=f.input.charCodeAt(++f.position),M===39)E=f.position,f.position++,N=f.position;else return!0;else T(M)?(Xe(f,E,N,!0),Vn(f,pe(f,!1,S)),E=N=f.position):f.position===f.lineStart&&pt(f)?z(f,"unexpected end of the document within a single quoted scalar"):(f.position++,R(M)||(N=f.position));z(f,"unexpected end of the stream within a single quoted scalar")}function Ni(f,S){let E,N,M,y=f.input.charCodeAt(f.position);if(y!==34)return!1;for(f.kind="scalar",f.result="",f.position++,E=N=f.position;(y=f.input.charCodeAt(f.position))!==0;){if(y===34)return Xe(f,E,f.position,!0),f.position++,!0;if(y===92){if(Xe(f,E,f.position,!0),y=f.input.charCodeAt(++f.position),T(y))pe(f,!1,S);else if(y<256&&tt[y])f.result+=Ee[y],f.position++;else if((M=j(y))>0){let C=M,v=0;for(;C>0;C--)y=f.input.charCodeAt(++f.position),(M=ne(y))>=0?v=(v<<4)+M:z(f,"expected hexadecimal character");f.result+=ye(v),f.position++}else z(f,"unknown escape sequence");E=N=f.position}else T(y)?(Xe(f,E,N,!0),Vn(f,pe(f,!1,S)),E=N=f.position):f.position===f.lineStart&&pt(f)?z(f,"unexpected end of the document within a double quoted scalar"):(f.position++,R(y)||(N=f.position))}z(f,"unexpected end of the stream within a double quoted scalar")}function Oi(f,S){let E=!0,N,M,y;const C=f.tag;let v;const O=f.anchor;let I,D,A,B;const F=Object.create(null);let W,K,J,X=f.input.charCodeAt(f.position);if(X===91)I=93,B=!1,v=[];else if(X===123)I=125,B=!0,v={};else return!1;for(f.anchor!==null&&Mt(f,f.anchor,v),X=f.input.charCodeAt(++f.position);X!==0;){if(pe(f,!0,S),X=f.input.charCodeAt(f.position),X===I)return f.position++,f.tag=C,f.anchor=O,f.kind=B?"mapping":"sequence",f.result=v,!0;if(E?X===44&&z(f,"expected the node content, but found ','"):z(f,"missed comma between flow collection entries"),K=W=J=null,D=A=!1,X===63){const qt=f.input.charCodeAt(f.position+1);$(qt)&&(D=A=!0,f.position++,pe(f,!0,S))}N=f.line,M=f.lineStart,y=f.position,Ut(f,S,o,!1,!0),K=f.tag,W=f.result,pe(f,!0,S),X=f.input.charCodeAt(f.position),(A||f.line===N)&&X===58&&(D=!0,X=f.input.charCodeAt(++f.position),pe(f,!0,S),Ut(f,S,o,!1,!0),J=f.result),B?Tt(f,v,F,K,W,J,N,M,y):D?v.push(Tt(f,null,F,K,W,J,N,M,y)):v.push(W),pe(f,!0,S),X=f.input.charCodeAt(f.position),X===44?(E=!0,X=f.input.charCodeAt(++f.position)):E=!1}z(f,"unexpected end of the stream within a flow collection")}function Vt(f,S){let E,N=c,M=!1,y=!1,C=S,v=0,O=!1,I,D=f.input.charCodeAt(f.position);if(D===124)E=!1;else if(D===62)E=!0;else return!1;for(f.kind="scalar",f.result="";D!==0;)if(D=f.input.charCodeAt(++f.position),D===43||D===45)c===N?N=D===43?d:u:z(f,"repeat of a chomping mode identifier");else if((I=ee(D))>=0)I===0?z(f,"bad explicit indentation width of a block scalar; it cannot be less than one"):y?z(f,"repeat of an indentation width identifier"):(C=S+I-1,y=!0);else break;if(R(D)){do D=f.input.charCodeAt(++f.position);while(R(D));if(D===35)do D=f.input.charCodeAt(++f.position);while(!T(D)&&D!==0)}for(;D!==0;){for(kr(f),f.lineIndent=0,D=f.input.charCodeAt(f.position);(!y||f.lineIndent<C)&&D===32;)f.lineIndent++,D=f.input.charCodeAt(++f.position);if(!y&&f.lineIndent>C&&(C=f.lineIndent),T(D)){v++;continue}if(!y&&C===0&&z(f,"missing indentation for block scalar"),f.lineIndent<C){N===d?f.result+=t.repeat(`
11
+ `,M?1+v:v):N===c&&M&&(f.result+=`
12
+ `);break}E?R(D)?(O=!0,f.result+=t.repeat(`
13
+ `,M?1+v:v)):O?(O=!1,f.result+=t.repeat(`
14
+ `,v+1)):v===0?M&&(f.result+=" "):f.result+=t.repeat(`
15
+ `,v):f.result+=t.repeat(`
16
+ `,M?1+v:v),M=!0,y=!0,v=0;const A=f.position;for(;!T(D)&&D!==0;)D=f.input.charCodeAt(++f.position);Xe(f,A,f.position,!1)}return!0}function Li(f,S){const E=f.tag,N=f.anchor,M=[];let y=!1;if(f.firstTabInLine!==-1)return!1;f.anchor!==null&&Mt(f,f.anchor,M);let C=f.input.charCodeAt(f.position);for(;C!==0&&(f.firstTabInLine!==-1&&(f.position=f.firstTabInLine,z(f,"tab characters must not be used in indentation")),C===45);){const v=f.input.charCodeAt(f.position+1);if(!$(v))break;if(y=!0,f.position++,pe(f,!0,-1)&&f.lineIndent<=S){M.push(null),C=f.input.charCodeAt(f.position);continue}const O=f.line;if(Ut(f,S,l,!1,!0),M.push(f.result),pe(f,!0,-1),C=f.input.charCodeAt(f.position),(f.line===O||f.lineIndent>S)&&C!==0)z(f,"bad indentation of a sequence entry");else if(f.lineIndent<S)break}return y?(f.tag=E,f.anchor=N,f.kind="sequence",f.result=M,!0):!1}function Ii(f,S,E){let N,M,y,C;const v=f.tag,O=f.anchor,I={},D=Object.create(null);let A=null,B=null,F=null,W=!1,K=!1;if(f.firstTabInLine!==-1)return!1;f.anchor!==null&&Mt(f,f.anchor,I);let J=f.input.charCodeAt(f.position);for(;J!==0;){!W&&f.firstTabInLine!==-1&&(f.position=f.firstTabInLine,z(f,"tab characters must not be used in indentation"));const X=f.input.charCodeAt(f.position+1),qt=f.line;if((J===63||J===58)&&$(X))J===63?(W&&(Tt(f,I,D,A,B,null,M,y,C),A=B=F=null),K=!0,W=!0,N=!0):W?(W=!1,N=!0):z(f,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),f.position+=1,J=X;else{if(M=f.line,y=f.lineStart,C=f.position,!Ut(f,E,s,!1,!0))break;if(f.line===qt){for(J=f.input.charCodeAt(f.position);R(J);)J=f.input.charCodeAt(++f.position);if(J===58)J=f.input.charCodeAt(++f.position),$(J)||z(f,"a whitespace character is expected after the key-value separator within a block mapping"),W&&(Tt(f,I,D,A,B,null,M,y,C),A=B=F=null),K=!0,W=!1,N=!1,A=f.tag,B=f.result;else if(K)z(f,"can not read an implicit mapping pair; a colon is missed");else return f.tag=v,f.anchor=O,!0}else if(K)z(f,"can not read a block mapping entry; a multiline key may not be an implicit key");else return f.tag=v,f.anchor=O,!0}if((f.line===qt||f.lineIndent>S)&&(W&&(M=f.line,y=f.lineStart,C=f.position),Ut(f,S,a,!0,N)&&(W?B=f.result:F=f.result),W||(Tt(f,I,D,A,B,F,M,y,C),A=B=F=null),pe(f,!0,-1),J=f.input.charCodeAt(f.position)),(f.line===qt||f.lineIndent>S)&&J!==0)z(f,"bad indentation of a mapping entry");else if(f.lineIndent<S)break}return W&&Tt(f,I,D,A,B,null,M,y,C),K&&(f.tag=v,f.anchor=O,f.kind="mapping",f.result=I),K}function Ri(f){let S=!1,E=!1,N,M,y=f.input.charCodeAt(f.position);if(y!==33)return!1;f.tag!==null&&z(f,"duplication of a tag property"),y=f.input.charCodeAt(++f.position),y===60?(S=!0,y=f.input.charCodeAt(++f.position)):y===33?(E=!0,N="!!",y=f.input.charCodeAt(++f.position)):N="!";let C=f.position;if(S){do y=f.input.charCodeAt(++f.position);while(y!==0&&y!==62);f.position<f.length?(M=f.input.slice(C,f.position),y=f.input.charCodeAt(++f.position)):z(f,"unexpected end of the stream within a verbatim tag")}else{for(;y!==0&&!$(y);)y===33&&(E?z(f,"tag suffix cannot contain exclamation marks"):(N=f.input.slice(C-1,f.position+1),b.test(N)||z(f,"named tag handle cannot contain such characters"),E=!0,C=f.position+1)),y=f.input.charCodeAt(++f.position);M=f.input.slice(C,f.position),g.test(M)&&z(f,"tag suffix cannot contain flow indicator characters")}M&&!x.test(M)&&z(f,"tag name cannot contain such characters: "+M);try{M=decodeURIComponent(M)}catch{z(f,"tag name is malformed: "+M)}return S?f.tag=M:i.call(f.tagMap,N)?f.tag=f.tagMap[N]+M:N==="!"?f.tag="!"+M:N==="!!"?f.tag="tag:yaml.org,2002:"+M:z(f,'undeclared tag handle "'+N+'"'),!0}function Di(f){let S=f.input.charCodeAt(f.position);if(S!==38)return!1;f.anchor!==null&&z(f,"duplication of an anchor property"),S=f.input.charCodeAt(++f.position);const E=f.position;for(;S!==0&&!$(S)&&!Y(S);)S=f.input.charCodeAt(++f.position);return f.position===E&&z(f,"name of an anchor node must contain at least one character"),f.anchor=f.input.slice(E,f.position),!0}function Rs(f){let S=f.input.charCodeAt(f.position);if(S!==42)return!1;S=f.input.charCodeAt(++f.position);const E=f.position;for(;S!==0&&!$(S)&&!Y(S);)S=f.input.charCodeAt(++f.position);f.position===E&&z(f,"name of an alias node must contain at least one character");const N=f.input.slice(E,f.position);return i.call(f.anchorMap,N)||z(f,'unidentified alias "'+N+'"'),f.result=f.anchorMap[N],pe(f,!0,-1),!0}function Pi(f,S,E,N){const M=yr(f);return Ls(f),jn(f,S),f.tag=null,f.anchor=null,f.kind=null,f.result=null,Ii(f,E,N)&&f.kind==="mapping"?(yn(f),!0):(Is(f),jn(f,M),!1)}function Ut(f,S,E,N,M){let y,C,v=1,O=!1,I=!1,D=null,A,B,F;f.depth>=f.maxDepth&&z(f,"nesting exceeded maxDepth ("+f.maxDepth+")"),f.depth+=1,f.listener!==null&&f.listener("open",f),f.tag=null,f.anchor=null,f.kind=null,f.result=null;const W=y=C=a===E||l===E;if(N&&pe(f,!0,-1)&&(O=!0,f.lineIndent>S?v=1:f.lineIndent===S?v=0:f.lineIndent<S&&(v=-1)),v===1)for(;;){const K=f.input.charCodeAt(f.position),J=yr(f);if(O&&(K===33&&f.tag!==null||K===38&&f.anchor!==null)||!Ri(f)&&!Di(f))break;D===null&&(D=J),pe(f,!0,-1)?(O=!0,C=W,f.lineIndent>S?v=1:f.lineIndent===S?v=0:f.lineIndent<S&&(v=-1)):C=!1}if(C&&(C=O||M),v===1||a===E)if(o===E||s===E?B=S:B=S+1,F=f.position-f.lineStart,v===1)if(C&&(Li(f,F)||Ii(f,F,B))||Oi(f,B))I=!0;else{const K=f.input.charCodeAt(f.position);D!==null&&W&&!C&&K!==124&&K!==62&&Pi(f,D,D.position-D.lineStart,B)||y&&Vt(f,B)||xr(f,B)||Ni(f,B)?I=!0:Rs(f)?(I=!0,(f.tag!==null||f.anchor!==null)&&z(f,"alias node should not have any properties")):Ei(f,B,o===E)&&(I=!0,f.tag===null&&(f.tag="?")),f.anchor!==null&&Mt(f,f.anchor,f.result)}else v===0&&(I=C&&Li(f,F));if(f.tag===null)f.anchor!==null&&Mt(f,f.anchor,f.result);else if(f.tag==="?"){f.result!==null&&f.kind!=="scalar"&&z(f,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+f.kind+'"');for(let K=0,J=f.implicitTypes.length;K<J;K+=1)if(A=f.implicitTypes[K],A.resolve(f.result)){f.result=A.construct(f.result),f.tag=A.tag,f.anchor!==null&&Mt(f,f.anchor,f.result);break}}else if(f.tag!=="!"){if(i.call(f.typeMap[f.kind||"fallback"],f.tag))A=f.typeMap[f.kind||"fallback"][f.tag];else{A=null;const K=f.typeMap.multi[f.kind||"fallback"];for(let J=0,X=K.length;J<X;J+=1)if(f.tag.slice(0,K[J].tag.length)===K[J].tag){A=K[J];break}}A||z(f,"unknown tag !<"+f.tag+">"),f.result!==null&&A.kind!==f.kind&&z(f,"unacceptable node kind for !<"+f.tag+'> tag; it should be "'+A.kind+'", not "'+f.kind+'"'),A.resolve(f.result,f.tag)?(f.result=A.construct(f.result,f.tag),f.anchor!==null&&Mt(f,f.anchor,f.result)):z(f,"cannot resolve a node with !<"+f.tag+"> explicit tag")}return f.listener!==null&&f.listener("close",f),f.depth-=1,f.tag!==null||f.anchor!==null||I}function Ds(f){const S=f.position;let E=!1,N;for(f.version=null,f.checkLineBreaks=f.legacy,f.tagMap=Object.create(null),f.anchorMap=Object.create(null);(N=f.input.charCodeAt(f.position))!==0&&(pe(f,!0,-1),N=f.input.charCodeAt(f.position),!(f.lineIndent>0||N!==37));){E=!0,N=f.input.charCodeAt(++f.position);let M=f.position;for(;N!==0&&!$(N);)N=f.input.charCodeAt(++f.position);const y=f.input.slice(M,f.position),C=[];for(y.length<1&&z(f,"directive name must not be less than one character in length");N!==0;){for(;R(N);)N=f.input.charCodeAt(++f.position);if(N===35){do N=f.input.charCodeAt(++f.position);while(N!==0&&!T(N));break}if(T(N))break;for(M=f.position;N!==0&&!$(N);)N=f.input.charCodeAt(++f.position);C.push(f.input.slice(M,f.position))}N!==0&&kr(f),i.call(Ai,y)?Ai[y](f,y,C):Hn(f,'unknown document directive "'+y+'"')}if(pe(f,!0,-1),f.lineIndent===0&&f.input.charCodeAt(f.position)===45&&f.input.charCodeAt(f.position+1)===45&&f.input.charCodeAt(f.position+2)===45?(f.position+=3,pe(f,!0,-1)):E&&z(f,"directives end mark is expected"),Ut(f,f.lineIndent-1,a,!1,!0),pe(f,!0,-1),f.checkLineBreaks&&h.test(f.input.slice(S,f.position))&&Hn(f,"non-ASCII line breaks are interpreted as content"),f.documents.push(f.result),f.position===f.lineStart&&pt(f)){f.input.charCodeAt(f.position)===46&&(f.position+=3,pe(f,!0,-1));return}f.position<f.length-1&&z(f,"end of the stream or a document separator is expected")}function Sr(f,S){f=String(f),S=S||{},f.length!==0&&(f.charCodeAt(f.length-1)!==10&&f.charCodeAt(f.length-1)!==13&&(f+=`
17
+ `),f.charCodeAt(0)===65279&&(f=f.slice(1)));const E=new le(f,S),N=f.indexOf("\0");for(N!==-1&&(E.position=N,z(E,"null byte is not allowed in input")),E.input+="\0";E.input.charCodeAt(E.position)===32;)E.lineIndent+=1,E.position+=1;for(;E.position<E.length-1;)Ds(E);return E.documents}function Ps(f,S,E){S!==null&&typeof S=="object"&&typeof E>"u"&&(E=S,S=null);const N=Sr(f,E);if(typeof S!="function")return N;for(let M=0,y=N.length;M<y;M+=1)S(N[M])}function $s(f,S){const E=Sr(f,S);if(E.length!==0){if(E.length===1)return E[0];throw new e("expected a single document in the stream, but found more")}}return $i.loadAll=Ps,$i.load=$s,$i}var il={},Gc;function Dg(){if(Gc)return il;Gc=1;const t=mi(),e=gi(),n=Ta(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,o=65279,s=9,l=10,a=13,c=32,u=33,d=34,p=35,h=37,g=38,b=39,x=42,w=44,T=45,R=58,$=61,Y=62,ne=63,j=64,ee=91,te=93,ye=96,Me=123,tt=124,Ee=125,le={};le[0]="\\0",le[7]="\\a",le[8]="\\b",le[9]="\\t",le[10]="\\n",le[11]="\\v",le[12]="\\f",le[13]="\\r",le[27]="\\e",le[34]='\\"',le[92]="\\\\",le[133]="\\N",le[160]="\\_",le[8232]="\\L",le[8233]="\\P";const De=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],z=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Hn(y,C){if(C===null)return{};const v={},O=Object.keys(C);for(let I=0,D=O.length;I<D;I+=1){let A=O[I],B=String(C[A]);A.slice(0,2)==="!!"&&(A="tag:yaml.org,2002:"+A.slice(2));const F=y.compiledTypeMap.fallback[A];F&&i.call(F.styleAliases,B)&&(B=F.styleAliases[B]),v[A]=B}return v}function Mt(y){let C,v;const O=y.toString(16).toUpperCase();if(y<=255)C="x",v=2;else if(y<=65535)C="u",v=4;else if(y<=4294967295)C="U",v=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+C+t.repeat("0",v-O.length)+O}const Ls=1,yn=2;function Is(y){this.schema=y.schema||n,this.indent=Math.max(1,y.indent||2),this.noArrayIndent=y.noArrayIndent||!1,this.skipInvalid=y.skipInvalid||!1,this.flowLevel=t.isNothing(y.flowLevel)?-1:y.flowLevel,this.styleMap=Hn(this.schema,y.styles||null),this.sortKeys=y.sortKeys||!1,this.lineWidth=y.lineWidth||80,this.noRefs=y.noRefs||!1,this.noCompatMode=y.noCompatMode||!1,this.condenseFlow=y.condenseFlow||!1,this.quotingType=y.quotingType==='"'?yn:Ls,this.forceQuotes=y.forceQuotes||!1,this.replacer=typeof y.replacer=="function"?y.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function yr(y,C){const v=t.repeat(" ",C);let O=0,I="";const D=y.length;for(;O<D;){let A;const B=y.indexOf(`
18
+ `,O);B===-1?(A=y.slice(O),O=D):(A=y.slice(O,B+1),O=B+1),A.length&&A!==`
19
+ `&&(I+=v),I+=A}return I}function jn(y,C){return`
20
+ `+t.repeat(" ",y.indent*C)}function Ai(y,C){for(let v=0,O=y.implicitTypes.length;v<O;v+=1)if(y.implicitTypes[v].resolve(C))return!0;return!1}function Xe(y){return y===c||y===s}function jt(y){return y>=32&&y<=126||y>=161&&y<=55295&&y!==8232&&y!==8233||y>=57344&&y<=65533&&y!==o||y>=65536&&y<=1114111}function br(y){return jt(y)&&y!==o&&y!==a&&y!==l}function Tt(y,C,v){const O=br(y),I=O&&!Xe(y);return(v?O:O&&y!==w&&y!==ee&&y!==te&&y!==Me&&y!==Ee)&&y!==p&&!(C===R&&!I)||br(C)&&!Xe(C)&&y===p||C===R&&I}function kr(y){return jt(y)&&y!==o&&!Xe(y)&&y!==T&&y!==ne&&y!==R&&y!==w&&y!==ee&&y!==te&&y!==Me&&y!==Ee&&y!==p&&y!==g&&y!==x&&y!==u&&y!==tt&&y!==$&&y!==Y&&y!==b&&y!==d&&y!==h&&y!==j&&y!==ye}function pe(y){return!Xe(y)&&y!==R}function pt(y,C){const v=y.charCodeAt(C);let O;return v>=55296&&v<=56319&&C+1<y.length&&(O=y.charCodeAt(C+1),O>=56320&&O<=57343)?(v-55296)*1024+O-56320+65536:v}function Vn(y){return/^\n* /.test(y)}const Ei=1,xr=2,Ni=3,Oi=4,Vt=5;function Li(y,C,v,O,I,D,A,B){let F,W=0,K=null,J=!1,X=!1;const qt=O!==-1;let wr=-1,Cr=kr(pt(y,0))&&pe(pt(y,y.length-1));if(C||A)for(F=0;F<y.length;W>=65536?F+=2:F++){if(W=pt(y,F),!jt(W))return Vt;Cr=Cr&&Tt(W,K,B),K=W}else{for(F=0;F<y.length;W>=65536?F+=2:F++){if(W=pt(y,F),W===l)J=!0,qt&&(X=X||F-wr-1>O&&y[wr+1]!==" ",wr=F);else if(!jt(W))return Vt;Cr=Cr&&Tt(W,K,B),K=W}X=X||qt&&F-wr-1>O&&y[wr+1]!==" "}return!J&&!X?Cr&&!A&&!I(y)?Ei:D===yn?Vt:xr:v>9&&Vn(y)?Vt:A?D===yn?Vt:xr:X?Oi:Ni}function Ii(y,C,v,O,I){y.dump=(function(){if(C.length===0)return y.quotingType===yn?'""':"''";if(!y.noCompatMode&&(De.indexOf(C)!==-1||z.test(C)))return y.quotingType===yn?'"'+C+'"':"'"+C+"'";const D=y.indent*Math.max(1,v),A=y.lineWidth===-1?-1:Math.max(Math.min(y.lineWidth,40),y.lineWidth-D),B=O||y.flowLevel>-1&&v>=y.flowLevel;function F(W){return Ai(y,W)}switch(Li(C,B,y.indent,A,F,y.quotingType,y.forceQuotes&&!O,I)){case Ei:return C;case xr:return"'"+C.replace(/'/g,"''")+"'";case Ni:return"|"+Ri(C,y.indent)+Di(yr(C,D));case Oi:return">"+Ri(C,y.indent)+Di(yr(Rs(C,A),D));case Vt:return'"'+Ut(C)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Ri(y,C){const v=Vn(y)?String(C):"",O=y[y.length-1]===`
21
+ `,D=O&&(y[y.length-2]===`
22
+ `||y===`
23
+ `)?"+":O?"":"-";return v+D+`
24
+ `}function Di(y){return y[y.length-1]===`
25
+ `?y.slice(0,-1):y}function Rs(y,C){const v=/(\n+)([^\n]*)/g;let O=(function(){let B=y.indexOf(`
26
+ `);return B=B!==-1?B:y.length,v.lastIndex=B,Pi(y.slice(0,B),C)})(),I=y[0]===`
27
+ `||y[0]===" ",D,A;for(;A=v.exec(y);){const B=A[1],F=A[2];D=F[0]===" ",O+=B+(!I&&!D&&F!==""?`
28
+ `:"")+Pi(F,C),I=D}return O}function Pi(y,C){if(y===""||y[0]===" ")return y;const v=/ [^ ]/g;let O,I=0,D,A=0,B=0,F="";for(;O=v.exec(y);)B=O.index,B-I>C&&(D=A>I?A:B,F+=`
29
+ `+y.slice(I,D),I=D+1),A=B;return F+=`
30
+ `,y.length-I>C&&A>I?F+=y.slice(I,A)+`
31
+ `+y.slice(A+1):F+=y.slice(I),F.slice(1)}function Ut(y){let C="",v=0;for(let O=0;O<y.length;v>=65536?O+=2:O++){v=pt(y,O);const I=le[v];!I&&jt(v)?(C+=y[O],v>=65536&&(C+=y[O+1])):C+=I||Mt(v)}return C}function Ds(y,C,v){let O="";const I=y.tag;for(let D=0,A=v.length;D<A;D+=1){let B=v[D];y.replacer&&(B=y.replacer.call(v,String(D),B)),(S(y,C,B,!1,!1)||typeof B>"u"&&S(y,C,null,!1,!1))&&(O!==""&&(O+=","+(y.condenseFlow?"":" ")),O+=y.dump)}y.tag=I,y.dump="["+O+"]"}function Sr(y,C,v,O){let I="";const D=y.tag;for(let A=0,B=v.length;A<B;A+=1){let F=v[A];y.replacer&&(F=y.replacer.call(v,String(A),F)),(S(y,C+1,F,!0,!0,!1,!0)||typeof F>"u"&&S(y,C+1,null,!0,!0,!1,!0))&&((!O||I!=="")&&(I+=jn(y,C)),y.dump&&l===y.dump.charCodeAt(0)?I+="-":I+="- ",I+=y.dump)}y.tag=D,y.dump=I||"[]"}function Ps(y,C,v){let O="";const I=y.tag,D=Object.keys(v);for(let A=0,B=D.length;A<B;A+=1){let F="";O!==""&&(F+=", "),y.condenseFlow&&(F+='"');const W=D[A];let K=v[W];y.replacer&&(K=y.replacer.call(v,W,K)),S(y,C,W,!1,!1)&&(y.dump.length>1024&&(F+="? "),F+=y.dump+(y.condenseFlow?'"':"")+":"+(y.condenseFlow?"":" "),S(y,C,K,!1,!1)&&(F+=y.dump,O+=F))}y.tag=I,y.dump="{"+O+"}"}function $s(y,C,v,O){let I="";const D=y.tag,A=Object.keys(v);if(y.sortKeys===!0)A.sort();else if(typeof y.sortKeys=="function")A.sort(y.sortKeys);else if(y.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let B=0,F=A.length;B<F;B+=1){let W="";(!O||I!=="")&&(W+=jn(y,C));const K=A[B];let J=v[K];if(y.replacer&&(J=y.replacer.call(v,K,J)),!S(y,C+1,K,!0,!0,!0))continue;const X=y.tag!==null&&y.tag!=="?"||y.dump&&y.dump.length>1024;X&&(y.dump&&l===y.dump.charCodeAt(0)?W+="?":W+="? "),W+=y.dump,X&&(W+=jn(y,C)),S(y,C+1,J,!0,X)&&(y.dump&&l===y.dump.charCodeAt(0)?W+=":":W+=": ",W+=y.dump,I+=W)}y.tag=D,y.dump=I||"{}"}function f(y,C,v){const O=v?y.explicitTypes:y.implicitTypes;for(let I=0,D=O.length;I<D;I+=1){const A=O[I];if((A.instanceOf||A.predicate)&&(!A.instanceOf||typeof C=="object"&&C instanceof A.instanceOf)&&(!A.predicate||A.predicate(C))){if(v?A.multi&&A.representName?y.tag=A.representName(C):y.tag=A.tag:y.tag="?",A.represent){const B=y.styleMap[A.tag]||A.defaultStyle;let F;if(r.call(A.represent)==="[object Function]")F=A.represent(C,B);else if(i.call(A.represent,B))F=A.represent[B](C,B);else throw new e("!<"+A.tag+'> tag resolver accepts not "'+B+'" style');y.dump=F}return!0}}return!1}function S(y,C,v,O,I,D,A){y.tag=null,y.dump=v,f(y,v,!1)||f(y,v,!0);const B=r.call(y.dump),F=O;O&&(O=y.flowLevel<0||y.flowLevel>C);const W=B==="[object Object]"||B==="[object Array]";let K,J;if(W&&(K=y.duplicates.indexOf(v),J=K!==-1),(y.tag!==null&&y.tag!=="?"||J||y.indent!==2&&C>0)&&(I=!1),J&&y.usedDuplicates[K])y.dump="*ref_"+K;else{if(W&&J&&!y.usedDuplicates[K]&&(y.usedDuplicates[K]=!0),B==="[object Object]")O&&Object.keys(y.dump).length!==0?($s(y,C,y.dump,I),J&&(y.dump="&ref_"+K+y.dump)):(Ps(y,C,y.dump),J&&(y.dump="&ref_"+K+" "+y.dump));else if(B==="[object Array]")O&&y.dump.length!==0?(y.noArrayIndent&&!A&&C>0?Sr(y,C-1,y.dump,I):Sr(y,C,y.dump,I),J&&(y.dump="&ref_"+K+y.dump)):(Ds(y,C,y.dump),J&&(y.dump="&ref_"+K+" "+y.dump));else if(B==="[object String]")y.tag!=="?"&&Ii(y,y.dump,C,D,F);else{if(B==="[object Undefined]")return!1;if(y.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+B)}if(y.tag!==null&&y.tag!=="?"){let X=encodeURI(y.tag[0]==="!"?y.tag.slice(1):y.tag).replace(/!/g,"%21");y.tag[0]==="!"?X="!"+X:X.slice(0,18)==="tag:yaml.org,2002:"?X="!!"+X.slice(18):X="!<"+X+">",y.dump=X+" "+y.dump}}return!0}function E(y,C){const v=[],O=[];N(y,v,O);const I=O.length;for(let D=0;D<I;D+=1)C.duplicates.push(v[O[D]]);C.usedDuplicates=new Array(I)}function N(y,C,v){if(y!==null&&typeof y=="object"){const O=C.indexOf(y);if(O!==-1)v.indexOf(O)===-1&&v.push(O);else if(C.push(y),Array.isArray(y))for(let I=0,D=y.length;I<D;I+=1)N(y[I],C,v);else{const I=Object.keys(y);for(let D=0,A=I.length;D<A;D+=1)N(y[I[D]],C,v)}}}function M(y,C){C=C||{};const v=new Is(C);v.noRefs||E(y,v);let O=y;return v.replacer&&(O=v.replacer.call({"":O},"",O)),S(v,0,O,!0,!0)?v.dump+`
32
+ `:""}return il.dump=M,il}var Xc;function Pg(){if(Xc)return Pe;Xc=1;const t=Rg(),e=Dg();function n(r,i){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+i+" instead, which is now safe by default.")}}return Pe.Type=We(),Pe.Schema=cf(),Pe.FAILSAFE_SCHEMA=pf(),Pe.JSON_SCHEMA=bf(),Pe.CORE_SCHEMA=kf(),Pe.DEFAULT_SCHEMA=Ta(),Pe.load=t.load,Pe.loadAll=t.loadAll,Pe.dump=e.dump,Pe.YAMLException=gi(),Pe.types={binary:wf(),float:yf(),map:ff(),null:hf(),pairs:vf(),set:Mf(),timestamp:xf(),bool:mf(),int:gf(),merge:Sf(),omap:Cf(),seq:df(),str:uf()},Pe.safeLoad=n("safeLoad","load"),Pe.safeLoadAll=n("safeLoadAll","loadAll"),Pe.safeDump=n("safeDump","dump"),Pe}var $g=Pg();const un=Lg($g),{Type:dT,Schema:fT,FAILSAFE_SCHEMA:pT,JSON_SCHEMA:hT,CORE_SCHEMA:mT,DEFAULT_SCHEMA:gT,load:yT,loadAll:bT,dump:kT,YAMLException:xT,types:ST,safeLoad:wT,safeLoadAll:CT,safeDump:vT}=un;async function Bg(){for(const t of["/studio/schema.yml","./schema.yml"])try{const e=await fetch(t,{cache:"no-store"});if(e.ok){const n=await e.text();return _g(un.load(n))}}catch{}throw new Error("Could not load studio/schema.yml")}function _g(t){const e=[],n=[];function r(i,o){for(const s of i||[])if(!(!s||typeof s!="object")){if(s.type==="group")e.push({name:s.name,label:s.label||s.name}),r(s.items,s.label||s.name);else if(s.type==="collection"||s.type==="file"){const l=s.view||{};n.push({name:s.name,label:s.label||s.name,group:o||"Content",type:s.type,path:s.path,format:s.format||"yaml-frontmatter",filename:s.filename,root_key:s.root_key||null,description:s.description||"",list:!!s.list,fields:s.fields||[],view:l,listMetaFields:Array.isArray(l.list_meta_fields)?l.list_meta_fields.map(String):null,operations:s.operations||{delete:!0}})}}}return r(t==null?void 0:t.content,null),{media:(t==null?void 0:t.media)||{},groups:e,collections:n,raw:t}}function Tf(t){const e=String((t==null?void 0:t.name)||"");return(t==null?void 0:t.component)==="markdown_body"||e==="body"||e.startsWith("body_")||e==="description"&&(t==null?void 0:t.component)==="markdown_body"}let Af=async()=>null;function zg(t){Af=t}async function ct(t,e={}){const n=await Af(),r={Accept:"application/json",...e.headers||{}};n&&(r.Authorization=`Bearer ${n}`),e.body&&!r["Content-Type"]&&(r["Content-Type"]="application/json");const i=await fetch(`/api/studio/${t.replace(/^\//,"")}`,{...e,headers:r}),o=await i.text();let s=null;try{s=o?JSON.parse(o):null}catch{s={raw:o}}if(!i.ok){const l=String((s==null?void 0:s.message)||(s==null?void 0:s.error)||`HTTP ${i.status}`),a=new Error(l);throw a.status=i.status,a.code=(s==null?void 0:s.error)||"",a.data=s,a}return s}const Je={session:()=>ct("session"),tree:t=>ct(`tree?path=${encodeURIComponent(t)}`),getFile:t=>ct(`file?path=${encodeURIComponent(t)}`),putFile:({path:t,content:e,message:n,sha:r})=>ct("file",{method:"PUT",body:JSON.stringify({path:t,content:e,message:n,sha:r})}),deleteFile:({path:t,message:e,sha:n})=>ct("file",{method:"DELETE",body:JSON.stringify({path:t,message:e,sha:n})}),listMedia:t=>ct(`media?path=${encodeURIComponent(t||"content/media")}`),uploadMedia:({path:t,content_base64:e,message:n})=>ct("media",{method:"POST",body:JSON.stringify({path:t,content_base64:e,message:n})}),createMediaFolder:({path:t,message:e})=>ct("media/folder",{method:"POST",body:JSON.stringify({path:t,message:e})}),searchXcite:t=>ct(`search/xcite?q=${encodeURIComponent(t||"")}`),searchCite:t=>ct(`search/cite?q=${encodeURIComponent(t||"")}`),rewrite:t=>ct("rewrite",{method:"POST",body:JSON.stringify(t)})};function Ef(t){const e=String(t||"");if(!e.startsWith("---"))return{fmLines:[],fm:{},body:e,hasFm:!1};const n=e.indexOf(`
33
+ ---`,3);if(n<0)return{fmLines:[],fm:{},body:e,hasFm:!1};const r=e.slice(4,n).replace(/^\r?\n/,""),i=e.slice(n+4),o=/^\r?\n\r?\n/.test(i),s=i.replace(/^(?:\r?\n)+/,""),l=r.split(/\r?\n/),a=Nf(r);return{fmLines:l,fm:a,body:s,hasFm:!0,rawFm:r,blankAfterFm:o}}function Nf(t){try{const n=un.load(t,{schema:un.JSON_SCHEMA});if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}const e={};for(const n of String(t||"").split(/\r?\n/)){const r=n.match(/^([A-Za-z0-9_]+):\s*(.*)$/);if(!r)continue;let i=r[2];i==="true"?i=!0:i==="false"?i=!1:(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),e[r[1]]=i}return e}function Zc(t){if(t===!0||t===!1||typeof t=="number")return String(t);if(t==null)return'""';const e=String(t);return e===""?'""':/^(true|false|null|yes|no|~)$/i.test(e)||/[:#&*!|>%@`]/.test(e)||/^[\s\-?]|:\s|\s$/.test(e)||/[\n"']/.test(e)?JSON.stringify(e):e}function ei(t){return!!(t===""||t==null||Array.isArray(t)&&t.length===0)}function $l(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Fg(t){const e=String(t||"").replace(/\r\n/g,`
34
+ `).replace(/\n$/,"").split(`
35
+ `),n=[];let r=0;for(;r<e.length;){if(e[r].trim()===""){r++;continue}const i=e[r].match(/^([A-Za-z0-9_]+):\s*(.*)$/);if(!i){r++;continue}const o=r;for(r++;r<e.length;){const s=e[r];if(s===""){const l=e[r+1];if(l==null||/^[A-Za-z0-9_]+:\s*/.test(l))break;r++;continue}if(/^\s/.test(s)){r++;continue}break}n.push({key:i[1],lines:e.slice(o,r)})}return n}function Bl(t,e){return Array.isArray(e)&&e.every(n=>n==null||typeof n!="object")?[`${t}:`,...e.map(n=>` - ${Zc(n)}`)]:e&&typeof e=="object"?un.dump({[t]:e},{schema:un.JSON_SCHEMA,lineWidth:-1,noRefs:!0}).replace(/\n$/,"").split(`
36
+ `):[`${t}: ${Zc(e)}`]}function Hg(t,e){const n={...t};for(const[i,o]of Object.entries(e||{}))ei(o)?ei(t[i])||delete n[i]:n[i]=o;const r=new Set([...Object.keys(t),...Object.keys(n)]);for(const i of r)if(!$l(t[i],n[i]))return!0;return!1}function jg(t,e){const n=Nf(t),r={...n};for(const[u,d]of Object.entries(e||{}))ei(d)?ei(n[u])||delete r[u]:r[u]=d;const i=Object.keys(n),o=Object.keys(r);if(i.length===o.length&&o.every(u=>$l(n[u],r[u])))return String(t||"").replace(/\n$/,"");const l=Fg(t),a=new Set,c=[];for(const u of l)Object.prototype.hasOwnProperty.call(r,u.key)&&(a.add(u.key),$l(n[u.key],r[u.key])?c.push(...u.lines):c.push(...Bl(u.key,r[u.key])));for(const[u,d]of Object.entries(r))a.has(u)||c.push(...Bl(u,d));return c.join(`
37
+ `)}function Of(t,{fields:e,body:n,format:r}){if(r==="raw"||r==="yaml")return n.endsWith(`
38
+ `)?n:n+`
39
+ `;const i=Ef(t),{rawFm:o,hasFm:s,blankAfterFm:l}=i,a=String(n||"").replace(/^(?:\r?\n)+/,"");if(s&&!Hg(i.fm,e)&&a===String(i.body||"").replace(/^(?:\r?\n)+/,""))return t;const c=["---"];if(s){const h=jg(o,e);h&&c.push(h)}else for(const[h,g]of Object.entries(e||{}))ei(g)||c.push(...Bl(h,g));c.push("---");const u=String(n||"").replace(/^(?:\r?\n)+/,""),d=u.endsWith(`
40
+ `)?u:u+`
41
+ `,p=l?`
42
+
43
+ `:`
44
+ `;return c.join(`
45
+ `)+p+d}var Qc=Object.defineProperty,Vg=(t,e)=>{let n={};for(var r in t)Qc(n,r,{get:t[r],enumerable:!0});return Qc(n,Symbol.toStringTag,{value:"Module"}),n};function Ne(t){this.content=t}Ne.prototype={constructor:Ne,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new Ne(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ne(n)},addToStart:function(t,e){return new Ne([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ne(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new Ne(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Ne.from(t),t.size?new Ne(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ne.from(t),t.size?new Ne(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ne.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}};Ne.from=function(t){if(t instanceof Ne)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ne(e)};function Lf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&Df(s.charCodeAt(a-1))&&Rf(s.charCodeAt(a))&&n--,n}if(i.content.size||o.content.size){let s=Lf(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function If(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,n--,r--;return d&&p&&d<c.length&&Df(c.charCodeAt(d-1))&&Rf(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=If(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Rf(t){return t>=56320&&t<57344}function Df(t){return t>=55296&&t<56320}class L{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new L(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=a}return new L(r,i)}cutByIndex(e,n){return e==n?L.empty:e==0&&n==this.content.length?this:new L(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new L(i,o)}addToStart(e){return new L([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new L(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Lf(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return If(this,e,n,r)}findIndex(e){if(e==0)return Bi(0,e);if(e==this.size)return Bi(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?Bi(n+1,o):Bi(n,r);r=o}}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 L.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return L.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return L.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new L(n||e,r)}static from(e){if(!e)return L.empty;if(e instanceof L)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new L([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}L.empty=new L([],0);const ol={index:0,offset:0};function Bi(t,e){return ol.index=t,ol.offset=e,ol}function lo(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(!lo(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!lo(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ue=class _l{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}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&&lo(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`);return r.create(n.attrs)}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 _l.none;if(e instanceof _l)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ue.none=[];class ti extends Error{}class _{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=$f(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _(Pf(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 _.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(L.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new _(e,r,i)}}_.empty=new _(L.empty,0,0);function Pf(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||o.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Pf(o.content,e-i-1,n-i-1)))}function $f(t,e,n,r,i,o){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=$f(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?i-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function Ug(t,e,n){if(n.openStart>t.depth)throw new ti("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ti("Inconsistent open depths");return Bf(t,e,n,0)}function Bf(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=Bf(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return En(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=qg(n,t);return En(o,zf(t,s,l,e,r))}else return En(o,ao(t,e,r))}function _f(t,e){if(!e.type.compatibleContent(t.type))throw new ti("Cannot join "+e.type.name+" onto "+t.type.name)}function zl(t,e,n){let r=t.node(n);return _f(r,e.node(n)),r}function An(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 _r(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(An(t.nodeAfter,r),o++));for(let l=o;l<s;l++)An(i.child(l),r);e&&e.depth==n&&e.textOffset&&An(e.nodeBefore,r)}function En(t,e){if(!t.type.validContent(e))throw new ti("Invalid content for node "+t.type.name);return t.copy(e)}function zf(t,e,n,r,i){let o=t.depth>i&&zl(t,e,i+1),s=r.depth>i&&zl(n,r,i+1),l=[];return _r(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(_f(o,s),An(En(o,zf(t,e,n,r,i+1)),l)):(o&&An(En(o,ao(t,e,i+1)),l),_r(e,n,i,l),s&&An(En(s,ao(n,r,i+1)),l)),_r(r,null,i,l),new L(l)}function ao(t,e,n){let r=[];if(_r(null,t,n,r),t.depth>n){let i=zl(t,e,n+1);An(En(i,ao(t,e,n+1)),r)}return _r(e,null,n,r),new L(r)}function qg(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(L.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ni{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ue.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].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 co(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new ni(n,r,o)}static resolveCached(e,n){let r=eu.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else eu.set(e,r=new Wg);let i=r.elts[r.i]=ni.resolve(e,n);return r.i=(r.i+1)%Kg,i}}class Wg{constructor(){this.elts=[],this.i=0}}const Kg=12,eu=new WeakMap;class co{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 Yg=Object.create(null);let Nn=class Fl{constructor(e,n,r,i=ue.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||L.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&lo(this.attrs,n||e.defaultAttrs||Yg)&&ue.sameSet(this.marks,r||ue.none)}copy(e=null){return e==this.content?this:new Fl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Fl(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 _.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new _(c,i.depth-s,o.depth-s)}replace(e,n,r){return Ug(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return ni.resolveCached(this,e)}resolveNoCache(e){return ni.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ff(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=L.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.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),tu(this.type.attrs,this.attrs,"node",this.type.name);let e=ue.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];tu(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!ue.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=L.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};Nn.prototype.text=void 0;class uo extends Nn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ff(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 uo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new uo(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 Ff(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function tu(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}class In{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Jg(e,n);if(r.next==null)return In.empty;let i=Hf(r);r.next&&r.err("Unexpected trailing text");let o=ny(ty(i));return ry(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return L.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=o(d,l.concat(u));if(p)return p}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),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 i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
46
+ `)}}In.empty=new In(!0);class Jg{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 Hf(t){let e=[];do e.push(Gg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Gg(t){let e=[];do e.push(Xg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Xg(t){let e=ey(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=Zg(t,e);else break;return e}function nu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Zg(t,e){let n=nu(t),r=n;return t.eat(",")&&(t.next!="}"?r=nu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Qg(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function ey(t){if(t.eat("(")){let e=Hf(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=Qg(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 ty(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=n();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function jf(t,e){return e-t}function ru(t,e){let n=[];return r(e),n.sort(jf);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&n.indexOf(a)==-1&&r(a)}}}function ny(t){let e=Object.create(null);return n(ru(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);ru(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new In(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(jf);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function ry(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Vf(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 Uf(t,e){let n=Object.create(null);for(let r in t){let i=t[r],o=e&&e[r];if(o===void 0)if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(o);n[r]=o}return n}function qf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new oy(t,r,e[r]);return n}let iu=class Wf{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=qf(e,r.attrs),this.defaultAttrs=Vf(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==In.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:Uf(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Nn(this,this.computeAttrs(e),L.from(n),ue.setFrom(r))}createChecked(e=null,n,r){return n=L.from(n),this.checkContent(n),new Nn(this,this.computeAttrs(e),n,ue.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=L.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(L.empty,!0);return o?new Nn(this,e,n.append(o),ue.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){}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:ue.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Wf(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function iy(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class oy{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?iy(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ss{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=qf(e,i.attrs),this.excluded=null;let o=Vf(this.attrs);this.instance=o?new ue(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ue(this,Uf(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new ss(o,i++,n,s)),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]}excludes(e){return this.excluded.indexOf(e)>-1}}class Kf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Ne.from(e.nodes),n.marks=Ne.from(e.marks||{}),this.nodes=iu.compile(this.spec.nodes,this),this.marks=ss.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=In.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?ou(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:ou(this,s.split(" "))}this.nodeFromJSON=i=>Nn.fromJSON(this,i),this.markFromJSON=i=>ue.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof iu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new uo(r,r.defaultAttrs,e,ue.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 ou(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function sy(t){return t.tag!=null}function ly(t){return t.style!=null}class nn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(sy(i))this.tags.push(i);else if(ly(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new lu(this,n,!1);return r.addAll(e,ue.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new lu(this,n,!0);return r.addAll(e,ue.none,n.from,n.to),_.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(uy(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=au(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=au(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nn(e,nn.schemaRules(e)))}}const Yf={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},ay={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jf={ol:!0,ul:!0},ri=1,Hl=2,zr=4;function su(t,e,n){return e!=null?(e?ri:0)|(e==="full"?Hl:0):t&&t.whitespace=="pre"?ri|Hl:n&~zr}class _i{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=ue.none,this.match=o||(s&zr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(L.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ri)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=L.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(L.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&&!Yf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class lu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=su(null,n.preserveWhitespace,0)|(r?zr:0);i?o=new _i(i.type,i.attrs,ue.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new _i(null,null,ue.none,!0,null,s):o=new _i(e.schema.topNodeType,null,ue.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&Hl?"full":this.localPreserveWS||(i.options&ri)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
47
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\S/.test(l[a]));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=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Jf.hasOwnProperty(s)&&this.parser.normalizeLists&&cy(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ay.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Yf.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
48
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=ue.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):cu(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=su(e,o,s.options);s.options&zr&&s.content.length==0&&(l|=zr);let a=ue.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):cu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new _i(e,n,a,i,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|=ri)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(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 cy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function uy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function au(t){let e={};for(let n in t)e[n]=t[n];return e}function cu(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class zn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=zi(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return zi(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Qi(zi(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Qi(zi(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Qi(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=uu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return uu(e.marks)}}function uu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zi(t){return t.document||window.document}const du=new WeakMap;function dy(t){let e=du.get(t);return e===void 0&&du.set(t,e=fy(t)),e}function fy(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Qi(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=dy(r))&&o.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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(t.createTextNode(p));else{let{dom:h,contentDOM:g}=Qi(t,p,n,r);if(a.appendChild(h),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const Gf=65535,Xf=Math.pow(2,16);function py(t,e){return t+e*Xf}function fu(t){return t&Gf}function hy(t){return(t-(t&Gf))/Xf}const Zf=1,Qf=2,eo=4,ep=8;class jl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ep)>0}get deletedBefore(){return(this.delInfo&(Zf|eo))>0}get deletedAfter(){return(this.delInfo&(Qf|eo))>0}get deletedAcross(){return(this.delInfo&eo)>0}}class Ze{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ze.empty)return Ze.empty}recover(e){let n=0,r=fu(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+hy(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:n:n,h=a+i+(p<0?0:u);if(r)return h;let g=e==(n<0?a:d)?null:py(l/3,e-a),b=0;return c&&(b|=e==a?Qf:e==d?Zf:eo,(n<0?e!=a:e!=d)&&(b|=ep)),new jl(h,b,g)}i+=u-c}return r?e+i:new jl(e+i,0,null)}touches(e,n){let r=0,i=fu(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new Ze(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ze.empty:new Ze(e<0?[0,-e,0]:[0,0,e])}}Ze.empty=new Ze([]);class ii{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ii(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new ii;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new jl(e,i,null)}}const sl=Object.create(null);class Fe{getMap(){return Ze.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=sl[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 sl)throw new RangeError("Duplicate use of step JSON ID "+e);return sl[e]=n,n.prototype.jsonID=e,n}}class ke{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ke(e,null)}static fail(e){return new ke(null,e)}static fromReplace(e,n,r,i){try{return ke.ok(e.replace(n,r,i))}catch(o){if(o instanceof ti)return ke.fail(o.message);throw o}}}function Aa(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(Aa(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return L.fromArray(r)}class en extends Fe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new _(Aa(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,o)}invert(){return new dt(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 en(n.pos,r.pos,this.mark)}merge(e){return e instanceof en&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new en(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 en(n.from,n.to,e.markFromJSON(n.mark))}}Fe.jsonID("addMark",en);class dt extends Fe{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 _(Aa(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,r)}invert(){return new en(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 dt(n.pos,r.pos,this.mark)}merge(e){return e instanceof dt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dt(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 dt(n.from,n.to,e.markFromJSON(n.mark))}}Fe.jsonID("removeMark",dt);class tn extends Fe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new _(L.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new tn(this.pos,n.marks[i]);return new tn(this.pos,this.mark)}}return new Rn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new tn(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 tn(n.pos,e.markFromJSON(n.mark))}}Fe.jsonID("addNodeMark",tn);class Rn extends Fe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new _(L.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new tn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rn(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 Rn(n.pos,e.markFromJSON(n.mark))}}Fe.jsonID("removeNodeMark",Rn);class me extends Fe{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Vl(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ze([this.from,this.to-this.from,this.slice.size])}invert(e){return new me(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&me.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new me(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof me)||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?_.empty:new _(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new me(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?_.empty:new _(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new me(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 me(n.from,n.to,_.fromJSON(e,n.slice),!!n.structure)}}me.MAP_BIAS=1;Fe.jsonID("replace",me);class Te extends Fe{constructor(e,n,r,i,o,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Vl(e,this.from,this.gapFrom)||Vl(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ke.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ke.fromReplace(e,this.from,this.to,r):ke.fail("Content does not fit in gap")}getMap(){return new Ze([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 Te(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new Te(n.pos,r.pos,i,o,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 Te(n.from,n.to,n.gapFrom,n.gapTo,_.fromJSON(e,n.slice),n.insert,!!n.structure)}}Fe.jsonID("replaceAround",Te);function Vl(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function my(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,n),g=r.addToSet(d);for(let b=0;b<d.length;b++)d[b].isInSet(g)||(s&&s.to==p&&s.mark.eq(d[b])?s.to=h:i.push(s=new dt(p,h,d[b])));l&&l.to==p?l.to=h:o.push(l=new en(p,h,r))}}),i.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function gy(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof ss){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],p;for(let h=0;h<i.length;h++){let g=i[h];g.step==o-1&&d.eq(i[h].style)&&(p=g)}p?(p.to=c,p.step=o):i.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>t.step(new dt(s.from,s.to,s.style)))}function Ea(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new me(l,u,_.empty));else{r=d;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||t.step(new dt(l,u,c.marks[p]));if(i&&c.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,g;for(;p=h.exec(c.text);)g||(g=new _(L.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new me(l+p.index,l+p.index+p[0].length,g))}}l=u}if(!r.validEnd){let a=r.fillBefore(L.empty,!0);t.replace(l,l,new _(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function yy(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function pr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!yy(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function by(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=L.empty,d=0;for(let g=o,b=!1;g>n;g--)b||r.index(g)>0?(b=!0,u=L.from(r.node(g).copy(u)),d++):a--;let p=L.empty,h=0;for(let g=o,b=!1;g>n;g--)b||i.after(g+1)<i.end(g)?(b=!0,p=L.from(i.node(g).copy(p)),h++):c++;t.step(new Te(a,c,s,l,new _(u.append(p),d,h),u.size-d,!0))}function Na(t,e,n=null,r=t){let i=ky(t,e),o=i&&xy(r,e);return o?i.map(pu).concat({type:e,attrs:n}).concat(o.map(pu)):null}function pu(t){return{type:t,attrs:null}}function ky(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function xy(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function Sy(t,e,n){let r=L.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].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=L.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Te(i,o,i,o,new _(r,0,0),n.length,!0))}function wy(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&Cy(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",g=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!g?c=!1:!h&&g&&(c=!0)}c===!1&&np(t,s,l,o),Ea(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),d=u.map(l,1),p=u.map(l+s.nodeSize,1);return t.step(new Te(d,p,d+1,p-1,new _(L.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&tp(t,s,l,o),!1}})}function tp(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function np(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
49
+ `))}})}function Cy(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function vy(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Te(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new _(L.from(s),0,0),1,!0))}function _t(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>o;c--,u--){let d=i.node(c),p=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(p,d.childCount),g=r&&r[u+1];g&&(h=h.replaceChild(0,g.type.create(g.attrs)));let b=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function My(t,e,n=1,r){let i=t.doc.resolve(e),o=L.empty,s=L.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){o=L.from(i.node(l).copy(o));let u=r&&r[c];s=L.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}t.step(new me(e,e,new _(o.append(s),n,n),!0))}function hn(t,e){let n=t.resolve(e),r=n.index();return rp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ty(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function rp(t,e){return!!(t&&e&&!t.isLeaf&&Ty(t,e))}function ls(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let o,s,l=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&rp(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function Ay(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);np(t,u.node(),u.before(),l)}s.inlineContent&&Ea(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new me(c,a.map(e+n,-1),_.empty,!0)),r===!0){let u=t.doc.resolve(c);tp(t,u.node(),u.before(),t.steps.length)}return t}function Ey(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function ip(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function as(t,e,n=e,r=_.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return op(i,o,r)?new me(e,n,r):new Ny(i,o,r).fit()}function op(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Ny{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=L.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=L.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new _(o,s,l);return e>-1?new Te(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new me(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=hu(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(L.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return mu(e,-1)<=n?!1:(this.unplaced.size>1&&mu(e,1)>r&&r++,this.unplaced=new _(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=hu(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new _(Ir(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new _(Ir(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)u.push(i.child(b));d=d.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let b=l.child(c),x=d.matchType(b.type);if(!x)break;c++,(c>1||a==0||b.content.size)&&(d=x,u.push(sp(b.mark(p.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let g=c==l.childCount;g||(h=-1),this.placed=Rr(this.placed,n,L.from(u)),this.frontier[n].match=d,g&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,x=l;b<h;b++){let w=x.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),x=w.content}this.unplaced=g?e==0?_.empty:new _(Ir(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new _(Ir(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ll(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=ll(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ll(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?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=Rr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Rr(this.placed,this.depth,L.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(L.empty,!0);n.childCount&&(this.placed=Rr(this.placed,this.frontier.length,n))}}function Ir(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ir(t.firstChild.content,e-1,n)))}function Rr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Rr(t.lastChild.content,e-1,n)))}function hu(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function sp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,sp(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(L.empty,!0)))),t.copy(r)}function ll(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Oy(n,o.content,s)?l:null}function Oy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Ly(t){return t.spec.defining||t.spec.definingForContent}function mu(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function Iy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(op(i,o,r))return t.step(new me(e,n,r));let s=ap(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let p=i.depth,h=i.pos-1;p>0;p--,h--){let g=i.node(p).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;s.indexOf(p)>-1?l=p:i.before(p)==h&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,h=0;;h++){let g=p.firstChild;if(c.push(g),h==r.openStart)break;p=g.content}for(let p=u-1;p>=0;p--){let h=c[p],g=Ly(h.type);if(g&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=p;else if(g||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+u+1)%(r.openStart+1),g=c[h];if(g)for(let b=0;b<s.length;b++){let x=s[(b+a)%s.length],w=!0;x<0&&(w=!1,x=-x);let T=i.node(x-1),R=i.index(x-1);if(T.canReplaceWith(R,R,g.type,g.marks))return t.replace(i.before(x),w?o.after(x):n,new _(lp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let p=s.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>d));p--){let h=s[p];h<0||(e=i.before(h),n=o.after(h))}}function lp(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(lp(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(L.empty,!0))}return t}function Ry(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Ey(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new _(L.from(r),0,0))}function Dy(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let o=ap(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ap(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class er extends Fe{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 ke.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ke.fromReplace(e,this.pos,this.pos+1,new _(L.from(i),0,n.isLeaf?0:1))}getMap(){return Ze.empty}invert(e){return new er(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 er(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 er(n.pos,n.attr,n.value)}}Fe.jsonID("attr",er);class oi extends Fe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ke.ok(r)}getMap(){return Ze.empty}invert(e){return new oi(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 oi(n.attr,n.value)}}Fe.jsonID("docAttr",oi);let ir=class extends Error{};ir=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ir.prototype=Object.create(Error.prototype);ir.prototype.constructor=ir;ir.prototype.name="TransformError";class cp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ii}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ir(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}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=_.empty){let i=as(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new _(L.from(r),0,0))}delete(e,n){return this.replace(e,n,_.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Iy(this,e,n,r),this}replaceRangeWith(e,n,r){return Ry(this,e,n,r),this}deleteRange(e,n){return Dy(this,e,n),this}lift(e,n){return by(this,e,n),this}join(e,n=1){return Ay(this,e,n),this}wrap(e,n){return Sy(this,e,n),this}setBlockType(e,n=e,r,i=null){return wy(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return vy(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new er(e,n,r)),this}setDocAttribute(e,n){return this.step(new oi(e,n)),this}addNodeMark(e,n){return this.step(new tn(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 ue)n.isInSet(r.marks)&&this.step(new Rn(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Rn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return My(this,e,n,r),this}addMark(e,n,r){return my(this,e,n,r),this}removeMark(e,n,r){return gy(this,e,n,r),this}clearIncompatible(e,n,r){return Ea(this,e,n,r),this}}const al=Object.create(null);class G{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Py(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=_.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?_.empty:n),l==0&&bu(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),bu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new q(e):Jn(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?Jn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Jn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qe(e.node(0))}static atStart(e){return Jn(e,e,0,0,1)||new Qe(e)}static atEnd(e){return Jn(e,e,e.content.size,e.childCount,-1)||new Qe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=al[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 al)throw new RangeError("Duplicate use of selection JSON ID "+e);return al[e]=n,n.prototype.jsonID=e,n}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class Py{constructor(e,n){this.$from=e,this.$to=n}}let gu=!1;function yu(t){!gu&&!t.parent.inlineContent&&(gu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class q extends G{constructor(e,n=e){yu(e),yu(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 G.near(r);let i=e.resolve(n.map(this.anchor));return new q(i.parent.inlineContent?i:r,r)}replace(e,n=_.empty){if(super.replace(e,n),n==_.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cs(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 q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=G.findFrom(n,r,!0)||G.findFrom(n,-r,!0);if(o)n=o.$head;else return G.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(G.findFrom(e,-r,!0)||G.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new q(e,n)}}G.jsonID("text",q);class cs{constructor(e,n){this.anchor=e,this.head=n}map(e){return new cs(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends G{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?G.near(o):new U(o)}content(){return new _(L.from(this.node),0,0)}eq(e){return e instanceof U&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Oa(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new U(e.resolve(n.anchor))}static create(e,n){return new U(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}U.prototype.visible=!1;G.jsonID("node",U);class Oa{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new cs(r,r):new Oa(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&U.isSelectable(r)?new U(n):G.near(n)}}class Qe extends G{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=_.empty){if(n==_.empty){e.delete(0,e.doc.content.size);let r=G.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Qe(e)}map(e){return new Qe(e)}eq(e){return e instanceof Qe}getBookmark(){return $y}}G.jsonID("all",Qe);const $y={map(){return this},resolve(t){return new Qe(t)}};function Jn(t,e,n,r,i,o=!1){if(e.inlineContent)return q.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&U.isSelectable(l))return U.create(t,n-(i<0?l.nodeSize:0))}else{let a=Jn(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function bu(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof me||i instanceof Te))return;let o=t.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(G.near(t.doc.resolve(s),n))}const ku=1,Fi=2,xu=4;class By extends cp{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|ku)&~Fi,this.storedMarks=null,this}get selectionSet(){return(this.updated&ku)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Fi,this}ensureMarks(e){return ue.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&Fi)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Fi,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)||ue.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(G.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|=xu,this}get scrolledIntoView(){return(this.updated&xu)>0}}function Su(t,e){return!e||!t?t:t.bind(e)}class Dr{constructor(e,n,r){this.name=e,this.init=Su(n.init,r),this.apply=Su(n.apply,r)}}const _y=[new Dr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Dr("selection",{init(t,e){return t.selection||G.atStart(e.doc)},apply(t){return t.selection}}),new Dr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Dr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class cl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_y.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 Dr(r.key,r.spec.state,r))})}}class Rt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Rt(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new By(this)}static create(e){let n=new cl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Rt(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new cl(this.schema,e.plugins),r=n.fields,i=new Rt(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new cl(e.schema,e.plugins),o=new Rt(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Nn.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=G.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=c.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function up(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=up(i,e,{})),n[r]=i}return n}class fe{constructor(e){this.spec=e,this.props={},e.props&&up(e.props,this,this.props),this.key=e.key?e.key.key:dp("plugin")}getState(e){return e[this.key]}}const ul=Object.create(null);function dp(t){return t in ul?t+"$"+ ++ul[t]:(ul[t]=0,t+"$")}class xe{constructor(e="key"){this.key=dp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const fp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function pp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const hp=(t,e,n)=>{let r=pp(t,n);if(!r)return!1;let i=La(r);if(!i){let s=r.blockRange(),l=s&&pr(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Cp(t,i,e,-1))return!0;if(r.parent.content.size==0&&(or(o,"end")||U.isSelectable(o)))for(let s=r.depth;;s--){let l=as(t.doc,r.before(s),r.after(s),_.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(or(o,"end")?G.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):U.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},zy=(t,e,n)=>{let r=pp(t,n);if(!r)return!1;let i=La(r);return i?mp(t,i,e):!1},Fy=(t,e,n)=>{let r=yp(t,n);if(!r)return!1;let i=Ia(r);return i?mp(t,i,e):!1};function mp(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=as(t.doc,o,a,_.empty);if(!c||c.from!=o||c instanceof me&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(q.create(u.doc,o)),n(u.scrollIntoView())}return!0}function or(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 gp=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=La(r)}let s=o&&o.nodeBefore;return!s||!U.isSelectable(s)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function La(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 yp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const bp=(t,e,n)=>{let r=yp(t,n);if(!r)return!1;let i=Ia(r);if(!i)return!1;let o=i.nodeAfter;if(Cp(t,i,e,1))return!0;if(r.parent.content.size==0&&(or(o,"start")||U.isSelectable(o))){let s=as(t.doc,r.before(),r.after(),_.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(or(o,"start")?G.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):U.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},kp=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Ia(r)}let s=o&&o.nodeAfter;return!s||!U.isSelectable(s)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,o.pos)).scrollIntoView()),!0)};function Ia(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 Hy=(t,e)=>{let n=t.selection,r=n instanceof U,i;if(r){if(n.node.isTextblock||!hn(t.doc,n.from))return!1;i=n.from}else if(i=ls(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(U.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},jy=(t,e)=>{let n=t.selection,r;if(n instanceof U){if(n.node.isTextblock||!hn(t.doc,n.to))return!1;r=n.to}else if(r=ls(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Vy=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&pr(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},xp=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
50
+ `).scrollIntoView()),!0)};function Ra(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 Uy=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=Ra(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(G.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Sp=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Qe||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Ra(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(s,o.createAndFill());l.setSelection(q.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},wp=(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 o=n.before();if(_t(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&pr(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function qy(t){return(e,n)=>{if(e.selection instanceof U&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!_t(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof q||e.selection instanceof Qe)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,c=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){c=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=Ra(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),s.unshift(c&&a?{type:a}:null),l=h;break}else{if(h==1)return!1;s.unshift(null)}let d=i.pos,p=_t(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=_t(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&i.node(l).type!=a){let h=r.mapping.slice(o),g=h.map(i.before(l)),b=r.doc.resolve(g);a&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const Wy=qy(),Ky=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(U.create(t.doc,i))),!0)};function Yy(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||hn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Cp(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Yy(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(n){let h=e.pos+o.nodeSize,g=L.empty;for(let w=s.length-1;w>=0;w--)g=L.from(s[w].create(null,g));g=L.from(i.copy(g));let b=t.tr.step(new Te(e.pos-1,h,e.pos,h,new _(g,1,0),s.length,!0)),x=b.doc.resolve(h+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&hn(b.doc,x.pos)&&b.join(x.pos),n(b.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:G.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&&pr(d);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(d,p).scrollIntoView()),!0;if(c&&or(o,"start",!0)&&or(i,"end")){let h=i,g=[];for(;g.push(h),!h.isTextblock;)h=h.lastChild;let b=o,x=1;for(;!b.isTextblock;b=b.firstChild)x++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(n){let w=L.empty;for(let R=g.length-1;R>=0;R--)w=L.from(g[R].copy(w));let T=t.tr.step(new Te(e.pos-g.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new _(w,g.length,0),0,!0));n(T.scrollIntoView())}return!0}}return!1}function vp(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(q.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Jy=vp(-1),Gy=vp(1);function Xy(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&Na(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function wu(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function Da(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Da(fp,hp,gp);Da(fp,bp,kp);Da(xp,Sp,wp,Wy);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Zy(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let l=r?n.tr:null;return Qy(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Qy(t,e,n,r=null){let i=!1,o=e,s=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 a=s.resolve(e.start-2);o=new co(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new co(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Na(o,n,r,e);return l?(t&&eb(t,e,l,i,n),!0):!1}function eb(t,e,n,r,i){let o=L.empty;for(let u=n.length-1;u>=0;u--)o=L.from(n[u].type.create(n[u].attrs,o));t.step(new Te(e.start-(r?2:0),e.end,e.start,e.end,new _(o,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&_t(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function tb(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?nb(e,n,t,o):rb(e,n,o):!0:!1}}function nb(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new Te(o-1,s,o,s,new _(L.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new co(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const l=pr(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return hn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function rb(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,g=n.endIndex-1,b=n.startIndex;g>b;g--)h-=i.child(g).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?L.empty:L.from(i))))return!1;let d=o.pos,p=d+s.nodeSize;return r.step(new Te(d-(l?1:0),p+(a?1:0),d+1,p-1,new _((l?L.empty:L.from(i.copy(L.empty))).append(a?L.empty:L.from(i.copy(L.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ib(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=L.from(c?t.create():null),d=new _(L.from(t.create(null,L.from(l.type.create(null,u)))),c?3:1,0),p=o.start,h=o.end;n(e.tr.step(new Te(p-(c?3:1),h,p,h,d,1,!0)).scrollIntoView())}return!0}}const Oe=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},sr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ul=null;const It=function(t,e,n){let r=Ul||(Ul=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},ob=function(){Ul=null},Dn=function(t,e,n,r){return n&&(Cu(t,e,n,r,-1)||Cu(t,e,n,r,1))},sb=/^(img|br|input|textarea|hr)$/i;function Cu(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Be(t))){let s=t.parentNode;if(!s||!V(s)||yi(t)||sb.test(t.nodeName)||t.contentEditable=="false")return!1;e=Oe(t)+(i<0?0:1),t=s}else if(V(t)){let s=t.childNodes[e+(i<0?-1:0)];if(V(s)&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Be(t):0}else return!1}}function Be(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function V(t){return t.nodeType==1}function we(t){return t.nodeType==3}function Pn(t,e){return e?t.contains(V(e)?e:e.parentNode):!1}function lb(t,e){for(;;){if(we(t)&&e)return t;if(V(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Be(t)}else if(t.parentNode&&!yi(t))e=Oe(t),t=t.parentNode;else return null}}function ab(t,e){for(;;){if(we(t)&&e<t.nodeValue.length)return t;if(V(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!yi(t))e=Oe(t)+1,t=t.parentNode;else return null}}function cb(t,e,n){for(let r=e==0,i=e==Be(t);r||i;){if(t==n)return!0;let o=Oe(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Be(t)}}function yi(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 us=function(t){return t.focusNode&&Dn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function ub(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function db(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Be(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Be(r.startContainer),r.startOffset)}}}const wt=typeof navigator<"u"?navigator:null,vu=typeof document<"u"?document:null,mn=wt&&wt.userAgent||"",ql=/Edge\/(\d+)/.exec(mn),Mp=/MSIE \d/.exec(mn),Wl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mn),Ye=!!(Mp||Wl||ql),rn=Mp?document.documentMode:Wl?+Wl[1]:ql?+ql[1]:0,et=!Ye&&/gecko\/(\d+)/i.test(mn);et&&+(/Firefox\/(\d+)/.exec(mn)||[0,0])[1];const Kl=!Ye&&/Chrome\/(\d+)/.exec(mn),Re=!!Kl,Tp=Kl?+Kl[1]:0,ze=!Ye&&!!wt&&/Apple Computer/.test(wt.vendor),lr=ze&&(/Mobile\/\w+/.test(mn)||!!wt&&wt.maxTouchPoints>2),ot=lr||(wt?/Mac/.test(wt.platform):!1),Ap=wt?/Win/.test(wt.platform):!1,Dt=/Android \d/.test(mn),ds=!!vu&&"webkitFontSmoothing"in vu.documentElement.style,fb=ds?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function pb(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 At(t,e){return typeof t=="number"?t:t[e]}function hb(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 Mu(t,e,n){if(!Yl(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(!V(s)){s=sr(s);continue}let l=s==o.body,a=l?pb(o):hb(s),c=0,u=0;if(e.top<a.top+At(r,"top")?u=-(a.top-e.top+At(i,"top")):e.bottom>a.bottom-At(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+At(i,"top")-a.top:e.bottom-a.bottom+At(i,"bottom")),e.left<a.left+At(r,"left")?c=-(a.left-e.left+At(i,"left")):e.right>a.right-At(r,"right")&&(c=e.right-a.right+At(i,"right")),c||u)if(l)o.defaultView.scrollBy(c,u);else{let p=s.scrollLeft,h=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let g=s.scrollLeft-p,b=s.scrollTop-h;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:sr(s)}}function mb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(o,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Ep(t.dom)}}function Ep(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=sr(r));return e}function gb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Np(n,r==0?0:r-e)}function Np(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Un=null;function yb(t){if(t.setActive)return t.setActive();if(Un)return t.focus(Un);let e=Ep(t);t.focus(Un==null?{get preventScroll(){return Un={preventScroll:!0},!0}}:void 0),Un||(Un=!1,Np(e,0))}function Op(t,e){let n,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(V(u))p=u.getClientRects();else if(we(u))p=It(u).getClientRects();else continue;for(let h=0;h<p.length;h++){let g=p[h];if(g.top<=s&&g.bottom>=l){s=Math.max(g.bottom,s),l=Math.min(g.top,l);let b=g.left>e.left?g.left-e.left:g.right<e.left?e.left-g.right:0;if(b<r){n=u,r=b,i=b&&we(n)?{left:g.right<e.left?g.right:g.left,top:e.top}:e,V(u)&&b&&(o=d+(e.left>=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!a&&g.left<=e.left&&g.right>=e.left&&(a=u,c={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!n&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(o=d+1)}}return!n&&a&&(n=a,i=c,r=0),n&&we(n)?bb(n,i):!n||r?{node:t,offset:o}:Op(n,i)}function bb(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=Yt(r,1);if(s.top!=s.bottom&&Pa(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Pa(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function kb(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function xb(t,e,n){let{node:r,offset:i}=Op(e,n),o=-1;if(V(r)&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Sb(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0),a;if(!l)return null;if(V(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Lp(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(V(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Pa(e,c))return Lp(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function wb(t,e){let n=t.dom.ownerDocument,r,i=0,o=db(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s)){let c=t.dom.getBoundingClientRect();if(!Pa(e,c)||(s=Lp(t.dom,e,c),!s))return null}if(ze)for(let c=s;r&&c;c=sr(c))c.draggable&&(r=void 0);if(s=kb(s,e),r){if(et&&V(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;ds&&i&&V(r)&&V(c=r.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&V(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!V(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Sb(t,r,i,e))}l==null&&(l=xb(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Yl(t){return t.top<t.bottom||t.left<t.right}function Yt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Yl(r))return r}return Array.prototype.find.call(n,Yl)||t.getBoundingClientRect()}const Cb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ip(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=ds||et;if(we(r))if(s&&(Cb.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Yt(It(r,i,i),n);if(et&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Yt(It(r,i-1,i-1),-1);if(c.top==a.top){let u=Yt(It(r,i,i+1),-1);if(u.top!=a.top)return vr(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,vr(Yt(It(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Be(r))){let a=r.childNodes[i-1];if(V(a))return dl(a.getBoundingClientRect(),!1)}if(o==null&&i<Be(r)){let a=r.childNodes[i];if(V(a))return dl(a.getBoundingClientRect(),!0)}return dl(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Be(r))){let a=r.childNodes[i-1],c=we(a)?It(a,Be(a)-(s?0:1)):V(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return vr(Yt(c,1),!1)}if(o==null&&i<Be(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?we(a)?It(a,0,s?0:1):V(a)?a:null:null;if(c)return vr(Yt(c,-1),!0)}return vr(Yt(we(r)?It(r):r,-n),n>=0)}function vr(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 dl(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 Rp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function vb(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Rp(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Ip(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(V(l))a=l.getClientRects();else if(we(l))a=It(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const Mb=/[\u0590-\u08ac]/;function Tb(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return l?!Mb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:Rp(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:g,focusOffset:b}=t.domSelectionRange(),x=g&&!Pn(h,g)||a==g&&c==b;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),x}):r.pos==r.start()||r.pos==r.end()}let Tu=null,Au=null,Eu=!1;function Ab(t,e,n){return Tu==e&&Au==n?Eu:(Tu=e,Au=n,Eu=n=="up"||n=="down"?vb(t,e,n):Tb(t,e,n))}const st=0,Nu=1,wn=2,ft=3;class bi{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=st,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&Pn(this.contentDOM,e))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(V(s)?Pn(s,e):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(;r>0;r--){let o=this.children[r-1];if(o.size||!(o instanceof Pp||o instanceof Dp&&o.side>=0))break}if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Oe(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?Oe(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Oe(p.dom)+1;break}e-=p.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=Oe(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}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(!V(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let h=0,g=0;h<this.children.length;h++){let b=this.children[h],x=g+b.size;if(o>g&&s<x)return b.setSelection(e-g-b.border,n-g-b.border,r,i);g=x}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((et||ze)&&e==n){let{node:h,offset:g}=l;if(we(h)){if(d=!!(g&&h.nodeValue[g-1]==`
51
+ `),d&&g==h.nodeValue.length)for(let b=h,x;b;b=b.parentNode){if(x=b.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Oe(x)+1});break}let w=b.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let b=h.childNodes[g-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(et&&u.focusNode&&u.focusNode!=a.node&&V(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&ze)&&Dn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Dn(a.node,a.offset,u.focusNode,u.focusOffset))return;let p=!1;if((c.extend||e==n)&&!(d&&et)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>n){let g=l;l=a,a=g}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?wn:Nu,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ft:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wn:ft}r=s}this.dirty=wn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wn:Nu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Dp extends bi{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){let l=V(s)?s:document.createElement("span");l!=s&&l.appendChild(s),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==st&&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 Eb extends bi{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class on extends bi{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=zn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new on(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ft||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ft&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=st){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=st}}slice(e,n,r){let i=on.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Gl(o,n,s,r)),e>0&&(o=Gl(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class sn extends bi{constructor(e,n,r,i,o,s,l){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,o,s){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!we(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=zn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let p=u;return u=_p(u,r,n),c?a=new Nb(e,n,r,i,u,d||null,p,c):n.isText?new fs(e,n,r,i,u,p):new sn(e,n,r,i,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(i=>V(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>L.empty}}return n}matchesNode(e,n,r){return this.dirty==st&&e.eq(this.node)&&fo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Lb(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Db(this.node,this.innerDeco,(d,p,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!h&&a.syncToMarks(p==this.node.childCount?ue.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,i)},(d,p,h,g)=>{a.syncToMarks(d.marks,r,e,g),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let b;a.findNodeMatch(d,p,h,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(b=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(d,p,h,b,e)||a.updateNextNode(d,p,h,e,g,i)||a.addNode(d,p,h,e,i),i+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==wn)&&(s&&this.protectLocalComposition(e,s),$p(this.contentDOM,this.children,e),lr&&Pb(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof q)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=$b(this.node.content,s,r-n,i-n);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Eb(this,o,n,i);e.input.compositionNodes.push(s),this.children=Gl(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==ft||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=st}updateOuterDeco(e){if(fo(e,this.outerDeco))return;let n=!V(this.nodeDOM),r=this.dom;this.dom=Bp(this.dom,this.nodeDOM,Jl(this.outerDeco,this.node,n),Jl(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){V(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){V(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ou(t,e,n,r,i){_p(r,e,t);let o=new sn(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class fs extends sn{constructor(e,n,r,i,o,s){super(e,n,r,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==ft||this.dirty!=st&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=st||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=st,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new fs(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ft)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Pp extends bi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==st&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Nb extends sn{constructor(e,n,r,i,o,s,l,a){super(e,n,r,i,o,s,l),this.spec=a}update(e,n,r,i){if(this.dirty==ft)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function $p(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=Lu(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof on){let a=r?r.previousSibling:t.lastChild;$p(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Lu(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Fr=function(t){t&&(this.nodeName=t)};Fr.prototype=Object.create(null);const Cn=[new Fr];function Jl(t,e,n){if(t.length==0)return Cn;let r=n?Cn[0]:new Fr,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new Fr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new Fr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Bp(t,e,n,r){if(n==Cn&&r==Cn)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=n[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Cn[0]),i=a}Ob(i,l||Cn[0],s)}return i}function Ob(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function _p(t,e,n){return Bp(t,t,Cn,Jl(e,n,!V(t)))}function fo(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 Lu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Lb{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ib(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=st,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof on&&u.dirty!=ft&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=on.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==ft&&s.dom==s.contentDOM&&(s.dirty=wn),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof sn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ft&&fo(n,a.outerDeco));if(!p&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=wn,d.updateChildren(i,s+1),d.dirty=st),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!fo(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=sn.create(this.top,n,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,i,o){let s=sn.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Dp(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof on;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof fs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ze||Re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Pp(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||V(e)&&e.contains(this.lock.parentNode))}}function Ib(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof on)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Rb(t,e){return t.type.side-e.type.side}function Db(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<i.length&&i[s].to==o;){let x=i[s++];x.widget&&(u?(d||(d=[u])).push(x):u=x)}if(u)if(d){d.sort(Rb);for(let x=0;x<d.length;x++)n(d[x],c,!!a)}else n(u,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<t.childCount)h=c,p=t.child(c++);else break;for(let x=0;x<l.length;x++)l[x].to<=o&&l.splice(x--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let g=o+p.nodeSize;if(p.isText){let x=g;s<i.length&&i[s].from<x&&(x=i[s].from);for(let w=0;w<l.length;w++)l[w].to<x&&(x=l[w].to);x<g&&(a=p.cut(x-o),p=p.cut(0,x-o),g=x,h=-1)}else for(;s<i.length&&i[s].to<g;)s++;let b=p.isInline&&!p.isLeaf?l.filter(x=>!x.inline):l.slice();r(p,b,e.forChild(o,p),h),o=g}}function Pb(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 $b(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Gl(t,e,n,r,i){let o=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function $a(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(us(n)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&U.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&cb(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new U(s==d?l:r.resolve(d))}else if(et&&e=="key"&&s>t.state.selection.to&&V(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=G.findFrom(r.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!V(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,p=s;for(let h=0;h<n.rangeCount;h++){let g=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(g.startContainer,g.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(d<0)return null;[a,s]=p==t.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=Ba(t,u,l,d)}return c}function zp(t){return t.editable?t.hasFocus():Hp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function zt(t,e=!1){let n=t.state.selection;if(Fp(t,n),!zp(t))return;let r=t.input.mouseDown;if(!e&&Re&&r){let i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Dn(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)_b(t);else{let{anchor:i,head:o}=n,s,l;Iu&&!(n instanceof q)&&(n.$from.parent.inlineContent||(s=Ru(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Ru(t,n.to))),t.docView.setSelection(i,o,t,e),Iu&&(s&&Du(s),l&&Du(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Bb(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Iu=ze||Re&&Tp<63;function Ru(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(ze&&i&&i.contentEditable=="false")return fl(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return fl(i);if(o)return fl(o)}}function fl(t){return t.contentEditable="true",ze&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Du(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Bb(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _b(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Oe(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ye&&rn<=11&&(n.disabled=!0,n.disabled=!1)}function Fp(t,e){if(e instanceof U){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Pu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Pu(t)}function Pu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ba(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||q.between(e,n,r)}function $u(t){return t.editable&&!t.hasFocus()?!1:Hp(t)}function Hp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return Pn(t.dom,e.anchorNode)&&(t.editable||Pn(t.dom,e.focusNode))}catch{return!1}}function zb(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Dn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Xl(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&G.findFrom(o,e)}function Jt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Bu(t,e,n){let r=t.state.selection;if(r instanceof q)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Jt(t,new q(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Xl(t.state,e);return i&&i instanceof U?Jt(t,i):!1}else if(!(ot&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?U.isSelectable(o)?Jt(t,new U(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Jt(t,new q(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof U&&r.node.isInline)return Jt(t,new q(e>0?r.$to:r.$from));{let i=Xl(t.state,e);return i?Jt(t,i):!1}}}function Hr(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):V(t)&&t.contentEditable=="false"}function qn(t,e){return e<0?Fb(t):Hb(t)}function Fb(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(et&&V(n)&&r<Be(n)&&Hr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!V(n))break;let l=n.childNodes[r-1];if(Hr(l,-1))i=n,o=--r;else if(we(l))n=l,r=n.nodeValue.length;else break}else{if(jp(n))break;{let l=n.previousSibling;for(;l&&Hr(l,-1);)i=n.parentNode,o=Oe(l),l=l.previousSibling;if(l)n=l,r=Be(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Zl(t,n,r):i&&Zl(t,i,o)}function Hb(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Be(n),o,s;for(;;)if(r<i){if(!V(n))break;let l=n.childNodes[r];if(Hr(l,1))o=n,s=++r;else break}else{if(jp(n))break;{let l=n.nextSibling;for(;l&&Hr(l,1);)o=l.parentNode,s=Oe(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Be(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&Zl(t,o,s)}function jp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function jb(t,e){for(;t&&e==t.childNodes.length&&!yi(t);)e=Oe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(we(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=0}}function Vb(t,e){for(;t&&!e&&!yi(t);)e=Oe(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(we(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Zl(t,e,n){if(!we(e)){let o,s;(s=jb(e,n))?(e=s,n=0):(o=Vb(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(us(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&zt(t)},50)}function _u(t,e){let n=t.state.doc.resolve(e);if(!(Re||Ap)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function zu(t,e,n){let r=t.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||ot&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Xl(t.state,e);if(s&&s instanceof U)return Jt(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Qe?G.near(s,e):G.findFrom(s,e);return l?Jt(t,l):!1}return!1}function Fu(t,e){if(!(t.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Hu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ub(t){if(!ze||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&V(e)&&n==0&&e.firstChild&&V(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Hu(t,r,"true"),setTimeout(()=>Hu(t,r,"false"),20)}return!1}function qb(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Wb(t,e){let n=e.keyCode,r=qb(e);if(n==8||ot&&n==72&&r=="c")return Fu(t,-1)||qn(t,-1);if(n==46&&!e.shiftKey||ot&&n==68&&r=="c")return Fu(t,1)||qn(t,1);if(n==13||n==27)return!0;if(n==37||ot&&n==66&&r=="c"){let i=n==37?_u(t,t.state.selection.from)=="ltr"?-1:1:-1;return Bu(t,i,r)||qn(t,i)}else if(n==39||ot&&n==70&&r=="c"){let i=n==39?_u(t,t.state.selection.from)=="ltr"?1:-1:1;return Bu(t,i,r)||qn(t,i)}else{if(n==38||ot&&n==80&&r=="c")return zu(t,-1,r)||qn(t,-1);if(n==40||ot&&n==78&&r=="c")return Ub(t)||zu(t,1,r)||qn(t,1);if(r==(ot?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function _a(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||zn.fromSchema(t.state.schema),l=Yp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&V(c)&&(u=Kp[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let g=l.createElement(u[h]);for(;a.firstChild;)g.appendChild(a.firstChild);a.appendChild(g),d++}c=a.firstChild}c&&V(c)&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
52
+
53
+ `);return{dom:a,text:p,slice:e}}function Vp(t,e,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,o||r,t)}),o)return l=new _(L.from(t.state.schema.text(e.replace(/\r\n?/g,`
54
+ `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(d)l=d;else{let p=i.marks(),{schema:h}=t.state,g=zn.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=s.appendChild(document.createElement("p"));b&&x.appendChild(g.serializeNode(h.text(b,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=Gb(n),ds&&Xb(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&!V(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||nn.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Kb.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Zb(ju(l,+u[1],+u[2]),u[4]);else if(l=_.maxOpen(Yb(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=ju(l,d,p)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const Kb=/^(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 Yb(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&qp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Wp(s[s.length-1],o.length));let u=Up(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return L.from(s)}return t}function Up(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,L.from(t));return t}function qp(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=qp(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(L.from(Up(n,t,i+1))))}}function Wp(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Wp(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(L.empty,!0);return t.copy(n.append(r))}function Ql(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(o=0),i<r-1&&(l=Ql(l,e,n,r,i+1,o)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(L.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function ju(t,e,n){return e<t.openStart&&(t=new _(Ql(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _(Ql(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Kp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Yp(){return document.implementation.createHTMLDocument("title")}let Mr=null;function Jb(t){let e=window.trustedTypes;if(!e)return t;if(!Mr){if(Mr=e.defaultPolicy)try{return Mr.createHTML(t)}catch{}Mr=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Mr.createHTML(t)}function Gb(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Yp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&Kp[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Jb(t),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Xb(t){let e=t.querySelectorAll(Re?"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 Zb(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{i=L.from(a.create(r[l+1],i))}catch{break}o++,s++}return new _(i,o,s)}const Ue={},qe={},Qb={touchstart:!0,touchmove:!0};class e0{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 t0(t){for(let e in Ue){let n=Ue[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{r0(t,r)&&!za(t,r)&&(t.editable||!(r.type in qe))&&n(t,r)},Qb[e]?{passive:!0}:void 0)}ze&&t.dom.addEventListener("input",()=>null),ea(t)}function Pt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function n0(t){t.input.mouseDown&&t.input.mouseDown.done(),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 ea(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>za(t,r))})}function za(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function r0(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 i0(t,e){!za(t,e)&&Ue[e.type]&&(t.editable||!(e.type in qe))&&Ue[e.type](t,e)}qe.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Zp(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Dt&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),lr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,xn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Wb(t,n)?n.preventDefault():Pt(t,"key")};qe.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};qe.keypress=(t,e)=>{let n=e;if(Zp(t)||!n.charCode||n.ctrlKey&&!n.altKey||ot&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function ki(t){return{left:t.clientX,top:t.clientY}}function o0(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Fa(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function xi(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 s0(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(xi(t,new U(n)),!0):!1}function l0(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof U&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(U.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(xi(t,U.create(t.state.doc,i)),!0):!1}function a0(t,e,n,r,i){return Fa(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?l0(t,n):s0(t,n))}function c0(t,e,n,r){return Fa(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function u0(t,e,n,r){return Fa(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||d0(t,n,r)}function d0(t,e,n){if(n.button!=0)return!1;let r=Jp(t,e,!0),i=t.state.doc;return r?(xi(t,r),r instanceof q&&i.eq(t.state.doc)&&(t.input.mouseDown=new p0(t,r)),!0):!1}function Jp(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?q.create(r,0,r.content.size):null;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return q.create(r,l+1,l+1+s.content.size);if(n&&U.isSelectable(s))return U.create(r,l)}return null}function Ha(t){return po(t)}const Gp=ot?"metaKey":"ctrlKey";Ue.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ha(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&o0(n,t.input.lastClick)&&!n[Gp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(ki(n));s&&(o=="singleClick"?t.input.mouseDown=new f0(t,s,n,!!r):(o=="doubleClick"?c0:u0)(t,s.pos,s.inside,n)?n.preventDefault():Pt(t,"pointer"))};class Xp{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class f0 extends Xp{constructor(e,n,r,i){super(e),this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Gp],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&V(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof U&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&et&&!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()),Pt(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||zt(this.view)})}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(ki(e))),this.updateAllowDefault(e),this.allowDefault||!n?Pt(this.view,"pointer"):a0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ze&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!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)?(xi(this.view,G.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Pt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class p0 extends Xp{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Pt(this.view,"pointer");let n=this.view.posAtCoords(ki(e)),r=n&&Jp(this.view,n.inside,!1);if(!r)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=r.from<o.from?[o.to,r.from]:[o.from,r.to];xi(this.view,q.create(i,s,l))}}Ue.touchstart=t=>{t.input.lastTouch=Date.now(),Ha(t),Pt(t,"pointer")};Ue.touchmove=t=>{t.input.lastTouch=Date.now(),Pt(t,"pointer")};Ue.contextmenu=t=>Ha(t);function Zp(t,e){return t.composing?!0:ze&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const h0=Dt?5e3:-1;qe.compositionstart=qe.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof q&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Re&&Ap&&m0(t)))t.markCursor=t.state.storedMarks||n.marks(),po(t,!0),t.markCursor=null;else if(po(t,!e.selection.empty),et&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&V(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(we(s)){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}Qp(t,h0)};function m0(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!V(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return V(r)&&r.contentEditable=="false"}qe.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),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++,Qp(t,20))};function Qp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>po(t),e))}function eh(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function g0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=lb(e.focusNode,e.focusOffset),r=ab(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function po(t,e=!1){if(!(Dt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),eh(t),e||t.docView&&t.docView.dirty){let n=$a(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 y0(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const si=Ye&&rn<15||lr&&fb<604;Ue.copy=qe.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=si?null:n.clipboardData,s=r.content(),{dom:l,text:a}=_a(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):y0(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function b0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function k0(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?li(t,r.value,null,i,e):li(t,r.textContent,r.innerHTML,i,e)},50)}function li(t,e,n,r,i){let o=Vp(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||_.empty)))return!0;if(!o)return!1;let s=b0(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function th(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," "):""}qe.paste=(t,e)=>{let n=e;if(t.composing&&!Dt)return;let r=si?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&li(t,th(r),r.getData("text/html"),i,n)?n.preventDefault():k0(t,n)};class nh{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const x0=ot?"altKey":"ctrlKey";function rh(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[x0]}Ue.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(ki(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof U?i.to-1:i.to))){if(r&&r.mightDrag)s=U.create(t.state.doc,r.mightDrag.pos);else if(n.target&&V(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=U.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=_a(t,l);(!n.dataTransfer.files.length||!Re||Tp>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(si?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",si||n.dataTransfer.setData("text/plain",c),t.dragging=new nh(u,rh(t,n),s)};Ue.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};qe.dragover=qe.dragenter=(t,e)=>e.preventDefault();qe.drop=(t,e)=>{try{S0(t,e,t.dragging)}finally{t.dragging=null}};function S0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(ki(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=Vp(t,th(e.dataTransfer),si?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&rh(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||_.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?ip(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&U.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new U(p));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,b,x,w)=>h=w),a.setSelection(Ba(t,p,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Ue.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())&&zt(t)},20))};Ue.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)};Ue.beforeinput=(t,e)=>{if(Dt&&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",o=>o(t,xn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in qe)Ue[t]=qe[t];function ai(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 ho{constructor(e,n){this.toDOM=e,this.spec=n||On,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new je(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ho&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ai(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ln{constructor(e,n){this.attrs=e,this.spec=n||On}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new je(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ln&&ai(this.attrs,e.attrs)&&ai(this.spec,e.spec)}static is(e){return e.type instanceof ln}destroy(){}}class ja{constructor(e,n){this.attrs=e,this.spec=n||On}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new je(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof ja&&ai(this.attrs,e.attrs)&&ai(this.spec,e.spec)}destroy(){}}class je{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new je(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 je(e,e,new ho(n,r))}static inline(e,n,r,i){return new je(e,n,new ln(r,i))}static node(e,n,r,i){return new je(e,n,new ja(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ln}get widget(){return this.type instanceof ho}}const Gn=[],On={};class re{constructor(e,n){this.local=e.length?e:Gn,this.children=n.length?n:Gn}static create(e,n){return n.length?mo(n,e,0,On):$e}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==$e||e.maps.length==0?this:this.mapInner(e,n,0,0,r||On)}mapInner(e,n,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?w0(this.children,s||[],e,n,r,i,o):s?new re(s.sort(Ln),Gn):$e}add(e,n){return n.length?this==$e?re.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=oh(n,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,mo(u,l,c+1,On)),o+=3}});let s=ih(o?sh(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new re(s.length?this.local.concat(s).sort(Ln):this.local,i||this.children)}remove(e){return e.length==0||this==$e?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+n,a=r[o+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=$e?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new re(i,r):$e}forChild(e,n){if(this==$e)return this;if(n.isLeaf)return re.empty;let r,i;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 o=e+1,s=o+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof ln){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new re(i.sort(Ln),Gn);return r?new Qt([l,r]):l}return r||$e}eq(e){if(this==e)return!0;if(!(e instanceof re)||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 Va(this.localsInner(e))}localsInner(e){if(this==$e)return Gn;if(e.inlineContent||!this.local.some(ln.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ln||n.push(this.local[r]);return n}forEachSet(e){e(this)}}re.empty=new re([],[]);re.removeOverlap=Va;const $e=re.empty;class Qt{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,On));return Qt.from(r)}forChild(e,n){if(n.isLeaf)return re.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=$e&&(o instanceof Qt?r=r.concat(o.members):r.push(o))}return Qt.from(r)}eq(e){if(!(e instanceof Qt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?Va(r?n:n.sort(Ln)):Gn}static from(e){switch(e.length){case 0:return $e;case 1:return e[0];default:return new Qt(e.every(n=>n instanceof re)?e:e.reduce((n,r)=>n.concat(r instanceof re?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function w0(t,e,n,r,i,o,s){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((p,h,g,b)=>{let x=b-g-(h-p);for(let w=0;w<l.length;w+=3){let T=l[w+1];if(T<0||p>T+u-d)continue;let R=l[w]+u-d;h>=R?l[w+1]=p<=R?-2:-1:p>=u&&x&&(l[w]+=x,l[w+1]+=x)}d+=x}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+o),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let p=n.map(t[c+1]+o,-1),h=p-i,{index:g,offset:b}=r.content.findIndex(d),x=r.maybeChild(g);if(x&&b==d&&b+x.nodeSize==h){let w=l[c+2].mapInner(n,x,u+1,t[c]+o+1,s);w!=$e?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=C0(l,t,e,n,i,o,s),u=mo(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let h=u.children[d];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new re(e.sort(Ln),l)}function ih(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new je(i.from+e,i.to+e,i.type))}return n}function C0(t,e,n,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?n.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function oh(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function sh(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function mo(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=oh(t,l,a+n);if(c){o=!0;let u=mo(c,l,n+a+1,r);u!=$e&&i.push(a,a+l.nodeSize,u)}});let s=ih(o?sh(t):t,-n).sort(Ln);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new re(s,i):$e}function Ln(t,e){return t.from-e.from||t.to-e.to}function Va(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Vu(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Vu(e,i,r.copy(o.from,r.to)));break}}}return e}function Vu(t,e,n){for(;e<t.length&&Ln(n,t[e])>0;)e++;t.splice(e,0,n)}function pl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=$e&&e.push(r)}),t.cursorWrapper&&e.push(re.create(t.state.doc,[t.cursorWrapper.deco])),Qt.from(e)}const v0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},M0=Ye&&rn<=11;class T0{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 A0{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new T0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Ye&&rn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ze&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),M0&&(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,v0)),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($u(this.view)){if(this.suppressingSelectionUpdates)return zt(this.view);if(Ye&&rn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Dn(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 o=e.focusNode;o;o=sr(o))n.add(o);for(let o=e.anchorNode;o;o=sr(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:we(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&$u(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Re&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&V(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(et&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let p of u){let h=p.parentNode;h&&h.nodeName=="LI"&&(!d||O0(e,d)!=h)&&p.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&us(r)&&(c=$a(e))&&c.eq(G.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,zt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),E0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,L0(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||zt(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 u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),we(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(Ye&&rn<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:p}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(o=p)}let s=i&&i.parentNode==e.target?Oe(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?Oe(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}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 Uu=new WeakMap,qu=!1;function E0(t){if(!Uu.has(t)&&(Uu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=et,qu)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."),qu=!0}}function Wu(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Dn(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function N0(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Wu(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Wu(t,n):null}function O0(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 L0(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!V(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function I0(t,e,n,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&Pn(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],us(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Re&&t.input.lastKeyCode===8)for(let w=s;w>o;w--){let T=i.childNodes[w-1],R=T.pmViewDesc;if(T.nodeName=="BR"&&!R){s=w;break}if(!R||R.size)break}let p=t.state.doc,h=t.someProp("domParser")||nn.fromSchema(t.state.schema),g=p.resolve(l),b=null,x=h.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:o,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:R0(r),context:g});if(u&&u[0].pos!=null){let w=u[0].pos,T=u[1]&&u[1].pos;T==null&&(T=w),b={anchor:w+l,head:T+l}}return{doc:x,sel:b,from:l,to:a}}const R0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ze&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ze&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},D0=/^(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 P0(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let j=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,ee=$a(t,j);if(ee&&!t.state.selection.eq(ee)){if(Re&&Dt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",ye=>ye(t,xn(13,"Enter"))))return;let te=t.state.tr.setSelection(ee);j=="pointer"?te.setMeta("pointer",!0):j=="key"&&te.scrollIntoView(),o&&te.setMeta("composition",o),t.dispatch(te)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=I0(t,e,n,i),u=t.state.doc,d=u.slice(c.from,c.to),p,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,h="end"):(p=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let g=z0(d.content,c.doc.content,c.from,p,h);if(g&&t.input.domChangeCount++,(lr&&t.input.lastIOSEnter>Date.now()-225||Dt)&&i.some(j=>V(j)&&!D0.test(j.nodeName))&&(!g||g.endA>=g.endB)&&t.someProp("handleKeyDown",j=>j(t,xn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!g)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))g={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let j=Ku(t,t.state.doc,c.sel);if(j&&!j.eq(t.state.selection)){let ee=t.state.tr.setSelection(j);o&&ee.setMeta("composition",o),t.dispatch(ee)}}return}t.state.selection.from<t.state.selection.to&&g.start==g.endB&&t.state.selection instanceof q&&(g.start>t.state.selection.from&&g.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?g.start=t.state.selection.from:g.endA<t.state.selection.to&&g.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(g.endB+=t.state.selection.to-g.endA,g.endA=t.state.selection.to)),Ye&&rn<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>c.from&&c.doc.textBetween(g.start-c.from-1,g.start-c.from+1)=="  "&&(g.start--,g.endA--,g.endB--);let b=c.doc.resolveNoCache(g.start-c.from),x=c.doc.resolveNoCache(g.endB-c.from),w=u.resolve(g.start),T=b.sameParent(x)&&b.parent.inlineContent&&w.end()>=g.endA;if((lr&&t.input.lastIOSEnter>Date.now()-225&&(!T||i.some(j=>j.nodeName=="DIV"||j.nodeName=="P"))||!T&&_0(c.doc,b.pos,x.pos))&&t.someProp("handleKeyDown",j=>j(t,xn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>g.start&&B0(u,g.start,g.endA,b,x)&&t.someProp("handleKeyDown",j=>j(t,xn(8,"Backspace")))){Dt&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&g.endB==g.start&&(t.input.lastChromeDelete=Date.now()),Dt&&!T&&b.start()!=x.start()&&x.parentOffset==0&&b.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==g.endA&&(g.endB-=2,x=c.doc.resolveNoCache(g.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(j){return j(t,xn(13,"Enter"))})},20));let R=g.start,$=g.endA,Y=j=>{let ee=j||t.state.tr.replace(R,$,c.doc.slice(g.start-c.from,g.endB-c.from));if(c.sel){let te=Ku(t,ee.doc,c.sel);te&&!(Re&&t.composing&&te.empty&&(g.start!=g.endB||t.input.lastChromeDelete<Date.now()-100)&&(te.head==R||te.head==ee.mapping.map($)-1)||Ye&&te.empty&&te.head==R)&&ee.setSelection(te)}return o&&ee.setMeta("composition",o),ee.scrollIntoView()},ne;if(T)if(b.pos==x.pos){Ye&&rn<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>zt(t),20));let j=Y(t.state.tr.delete(R,$)),ee=u.resolve(g.start).marksAcross(u.resolve(g.endA));ee&&j.ensureMarks(ee),t.dispatch(j)}else if(g.endA==g.endB&&(ne=$0(b.parent.content.cut(b.parentOffset,x.parentOffset),w.parent.content.cut(w.parentOffset,g.endA-w.start())))){let j=Y(t.state.tr);ne.type=="add"?j.addMark(R,$,ne.mark):j.removeMark(R,$,ne.mark),t.dispatch(j)}else if(b.parent.child(b.index()).isText&&b.index()==x.index()-(x.textOffset?0:1)){let j=b.parent.textBetween(b.parentOffset,x.parentOffset),ee=()=>Y(t.state.tr.insertText(j,R,$));t.someProp("handleTextInput",te=>te(t,R,$,j,ee))||t.dispatch(ee())}else t.dispatch(Y());else t.dispatch(Y())}function Ku(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ba(t,e.resolve(n.anchor),e.resolve(n.head))}function $0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(L.from(c).eq(t))return{mark:l,type:s}}function B0(t,e,n,r,i){if(n-e<=i.pos-r.pos||hl(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(hl(o,!0,!0));return!s.parent.isTextblock||s.pos>n||hl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function _0(t,e,n){let r=0,i=0;return t.nodesBetween(e,n,(o,s)=>{o.isTextblock&&s>=e&&s<n?r++:(o.isText?/\S/.test(o.text.slice(Math.max(0,e-s),Math.min(o.nodeSize,n-s))):o.isLeaf)&&i++}),i==0&&r==1}function hl(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function z0(t,e,n,r,i){let o=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(o==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(i=="end"){let u=Math.max(0,o-Math.min(a,c));r-=a+u-o}if(a<o&&s<l){let u=r<=o&&r>=a?o-r:0;o-=u,c=o+(c-a),a=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,a=o+(a-c),c=o}return{start:o,endA:a,endB:c}}class lh{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 e0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Zu),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=Gu(this),Ju(this),this.nodeViews=Xu(this),this.docView=Ou(this.state.doc,Yu(this),pl(this),this.dom,this),this.domObserver=new A0(this,(r,i,o,s)=>P0(this,r,i,o,s)),this.domObserver.start(),t0(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&&ea(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Zu),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(eh(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Xu(this);H0(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ea(this),this.editable=Gu(this),Ju(this);let a=pl(this),c=Yu(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&mb(this);if(s){this.domObserver.stop();let h=d&&(Ye||Re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&F0(i.selection,e.selection);if(d){let b=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=g0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ou(e.doc,c,a,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let g=this.input.mouseDown;h||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&zb(this)&&g.delaySelUpdate())?zt(this,h):(Fp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&gb(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!Pn(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof U){let n=this.docView.domAfterPos(this.state.selection.from);V(n)&&Mu(this,n.getBoundingClientRect(),e)}else Mu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new nh(e.slice,e.move,i<0?void 0:U.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Ye){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&&yb(this.dom),zt(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 wb(this,e)}coordsAtPos(e,n=1){return Ip(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return Ab(this,n||this.state,e)}pasteHTML(e,n){return li(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return li(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return _a(this,e)}destroy(){this.docView&&(n0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],pl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ob())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return i0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ze&&this.root.nodeType===11&&ub(this.dom.ownerDocument)==this.dom&&N0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}lh.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Yu(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"),[je.node(0,t.state.doc.content.size,e)]}function Ju(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:je.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Gu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function F0(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 Xu(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function H0(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Zu(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 dn={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:"'"},go={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},j0=typeof navigator<"u"&&/Mac/.test(navigator.platform),V0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Le=0;Le<10;Le++)dn[48+Le]=dn[96+Le]=String(Le);for(var Le=1;Le<=24;Le++)dn[Le+111]="F"+Le;for(var Le=65;Le<=90;Le++)dn[Le]=String.fromCharCode(Le+32),go[Le]=String.fromCharCode(Le);for(var ml in dn)go.hasOwnProperty(ml)||(go[ml]=dn[ml]);function U0(t){var e=j0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||V0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?go:dn)[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 q0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),W0=typeof navigator<"u"&&/Win/.test(navigator.platform);function K0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))q0?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Y0(t){let e=Object.create(null);for(let n in t)e[K0(n)]=t[n];return e}function gl(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 J0(t){return new fe({props:{handleKeyDown:ah(t)}})}function ah(t){let e=Y0(t);return function(n,r){let i=U0(r),o,s=e[gl(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[gl(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(W0&&r.ctrlKey&&r.altKey)&&(o=dn[r.keyCode])&&o!=i){let l=e[gl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var yo=200,Ae=function(){};Ae.prototype.append=function(e){return e.length?(e=Ae.from(e),!this.length&&e||e.length<yo&&this.leafAppend(e)||this.length<yo&&e.leafPrepend(this)||this.appendInner(e)):this};Ae.prototype.prepend=function(e){return e.length?Ae.from(e).append(this):this};Ae.prototype.appendInner=function(e){return new G0(this,e)};Ae.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ae.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ae.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ae.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)};Ae.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};Ae.from=function(e){return e instanceof Ae?e:e&&e.length?new ch(e):Ae.empty};var ch=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=yo)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=yo)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ae);Ae.empty=new ch([]);var G0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ae);const X0=500;class ut{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new gt(d.map));let h=d.step.map(i.slice(o)),g;h&&s.maybeStep(h).doc&&(g=s.mapping.maps[s.mapping.maps.length-1],c.push(new gt(g,void 0,void 0,c.length+u.length))),o--,g&&i.appendMap(g,o)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(o)):d.selection,a=new ut(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new gt(e.mapping.maps[u],d,n),h;(h=a&&a.merge(p))&&(p=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(p),n&&(s++,n=void 0),i||(a=p)}let c=s-r.depth;return c>Q0&&(l=Z0(l,c),s-=c),new ut(l.append(o),s)}remapping(e,n){let r=new ii;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new ut(this.items.append(e.map(n=>new gt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=n;this.items.forEach(p=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let g=o.maps[h];if(p.step){let b=e.steps[h].invert(e.docs[h]),x=p.selection&&p.selection.map(o.slice(a+1,h));x&&l++,r.push(new gt(g,b,x))}else r.push(new gt(g))},i);let c=[];for(let p=n;p<s;p++)c.push(new gt(o.maps[p]));let u=this.items.slice(0,i).append(c).append(r),d=new ut(u,l);return d.emptyItemCount()>X0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let d=new gt(c.invert(),a,u),p,h=i.length-1;(p=i.length&&i[h].merge(d))?i[h]=p:i.push(d)}}else s.map&&r--},this.items.length,0),new ut(Ae.from(i.reverse()),o)}}ut.empty=new ut(Ae.empty,0);function Z0(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class gt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new gt(n.getMap().invert(),n,this.selection)}}}class Gt{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const Q0=20;function ek(t,e,n,r){let i=n.getMeta(an),o;if(i)return i.historyState;n.getMeta(uh)&&(t=new Gt(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(an))return s.getMeta(an).redo?new Gt(t.done.addTransform(n,void 0,r,to(e)),t.undone,Qu(n.mapping.maps),t.prevTime,t.prevComposition):new Gt(t.done,t.undone.addTransform(n,void 0,r,to(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!tk(n,t.prevRanges)),c=s?yl(t.prevRanges,n.mapping):Qu(n.mapping.maps);return new Gt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,to(e)),ut.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Gt(t.done.rebased(n,o),t.undone.rebased(n,o),yl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),yl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function tk(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function Qu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function yl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function nk(t,e,n){let r=to(e),i=an.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new Gt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(an,{redo:n,historyState:a})}let bl=!1,ed=null;function to(t){let e=t.plugins;if(ed!=e){bl=!1,ed=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){bl=!0;break}}return bl}function rk(t){return t.setMeta(uh,!0)}const an=new xe("history"),uh=new xe("closeHistory");function ik(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new fe({key:an,state:{init(){return new Gt(ut.empty,ut.empty,null,0,-1)},apply(e,n,r){return ek(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?fh:r=="historyRedo"?ph:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function dh(t,e){return(n,r)=>{let i=an.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=nk(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const fh=dh(!1,!0),ph=dh(!0,!0);function ok(t){return t.getMeta(an)!=null}function ps(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=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 o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}var tr=class hh{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l=[],a=!!e,c=e||o.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...b)=>{const x=this.buildProps(c,n),w=h(...b)(x);return l.push(w),d}])),run:u};return d}static createFakeChain(){const e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}static createFallbackCan(){const e=hh.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l={tr:e,editor:i,view:s,state:ps({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}};const sk=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),lk=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),ak=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),p=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(p);if(!h)return;const g=pr(h);if(l.type.isTextblock){const{defaultType:b}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,b)}(g||g===0)&&e.lift(h,g)})}),!0},ck=t=>e=>t(e),uk=()=>({state:t,dispatch:e})=>Sp(t,e),dk=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new q(r.doc.resolve(Math.max(s-1,0)))),!0},fk=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const s=i.before(o),l=i.after(o);t.delete(s,l).scrollIntoView()}return!0}return!1};function Ce(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}const pk=t=>({tr:e,state:n,dispatch:r})=>{const i=Ce(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),a=o.after(s);e.delete(l,a).scrollIntoView()}return!0}return!1},hk=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},mk=t=>t.content?/^text(\*|\+)/.test(t.content):!1,td=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return mk(r)?n==="left"?t.start()-1:t.end()+1:t.pos},gk=(t,e,n)=>({from:td(t,n,"left"),to:td(e,n,"right")}),yk=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,i=n.steps.length;r.forEach(o=>{const s=n.mapping.slice(i),l=n.doc.resolve(s.map(o.$from.pos)),a=n.doc.resolve(s.map(o.$to.pos)),{from:c,to:u}=gk(l,a,t.schema);n.deleteRange(c,u)}),n.selection.empty||n.setSelection(q.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},bk=()=>({commands:t})=>t.keyboardShortcut("Enter"),kk=()=>({state:t,dispatch:e})=>Uy(t,e);function Ua(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function bo(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Ua(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function mh(t,e,n={}){return t.find(r=>r.type===e&&bo(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function nd(t,e,n={}){return!!mh(t,e,n)}function qa(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){const a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!mh([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,s=i+1,l=o+r.node.nodeSize;for(;i>0&&nd([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;s<t.parent.childCount&&nd([...t.parent.child(s).marks],e,n);)l+=t.parent.child(s).nodeSize,s+=1;return{from:o,to:l}}function Ht(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}const xk=(t,e)=>({tr:n,state:r,dispatch:i})=>{const o=Ht(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=qa(a,o,e);if(d&&d.from<=c&&d.to>=u){const p=q.create(s,d.from,d.to);n.setSelection(p)}}return!0},Sk=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 gh(t){return t instanceof q}function vn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ta(t,e=null){if(!e)return null;const n=G.atStart(t),r=G.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?q.create(t,vn(0,i,o),vn(t.content.size,i,o)):q.create(t,vn(e,i,o),vn(e,i,o))}function rd(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function ko(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function wk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Ck=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(ko()||rd())&&r.dom.focus(),wk()&&!ko()&&!rd()&&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(o&&t===null&&!gh(n.state.selection))return s(),!0;const l=ta(i.doc,t)||n.state.selection,a=n.state.selection.eq(l);return o&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},vk=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Mk=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),yh=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&&yh(r)}return t};function Hi(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 yh(n)}function bh(t){return typeof(t==null?void 0:t.nodesBetween)=="function"}function ar(t,e,n){if(bh(t))return t;const r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};const i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return L.fromArray(t.map(s=>e.nodeFromJSON(s)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),ar("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,l="";const a=new Kf({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:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?nn.fromSchema(a).parseSlice(Hi(t),n.parseOptions):nn.fromSchema(a).parse(Hi(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=nn.fromSchema(e);return n.slice?o.parseSlice(Hi(t),n.parseOptions).content:o.parse(Hi(t),n.parseOptions)}return ar("",e,n)}function kh(t){return!("type"in t)}function xh(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof me||i instanceof Te))return;const o=t.mapping.maps[r];let s=0;o.forEach((l,a,c,u)=>{s===0&&(s=u)}),t.setSelection(G.near(t.doc.resolve(s),n))}const Tk=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=x=>{o.emit("contentError",{editor:o,error:x,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{ar(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){a(x)}try{var s;l=ar(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(x){return a(x),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,h=!0;const g=kh(l)?l.content:[l];if(g.forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,h=h?x.isBlock:!1}),u===d&&h){const{parent:x}=r.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,d+=1)}let b;if(p)Array.isArray(e)?b=e.map(x=>x.text||"").join(""):bh(e)?b=g.map(x=>{var w;return(w=x.text)!==null&&w!==void 0?w:""}).join(""):typeof e=="object"&&e&&e.text?b=e.text:b=e,r.insertText(b,u,d);else{b=L.from(g);const x=r.doc.resolve(u),w=x.node(),T=x.parentOffset===0,R=w.isText||w.isTextblock,$=w.content.size>0;T&&R&&$&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&xh(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:b})}return!0};function Sh(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}const Ak=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:i,attrs:o,content:s,updateSelection:l=!0}=t;let a;typeof i=="number"?a=e.doc.resolve(i):i?a=i:a=e.selection.$from;const c=Sh(a.parent.contentMatchAt(a.index()));if(!c)return!1;const u=Object.keys(c.spec.attrs||{}),d=o?Object.fromEntries(Object.entries(o).filter(([h])=>u.includes(h))):{};let p;if(s){const h=ar(s,r.schema);p=c.createAndFill(d,h)}else p=c.createAndFill(d);return p?(n&&(e.insert(a.pos,p),l&&xh(e,e.steps.length-1,-1)),!0):!1},Ek=()=>({state:t,dispatch:e})=>Hy(t,e),Nk=()=>({state:t,dispatch:e})=>jy(t,e),Ok=()=>({state:t,dispatch:e})=>hp(t,e),Lk=()=>({state:t,dispatch:e})=>bp(t,e),wh=(t,e)=>{const n=t.resolve(e),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Ik=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ls(t.doc,t.selection.$from.pos,-1);return r==null||!wh(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Rk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ls(t.doc,t.selection.$from.pos,1);return r==null||!wh(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Dk=()=>({state:t,dispatch:e})=>zy(t,e),Pk=()=>({state:t,dispatch:e})=>Fy(t,e);function Ch(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function $k(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))ko()||Ch()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const Bk=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=$k(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Ft(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?Ce(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(u,d)=>{if(u.isText)return;const p=Math.max(r,d),h=Math.min(i,d+u.nodeSize);l.push({node:u,from:p,to:h})});const a=i-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>bo(u.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}const _k=(t,e={})=>({state:n,dispatch:r})=>Ft(n,Ce(t,n.schema),e)?Vy(n,r):!1,zk=()=>({state:t,dispatch:e})=>wp(t,e),Fk=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return tb(r)(e,n)},Hk=()=>({state:t,dispatch:e})=>xp(t,e);function hs(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function id(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const jk=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const l=hs(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=Ce(t,r.schema)),l==="mark"&&(s=Ht(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(a=!0,i&&n.setNodeMarkup(d,void 0,id(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(p=>{s===p.type&&(a=!0,i&&n.addMark(d,d+u.nodeSize,s.create(id(p.attrs,e))))})})}),a},Vk=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Uk=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qe(t.doc);t.setSelection(n)}return!0},qk=()=>({state:t,dispatch:e})=>gp(t,e),Wk=()=>({state:t,dispatch:e})=>kp(t,e),Kk=()=>({state:t,dispatch:e})=>Ky(t,e),Yk=()=>({state:t,dispatch:e})=>Gy(t,e),Jk=()=>({state:t,dispatch:e})=>Jy(t,e);function na(t,e,n={},r={}){return ar(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Gk=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:s,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=na(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});if(s){const u=kh(c)?c.content:[c];o.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return s&&o.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function vh(t,e){const n=Ht(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,a=>{s.push(...a.marks)});const l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Mh(t,e){const n=new cp(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Xk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function Zk(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 ms(t){return e=>Zk(e.$from,t)}function H(t,e,n){return t.config[e]===void 0&&t.parent?H(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?H(t.parent,e,n):null}):t.config[e]}function Wa(t){return t.map(e=>{const n=H(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Wa(n())]:e}).flat(10)}function Ka(t,e){const n=zn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function ra(t){return typeof t=="function"}function ie(t,e=void 0,...n){return ra(t)?e?t.bind(e)(...n):t(...n):t}function Qk(t={}){return Object.keys(t).length===0&&t.constructor===Object}function cr(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function Th(t){const e=[],{nodeExtensions:n,markExtensions:r}=cr(t),i=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{const u=H(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:i});u&&u().forEach(d=>{let p;Array.isArray(d.types)?p=d.types:d.types==="*"?p=a:d.types==="nodes"?p=s:d.types==="marks"?p=l:p=[],p.forEach(h=>{Object.entries(d.attributes).forEach(([g,b])=>{e.push({type:h,name:g,attribute:{...o,...b}})})})})}),i.forEach(c=>{const u=H(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;const d=u();Object.entries(d).forEach(([p,h])=>{const g={...o,...h};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:c.name,name:p,attribute:g})})}),e}function ex(t){const e=[];let n="",r=!1,i=!1,o=0;const s=t.length;for(let l=0;l<s;l+=1){const a=t[l];if(a==="'"&&!i){r=!r,n+=a;continue}if(a==='"'&&!r){i=!i,n+=a;continue}if(!r&&!i){if(a==="("){o+=1,n+=a;continue}if(a===")"&&o>0){o-=1,n+=a;continue}if(a===";"&&o===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function od(t){const e=[],n=ex(t||""),r=n.length;for(let i=0;i<r;i+=1){const o=n[i],s=o.indexOf(":");if(s===-1)continue;const l=o.slice(0,s).trim(),a=o.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function be(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(i==="__proto__"){Object.defineProperty(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0});return}if(!r[i]){r[i]=o;return}if(i==="class"){const s=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],a=s.filter(c=>!l.includes(c));r[i]=[...l,...a].join(" ")}else if(i==="style"){const s=new Map([...od(r[i]),...od(o)]);r[i]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[i]=o}),r},{})}function ci(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)=>be(n,r),{})}function tx(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function sd(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(n):tx(n.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function ld(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Qk(n)?!1:n!=null))}function ad(t){var e,n;const r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function nx(t,e){var n;const r=Th(t),{nodeExtensions:i,markExtensions:o}=cr(t),s=(n=i.find(c=>H(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(x=>x.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},p=ld({...t.reduce((x,w)=>{const T=H(w,"extendNodeSchema",d);return{...x,...T?T(c):{}}},{}),content:ie(H(c,"content",d)),marks:ie(H(c,"marks",d)),group:ie(H(c,"group",d)),inline:ie(H(c,"inline",d)),atom:ie(H(c,"atom",d)),selectable:ie(H(c,"selectable",d)),draggable:ie(H(c,"draggable",d)),code:ie(H(c,"code",d)),whitespace:ie(H(c,"whitespace",d)),linebreakReplacement:ie(H(c,"linebreakReplacement",d)),defining:ie(H(c,"defining",d)),isolating:ie(H(c,"isolating",d)),attrs:Object.fromEntries(u.map(ad))}),h=ie(H(c,"parseHTML",d));h&&(p.parseDOM=h.map(x=>sd(x,u)));const g=H(c,"renderHTML",d);g&&(p.toDOM=x=>g({node:x,HTMLAttributes:ci(x,u)}));const b=H(c,"renderText",d);return b&&(p.toText=b),[c.name,p]})),a=Object.fromEntries(o.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},p=ld({...t.reduce((b,x)=>{const w=H(x,"extendMarkSchema",d);return{...b,...w?w(c):{}}},{}),inclusive:ie(H(c,"inclusive",d)),excludes:ie(H(c,"excludes",d)),group:ie(H(c,"group",d)),spanning:ie(H(c,"spanning",d)),code:ie(H(c,"code",d)),attrs:Object.fromEntries(u.map(ad))}),h=ie(H(c,"parseHTML",d));h&&(p.parseDOM=h.map(b=>sd(b,u)));const g=H(c,"renderHTML",d);return g&&(p.toDOM=b=>g({mark:b,HTMLAttributes:ci(b,u)})),[c.name,p]}));return new Kf({topNode:s,nodes:l,marks:a})}function rx(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function jr(t){return t.sort((n,r)=>{const i=H(n,"priority")||100,o=H(r,"priority")||100;return i>o?-1:i<o?1:0})}function Ah(t){const e=jr(Wa(t)),n=rx(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 Eh(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
55
+
56
+ `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,i,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=o);const p=s==null?void 0:s[a.type.name];if(p)return u&&(l+=p({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c)}}),l}function ix(t,e){return Eh(t,{from:0,to:t.content.size},e)}function Nh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ox(t,e){const n=Ce(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,l=>{o.push(l)});const s=o.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Oh(t,e){const n=hs(typeof e=="string"?e:e.name,t.schema);return n==="node"?ox(t,e):n==="mark"?vh(t,e):{}}function sx(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function lx(t){const e=sx(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 gs(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{const s=[];if(i.ranges.length)i.forEach((l,a)=>{s.push({from:l,to:a})});else{const{from:l,to:a}=n[o];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),u=e.slice(o).map(a),d=e.invert().map(c,-1),p=e.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:c,to:u}})})}),lx(r)}function ys(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=qa(n.resolve(t),i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}const ax=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let o=r,s=null;for(;o>0&&s===null;){const l=i.node(o);(l==null?void 0:l.type.name)===e?s=l:o-=1}return[s,o]},cx=t=>{const e=t.depth-1;if(e<0)return null;const n=t.index(e);return n===0?null:t.node(e).child(n-1)};function Wn(t,e){return e.nodes[t]||e.marks[t]||null}function no(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}const ux=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,l)=>{var a,c;const u=((a=(c=i.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:i,pos:o,parent:s,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),n};function ia(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Ht(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>bo(u.attrs,n,{strict:!1}));let s=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const p=u.pos,h=d.pos;t.doc.nodesBetween(p,h,(g,b)=>{if(o&&g.inlineContent&&!g.type.allowsMarkType(o))return!1;if(!g.isText&&!g.marks.length)return;const x=Math.max(p,b),w=Math.min(h,b+g.nodeSize),T=w-x;s+=T,l.push(...g.marks.map(R=>({mark:R,from:x,to:w})))})}),s===0)return!1;const a=l.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>bo(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=s}function dx(t,e,n={}){if(!e)return Ft(t,null,n)||ia(t,null,n);const r=hs(e,t.schema);return r==="node"?Ft(t,e,n):r==="mark"?ia(t,e,n):!1}const fx=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const o=ms(l=>l.type.name===e)(t.selection);if(!o)return!1;const s=t.doc.resolve(o.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},px=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function cd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function kl(t,e){const{nodeExtensions:n}=cr(e),r=n.find(o=>o.name===t);if(!r)return!1;const i=ie(H(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof i!="string"?!1:i.split(" ").includes("list")}function Si(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(Si(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Lh(t){return t instanceof U}var Ih=class Rh{constructor(e){this.position=e}static fromJSON(e){return new Rh(e.position)}toJSON(){return{position:this.position}}};function hx(t,e){const n=e.mapping.mapResult(t.position);return{position:new Ih(n.pos),mapResult:n}}function mx(t){return new Ih(t)}function gx(t,e,n){const{selection:r}=e;let i=null;if(gh(r)&&(i=r.$cursor),i){var o;const l=(o=t.storedMarks)!==null&&o!==void 0?o:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}const{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,p)=>{if(c)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(n),g=!!n.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(n));c=h&&g}return!c}),c})}const yx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:l}=o,a=Ht(t,r.schema);if(i)if(s){const c=vh(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(p,h)=>{const g=Math.max(h,u),b=Math.min(h+p.nodeSize,d);p.marks.find(x=>x.type===a)?p.marks.forEach(x=>{a===x.type&&n.addMark(g,b,a.create({...x.attrs,...e}))}):n.addMark(g,b,a.create(e))})});return gx(r,n,a)},bx=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),kx=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=Ce(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:l})=>wu(o,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>wu(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},xx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=vn(t,0,r.content.size),o=U.create(r,i);e.setSelection(o)}return!0},Sx=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=o.from,l=o.to),i&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},wx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=q.atStart(r).from,l=q.atEnd(r).to,a=vn(i,s,l),c=vn(o,s,l),u=q.create(r,a,c);e.setSelection(u)}return!0},Cx=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return ib(r)(e,n)};function ud(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const vx=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:l,$to:a}=o,c=i.extensionManager.attributes,u=no(c,l.node().type.name,l.node().attrs);if(o instanceof U&&o.node.isBlock)return!l.parentOffset||!_t(s,l.pos)?!1:(r&&(t&&ud(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,p=l.depth===0?void 0:Sh(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&p?[{type:p,attrs:u}]:void 0;const g=o instanceof q&&!o.empty?Rt.create({doc:e.doc,selection:o}).tr.deleteSelection():null,b=g?g.doc:e.doc,x=g?g.mapping.map(l.pos):l.pos;let w=_t(b,x,1,h);if(!h&&!w&&_t(b,x,1,p?[{type:p}]:void 0)&&(w=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(w){const T=e.steps.length;if(o instanceof q&&e.deleteSelection(),e.split(e.mapping.slice(T).map(l.pos),1,h),p&&!d&&!l.parentOffset&&l.parent.type!==p){const R=e.mapping.slice(T).map(l.before()),$=e.doc.resolve(R);l.node(-1).canReplaceWith($.index(),$.index()+1,p)&&e.setNodeMarkup(e.mapping.slice(T).map(l.before()),p)}}t&&ud(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return w},Mx=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{const s=Ce(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==s)return!1;const d=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){var p;let $=L.empty;const Y=l.index(-1)?1:l.index(-2)?2:3;for(let Me=l.depth-Y;Me>=l.depth-3;Me-=1)$=L.from(l.node(Me).copy($));const ne=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,j={...no(d,l.node().type.name,l.node().attrs),...e},ee=((p=s.contentMatch.defaultType)===null||p===void 0?void 0:p.createAndFill(j))||void 0;$=$.append(L.from(s.createAndFill(null,ee)||void 0));const te=l.before(l.depth-(Y-1));n.replace(te,l.after(-ne),new _($,4-Y,0));let ye=-1;n.doc.nodesBetween(te,n.doc.content.size,(Me,tt)=>{if(ye>-1)return!1;Me.isTextblock&&Me.content.size===0&&(ye=tt+1)}),ye>-1&&n.setSelection(q.near(n.doc.resolve(ye))),n.scrollIntoView()}return!0}const h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...no(d,u.type.name,u.attrs),...e},b={...no(d,l.node().type.name,l.node().attrs),...e},x=l.parentOffset===0&&l.index(-1)===0,w=l.before(-1);n.delete(l.pos,a.pos);const T=x?u.attrs:g,R=h?[{type:s,attrs:T},{type:h,attrs:b}]:[{type:s,attrs:T}];if(!_t(n.doc,l.pos,2))return!1;if(i){const{selection:$,storedMarks:Y}=r,{splittableMarks:ne}=o.extensionManager,j=Y||$.$to.parentOffset&&$.$from.marks();if(n.split(l.pos,2,R).scrollIntoView(),x&&n.setNodeMarkup(w,void 0,g),!j||!i)return!0;const ee=j.filter(te=>ne.includes(te.type.name));n.ensureMarks(ee)}return!0};function dd(t){return!t||t==="1"?null:t}function Dh(t,e){return dd(t)===dd(e)}const xl=(t,e)=>{const n=ms(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 i=t.doc.nodeAt(r);return!(n.node.type===(i==null?void 0:i.type)&&hn(t.doc,n.pos))||!Dh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(n.pos),!0},Sl=(t,e)=>{const n=ms(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 i=t.doc.nodeAt(r);return!(n.node.type===(i==null?void 0:i.type)&&hn(t.doc,r))||!Dh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(r),!0};function Tx(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return q.between(r,i)}const Ax=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,h=Ce(t,s.schema),g=Ce(e,s.schema),{selection:b,storedMarks:x}=s,{$from:w,$to:T}=b,R=w.blockRange(T),$=x||b.$to.parentOffset&&b.$from.marks();if(!R)return!1;const Y=ms(Ee=>kl(Ee.type.name,d))(b),ne=b.from===0&&b.to===s.doc.content.size,j=s.doc.content.content,ee=j.length===1?j[0]:null,te=ne&&ee&&kl(ee.type.name,d)?{node:ee,pos:0}:null,ye=Y??te,Me=!!Y&&R.depth>=1&&R.depth-Y.depth<=1,tt=!!te;if((Me||tt)&&ye){if(ye.node.type===h)return ne&&tt?a().command(({tr:Ee,dispatch:le})=>{const De=Tx(Ee);return De?(Ee.setSelection(De),le&&le(Ee),!0):!1}).liftListItem(g).run():c.liftListItem(g);if(kl(ye.node.type.name,d)&&h.validContent(ye.node.content))return a().command(()=>(o.setNodeMarkup(ye.pos,h),!0)).command(()=>xl(o,h)).command(()=>Sl(o,h)).run()}return!n||!$||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>xl(o,h)).command(()=>Sl(o,h)).run():a().command(()=>{const Ee=u().wrapInList(h,r),le=$.filter(De=>p.includes(De.type.name));return o.ensureMarks(le),Ee?!0:c.clearNodes()}).wrapInList(h,r).command(()=>xl(o,h)).command(()=>Sl(o,h)).run()},Ex=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Ht(t,r.schema);return ia(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Nx=(t,e,n={})=>({state:r,commands:i})=>{const o=Ce(t,r.schema),s=Ce(e,r.schema),l=Ft(r,o,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(s,a):i.setNode(o,{...a,...n})},Ox=(t,e={})=>({state:n,commands:r})=>{const i=Ce(t,n.schema);return Ft(n,i,e)?r.lift(i):r.wrapIn(i,e)},Lx=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const s=t.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,a))}else s.delete(o.from,o.to)}return!0}}return!1},Ix=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:i=!1}=t,{selection:o}=e,{empty:s,ranges:l}=o;if(s)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>i||!a.includes(u.name));l.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},Rx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{extendEmptyMarkRange:o=!1}=e,{selection:s}=n,l=Ht(t,r.schema),{$from:a,empty:c,ranges:u}=s;if(!i)return!0;if(c&&o){var d;let{from:p,to:h}=s;const g=qa(a,l,(d=a.marks().find(b=>b.type===l))===null||d===void 0?void 0:d.attrs);g&&(p=g.from,h=g.to),n.removeMark(p,h,l)}else u.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},Dx=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let o,s;return typeof t=="number"?(o=t,s=t):t&&"from"in t&&"to"in t?(o=t.from,s=t.to):(o=i.from,s=i.to),r&&e.doc.nodesBetween(o,s,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Px=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const l=hs(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=Ce(t,r.schema)),l==="mark"&&(s=Ht(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let p,h,g,b;n.selection.empty?r.doc.nodesBetween(u,d,(x,w)=>{o&&o===x.type&&(a=!0,g=Math.max(w,u),b=Math.min(w+x.nodeSize,d),p=w,h=x)}):r.doc.nodesBetween(u,d,(x,w)=>{w<u&&o&&o===x.type&&(a=!0,g=Math.max(w,u),b=Math.min(w+x.nodeSize,d),p=w,h=x),w>=u&&w<=d&&(o&&o===x.type&&(a=!0,i&&n.setNodeMarkup(w,void 0,{...x.attrs,...e})),s&&x.marks.length&&x.marks.forEach(T=>{if(s===T.type&&(a=!0,i)){const R=Math.max(w,u),$=Math.min(w+x.nodeSize,d);n.addMark(R,$,s.create({...T.attrs,...e}))}}))}),h&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(x=>{s===x.type&&i&&n.addMark(g,b,s.create({...x.attrs,...e}))}))}),a},Xn=new xe("__tiptap_decorations__"),$x=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(Xn,{type:"force",name:t}),!0),Bx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return Xy(i,e)(n,r)},_x=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return Zy(i,e)(n,r)};var zx=Vg({blur:()=>sk,clearContent:()=>lk,clearNodes:()=>ak,command:()=>ck,createParagraphNear:()=>uk,cut:()=>dk,deleteCurrentNode:()=>fk,deleteNode:()=>pk,deleteRange:()=>hk,deleteSelection:()=>yk,enter:()=>bk,exitCode:()=>kk,extendMarkRange:()=>xk,first:()=>Sk,focus:()=>Ck,forEach:()=>vk,insertContent:()=>Mk,insertContentAt:()=>Tk,insertDefaultBlock:()=>Ak,joinBackward:()=>Ok,joinDown:()=>Nk,joinForward:()=>Lk,joinItemBackward:()=>Ik,joinItemForward:()=>Rk,joinTextblockBackward:()=>Dk,joinTextblockForward:()=>Pk,joinUp:()=>Ek,keyboardShortcut:()=>Bk,lift:()=>_k,liftEmptyBlock:()=>zk,liftListItem:()=>Fk,newlineInCode:()=>Hk,resetAttributes:()=>jk,scrollIntoView:()=>Vk,selectAll:()=>Uk,selectNodeBackward:()=>qk,selectNodeForward:()=>Wk,selectParentNode:()=>Kk,selectTextblockEnd:()=>Yk,selectTextblockStart:()=>Jk,setContent:()=>Gk,setMark:()=>yx,setMeta:()=>bx,setNode:()=>kx,setNodeSelection:()=>xx,setTextDirection:()=>Sx,setTextSelection:()=>wx,sinkListItem:()=>Cx,splitBlock:()=>vx,splitListItem:()=>Mx,toggleList:()=>Ax,toggleMark:()=>Ex,toggleNode:()=>Nx,toggleWrap:()=>Ox,undoInputRule:()=>Lx,unsetAllMarks:()=>Ix,unsetMark:()=>Rx,unsetTextDirection:()=>Dx,updateAttributes:()=>Px,updateDecorations:()=>$x,wrapIn:()=>Bx,wrapInList:()=>_x});const Tr=new WeakMap;function Fx(t,e){var n;Tr.set(t,((n=Tr.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;const i=((r=Tr.get(t))!==null&&r!==void 0?r:1)-1;i>0?Tr.set(t,i):Tr.delete(t)}}var Hx=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={}}};function jx(t){return t.kind==="widget"}function Ph(t,e){const n=[],r=new Set;for(const i of t)i.kind==="widget"&&jx(i)&&r.add(i.key),n.push(i.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function Vx(t,e,n){const{decorations:r,widgetKeys:i}=Ph(e,n);return{set:re.create(t,r),widgetKeys:i}}function $h({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function Ux({decorations:t,from:e,to:n,docSize:r,extensionName:i,warnedExtensions:o}){return t.filter(s=>$h({position:s.anchor,from:e,to:n,docSize:r})?!0:(s.anchor===n||o.has(i)||(o.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function qx(t){var e;const n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function Bh(t){return t.jsonID==="attr"}function Wx(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Bh(t))return!0;const n=t;return typeof n.from=="number"&&typeof n.to=="number"}function Kx(t,e){let n=null,r=0,i=0;for(let o=0;o<t.childCount&&!(i>e.to);o+=1){const s=i+t.child(o).nodeSize;s>=e.from&&(n===null&&(n=i),r=s),i=s}return n===null?null:{from:n,to:r}}function Yx(t,e){if(t.steps.some(o=>!Wx(o)))return{type:"full"};const n=gs(t).map(({newRange:o})=>o);t.steps.forEach((o,s)=>{if(!Bh(o))return;const l=t.mapping.slice(s);n.push({from:l.map(o.pos,-1),to:l.map(o.pos+1)})});const r=[];for(const o of n){const s=Kx(e,o);s&&r.push(s)}r.sort((o,s)=>o.from-s.from);const i=[];for(const o of r){const s=i[i.length-1];s&&o.from<=s.to?s.to=Math.max(s.to,o.to):i.push({...o})}return{type:"ranges",ranges:i}}function _h(t,e,n,r){return t.map(e,n,{onRemove:i=>{const o=i==null?void 0:i.key;typeof o=="string"&&r.delete(o)}})}function Jx(t,e,n){var r,i;const o=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:re.empty,s=new Set((i=e.widgetKeysByExtension[t])!==null&&i!==void 0?i:[]);return{set:_h(o,n.mapping,n.doc,s),widgetKeys:s}}function fd(t,e){const n=Object.values(e).flatMap(r=>r.find());return re.create(t,n)}function pd(t){const e=new Set;for(const n of Object.values(t))for(const r of n)e.add(r);return e}function Gx(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function Xx(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}const Zx=new Set;var Qx=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const n=Xn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>Gx(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=Xn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:Zx}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){const e=[];for(const{name:n,addDecorations:r}of t){const i=r();i&&e.push({name:n,spec:i})}return e}createPlugin(){const{editor:t,entries:e}=this;return new fe({key:Xn,state:{init:(n,r)=>{const i={},o={};for(const{name:l,spec:a}of e){const{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);i[l]=c,o[l]=u}const s={decorationSetsByExtension:i,widgetKeysByExtension:o,mergedDecorationSet:this.buildMergedSet(r.doc,i),widgetKeys:pd(o)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,i,o)=>{const s=n.getMeta(Xn),l=(s==null?void 0:s.type)==="force"&&!s.name,a=(s==null?void 0:s.type)==="force"?s.name:void 0,c={},u={},d=new Set;return Fx(t,()=>{for(const{name:p,spec:h}of e){const g=l||a===p;if(Xx(h,{editor:t,tr:n,oldState:i,newState:o},g))if(h.update==="changedRanges"&&n.docChanged&&!g){const b=this.applyChangedRangesRecompute(p,h,r,n,o);c[p]=b.set,u[p]=b.widgetKeys,d.add(p)}else{const{set:b,widgetKeys:x}=this.buildFullSet(p,h,o);c[p]=b,u[p]=x,d.add(p)}else{const b=Jx(p,r,n);c[p]=b.set,u[p]=b.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:pd(u)}}},props:{decorations(n){var r,i;return(r=(i=Xn.getState(n))===null||i===void 0?void 0:i.mergedDecorationSet)!==null&&r!==void 0?r:re.empty}}})}applyChangedRangesRecompute(t,e,n,r,i){const o=Yx(r,i.doc);return o.type==="full"?this.buildFullSet(t,e,i):this.rebuildRanges(t,e,n,r,i,o.ranges)}rebuildRanges(t,e,n,r,i,o){var s,l;const a=(s=n.decorationSetsByExtension[t])!==null&&s!==void 0?s:re.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]);let u=_h(a,r.mapping,r.doc,c);const d=i.doc.content.size;for(const{from:p,to:h}of o){const g=u.find(p,h).filter(w=>$h({position:w.from,from:p,to:h,docSize:d}));for(const w of g){const T=qx(w);T&&c.delete(T)}u=u.remove(g);const{decorations:b,widgetKeys:x}=Ph(Ux({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:p,to:h})),from:p,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(i.doc,b);for(const w of x)c.add(w)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){const r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return Vx(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){}buildMergedSet(t,e){const n=Object.keys(e);return n.length===1?e[n[0]]:fd(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return t.length===1?r[t[0].name]:i.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):fd(n.doc,r)}};function eS(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof U){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}function tS(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}function wi(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(o=>o.trim()).filter(Boolean),i=e.toLowerCase();for(let o=r.length-1;o>=0;o-=1){const s=r[o],l=s.indexOf(":");if(l!==-1&&s.slice(0,l).trim().toLowerCase()===i)return s.slice(l+1).trim()}return null}function nS(t){return typeof t=="number"}function rS(t){return Object.prototype.toString.call(t).slice(8,-1)}function ji(t){return rS(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Ci(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function hd(t,e,n){const r=t.split(`
57
+ `),i=[];let o="",s=0;const l=e.baseIndentSize||2;for(;s<r.length;){const u=r[s],d=u.match(e.itemPattern);if(!d){if(i.length>0)break;if(u.trim()===""){s+=1,o=`${o}${u}
58
+ `;continue}else return}const p=e.extractItemData(d),{indentLevel:h,mainContent:g}=p;o=`${o}${u}
59
+ `;const b=[g];for(s+=1;s<r.length;){var a;const R=r[s];if(R.trim()===""){var c;const $=r.slice(s+1).findIndex(Y=>Y.trim()!=="");if($===-1)break;if((((c=r[s+1+$].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){b.push(R),o=`${o}${R}
60
+ `,s+=1;continue}else break}if((((a=R.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)b.push(R),o=`${o}${R}
61
+ `,s+=1;else break}let x;const w=b.slice(1);if(w.length>0){const R=w.map($=>$.slice(h+l)).join(`
62
+ `);R.trim()&&(e.customNestedParser?x=e.customNestedParser(R):x=n.blockTokens(R))}const T=e.createToken(p,x);i.push(T)}if(i.length!==0)return{items:i,raw:o}}const md=4;function gd(t){let e=0;for(const n of t)e=n===" "?e+md-e%md:e+1;return e}function zh(t,e,n,r,i){if(!t||!Array.isArray(t.content))return"";const o=typeof n=="function"?n(r):n,[s,...l]=t.content;let a=`${o}${e.renderChildren([s])}`;return l&&l.length>0&&l.forEach((c,u)=>{var d,p;const h=(d=(p=e.renderChild)===null||p===void 0?void 0:p.call(e,c,u+1))!==null&&d!==void 0?d:e.renderChildren([c]);if(h!=null){const g=x=>{if(!(i!=null&&i.alignNestedToPrefix))return e.indent(x);const w=e.indent(""),T=gd(o);return(gd(w)>=T?w:" ".repeat(T))+x},b=h.split(`
63
+ `).map(x=>g(x||"")).join(`
64
+ `);a+=c.type==="paragraph"?`
65
+
66
+ ${b}`:`
67
+ ${b}`}}),a}function Fh(t,e){const n={...t};return ji(t)&&ji(e)&&Object.keys(e).forEach(r=>{ji(e[r])&&ji(t[r])?n[r]=Fh(t[r],e[r]):n[r]=e[r]}),n}function iS(t,e,n={}){const{state:r}=e,{doc:i,tr:o}=r,s=t;i.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==s)return!1;d=h}),!d)return;let p=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(p=!0)}),p){const h=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var vi=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}};const oS=(t,e)=>{if(Ua(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 sS(t){const{editor:e,from:n,to:r,text:i,insertText:o}=t;if(!o)return{inputTransaction:null,tr:e.view.state.tr};const s=e.view.state.tr.insertText(i,n,r);return{inputTransaction:s,tr:Rt.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function lS(t){const{editor:e,from:n,to:r,text:i,rule:o,match:s,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=sS({editor:e,from:n,to:r,text:i,insertText:a}),p=u?n+i.length:r,h=ps({state:c.state,transaction:d}),g={from:n-(s[0].length-i.length),to:p},{commands:b,chain:x,can:w}=new tr({editor:e,state:h});return o.handler({state:h,range:g,match:s,commands:b,chain:x,can:w})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(rk(d),d.setMeta("inputRule",!0),o.undoable&&d.setMeta(l,{transform:d,from:n,to:p,text:i}),c.dispatch(d)),!0)}function aS(t,e,n){const r=e[0].length-n.length;if(r<=0)return!0;const i=t.parentOffset-r;return i>=0&&t.parent.textBetween(i,t.parentOffset)===e[0].slice(0,r)}function Vi(t){var e;const{editor:n,from:r,to:i,text:o,rules:s,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(p=>p.type.spec.code))return!1;const d=ux(u)+o;for(const p of s){const h=oS(d,p.find);if(!(!h||!aS(u,h,o))&&lS({editor:n,from:r,to:i,text:o,rule:p,match:h,plugin:l,insertText:a}))return!0}return!1}function cS(t){const{editor:e,rules:n}=t,r=new fe({state:{init(){return null},apply(i,o,s){const l=i.getMeta(r);if(l)return l;const a=i.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=Ka(L.from(c),s.schema);const{from:u}=a,d=u+c.length;Vi({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,l){return Vi({editor:e,from:o,to:s,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&Vi({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Vi({editor:e,from:s.pos,to:s.pos,text:`
68
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Ya=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{...ie(H(this,"addOptions",{name:this.name}))}}get storage(){return{...ie(H(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fh(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,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}},gn=class Hh extends Ya{constructor(...e){super(...e),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Hh(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!o.find(l=>(l==null?void 0:l.type.name)===n.name))return!1;const s=o.find(l=>(l==null?void 0:l.type.name)===n.name);return s&&r.removeStoredMark(s),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},jh=class{constructor(t){this.find=t.find,this.handler=t.handler}};const uS=(t,e,n)=>{if(Ua(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function dS(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new tr({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(p,h)=>{var g,b,x,w;if(!((g=p.type)===null||g===void 0||(g=g.spec)===null||g===void 0)&&g.code||!(p.isText||p.isTextblock||p.isInline))return;const T=(b=(x=(w=p.content)===null||w===void 0?void 0:w.size)!==null&&x!==void 0?x:p.nodeSize)!==null&&b!==void 0?b:0,R=Math.max(r,h),$=Math.min(i,h+T);if(R>=$)return;const Y=p.isText?p.text||"":p.textBetween(R-h,$-h,void 0,"");uS(Y,o.find,s).forEach(ne=>{if(ne.index===void 0)return;const j=R+ne.index+1,ee=j+ne[0].length,te={from:n.tr.mapping.map(j),to:n.tr.mapping.map(ee)},ye=o.handler({state:n,range:te,match:ne,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(ye)})}),d.every(p=>p!==null)}let Kn=null;const fS=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function pS(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:c,from:u,to:d,rule:p,pasteEvt:h})=>{const g=c.tr,b=ps({state:c,transaction:g});if(!(!dS({editor:e,state:b,from:Math.max(u-1,0),to:d.b-1,rule:p,pasteEvent:h,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return e.on("destroy",()=>{Kn===e&&(Kn=null)}),n.map(c=>new fe({view(u){const d=h=>{var g;r=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(h.target)?u.dom.parentElement:null,r&&(Kn=e)},p=()=>{Kn&&(Kn=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(o=r===u.dom.parentElement,l=d,!o){const p=Kn;p!=null&&p.isEditable&&setTimeout(()=>{if(p.isDestroyed)return;const h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var p;const h=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=d,i=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,d,p)=>{const h=u[0],g=h.getMeta("uiEvent")==="paste"&&!i,b=h.getMeta("uiEvent")==="drop"&&!o,x=h.getMeta("applyPasteRules"),w=!!x;if(!g&&!b&&!w)return;if(w){let{text:$}=x;typeof $=="string"?$=$:$=Ka(L.from($),p.schema);const{from:Y}=x,ne=Y+$.length,j=fS($);return a({rule:c,state:p,from:Y,to:{b:ne},pasteEvt:j})}const T=d.doc.content.findDiffStart(p.doc.content),R=d.doc.content.findDiffEnd(p.doc.content);if(!(!nS(T)||!R||T===R.b))return a({rule:c,state:p,from:T,to:R,pasteEvt:s})}}))}var bs=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=Ah(t),this.schema=nx(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=H(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Wn(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=jr([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Wn(r.name,this.schema)},o=[],s=H(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&H(r,"exitable",i)&&(l.ArrowRight=()=>gn.handleExit({editor:t,mark:r})),s){const p=Object.fromEntries(Object.entries(s()).map(([h,g])=>[h,()=>g({editor:t})]));l={...l,...p}}const a=J0(l);o.push(a);const c=H(r,"addInputRules",i);if(cd(r,t.options.enableInputRules)&&c){const p=c();if(p&&p.length){const h=cS({editor:t,rules:p}),g=Array.isArray(h)?h:[h];o.push(...g)}}const u=H(r,"addPasteRules",i);if(cd(r,t.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const h=pS({editor:t,rules:p});o.push(...h)}}const d=H(r,"addProseMirrorPlugins",i);if(d){const p=d();o.push(...p)}return o}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;const{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();const n=[];return this.extensions.forEach(r=>{const i=H(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Wn(r.name,this.schema)});i&&n.push({name:r.name,addDecorations:i})}),this.decorationManager=new Qx({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){return Th(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=cr(this.extensions);return Object.fromEntries(e.filter(n=>!!H(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i=H(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ce(n.name,this.schema)});if(!i)return[];const o=i();if(!o)return[];const s=(l,a,c,u,d)=>{const p=ci(l,r);return o({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:p})};return[n.name,s]}))}dispatchTransaction(t){const{editor:e}=this;return jr([...this.extensions].reverse()).reduceRight((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Wn(r.name,this.schema)},o=H(r,"dispatchTransaction",i);return o?s=>{o.call(i,{transaction:s,next:n})}:n},t)}transformPastedHTML(t){const{editor:e}=this;return jr([...this.extensions]).reduce((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Wn(r.name,this.schema)},o=H(r,"transformPastedHTML",i);return o?(s,l)=>{const a=n(s,l);return o.call(i,a)}:n},t||(n=>n))}get markViews(){const{editor:t}=this,{markExtensions:e}=cr(this.extensions);return Object.fromEntries(e.filter(n=>!!H(n,"addMarkView")).map(n=>{const r=this.attributes.filter(s=>s.type===n.name),i=H(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ht(n.name,this.schema)});if(!i)return[];const o=(s,l,a)=>{const c=ci(s,r);return i()({mark:s,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{iS(s,t,u)}})};return[n.name,o]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){const r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Wn(e.name,this.schema)};if(e.type==="mark"){var r,i;(!((r=ie(H(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((i=ie(H(e,"clearable",n)))!==null&&i!==void 0)||i||this.nonClearableMarks.push(e.name)}const o=H(e,"onBeforeCreate",n),s=H(e,"onCreate",n),l=H(e,"onUpdate",n),a=H(e,"onSelectionUpdate",n),c=H(e,"onTransaction",n),u=H(e,"onFocus",n),d=H(e,"onBlur",n),p=H(e,"onDestroy",n);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),p&&this.editor.on("destroy",p)})}};bs.resolve=Ah;bs.sort=jr;bs.flatten=Wa;var ae=class Vh extends Ya{constructor(...e){super(...e),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Vh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};const hS=ae.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fe({key:new xe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,o=Nh(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:o};return[...i.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>Eh(r,{from:a.pos,to:c.pos},l)).join(s??`
69
+
70
+ `)}}})]}}),mS=ae.create({name:"commands",addCommands(){return{...zx}}}),gS=ae.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;const i=()=>{var o,s,l;if((o=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,t))!==null&&o!==void 0?o:t.getMeta("y-sync$"))return;const a=Mh(t.before,[t,...e]);gs(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,p)=>{const h=p+d.nodeSize-2,g=u.oldRange.from<=p&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:p,to:h,newFrom:a.mapping.map(p),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!g,editor:this.editor,transaction:t,combinedTransform:a})})});const c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof dt){var p,h;const g=c.slice(d).map(u.from,-1),b=c.slice(d).map(u.to),x=c.invert().map(g,-1),w=c.invert().map(b),T=g>0?(p=a.doc.nodeAt(g-1))===null||p===void 0?void 0:p.marks.some($=>$.eq(u.mark)):!1,R=(h=a.doc.nodeAt(b))===null||h===void 0?void 0:h.marks.some($=>$.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:x,to:w},newRange:{from:g,to:b},partial:!!(R||T),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(i,0):i()}}),yS=ae.create({name:"drop",addProseMirrorPlugins(){return[new fe({key:new xe("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),bS=ae.create({name:"editable",addProseMirrorPlugins(){return[new fe({key:new xe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kS=new xe("focusEvents"),xS=ae.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new fe({key:kS,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}}}})]}}),SS=ae.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:p,parent:h}=d,g=d.parent.isTextblock&&p>0?l.doc.resolve(p-1):d,b=g.parent.type.spec.isolating,x=d.pos-d.parentOffset,w=b&&g.parent.childCount===1?x===d.pos:G.atStart(c).from===p;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...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 ko()||Ch()?o:i},addProseMirrorPlugins(){return[new fe({key:new xe("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta("composition")))return;const r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),i=t.some(h=>h.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:l}=e.selection,a=G.atStart(e.doc).from,c=G.atEnd(e.doc).to;if(o||!(s===a&&l===c)||!Si(n.doc))return;const u=n.tr,d=ps({state:n,transaction:u}),{commands:p}=new tr({editor:this.editor,state:d});if(p.clearNodes(),!!u.steps.length)return u}})]}}),wS=ae.create({name:"paste",addProseMirrorPlugins(){return[new fe({key:new xe("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),CS=ae.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new fe({key:new xe("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),vS=ae.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=cr(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 fe({key:new xe("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}});let yd=!1;function MS(t){if(yd)return;yd=!0;let e;try{e=me.fromJSON(t,{from:0,to:0}).slice.content}catch{return}e instanceof L||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var TS=class Pr{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get 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!==void 0?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 Pr(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 Pr(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 Pr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!i&&!s&&a.depth<=this.depth)return;const c=new Pr(a,this.editor,i,i||s?n:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const a=s[l];if(o[a]!==n[a])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}};const AS=`.ProseMirror {
71
+ position: relative;
72
+ }
73
+
74
+ .ProseMirror {
75
+ word-wrap: break-word;
76
+ white-space: pre-wrap;
77
+ white-space: break-spaces;
78
+ -webkit-font-variant-ligatures: none;
79
+ font-variant-ligatures: none;
80
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
81
+ }
82
+
83
+ .ProseMirror [contenteditable="false"] {
84
+ white-space: normal;
85
+ }
86
+
87
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
88
+ white-space: pre-wrap;
89
+ }
90
+
91
+ .ProseMirror pre {
92
+ white-space: pre-wrap;
93
+ }
94
+
95
+ img.ProseMirror-separator {
96
+ display: inline !important;
97
+ border: none !important;
98
+ margin: 0 !important;
99
+ width: 0 !important;
100
+ height: 0 !important;
101
+ }
102
+
103
+ .ProseMirror-gapcursor {
104
+ display: none;
105
+ pointer-events: none;
106
+ position: absolute;
107
+ margin: 0;
108
+ }
109
+
110
+ .ProseMirror-gapcursor:after {
111
+ content: "";
112
+ display: block;
113
+ position: absolute;
114
+ top: -2px;
115
+ width: 20px;
116
+ border-top: 1px solid black;
117
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
118
+ }
119
+
120
+ @keyframes ProseMirror-cursor-blink {
121
+ to {
122
+ visibility: hidden;
123
+ }
124
+ }
125
+
126
+ .ProseMirror-hideselection *::selection {
127
+ background: transparent;
128
+ }
129
+
130
+ .ProseMirror-hideselection *::-moz-selection {
131
+ background: transparent;
132
+ }
133
+
134
+ .ProseMirror-hideselection * {
135
+ caret-color: transparent;
136
+ }
137
+
138
+ .ProseMirror-focused .ProseMirror-gapcursor {
139
+ display: block;
140
+ }`;var ES=class extends Hx{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:hx,createMappablePosition:mx},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:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const n=ta(e,this.options.autofocus);this.editorState=Rt.create({doc:e,schema:this.schema,selection:n||void 0})}MS(this.schema),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){this.editorState=this.editorView.state;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?this.commandManager.chain():tr.createFakeChain()}can(){return this.commandManager?this.commandManager.can():tr.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=tS(AS,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,attributes:this.getEditorViewAttributes()}),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=ra(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;n=n.filter(s=>!s.key.startsWith(o))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[bS,hS.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),mS,xS,SS,CS.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),yS,wS,gS,vS.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r==null?void 0:r.type));this.extensionManager=new bs(n,this)}createCommandManager(){this.commandManager=new tr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=na(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;const n=na(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Rt.create({doc:n,schema:this.schema,selection:ta(n,this.options.autofocus)||void 0}),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(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;const e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return ra(e)?n=>({role:"textbox",...e(n)}):{role:"textbox",...e}}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,o=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(o);this.editorView=new lh(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.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(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s==null?void 0:s.getMeta("focus"),a=s==null?void 0:s.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Oh(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return dx(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ka(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
141
+
142
+ `,textSerializers:n={}}=t||{};return ix(this.state.doc,{blockSeparator:e,textSerializers:{...Nh(this.schema),...n}})}get isEmpty(){return Si(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new TS(e,this,!1,n)}get $doc(){return this.$pos(0)}};function $n(t){return new vi({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ie(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],l=r[0];if(s){const a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(ys(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(h=>h===t.type&&h!==p.mark.type)).filter(p=>p.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+a,c);const d=n.from+a+s.length;o.addMark(n.from+a,d,t.type.create(i||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function NS(t){return new vi({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ie(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from;let l=n.to;const a=t.type.create(i);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,s+r[0].length-1),o.replaceWith(c,l,a)}else if(r[0]){const c=t.type.isInline?s:s-1;o.insert(c,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(l))}o.scrollIntoView()},undoable:t.undoable})}function oa(t){return new vi({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=ie(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function ur(t){return new vi({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=ie(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&Na(l,t.type,o);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){const{selection:u,storedMarks:d}=e,{splittableMarks:p}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){const g=h.filter(b=>p.includes(b.type.name));s.ensureMarks(g)}}if(t.keepAttributes){const u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,o).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&hn(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var Ge=class Uh extends Ya{constructor(...e){super(...e),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Uh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function fn(t){return new jh({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=ie(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),p=d+l.length;if(ys(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>d).length)return null;p<n.to&&s.delete(p,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(o||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}const qh=new WeakSet,Wh=new WeakSet;function bn(t){const e=t;return qh.add(e),e}function sa(t){return Array.isArray(t)&&qh.has(t)}function Kh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Wh.has(e)&&!sa(e)?Kh(e):[e])}function OS(t,e){if(t==="slot")return 0;if(t instanceof Function){const i=t(e);return Array.isArray(i)&&!sa(i)&&!Wh.has(i)?bn(i):i}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");if(Array.isArray(n)){if(sa(n))return bn([t,r,n]);if(n.length===0)return bn([t,r]);const i=Kh(n);return i.length===0?bn([t,r]):bn([t,r,...i])}return n!=null?bn([t,r,n]):bn([t,r])}const xo=(t,e)=>OS(t,e),LS=(t,e)=>{var n;const{state:r}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0)return!1;const s=o.depth-1;if(s<0)return!1;const l=o.node(s),a=o.index(s);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);const c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;const u=o.before()-1-1;return t.commands.command(({tr:d,dispatch:p})=>{if(!p)return!0;const h=o.parent.content,g=new _(h,0,0);return d.replace(u,o.after(),g),d.setSelection(q.create(d.doc,u+h.size)),d.scrollIntoView(),p(d),!0})},IS=/^\s*>\s$/,RS=Ge.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return xo("blockquote",{...be(this.options.HTMLAttributes,t),children:xo("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((i,o)=>{var s,l;const a=((s=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,o))!==null&&s!==void 0?s:e.renderChildren([i])).split(`
143
+ `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
144
+ `))}),r.join(`
145
+ ${n}
146
+ `)},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(),Backspace:()=>LS(this.editor,this.type)}},addInputRules(){return[ur({find:IS,type:this.type})]}}),DS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,PS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,$S=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,BS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_S=gn.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 xo("strong",{...be(this.options.HTMLAttributes,t),children:xo("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},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[$n({find:DS,type:this.type}),$n({find:$S,type:this.type})]},addPasteRules(){return[fn({find:PS,type:this.type}),fn({find:BS,type:this.type})]}}),zS=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},FS=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function HS(t){const e=new Set((t.match(/`+/g)||[]).map(r=>r.length));let n=1;for(;e.has(n);)n+=1;return n}const jS=gn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";const i=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",o="`".repeat(HS(i)),s=i.startsWith("`")||i.endsWith("`")?" ":"";return`${o}${s}${e.renderChildren(t.content)}${s}${o}`},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[$n({find:zS,type:this.type})]},addPasteRules(){return[fn({find:FS,type:this.type})]}}),wl=4,VS=/^```([a-z]+)?[\s\n]$/,US=/^~~~([a-z]+)?[\s\n]$/,qS=Ge.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:wl,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 r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",be(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
147
+ `):r=`\`\`\`${i}
148
+
149
+ \`\`\``,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!==void 0?e:wl,{state:r}=t,{selection:i}=r,{$from:o,empty:s}=i;if(o.parent.type!==this.type)return!1;const l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=i,d=r.doc.textBetween(c,u,`
150
+ `,`
151
+ `).split(`
152
+ `).map(p=>l+p).join(`
153
+ `);return a.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!==null&&e!==void 0?e:wl,{state:r}=t,{selection:i}=r,{$from:o,empty:s}=i;return o.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;const{pos:c}=o,u=o.start(),d=o.end(),p=r.doc.textBetween(u,d,`
154
+ `,`
155
+ `).split(`
156
+ `);let h=0,g=0;const b=c-u;for(let R=0;R<p.length;R+=1){if(g+p[R].length>=b){h=R;break}g+=p[R].length+1}const x=((a=p[h].match(/^ */))===null||a===void 0?void 0:a[0])||"",w=Math.min(x.length,n);if(w===0)return!0;let T=u;for(let R=0;R<h;R+=1)T+=p[R].length+1;return l.delete(T,T+w),c-T<=w&&l.setSelection(q.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=i,u=r.doc.textBetween(a,c,`
157
+ `,`
158
+ `).split(`
159
+ `).map(d=>{var p;const h=((p=d.match(/^ */))===null||p===void 0?void 0:p[0])||"",g=Math.min(h.length,n);return d.slice(g)}).join(`
160
+ `);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
161
+
162
+ `);return!o||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;const o=r.before();return o>0?!1:t.commands.insertDefaultBlock({pos:o})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const s=i.after();return s===void 0?!1:r.nodeAt(s)?t.commands.command(({tr:l})=>(l.setSelection(G.near(r.resolve(s))),!0)):t.commands.exitCode()}}},addInputRules(){return[oa({find:VS,type:this.type,getAttributes:t=>({language:t[1]})}),oa({find:US,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new fe({key:new xe("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!n||!o)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
163
+ `));return s.replaceSelectionWith(this.type.create({language:o},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(q.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),WS=Ge.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
+
165
+ `):""}),KS=Ge.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",be(this.options.HTMLAttributes,t)]},renderText(){return`
166
+ `},renderMarkdown:()=>`
167
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){const d=a.filter(p=>l.includes(p.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),YS=Ge.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]}`,be(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===void 0)&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>oa({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),JS=Ge.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",be(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!eS(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Lh(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:o,tr:s,dispatch:l})=>{if(l){const{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(q.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(U.create(s.doc,a.pos)):s.setSelection(q.create(s.doc,a.pos));else{const u=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(s.insert(c,d),s.setSelection(q.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[NS({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,XS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ZS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,QS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ew=gn.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",be(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||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$n({find:GS,type:this.type}),$n({find:ZS,type:this.type})]},addPasteRules(){return[fn({find:XS,type:this.type}),fn({find:QS,type:this.type})]}}),tw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",nw="ελ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",la="numeric",aa="ascii",ca="alpha",Vr="asciinumeric",$r="alphanumeric",ua="domain",Yh="emoji",rw="scheme",iw="slashscheme",Cl="whitespace";function ow(t,e){return t in e||(e[t]=[]),e[t]}function Mn(t,e,n){e[la]&&(e[Vr]=!0,e[$r]=!0),e[aa]&&(e[Vr]=!0,e[ca]=!0),e[Vr]&&(e[$r]=!0),e[ca]&&(e[$r]=!0),e[$r]&&(e[ua]=!0),e[Yh]&&(e[ua]=!0);for(const r in e){const i=ow(r,n);i.indexOf(t)<0&&i.push(t)}}function sw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ke(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ke.groups={};Ke.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ke.groups;let i;return e&&e.j?i=e:(i=new Ke(e),n&&r&&Mn(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const o=t.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(t[s]);return i.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||Ke.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const o=e;let s,l=i.go(t);if(l?(s=new Ke,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ke,o){if(r)if(s.t&&typeof s.t=="string"){const a=Object.assign(sw(s.t,r),n);Mn(o,a,r)}else n&&Mn(o,n,r);s.t=o}return i.j[t]=s,s}};const Z=(t,e,n,r,i)=>t.ta(e,n,r,i),he=(t,e,n,r,i)=>t.tr(e,n,r,i),bd=(t,e,n,r,i)=>t.ts(e,n,r,i),P=(t,e,n,r,i)=>t.tt(e,n,r,i),Lt="WORD",da="UWORD",Jh="ASCIINUMERICAL",Gh="ALPHANUMERICAL",ui="LOCALHOST",fa="TLD",pa="UTLD",ro="SCHEME",Zn="SLASH_SCHEME",Ja="NUM",ha="WS",Ga="NL",Ur="OPENBRACE",qr="CLOSEBRACE",So="OPENBRACKET",wo="CLOSEBRACKET",Co="OPENPAREN",vo="CLOSEPAREN",Mo="OPENANGLEBRACKET",To="CLOSEANGLEBRACKET",Ao="FULLWIDTHLEFTPAREN",Eo="FULLWIDTHRIGHTPAREN",No="LEFTCORNERBRACKET",Oo="RIGHTCORNERBRACKET",Lo="LEFTWHITECORNERBRACKET",Io="RIGHTWHITECORNERBRACKET",Ro="FULLWIDTHLESSTHAN",Do="FULLWIDTHGREATERTHAN",Po="AMPERSAND",$o="APOSTROPHE",Bo="ASTERISK",Xt="AT",_o="BACKSLASH",zo="BACKTICK",Fo="CARET",Tn="COLON",Xa="COMMA",Ho="DOLLAR",yt="DOT",jo="EQUALS",Za="EXCLAMATION",it="HYPHEN",Wr="PERCENT",Vo="PIPE",Uo="PLUS",qo="POUND",Kr="QUERY",Qa="QUOTE",Xh="FULLWIDTHMIDDLEDOT",ec="SEMI",bt="SLASH",Yr="TILDE",Wo="UNDERSCORE",Zh="EMOJI",Ko="SYM";var Qh=Object.freeze({__proto__:null,ALPHANUMERICAL:Gh,AMPERSAND:Po,APOSTROPHE:$o,ASCIINUMERICAL:Jh,ASTERISK:Bo,AT:Xt,BACKSLASH:_o,BACKTICK:zo,CARET:Fo,CLOSEANGLEBRACKET:To,CLOSEBRACE:qr,CLOSEBRACKET:wo,CLOSEPAREN:vo,COLON:Tn,COMMA:Xa,DOLLAR:Ho,DOT:yt,EMOJI:Zh,EQUALS:jo,EXCLAMATION:Za,FULLWIDTHGREATERTHAN:Do,FULLWIDTHLEFTPAREN:Ao,FULLWIDTHLESSTHAN:Ro,FULLWIDTHMIDDLEDOT:Xh,FULLWIDTHRIGHTPAREN:Eo,HYPHEN:it,LEFTCORNERBRACKET:No,LEFTWHITECORNERBRACKET:Lo,LOCALHOST:ui,NL:Ga,NUM:Ja,OPENANGLEBRACKET:Mo,OPENBRACE:Ur,OPENBRACKET:So,OPENPAREN:Co,PERCENT:Wr,PIPE:Vo,PLUS:Uo,POUND:qo,QUERY:Kr,QUOTE:Qa,RIGHTCORNERBRACKET:Oo,RIGHTWHITECORNERBRACKET:Io,SCHEME:ro,SEMI:ec,SLASH:bt,SLASH_SCHEME:Zn,SYM:Ko,TILDE:Yr,TLD:fa,UNDERSCORE:Wo,UTLD:pa,UWORD:da,WORD:Lt,WS:ha});const Et=/[a-z]/,Ar=new RegExp("\\p{L}","u"),vl=new RegExp("\\p{Emoji}","u"),Nt=/\d/,Ml=/\s/,kd="\r",Tl=`
168
+ `,lw="️",aw="‍",Al="";let Ui=null,qi=null;function cw(t=[]){const e={};Ke.groups=e;const n=new Ke;Ui==null&&(Ui=xd(tw)),qi==null&&(qi=xd(nw)),P(n,"'",$o),P(n,"{",Ur),P(n,"}",qr),P(n,"[",So),P(n,"]",wo),P(n,"(",Co),P(n,")",vo),P(n,"<",Mo),P(n,">",To),P(n,"(",Ao),P(n,")",Eo),P(n,"「",No),P(n,"」",Oo),P(n,"『",Lo),P(n,"』",Io),P(n,"<",Ro),P(n,">",Do),P(n,"&",Po),P(n,"*",Bo),P(n,"@",Xt),P(n,"`",zo),P(n,"^",Fo),P(n,":",Tn),P(n,",",Xa),P(n,"$",Ho),P(n,".",yt),P(n,"=",jo),P(n,"!",Za),P(n,"-",it),P(n,"%",Wr),P(n,"|",Vo),P(n,"+",Uo),P(n,"#",qo),P(n,"?",Kr),P(n,'"',Qa),P(n,"/",bt),P(n,";",ec),P(n,"~",Yr),P(n,"_",Wo),P(n,"\\",_o),P(n,"・",Xh);const r=he(n,Nt,Ja,{[la]:!0});he(r,Nt,r);const i=he(r,Et,Jh,{[Vr]:!0}),o=he(r,Ar,Gh,{[$r]:!0}),s=he(n,Et,Lt,{[aa]:!0});he(s,Nt,i),he(s,Et,s),he(i,Nt,i),he(i,Et,i);const l=he(n,Ar,da,{[ca]:!0});he(l,Et),he(l,Nt,o),he(l,Ar,l),he(o,Nt,o),he(o,Et),he(o,Ar,o);const a=P(n,Tl,Ga,{[Cl]:!0}),c=P(n,kd,ha,{[Cl]:!0}),u=he(n,Ml,ha,{[Cl]:!0});P(n,Al,u),P(c,Tl,a),P(c,Al,u),he(c,Ml,u),P(u,kd),P(u,Tl),he(u,Ml,u),P(u,Al,u);const d=he(n,vl,Zh,{[Yh]:!0});P(d,"#"),he(d,vl,d),P(d,lw,d);const p=P(d,aw);P(p,"#"),he(p,vl,d);const h=[[Et,s],[Nt,i]],g=[[Et,null],[Ar,l],[Nt,o]];for(let b=0;b<Ui.length;b++)Kt(n,Ui[b],fa,Lt,h);for(let b=0;b<qi.length;b++)Kt(n,qi[b],pa,da,g);Mn(fa,{tld:!0,ascii:!0},e),Mn(pa,{utld:!0,alpha:!0},e),Kt(n,"file",ro,Lt,h),Kt(n,"mailto",ro,Lt,h),Kt(n,"http",Zn,Lt,h),Kt(n,"https",Zn,Lt,h),Kt(n,"ftp",Zn,Lt,h),Kt(n,"ftps",Zn,Lt,h),Mn(ro,{scheme:!0,ascii:!0},e),Mn(Zn,{slashscheme:!0,ascii:!0},e),t=t.sort((b,x)=>b[0]>x[0]?1:-1);for(let b=0;b<t.length;b++){const x=t[b][0],T=t[b][1]?{[rw]:!0}:{[iw]:!0};x.indexOf("-")>=0?T[ua]=!0:Et.test(x)?Nt.test(x)?T[Vr]=!0:T[aa]=!0:T[la]=!0,bd(n,x,x,T)}return bd(n,"localhost",ui,{ascii:!0}),n.jd=new Ke(Ko),{start:n,tokens:Object.assign({groups:e},Qh)}}function em(t,e){const n=uw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let o=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,p=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,p=0,u=l):d>=0&&(d+=n[s].length,p++),c+=n[s].length,o+=n[s].length,s++;o-=d,s-=p,c-=d,i.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function uw(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),o,s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Kt(t,e,n,r,i){let o;const s=e.length;for(let l=0;l<s-1;l++){const a=e[l];t.j[a]?o=t.j[a]:(o=new Ke(r),o.jr=i.slice(),t.j[a]=o),t=o}return o=new Ke(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function xd(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let o=0;for(;i.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+o),10);s>0;s--)n.pop();r+=o}else n.push(t[r]),r++}return e}const di={defaultProtocol:"http",events:null,format:Sd,formatHref:Sd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function tc(t,e=null){let n=Object.assign({},di);t&&(n=Object.assign(n,t instanceof tc?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}tc.prototype={o:di,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:di[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Sd(t){return t}function tm(t,e){this.t="token",this.v=t,this.tk=e}tm.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=di.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:o,eventListeners:d}}};function ks(t,e){class n extends tm{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const dw=ks("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),wd=ks("text"),fw=ks("nl"),Wi=ks("url",{isLink:!0,toHref(t=di.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ui&&t[1].t===Tn}}),nt=t=>new Ke(t);function pw({groups:t}){const e=t.domain.concat([Po,Bo,Xt,_o,zo,Fo,Ho,jo,it,Ja,Wr,Vo,Uo,qo,bt,Ko,Yr,Wo]),n=[$o,Tn,Xa,yt,Za,Wr,Kr,Qa,ec,Mo,To,Ur,qr,wo,So,Co,vo,Ao,Eo,No,Oo,Lo,Io,Ro,Do],r=[Po,$o,Bo,_o,zo,Fo,Ho,jo,it,Ur,qr,Wr,Vo,Uo,qo,Kr,bt,Ko,Yr,Wo],i=nt(),o=P(i,Yr);Z(o,r,o),Z(o,t.domain,o);const s=nt(),l=nt(),a=nt();Z(i,t.domain,s),Z(i,t.scheme,l),Z(i,t.slashscheme,a),Z(s,r,o),Z(s,t.domain,s);const c=P(s,Xt);P(o,Xt,c),P(l,Xt,c),P(a,Xt,c);const u=P(o,yt);Z(u,r,o),Z(u,t.domain,o);const d=nt();Z(c,t.domain,d),Z(d,t.domain,d);const p=P(d,yt);Z(p,t.domain,d);const h=nt(dw);Z(p,t.tld,h),Z(p,t.utld,h),P(c,ui,h);const g=P(d,it);P(g,it,g),Z(g,t.domain,d),Z(h,t.domain,d),P(h,yt,p),P(h,it,g);const b=P(s,it),x=P(s,yt);P(b,it,b),Z(b,t.domain,s),Z(x,r,o),Z(x,t.domain,s);const w=nt(Wi);Z(x,t.tld,w),Z(x,t.utld,w),Z(w,t.domain,s),Z(w,r,o),P(w,yt,x),P(w,it,b),P(w,Xt,c);const T=P(w,Tn),R=nt(Wi);Z(T,t.numeric,R);const $=nt(Wi),Y=nt();Z($,e,$),Z($,n,Y),Z(Y,e,$),Z(Y,n,Y),P(w,bt,$),P(R,bt,$);const ne=P(l,Tn),j=P(a,Tn),ee=P(j,bt),te=P(ee,bt);Z(l,t.domain,s),P(l,yt,x),P(l,it,b),Z(a,t.domain,s),P(a,yt,x),P(a,it,b),Z(ne,t.domain,$),P(ne,bt,$),P(ne,Kr,$),Z(te,t.domain,$),Z(te,e,$),P(te,bt,$);const ye=[[Ur,qr],[So,wo],[Co,vo],[Mo,To],[Ao,Eo],[No,Oo],[Lo,Io],[Ro,Do]];for(let Me=0;Me<ye.length;Me++){const[tt,Ee]=ye[Me],le=P($,tt);P(Y,tt,le);const De=nt(Wi);Z(le,e,De);const z=nt();Z(le,n,z),P(le,Ee,$),Z(De,e,De),Z(De,n,z),Z(z,e,De),Z(z,n,z),P(De,Ee,$),P(z,Ee,$)}return P(i,ui,w),P(i,Ga,fw),{start:i,tokens:Qh}}function hw(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let l=t,a=null,c=null,u=0,d=null,p=-1;for(;i<r&&!(a=l.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=a||l.go(n[i].t));)a=null,l=c,l.accepts()?(p=0,d=l):p>=0&&p++,i++,u++;if(p<0)i-=u,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(El(wd,e,s)),s=[]),i-=p,u-=p;const h=d.t,g=n.slice(i-u,i);o.push(El(h,e,g))}}return s.length>0&&o.push(El(wd,e,s)),o}function El(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const mw=typeof console<"u"&&console&&console.warn||(()=>{}),gw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",de={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function yw(){return Ke.groups={},de.scanner=null,de.parser=null,de.tokenQueue=[],de.pluginQueue=[],de.customSchemes=[],de.initialized=!1,de}function Cd(t,e=!1){if(de.initialized&&mw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${gw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
169
+ 1. Must only contain digits, lowercase ASCII letters or "-"
170
+ 2. Cannot start or end with "-"
171
+ 3. "-" cannot repeat`);de.customSchemes.push([t,e])}function bw(){de.scanner=cw(de.customSchemes);for(let t=0;t<de.tokenQueue.length;t++)de.tokenQueue[t][1]({scanner:de.scanner});de.parser=pw(de.scanner.tokens);for(let t=0;t<de.pluginQueue.length;t++)de.pluginQueue[t][1]({scanner:de.scanner,parser:de.parser});return de.initialized=!0,de}function nc(t){return de.initialized||bw(),hw(de.parser.start,t,em(de.scanner.start,t))}nc.scan=em;function nm(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 tc(n),i=nc(t),o=[];for(let s=0;s<i.length;s++){const l=i[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}const xs="[\0-   ᠎ -\u2029  ]",kw=new RegExp(xs),xw=new RegExp(`${xs}$`),Sw=new RegExp(`${xs}+$`),ww=new RegExp(xs,"g");function Cw(t,e,n){var r,i;const o=t.doc.resolve(e.to);if(!(!((r=o.nodeBefore)===null||r===void 0)&&r.isText))return;const s=(i=t.doc.textBetween(e.from,e.to,"","").match(Sw))===null||i===void 0?void 0:i[0];if(!s)return;const l=e.to-s.length,a=ys(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;const{nodeAfter:c}=o;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;const u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function vw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Mw(t){return new fe({key:new xe("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),o=e.some(a=>a.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,l=Mh(n.doc,[...e]);if(!e.some(ok)){const a=[];l.steps.forEach((c,u)=>{if(!(c instanceof me)||!c.slice.size)return;const d=l.mapping.slice(u+1),p=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);p<h&&a.push({from:p,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Cw(s,c,t.type))}if(gs(l).forEach(({newRange:a})=>{const c=Xk(r.doc,a,p=>p.isTextblock);let u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){const p=r.doc.textBetween(a.from,a.to," "," ");if(!xw.test(p))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){const p=d.split(kw).filter(Boolean);if(p.length<=0)return!1;const h=p[p.length-1],g=u.pos+d.lastIndexOf(h);if(!h)return!1;const b=nc(h).map(x=>x.toObject(t.defaultProtocol));if(!vw(b))return!1;b.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{ys(x.from,x.to,r.doc).some(w=>w.mark.type===t.type)||s.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!s.steps.length)return s}})}function Tw(t){return new fe({key:new xe("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=t.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;const a=Oh(e.state,t.type.name),c=(s=i.href)!==null&&s!==void 0?s:a.href,u=(l=i.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),o=!0)}return o}}})}const Aw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Ew=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function rm(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Nw(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&rm(t,r)){r+=1;continue}let i=0;for(;r<e&&t[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function im(t,e,n){var r,i;const[,o,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||rm(t,(r=e.index)!==null&&r!==void 0?r:0)||Nw(t,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!o.trim()&&n(s)}function om(t){var e,n;const[r,i,o,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:i,data:{href:o,title:c||null,markdown:!0}}}function Ow(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function sm(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Lw(t){const e=$n({find:n=>{const r=Aw.exec(n);return!r||!im(n,r,t.isAllowedHref)?null:om(r)},type:t.type,getAttributes:sm});return new vi({find:e.find,handler:n=>{const r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function Iw(t){const e=fn({find:n=>{var r,i;const o=[];for(const l of n.matchAll(Ew))im(n,l,t.isAllowedHref)&&o.push(om(l));const s=((r=(i=t.findPlainUrls)===null||i===void 0?void 0:i.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!o.some(a=>Ow(a,l)));return[...o,...s]},type:t.type,getAttributes:sm});return new jh({find:e.find,handler:n=>{var r;const i=e.handler(n);return i!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),i}})}function Rw(t){return new fe({key:new xe("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:o}=e,{selection:s}=o,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=nm(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ot(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(ww,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const lm=gn.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"){Cd(t);return}Cd(t.scheme,t.optionalSlashes)})},onDestroy(){yw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ot(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 r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ot(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=>!!Ot(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",be(this.options.HTMLAttributes,t),0]:["a",be(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,i,o;const s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(i=(o=t.attrs)===null||o===void 0?void 0:o.title)!==null&&i!==void 0?i:"",a=e.renderChildren(t);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ot(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=>!!Ot(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()}},addInputRules(){return this.options.markdownLinks?[Lw({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!Ot(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:i}=this.options;nm(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Ot(s,r),protocols:r,defaultProtocol:i})).forEach(o=>{this.options.shouldAutoLink(o.value)&&n.push({text:o.value,data:{href:o.href},index:o.start})})}return n};return this.options.markdownLinks?[Iw({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!Ot(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[fn({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Mw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ot(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Tw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Rw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Dw=lm;const Pw="listItem",vd="textStyle",Md=/^\s*([-+*])\s$/,am=Ge.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",be(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,`
172
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Pw,this.editor.getAttributes(vd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ur({find:Md,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ur({find:Md,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(vd),editor:this.editor})),[t]}}),$w=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let o=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){o=h;break}if(o<0)return null;const s=i.node(o),l=i.index(o);if(l+1>=s.childCount)return null;const a=s.child(l+1);if(!n.includes(a.type.name))return null;const c=t.schema.nodes[e];let u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;const d=t.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;const p=[];return d.forEach(h=>{p.push(h)}),p.length===0?null:{listItemDepth:o,nestedList:d,nestedListPos:i.after(),insertPos:i.after(o),items:p}},Bw=(t,e,n,r)=>{const i=$w(t,n,r);if(!i)return!1;const{selection:o}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=i,u=t.tr;u.delete(l,l+s.nodeSize);const d=u.mapping.map(a);return u.insert(d,L.from(c)),u.setSelection(o.map(u.doc,u.mapping)),e&&e(u),!0},_w=(t,e,n)=>Bw(t.state,t.view.dispatch,e,n),cm=(t,e)=>ae.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>_w(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),um=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ki="abcdefghijklmnopqrstuvwxyz",dm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Ss(t){let e=t,n="";for(const[r,i]of um)for(;e>=r;)n+=i,e-=r;return n}function rc(t){return Ss(t).toUpperCase()}function fm(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let i=!1;for(const[o,s]of um)if(e.startsWith(s,n)){r+=o,n+=s.length,i=!0;break}if(!i)return 0}return r}function zw(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=fm(t);return e<=0?!1:(t===t.toLowerCase()?Ss(e):rc(e))===t}function Fw(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Yo(t){if(t<=26)return Ki[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Ki[n]:Ki[e]+Ki[n]}function ws(t){if(!(!t||/^\d+$/.test(t))){if(zw(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function ic(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=ws(t);if(e==="i"||e==="I")return fm(t);if(e==="a"||e==="A"){const r=Fw(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function Hw(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Yo(e);case"A":return Yo(e).toUpperCase();case"i":return Ss(e);case"I":return rc(e);default:return String(e)}}function jw(t){var e;if(t.length===0)return!1;const n=(e=ws(t[0]))!==null&&e!==void 0?e:"numeric",r=ic(t[0]);if(r<1)return!1;for(let i=0;i<t.length;i++){const o=Hw(n,r+i);if(t[i]!==o)return!1}return!0}function Vw(t){return{type:ws(t),start:ic(t)}}function Uw(t){const{type:e,start:n}=Vw(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function qw(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Yo(r)}${n}`;case"A":return`${Yo(r).toUpperCase()}${n}`;case"i":return`${Ss(r)}${n}`;case"I":return`${rc(r)}${n}`;default:return`${r}${n}`}}function Ww(t){var e,n;const r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&(r==null?void 0:r.type)==="list"&&r.ordered&&r.raw===t.text)}function Kw(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const pm=Ge.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0){if(Ww(t))return{type:"listItem",content:[{type:"paragraph",content:Kw(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))i=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const s=r(t.tokens.slice(1));i.push(...s)}}else i=r(t.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>zh(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var i,o;const s=((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return qw((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:(n==null?void 0:n.parentType)==="orderedList"}),addExtensions(){return[cm(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),oc=(t,e)=>{const{$from:n}=e.selection,r=Ce(t,e.schema);let i=null,o=n.depth,s=n.pos,l=null;for(;o>0&&l===null;)i=n.node(o),i.type===r?l=o:(o-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},hm=(t,e)=>{const n=oc(t,e);if(!n)return!1;const[,r]=ax(e,t,n.$pos.pos+4);return r},Yw=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),o=t.doc.resolve(i).node();return!(!o||!n.includes(o.type.name))},Td=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ft(t.state,e)&&Yw(t.state,e,n)){const{$anchor:o}=t.state.selection,s=t.state.doc.resolve(o.before()-1),l=[];s.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});const a=l.at(-1);if(!a)return!1;const c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},c.end()).joinForward().run()}if(!Ft(t.state,e)||!px(t.state))return!1;const{$from:r}=t.state.selection,i=r.depth-1;return r.node(i).type!==t.schema.nodes[e]||r.index(i)!==0?!1:t.chain().liftListItem(e).run()},Jw=(t,e)=>{const n=hm(t,e),r=oc(t,e);return!r||!n?!1:n>r.depth},Gw=(t,e)=>{const n=hm(t,e),r=oc(t,e);return!r||!n?!1:n<r.depth},Ad=(t,e)=>{if(!Ft(t.state,e)||!fx(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Jw(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Gw(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Xw=(t,e,n)=>{const{state:r}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0||!o.parent.isTextblock||Ft(r,e))return!1;const s=cx(o);if(!s||!n.includes(s.type.name))return!1;const l=s.lastChild;if(!l||l.type.name!==e)return!1;const a=o.parent;if(!l.canReplace(l.childCount,l.childCount,L.from(a)))return!1;const c=o.before(),u=o.after(),d=c-2;return t.commands.command(({tr:p,dispatch:h})=>(h&&(p.delete(c,u).insert(d,L.from(a)),p.setSelection(q.create(p.doc,d+1)),p.scrollIntoView()),!0))},mm=ae.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&&Ad(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&&Ad(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&&Td(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&&Td(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(const{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&Xw(t,e,n))return!0;return!1}}}}),Jo=new RegExp(`^(\\s*)(${dm})([.)])\\s+(.*)$`),Zw=/^\s/,Qn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Qw(t){return Jo.test(t.trimStart())}function e1(t){const e=t.trimStart();return Qn.bulletItem.test(e)||Qw(e)||Qn.heading.test(e)||Qn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Qn.codeFence.test(e)||Qn.blockMath.test(e)}function t1(t){return Object.values(Qn).some(e=>e.test(t))}function n1(t){const e=[],n=[];let r=!1;return t.forEach(i=>{if(r){n.push(i);return}if(i.trim()===""){r=!0,n.push(i);return}if(e.length>0&&e1(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function Ed(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],o=i.match(Jo);if(!o)break;const[,s,l,a,c]=o,u=s.length,d=parseInt(l,10),p=isNaN(d)?ws(l):void 0,h=isNaN(d)?ic(l):d,g=[c];let b=n+1;const x=[i];let w=!1;for(;b<t.length;){const T=t[b];if(T.match(Jo))break;if(T.trim()==="")x.push(T),g.push(""),w=!0,b+=1;else if(T.match(Zw)){const R=T.length-T.trimStart().length,$=u+l.length+1;x.push(T),g.push(T.slice(Math.min(R,$))),b+=1}else{if(w||t1(T))break;x.push(T),g.push(T),b+=1}}e.push({indent:u,number:h,type:p,content:g.join(`
173
+ `).trim(),contentLines:g,raw:x.join(`
174
+ `)}),r=b,n=b}return[e,r]}const r1=new RegExp(`^(${dm})([.)])\\s+(.+)$`);function i1(t){const e=t.split(`
175
+ `).filter(r=>r.trim().length>0);if(e.length===0)return null;const n=[];for(const r of e){const i=r.trim().match(r1);if(!i)return null;n.push({marker:i[1],content:i[3]})}return jw(n.map(r=>r.marker))?{type:"orderedList",attrs:Uw(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function gm(t,e,n){const r=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const{paragraphLines:s,blockLines:l}=n1(o.contentLines),a=s.join(`
176
+ `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
177
+ `).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=i+1;const p=[];for(;d<t.length&&t[d].indent>e;)p.push(t[d]),d+=1;if(p.length>0){const h=gm(p,Math.min(...p.map(g=>g.indent)),n);c.push({type:"list",ordered:!0,start:p[0].number,typeMarker:p[0].type,items:h,raw:p.map(g=>g.raw).join(`
178
+ `)})}r.push({type:"list_item",raw:o.raw,tokens:c}),i=d}else i+=1}return r}function o1(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const o=e.parseChildren([i]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([i]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}const s1=64;function Nd(t,e){const n=[];let r=0;for(;n.length<e;){const i=t.indexOf(`
179
+ `,r);if(i===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,i)),r=i+1}return n}function l1(t){const e=t.indexOf(`
180
+ `),n=e===-1?t:t.slice(0,e);if(!Jo.test(n))return[[],0,[]];let r=s1,i=Nd(t,r),o=Ed(i);for(;o[1]===i.length&&i.length===r;)r*=2,i=Nd(t,r),o=Ed(i);return[o[0],o[1],i]}const a1="listItem",Od="textStyle",Ld=/^(\d+)\.\s$/;function Id(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}const ym=Ge.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=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const i=Id(n);if(i)return i}const r=t.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const o=Id(i);if(o)return o}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,i=be(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),n&&n!=="1"&&(i.type=n),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,i=t.items?o1(t.items,e):[],o={};return n!==1&&(o.start=n),r&&(o.type=r),Object.keys(o).length>0?{type:"orderedList",attrs:o,content:i}:{type:"orderedList",content:i}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
181
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,i;const[o,s,l]=l1(t);if(o.length===0)return;const a=gm(o,o[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=o[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(i=o[0])===null||i===void 0?void 0:i.type,items:a,raw:l.slice(0,s).join(`
182
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(a1,this.editor.getAttributes(Od)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new fe({props:{handlePaste:(t,e)=>{var n,r;const i=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(i!=null&&i.trim())return!1;const o=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!o)return!1;const s=i1(o);if(!s)return!1;try{const l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){const t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1];let e=ur({find:Ld,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ur({find:Ld,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Od)}),joinPredicate:t,editor:this.editor})),[e]}}),c1=/^\s*(\[([( |x])?\])\s$/,u1="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",d1=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},f1=Ge.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,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",be(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 r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return zh(t,e,r)},addExtensions(){return this.options.nested?[cm(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=u1;const c=d=>{const p=d1(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",p),s.textContent=p};c(t),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:p}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const g=n();if(typeof g!="number")return!1;const b=h.doc.nodeAt(g);return h.setNodeMarkup(g,void 0,{...b==null?void 0:b.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,p])=>{i.setAttribute(d,p)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,o.append(l,s),i.append(o,a),Object.entries(e).forEach(([d,p])=>{i.setAttribute(d,p)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const p=r.extensionManager.attributes,h=ci(d,p),g=new Set(Object.keys(h)),b=this.options.HTMLAttributes;return u.forEach(x=>{g.has(x)||(x in b?i.setAttribute(x,b[x]):i.removeAttribute(x))}),Object.entries(h).forEach(([x,w])=>{w==null?x in b?i.setAttribute(x,b[x]):i.removeAttribute(x):i.setAttribute(x,w)}),u=g,!0}}}},addInputRules(){return[ur({find:c1,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),p1=Ge.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",be(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,`
183
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const s=hd(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){const l={type:"taskList",raw:s.raw,items:s.items},a=o.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(o)},i=hd(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,s)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ae.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(am.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(pm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(mm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(ym.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(f1.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(p1.configure(this.options.taskList)),t}});const Yi="&nbsp;",Nl=" ",h1=Ge.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",be(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 n.length===1&&n[0].type==="text"&&(n[0].raw===Yi||n[0].text===Yi||n[0].raw===Nl||n[0].text===Nl)&&r.length===1&&r[0].type==="text"&&(r[0].text===Yi||r[0].text===Nl)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";const r=Array.isArray(t.content)?t.content:[];if(r.length===0){var i,o;const s=Array.isArray(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.content)?n.previousNode.content:[];return(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.type)==="paragraph"&&s.length===0?Yi:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),m1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,g1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,y1=gn.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",be(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[$n({find:m1,type:this.type})]},addPasteRules(){return[fn({find:g1,type:this.type})]}}),b1=Ge.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),k1=gn.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",be(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 r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[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()}}});function x1(t={}){return new fe({view(e){return new S1(e,t)}})}class S1{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(n){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let g=h.getBoundingClientRect(),b=d?g.bottom:g.top;d&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:g.left,right:g.right,top:b-x,bottom:b+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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 c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(!n||o)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ip(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ge extends G{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ge.valid(r)?new ge(r):G.near(r)}content(){return _.empty}eq(e){return e instanceof ge&&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 ge(e.resolve(n.pos))}getBookmark(){return new sc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!w1(e)||!C1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ge.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let a=e.doc.resolve(i);if(ge.valid(a))return a}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!U.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let l=e.doc.resolve(i);if(ge.valid(l))return l}return null}}}ge.prototype.visible=!1;ge.findFrom=ge.findGapCursorFrom;G.jsonID("gapcursor",ge);class sc{constructor(e){this.pos=e}map(e){return new sc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ge.valid(n)?new ge(n):G.near(n)}}function bm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function w1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||bm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function C1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||bm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v1(){return new fe({props:{decorations:E1,createSelectionBetween(t,e,n){return e.pos==n.pos&&ge.valid(n)?new ge(n):null},handleClick:T1,handleKeyDown:M1,handleDOMEvents:{beforeinput:A1}}})}const M1=ah({ArrowLeft:Ji("horiz",-1),ArrowRight:Ji("horiz",1),ArrowUp:Ji("vert",-1),ArrowDown:Ji("vert",1)});function Ji(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof q){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ge.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new ge(c))),!0):!1}}function T1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ge.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&U.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ge(r))),!0)}function A1(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ge))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=L.empty;for(let s=r.length-1;s>=0;s--)i=L.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new _(i,0,0));return o.setSelection(q.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function E1(t){if(!(t.selection instanceof ge))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[je.widget(t.selection.head,e,{key:"gapcursor"})])}ae.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,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 n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}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 fe({key:new xe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit,o=this.options.autoTrim;if(i==null||i===0||o===!1){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const l=s-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!e.getMeta("paste"))return!1;const s=e.selection.$head.pos,l=s-(o-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}});const N1=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[x1(this.options)]}});ae.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new xe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,o=[];if(!n||!r)return re.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(i>=c&&i<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(je.node(c,c+a.nodeSize,{class:this.options.className}))}),re.create(t,o)}}})]}});const O1=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[v1()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ie(H(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),km="placeholder",Rd=new xe("tiptap__placeholder");function xm(t){const{editor:e,placeholder:n,dataAttribute:r,pos:i,node:o,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return s&&u.push(c),je.node(i,i+o.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:o,pos:i,hasAnchor:l}):n})}function Sm(t,e){return typeof t=="function"?t(e):t}function wm({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:o,to:s}){const{anchor:l}=i,a=[],c=t.isEmpty;return r.nodesBetween(o,s,(u,d)=>{const p=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&Si(u);return u.type.isTextblock&&(p||!e.showOnlyCurrent)&&h&&a.push(xm({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Sm(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:p})},node:u,pos:d})),e.includeChildren}),a}function Cm({editor:t,options:e,dataAttribute:n,doc:r,selection:i}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:o}=i,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const a=r.resolve(o),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):o;if(c&&c.type.isTextblock&&Si(c)){const d=o>=u&&o<=u+c.nodeSize;s.push(xm({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Sm(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...wm({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return re.create(r,s)}function Jr(t,e){const n=t.resolve(e);if(n.depth===0){var r;const o=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!o)return{from:e,to:e};const s=n.nodeAfter?e:e-o.nodeSize;return{from:s,to:s+o.nodeSize}}const i=n.before(1);return{from:i,to:i+n.node(1).nodeSize}}function Gr(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function L1(t,e,n){const r=[];return t.forEach((i,o)=>{const s=o,l=s+i.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function I1(t){if(t.length===0)return[];const e=[...t].sort((r,i)=>r.from-i.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){const i=n[n.length-1],o=e[r];o.from<=i.to?i.to=Math.max(i.to,o.to):n.push({...o})}return n}function R1(t,e){const n=L1(t,e.from,e.to);return n.push(Gr(t,Jr(t,e.from))),e.to>e.from?n.push(Gr(t,Jr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Gr(t,Jr(t,Math.min(e.from+1,t.content.size)))),n}function D1(t,e,n){const r=[];if(t.docChanged){const i=gs(t);for(const o of i)r.push(...R1(n.doc,o.newRange))}return t.selectionSet&&(r.push(Gr(n.doc,Jr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Gr(n.doc,Jr(n.doc,n.selection.anchor)))),I1(r)}function P1(t,e,n){const r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function $1({decorations:t,ranges:e,editor:n,options:r,dataAttribute:i,doc:o,selection:s}){let l=t;for(const a of e){const{from:c,to:u}=P1(a.from,a.to,o),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));const p=wm({editor:n,options:r,dataAttribute:i,doc:o,selection:s,from:c,to:u});p.length&&(l=l.add(o,p))}return l}function B1({editor:t,options:e,dataAttribute:n}){return{init(r,i){const o=Cm({editor:t,options:e,dataAttribute:n,doc:i.doc,selection:i.selection});return o??re.empty},apply(r,i,o,s){return!r.docChanged&&!r.selectionSet?i:$1({decorations:i.map(r.mapping,r.doc),ranges:D1(r,o,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function _1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function z1({editor:t,options:e}){const n=e.dataAttribute?`data-${_1(e.dataAttribute)}`:`data-${km}`,r=e.showOnlyCurrent&&!e.includeChildren;return new fe({key:Rd,...r?{}:{state:B1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:i,selection:o})=>Cm({editor:t,options:e,dataAttribute:n,doc:i,selection:o}):i=>{var o;return e.showOnlyWhenEditable&&!t.isEditable?re.empty:(o=Rd.getState(i))!==null&&o!==void 0?o:re.empty}}})}const F1=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:km,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[z1({editor:this.editor,options:this.options})]}});function ma(t,e){return!t.selection.empty&&!Lh(t.selection)&&e.isEditable}function H1(t,e){return ma(t,e)&&!e.isFocused&&!e.view.dragging}function j1(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function V1(t){t.focus()}ae.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new fe({key:new xe("selection"),props:{decorations(n){return H1(n,t)?re.create(n.doc,[je.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return ma(n.state,t)&&j1(),!1},focus(n){return ma(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&V1(n)}),!1}}}})]}});function Dd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}const U1=ae.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new xe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new fe({key:e,appendTransaction:(i,o,s)=>{const{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,p=c.nodes[n];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,p.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!Dd({node:s,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!Dd({node:s,types:r})}}})]}}),q1=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>fh(t,e),redo:()=>({state:t,dispatch:e})=>ph(t,e)}},addProseMirrorPlugins(){return[ik(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()}}}),W1=ae.create({name:"starterKit",addExtensions(){const t=[];if(this.options.bold!==!1&&t.push(_S.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(RS.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(am.configure(this.options.bulletList)),this.options.code!==!1&&t.push(jS.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(qS.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(WS.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(N1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(O1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(KS.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(YS.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(q1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(JS.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(ew.configure(this.options.italic)),this.options.listItem!==!1&&t.push(pm.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(mm.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(lm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(ym.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(h1.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(y1.configure(this.options.strike)),this.options.text!==!1&&t.push(b1.configure(this.options.text)),this.options.underline!==!1){var r;t.push(k1.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;t.push(U1.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return t}});var K1=W1,Y1=F1;const J1=20,vm=(t,e=0)=>{const n=[];return!t.children.length||e>J1||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...vm(r,e+1))}),n},G1=t=>{if(!t.children.length)return;const e=vm(t);e&&e.forEach(n=>{var r;const i=n.getAttribute("style"),o=(r=n.parentElement)===null||r===void 0||(r=r.closest("span"))===null||r===void 0?void 0:r.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},Mm=gn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&G1(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",be(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.isInline)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(o=>!!o))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),X1=ae.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=wi(t,"background-color"))!==null&&e!==void 0?e:t.style.backgroundColor;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>Ci(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()}}}),Tm=ae.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=wi(t,"color"))!==null&&e!==void 0?e:t.style.color;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>Ci(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()}}}),Z1=ae.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=wi(t,"font-family"))!==null&&e!==void 0?e:t.style.fontFamily},renderHTML:t=>Ci(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()}}}),Q1=ae.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=wi(t,"font-size"))!==null&&e!==void 0?e:t.style.fontSize},renderHTML:t=>Ci(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()}}}),eC=ae.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=wi(t,"line-height"))!==null&&e!==void 0?e:t.style.lineHeight},renderHTML:t=>Ci(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()}}});ae.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(X1.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Tm.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Z1.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(Q1.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(eC.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Mm.configure(this.options.textStyle)),t}});const dr=[{name:"figure",include:"figure.html",label:"Figure",fields:["src","alt","caption","source","width"]},{name:"cutIn",include:"cut-in.html",label:"Cut-in",fields:["src","alt","side"]},{name:"youtube",include:"youtube.html",label:"YouTube",fields:["id","caption","width"]},{name:"youtubeShort",include:"youtube-short.html",label:"YouTube Short",fields:["src","src2"]},{name:"video",include:"video.html",label:"Video",fields:["src","caption","width"]},{name:"plotly",include:"plotly.html",label:"Plotly",fields:["src","caption","width","height","source","alt"]},{name:"xcite",include:"xcite.html",label:"Xcite",fields:["key"],inline:!0},{name:"cite",include:"cite.html",label:"Cite",fields:["key"],inline:!0},{name:"articleNote",include:"article-note",label:"Article note",fields:["body"],blockBody:!0},{name:"poem",include:"poem",label:"Poem",fields:["body"],blockBody:!0}];function tC(t,e){if(t.blockBody){const r=e.body||"";return`{% include ${t.include} markdown="1" %}
184
+ ${r}
185
+ {% endinclude %}`}const n=t.fields.filter(r=>e[r]!=null&&String(e[r]).length).map(r=>`${r}="${String(e[r]).replace(/"/g,"&quot;")}"`);return n.length?`{% include ${t.include} ${n.join(" ")} %}`:`{% include ${t.include} %}`}function Am(t){const e={};return String(t||"").replace(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,(n,r,i,o)=>(e[r]=i??o,"")),e}const Em=/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g;function Go(t){return dr.find(e=>e.include===t)}function nC(t){const e=String(t||"").trim();if(!e.startsWith("{%"))return null;const n=e.match(/^\{%-?\s*include\s+([\w.-]+)\b[^%]*?-?%\}\s*([\s\S]*?)\s*\{%-?\s*endinclude\s*-?%\}$/);if(n){const o=Go(n[1]);return o!=null&&o.blockBody?{type:o.name,attrs:{body:n[2].replace(/^\n|\n$/g,""),raw:e}}:null}const r=e.match(/^\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}$/);if(!r)return null;const i=Go(r[1]);return!i||i.inline||i.blockBody?null:lc(i,r[2],r[0])}function lc(t,e,n){return{type:t.name,attrs:{...Am(e),raw:n}}}function rC(t,e){const n=e==null?void 0:e.raw;if(typeof n!="string"||!n)return!1;if(t.blockBody){const i=e.body==null?"":String(e.body);return n.includes(i)}const r=Am(n);for(const i of t.fields){const o=e[i]==null?"":String(e[i]),s=r[i]==null?"":String(r[i]);if(o!==s)return!1}return!0}function Nm(t,e){return rC(t,e)?e.raw:tC(t,e)}function Pd(t){const e=String(t||""),n=[],r=new RegExp(Em.source,"g");let i=0,o;for(;o=r.exec(e);){o.index>i&&n.push({type:"text",text:e.slice(i,o.index)});const s=Go(o[1]);s!=null&&s.inline?n.push(lc(s,o[2],o[0])):n.push({type:"text",text:o[0]}),i=o.index+o[0].length}return i<e.length&&n.push({type:"text",text:e.slice(i)}),n.filter(s=>s.type!=="text"||s.text!=="")}function Om(t){return String(t||"").replace(/^\n+|\n+$/g,"")}function $d(t,e){const n=Om(e);if(!n)return;const r=n.match(/^(#{1,6})\s+([\s\S]*)$/);if(r&&!n.includes(`
186
+ `)&&n.trim()===n){t.push({type:"heading",attrs:{level:r[1].length},content:Pd(r[2])});return}t.push({type:"paragraph",content:Pd(n)})}function iC(t,e){const n=Om(e);if(!n)return;const r=nC(n);if(r){t.push(r);return}const i=new RegExp(Em.source,"g"),o=[];let s=0,l,a=!1;for(;l=i.exec(n);){const c=Go(l[1]);c&&!c.inline&&!c.blockBody&&(a=!0,o.push({kind:"text",text:n.slice(s,l.index)}),o.push({kind:"block",node:lc(c,l[2],l[0])}),s=l.index+l[0].length)}if(!a){$d(t,n);return}o.push({kind:"text",text:n.slice(s)});for(const c of o)c.kind==="block"?t.push(c.node):c.text.trim()&&$d(t,c.text)}function oC(t,e){const n=/```([^\n`]*)\n([\s\S]*?)```/g;let r=0,i;const o=String(e||"");for(;i=n.exec(o);){i.index>r&&Bd(t,o.slice(r,i.index));const s=String(i[1]||"").trim(),l=String(i[2]||"").replace(/\n$/,"");t.push({type:"codeBlock",attrs:{language:s||null},content:l?[{type:"text",text:l}]:[]}),r=i.index+i[0].length}r<o.length&&Bd(t,o.slice(r))}function Bd(t,e){const n=String(e||"").split(/\n{2,}/);for(const r of n)iC(t,r)}function ga(t){const e=[];return oC(e,t),e.length||e.push({type:"paragraph"}),{type:"doc",content:e}}function _d(t){return(t||[]).map(e=>{var r,i;if(e.type==="text"){let o=e.text||"";const s=e.marks||[];for(const l of s)l.type==="bold"&&(o=`**${o}**`),l.type==="italic"&&(o=`*${o}*`),l.type==="strike"&&(o=`~~${o}~~`),l.type==="code"&&(o=`\`${o}\``),l.type==="link"&&(o=`[${o}](${((r=l.attrs)==null?void 0:r.href)||""})`),l.type==="textStyle"&&((i=l.attrs)!=null&&i.color)&&(o=`<span style="color:${l.attrs.color}">${o}</span>`);return o}if(e.type==="hardBreak")return`
187
+ `;const n=dr.find(o=>o.name===e.type);return n?Nm(n,e.attrs||{}):""}).join("")}function Br(t){return(t||[]).map(e=>{var r,i;const n=dr.find(o=>o.name===e.type);if(n){const o=Nm(n,e.attrs||{});return o.endsWith(`
188
+ `)?`${o}
189
+ `:`${o}
190
+
191
+ `}switch(e.type){case"paragraph":return`${_d(e.content||[])}
192
+
193
+ `;case"heading":{const o=((r=e.attrs)==null?void 0:r.level)||1;return`${"#".repeat(o)} ${_d(e.content||[])}
194
+
195
+ `}case"blockquote":return Br(e.content||[]).split(`
196
+ `).map(o=>o?`> ${o}`:">").join(`
197
+ `)+`
198
+
199
+ `;case"bulletList":return(e.content||[]).map(o=>`- ${Br(o.content||[]).trim()}`).join(`
200
+ `)+`
201
+
202
+ `;case"orderedList":return(e.content||[]).map((o,s)=>`${s+1}. ${Br(o.content||[]).trim()}`).join(`
203
+ `)+`
204
+
205
+ `;case"codeBlock":return"```"+(((i=e.attrs)==null?void 0:i.language)||"")+`
206
+ `+(e.content||[]).map(s=>s.text||"").join("")+"\n```\n\n";case"horizontalRule":return`---
207
+
208
+ `;default:return e.content?Br(e.content):""}}).join("")}function Lm(t){return Br(t).trim()+`
209
+ `}function sC(t){const e=ga(t);return Lm(e.content||[])}function lC(t){return Ge.create({name:t.name,group:t.inline?"inline":"block",inline:!!t.inline,atom:!0,selectable:!0,draggable:!0,addAttributes(){const e={};for(const n of t.fields)e[n]={default:""};return e.raw={default:""},e},parseHTML(){return[{tag:`div[data-liquid="${t.name}"]`}]},renderHTML({HTMLAttributes:e}){const n=t.fields.map(i=>e[i]).filter(Boolean).slice(0,2).join(" | "),r=t.inline?"span":"div";return[r,be(e,{"data-liquid":t.name,class:t.inline?"liquid-block liquid-block--inline":"liquid-block","data-include":t.include}),["strong",{},t.label],[r==="span"?"span":"div",{},n||"(empty)"]]},addCommands(){return{[`insert${t.name.charAt(0).toUpperCase()}${t.name.slice(1)}`]:(e={})=>({commands:n})=>n.insertContent({type:t.name,attrs:e})}}})}function zd(t){const e=t.getJSON();return Lm(e.content||[])}function aC(t,{content:e="",onUpdate:n}={}){const r=dr.map(lC),i=new ES({element:t,extensions:[K1.configure({heading:{levels:[1,2,3,4]}}),Mm,Tm,Dw.configure({autolink:!1,linkOnPaste:!1,openOnClick:!1}),Y1.configure({placeholder:"Write… Use Insert for Liquid blocks."}),...r],content:ga(e),onUpdate:({editor:o})=>{n&&n(zd(o))}});return{editor:i,getMarkdown:()=>zd(i),setMarkdown:o=>{i.commands.setContent(ga(o))},destroy:()=>i.destroy(),insertInclude:(o,s={})=>{const l=dr.find(a=>a.name===o);l&&i.commands.insertContent({type:l.name,attrs:s})},transformSelectionCase:o=>{const{from:s,to:l,empty:a}=i.state.selection;if(a)return;const c=i.state.doc.textBetween(s,l,"");let u=c;if(o==="lower")u=c.toLocaleLowerCase();else if(o==="upper")u=c.toLocaleUpperCase();else if(o==="title")u=c.replace(/\S+/g,d=>{const p=[...d][0]||"",h=[...d].slice(1).join("");return p.toLocaleUpperCase()+h.toLocaleLowerCase()});else return;i.chain().focus().insertContentAt({from:s,to:l},u).run()}}}function ac(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Fn=ac();function Im(t){Fn=t}var Xr={exec:()=>null};function se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,o)=>{let s=typeof o=="string"?o:o.source;return s=s.replace(Ve.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var Ve={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},cC=/^(?:[ \t]*(?:\n|$))+/,uC=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,dC=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,fC=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,cc=/(?:[*+-]|\d{1,9}[.)])/,Rm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Dm=se(Rm).replace(/bull/g,cc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),pC=se(Rm).replace(/bull/g,cc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),uc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,hC=/^[^\n]+/,dc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mC=se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",dc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gC=se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,cc).getRegex(),Cs="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yC=se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",fc).replace("tag",Cs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Pm=se(uc).replace("hr",Mi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Cs).getRegex(),bC=se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Pm).getRegex(),pc={blockquote:bC,code:uC,def:mC,fences:dC,heading:fC,hr:Mi,html:yC,lheading:Dm,list:gC,newline:cC,paragraph:Pm,table:Xr,text:hC},Fd=se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Cs).getRegex(),kC={...pc,lheading:pC,table:Fd,paragraph:se(uc).replace("hr",Mi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Cs).getRegex()},xC={...pc,html:se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Xr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:se(uc).replace("hr",Mi).replace("heading",` *#{1,6} *[^
210
+ ]`).replace("lheading",Dm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},SC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,wC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$m=/^( {2,}|\\)\n(?!\s*$)/,CC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vs=/[\p{P}\p{S}]/u,hc=/[\s\p{P}\p{S}]/u,Bm=/[^\s\p{P}\p{S}]/u,vC=se(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,hc).getRegex(),_m=/(?!~)[\p{P}\p{S}]/u,MC=/(?!~)[\s\p{P}\p{S}]/u,TC=/(?:[^\s\p{P}\p{S}]|~)/u,AC=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,zm=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,EC=se(zm,"u").replace(/punct/g,vs).getRegex(),NC=se(zm,"u").replace(/punct/g,_m).getRegex(),Fm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",OC=se(Fm,"gu").replace(/notPunctSpace/g,Bm).replace(/punctSpace/g,hc).replace(/punct/g,vs).getRegex(),LC=se(Fm,"gu").replace(/notPunctSpace/g,TC).replace(/punctSpace/g,MC).replace(/punct/g,_m).getRegex(),IC=se("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Bm).replace(/punctSpace/g,hc).replace(/punct/g,vs).getRegex(),RC=se(/\\(punct)/,"gu").replace(/punct/g,vs).getRegex(),DC=se(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),PC=se(fc).replace("(?:-->|$)","-->").getRegex(),$C=se("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",PC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,BC=se(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Hm=se(/^!?\[(label)\]\[(ref)\]/).replace("label",Xo).replace("ref",dc).getRegex(),jm=se(/^!?\[(ref)\](?:\[\])?/).replace("ref",dc).getRegex(),_C=se("reflink|nolink(?!\\()","g").replace("reflink",Hm).replace("nolink",jm).getRegex(),mc={_backpedal:Xr,anyPunctuation:RC,autolink:DC,blockSkip:AC,br:$m,code:wC,del:Xr,emStrongLDelim:EC,emStrongRDelimAst:OC,emStrongRDelimUnd:IC,escape:SC,link:BC,nolink:jm,punctuation:vC,reflink:Hm,reflinkSearch:_C,tag:$C,text:CC,url:Xr},zC={...mc,link:se(/^!?\[(label)\]\((.*?)\)/).replace("label",Xo).getRegex(),reflink:se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xo).getRegex()},ya={...mc,emStrongRDelimAst:LC,emStrongLDelim:NC,url:se(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},FC={...ya,br:se($m).replace("{2,}","*").getRegex(),text:se(ya.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:pc,gfm:kC,pedantic:xC},Er={normal:mc,gfm:ya,breaks:FC,pedantic:zC},HC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hd=t=>HC[t];function mt(t,e){if(e){if(Ve.escapeTest.test(t))return t.replace(Ve.escapeReplace,Hd)}else if(Ve.escapeTestNoEncode.test(t))return t.replace(Ve.escapeReplaceNoEncode,Hd);return t}function jd(t){try{t=encodeURI(t).replace(Ve.percentDecode,"%")}catch{return null}return t}function Vd(t,e){var o;const n=t.replace(Ve.findPipe,(s,l,a)=>{let c=!1,u=l;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Ve.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!((o=r.at(-1))!=null&&o.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ve.slashPipe,"|");return r}function Nr(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function jC(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ud(t,e,n,r,i){const o=e.href,s=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:s,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,a}function VC(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
211
+ `).map(o=>{const s=o.match(n.other.beginningSpace);if(s===null)return o;const[l]=s;return l.length>=i.length?o.slice(i.length):o}).join(`
212
+ `)}var Zo=class{constructor(t){ce(this,"options");ce(this,"rules");ce(this,"lexer");this.options=t||Fn}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Nr(n,`
213
+ `)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=VC(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){const r=Nr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Nr(e[0],`
214
+ `)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Nr(e[0],`
215
+ `).split(`
216
+ `),r="",i="";const o=[];for(;n.length>0;){let s=!1;const l=[];let a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),s=!0;else if(!s)l.push(n[a]);else break;n=n.slice(a);const c=l.join(`
217
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
218
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
219
+ ${c}`:c,i=i?`${i}
220
+ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=d,n.length===0)break;const p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){const h=p,g=h.raw+`
221
+ `+n.join(`
222
+ `),b=this.blockquote(g);o[o.length-1]=b,r=r.substring(0,r.length-h.raw.length)+b.raw,i=i.substring(0,i.length-h.text.length)+b.text;break}else if((p==null?void 0:p.type)==="list"){const h=p,g=h.raw+`
223
+ `+n.join(`
224
+ `),b=this.list(g);o[o.length-1]=b,r=r.substring(0,r.length-p.raw.length)+b.raw,i=i.substring(0,i.length-h.raw.length)+b.raw,n=g.substring(o.at(-1).raw.length).split(`
225
+ `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const o=this.rules.other.listItemRegex(n);let s=!1;for(;t;){let a=!1,c="",u="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=e[2].split(`
226
+ `,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),p=t.split(`
227
+ `,1)[0],h=!d.trim(),g=0;if(this.options.pedantic?(g=2,u=d.trimStart()):h?g=e[1].length+1:(g=e[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=d.slice(g),g+=e[1].length),h&&this.rules.other.blankLine.test(p)&&(c+=p+`
228
+ `,t=t.substring(p.length+1),a=!0),!a){const w=this.rules.other.nextBulletRegex(g),T=this.rules.other.hrRegex(g),R=this.rules.other.fencesBeginRegex(g),$=this.rules.other.headingBeginRegex(g),Y=this.rules.other.htmlBeginRegex(g);for(;t;){const ne=t.split(`
229
+ `,1)[0];let j;if(p=ne,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),j=p):j=p.replace(this.rules.other.tabCharGlobal," "),R.test(p)||$.test(p)||Y.test(p)||w.test(p)||T.test(p))break;if(j.search(this.rules.other.nonSpaceChar)>=g||!p.trim())u+=`
230
+ `+j.slice(g);else{if(h||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(d)||$.test(d)||T.test(d))break;u+=`
231
+ `+p}!h&&!p.trim()&&(h=!0),c+=ne+`
232
+ `,t=t.substring(ne.length+1),d=j.slice(g)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0));let b=null,x;this.options.gfm&&(b=this.rules.other.listIsTask.exec(u),b&&(x=b[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!b,checked:x,loose:!1,text:u,tokens:[]}),i.raw+=c}const l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let a=0;a<i.items.length;a++)if(this.lexer.state.top=!1,i.items[a].tokens=this.lexer.blockTokens(i.items[a].text,[]),!i.loose){const c=i.items[a].tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}if(i.loose)for(let a=0;a<i.items.length;a++)i.items[a].loose=!0;return i}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){var s;const e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const n=Vd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(s=e[3])!=null&&s.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
233
+ `):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const l of r)this.rules.other.tableAlignRight.test(l)?o.align.push("right"):this.rules.other.tableAlignCenter.test(l)?o.align.push("center"):this.rules.other.tableAlignLeft.test(l)?o.align.push("left"):o.align.push(null);for(let l=0;l<n.length;l++)o.header.push({text:n[l],tokens:this.lexer.inline(n[l]),header:!0,align:o.align[l]});for(const l of i)o.rows.push(Vd(l,o.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[c]})));return o}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
234
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const o=Nr(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{const o=jC(e[2],"()");if(o===-2)return;if(o>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){const o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Ud(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){const o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Ud(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const o=[...r[0]].length-1;let s,l,a=o,c=0;const u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+o);(r=u.exec(e))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(l=[...s].length,r[3]||r[4]){a+=l;continue}else if((r[5]||r[6])&&o%3&&!((o+l)%3)){c+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+c);const d=[...r[0]][0].length,p=t.slice(0,o+r.index+d+l);if(Math.min(o,l)%2){const g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," ");const r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let o;do o=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(o!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){const n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},$t=class ba{constructor(e){ce(this,"tokens");ce(this,"options");ce(this,"state");ce(this,"tokenizer");ce(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Fn,this.options.tokenizer=this.options.tokenizer||new Zo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:Ve,block:Gi.normal,inline:Er.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=Er.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=Er.breaks:n.inline=Er.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:Er}}static lex(e,n){return new ba(n).lex(e)}static lexInline(e,n){return new ba(n).inlineTokens(e)}lex(e){e=e.replace(Ve.carriageReturn,`
235
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var i,o,s;for(this.options.pedantic&&(e=e.replace(Ve.tabCharGlobal," ").replace(Ve.spaceLine,""));e;){let l;if((o=(i=this.options.extensions)==null?void 0:i.block)!=null&&o.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.space(e)){e=e.substring(l.raw.length);const c=n.at(-1);l.raw.length===1&&c!==void 0?c.raw+=`
236
+ `:n.push(l);continue}if(l=this.tokenizer.code(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=`
237
+ `+l.raw,c.text+=`
238
+ `+l.text,this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(l=this.tokenizer.fences(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.heading(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.hr(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.blockquote(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.list(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.html(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.def(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=`
239
+ `+l.raw,c.text+=`
240
+ `+l.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title});continue}if(l=this.tokenizer.table(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.lheading(e)){e=e.substring(l.raw.length),n.push(l);continue}let a=e;if((s=this.options.extensions)!=null&&s.startBlock){let c=1/0;const u=e.slice(1);let d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(this.state.top&&(l=this.tokenizer.paragraph(a))){const c=n.at(-1);r&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=`
241
+ `+l.raw,c.text+=`
242
+ `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l),r=a.length!==e.length,e=e.substring(l.raw.length);continue}if(l=this.tokenizer.text(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=`
243
+ `+l.raw,c.text+=`
244
+ `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,a,c;let r=e,i=null;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)u.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let o=!1,s="";for(;e;){o||(s=""),o=!1;let u;if((a=(l=this.options.extensions)==null?void 0:l.inline)!=null&&a.some(p=>(u=p.call({lexer:this},e,n))?(e=e.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.escape(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.tag(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.link(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(u.raw.length);const p=n.at(-1);u.type==="text"&&(p==null?void 0:p.type)==="text"?(p.raw+=u.raw,p.text+=u.text):n.push(u);continue}if(u=this.tokenizer.emStrong(e,r,s)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.codespan(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.br(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.del(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.autolink(e)){e=e.substring(u.raw.length),n.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(e))){e=e.substring(u.raw.length),n.push(u);continue}let d=e;if((c=this.options.extensions)!=null&&c.startInline){let p=1/0;const h=e.slice(1);let g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},h),typeof g=="number"&&g>=0&&(p=Math.min(p,g))}),p<1/0&&p>=0&&(d=e.substring(0,p+1))}if(u=this.tokenizer.inlineText(d)){e=e.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(s=u.raw.slice(-1)),o=!0;const p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=u.raw,p.text+=u.text):n.push(u);continue}if(e){const p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}},Qo=class{constructor(t){ce(this,"options");ce(this,"parser");this.options=t||Fn}space(t){return""}code({text:t,lang:e,escaped:n}){var o;const r=(o=(e||"").match(Ve.notSpaceStart))==null?void 0:o[0],i=t.replace(Ve.endingNewline,"")+`
245
+ `;return r?'<pre><code class="language-'+mt(r)+'">'+(n?i:mt(i,!0))+`</code></pre>
246
+ `:"<pre><code>"+(n?i:mt(i,!0))+`</code></pre>
247
+ `}blockquote({tokens:t}){return`<blockquote>
248
+ ${this.parser.parse(t)}</blockquote>
249
+ `}html({text:t}){return t}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
250
+ `}hr(t){return`<hr>
251
+ `}list(t){const e=t.ordered,n=t.start;let r="";for(let s=0;s<t.items.length;s++){const l=t.items[s];r+=this.listitem(l)}const i=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
252
+ `+r+"</"+i+`>
253
+ `}listitem(t){var n;let e="";if(t.task){const r=this.checkbox({checked:!!t.checked});t.loose?((n=t.tokens[0])==null?void 0:n.type)==="paragraph"?(t.tokens[0].text=r+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=r+" "+mt(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
254
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
255
+ `}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){const o=t.rows[i];n="";for(let s=0;s<o.length;s++)n+=this.tablecell(o[s]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
256
+ <thead>
257
+ `+e+`</thead>
258
+ `+r+`</table>
259
+ `}tablerow({text:t}){return`<tr>
260
+ ${t}</tr>
261
+ `}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
262
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${mt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const r=this.parser.parseInline(n),i=jd(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+mt(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));const i=jd(t);if(i===null)return mt(n);t=i;let o=`<img src="${t}" alt="${n}"`;return e&&(o+=` title="${mt(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mt(t.text)}},gc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},Bt=class ka{constructor(e){ce(this,"options");ce(this,"renderer");ce(this,"textRenderer");this.options=e||Fn,this.options.renderer=this.options.renderer||new Qo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new gc}static parse(e,n){return new ka(n).parse(e)}static parseInline(e,n){return new ka(n).parseInline(e)}parse(e,n=!0){var i,o;let r="";for(let s=0;s<e.length;s++){const l=e[s];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[l.type]){const c=l,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type)){r+=u||"";continue}}const a=l;switch(a.type){case"space":{r+=this.renderer.space(a);continue}case"hr":{r+=this.renderer.hr(a);continue}case"heading":{r+=this.renderer.heading(a);continue}case"code":{r+=this.renderer.code(a);continue}case"table":{r+=this.renderer.table(a);continue}case"blockquote":{r+=this.renderer.blockquote(a);continue}case"list":{r+=this.renderer.list(a);continue}case"html":{r+=this.renderer.html(a);continue}case"paragraph":{r+=this.renderer.paragraph(a);continue}case"text":{let c=a,u=this.renderer.text(c);for(;s+1<e.length&&e[s+1].type==="text";)c=e[++s],u+=`
263
+ `+this.renderer.text(c);n?r+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u,escaped:!0}]}):r+=u;continue}default:{const c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}parseInline(e,n=this.renderer){var i,o;let r="";for(let s=0;s<e.length;s++){const l=e[s];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[l.type]){const c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){r+=c||"";continue}}const a=l;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{const c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Pl,io=(Pl=class{constructor(t){ce(this,"options");ce(this,"block");this.options=t||Fn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?$t.lex:$t.lexInline}provideParser(){return this.block?Bt.parse:Bt.parseInline}},ce(Pl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),Pl),UC=class{constructor(...t){ce(this,"defaults",ac());ce(this,"options",this.setOptions);ce(this,"parse",this.parseMarkdown(!0));ce(this,"parseInline",this.parseMarkdown(!1));ce(this,"Parser",Bt);ce(this,"Renderer",Qo);ce(this,"TextRenderer",gc);ce(this,"Lexer",$t);ce(this,"Tokenizer",Zo);ce(this,"Hooks",io);this.use(...t)}walkTokens(t,e){var r,i;let n=[];for(const o of t)switch(n=n.concat(e.call(this,o)),o.type){case"table":{const s=o;for(const l of s.header)n=n.concat(this.walkTokens(l.tokens,e));for(const l of s.rows)for(const a of l)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{const s=o;n=n.concat(this.walkTokens(s.items,e));break}default:{const s=o;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[s.type]?this.defaults.extensions.childTokens[s.type].forEach(l=>{const a=s[l].flat(1/0);n=n.concat(this.walkTokens(a,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const o=e.renderers[i.name];o?e.renderers[i.name]=function(...s){let l=i.renderer.apply(this,s);return l===!1&&(l=o.apply(this,s)),l}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=this.defaults.renderer||new Qo(this.defaults);for(const o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;const s=o,l=n.renderer[s],a=i[s];i[s]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){const i=this.defaults.tokenizer||new Zo(this.defaults);for(const o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const s=o,l=n.tokenizer[s],a=i[s];i[s]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){const i=this.defaults.hooks||new io;for(const o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;const s=o,l=n.hooks[s],a=i[s];io.passThroughHooks.has(o)?i[s]=c=>{if(this.defaults.async)return Promise.resolve(l.call(i,c)).then(d=>a.call(i,d));const u=l.call(i,c);return a.call(i,u)}:i[s]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){const i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(s){let l=[];return l.push(o.call(this,s)),i&&(l=l.concat(i.call(this,s))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return $t.lex(t,e??this.defaults)}parser(t,e){return Bt.parse(t,e??this.defaults)}parseMarkdown(t){return(n,r)=>{const i={...r},o={...this.defaults,...i},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&i.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));o.hooks&&(o.hooks.options=o,o.hooks.block=t);const l=o.hooks?o.hooks.provideLexer():t?$t.lex:$t.lexInline,a=o.hooks?o.hooks.provideParser():t?Bt.parse:Bt.parseInline;if(o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(n):n).then(c=>l(c,o)).then(c=>o.hooks?o.hooks.processAllTokens(c):c).then(c=>o.walkTokens?Promise.all(this.walkTokens(c,o.walkTokens)).then(()=>c):c).then(c=>a(c,o)).then(c=>o.hooks?o.hooks.postprocess(c):c).catch(s);try{o.hooks&&(n=o.hooks.preprocess(n));let c=l(n,o);o.hooks&&(c=o.hooks.processAllTokens(c)),o.walkTokens&&this.walkTokens(c,o.walkTokens);let u=a(c,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(c){return s(c)}}}onError(t,e){return n=>{if(n.message+=`
264
+ Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An error occurred:</p><pre>"+mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Bn=new UC;function oe(t,e){return Bn.parse(t,e)}oe.options=oe.setOptions=function(t){return Bn.setOptions(t),oe.defaults=Bn.defaults,Im(oe.defaults),oe};oe.getDefaults=ac;oe.defaults=Fn;oe.use=function(...t){return Bn.use(...t),oe.defaults=Bn.defaults,Im(oe.defaults),oe};oe.walkTokens=function(t,e){return Bn.walkTokens(t,e)};oe.parseInline=Bn.parseInline;oe.Parser=Bt;oe.parser=Bt.parse;oe.Renderer=Qo;oe.TextRenderer=gc;oe.Lexer=$t;oe.lexer=$t.lex;oe.Tokenizer=Zo;oe.Hooks=io;oe.parse=oe;oe.options;oe.setOptions;oe.use;oe.walkTokens;oe.parseInline;Bt.parse;$t.lex;function Ie(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Se(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hr(t){const e=String(t??"").trim();if(!e)return"";const n=e.match(/^\[([^\]]*)\]\(([^)\s]+)\)\s*$/);return n?String(n[2]||"").trim():e}function Vm(t,e="100"){let n=String(t==null||t===""?e:t).trim();return n||(n=e),n=n.replace(/%$/,""),`max-width:${Ie(n)}%;`}function qC(t){const e={};let n=String(t||"");return n=n.replace(/([\w-]+)\s*=\s*(?:"([\s\S]*?)"|'([\s\S]*?)')/g,(r,i,o,s)=>(e[i]=o??s,"")),n.replace(/([\w-]+)\s*=\s*([^\s%]+)/g,(r,i,o)=>(i in e||(e[i]=o),"")),e}function WC(t){const e=hr(t.src);if(!e)return"";const n=Vm(t.width),r=t.caption||"";return[`<figure class="my-8 mx-auto text-center w-full" style="display:block;${n}">`,`<img class="figure-lightbox-trigger" src="${Ie(e)}" alt="${Ie(t.alt||r)}" loading="lazy">`,r?`<figcaption class="mt-3">${Se(r)}</figcaption>`:"","</figure>"].join("")}function KC(t){const e=hr(t.src);if(!e)return"";const n=t.side==="right"?" article-cut-in--right":"";return`<figure class="article-cut-in-plate${n}"><img class="article-cut-in${n}" src="${Ie(e)}" alt="${Ie(t.alt||"")}" width="120" loading="lazy"></figure>`}function Um(t){const e=hr(t);if(!e)return"";const n=e.split(/[?#]/)[0],r=n.split(/[/\\]/).filter(Boolean);return r[r.length-1]||n}function xa(t){const e=hr(t);if(!e)return"";const n=e.match(/(?:youtube\.com\/(?:embed\/|shorts\/|watch\?v=)|youtu\.be\/)([A-Za-z0-9_-]{6,})/);return n?n[1]:(/^[A-Za-z0-9_-]{6,}$/.test(e),e)}function nr(t,{width:e,height:n,aspect:r,caption:i}={}){const o=String(t||"").trim()||"Embed",s=[Vm(e)];n?s.push(`min-height:${Ie(String(n))}px`):r?s.push(`aspect-ratio:${Ie(r)}`):s.push("min-height:12rem");const l=[`<figure class="studio-embed-placeholder" style="display:block;margin:1.5rem auto;text-align:center;${s.join("")}">`,`<div class="studio-embed-placeholder__box" role="img" aria-label="${Ie(o)}">`,`<code class="studio-embed-placeholder__label">${Se(o)}</code>`,"</div>"];return i&&l.push(`<figcaption>${Se(i)}</figcaption>`),l.push("</figure>"),l.join("")}function YC(t){const e=xa(t.id||t.src);return e?nr(`YouTube video: ${e}`,{width:t.width,aspect:"16 / 9",caption:t.caption}):""}function JC(t){const e=xa(t.src||t.id);if(!e)return"";const n=xa(t.src2||t.id2);return n?[nr(`YouTube short: ${e}`,{width:"45",aspect:"9 / 16"}),nr(`YouTube short: ${n}`,{width:"45",aspect:"9 / 16"})].join(""):nr(`YouTube short: ${e}`,{width:t.width||"45",aspect:"9 / 16"})}function GC(t){const e=hr(t.src);if(!e)return"";const n=Um(e)||e;return nr(`Video: ${n}`,{width:t.width,aspect:"16 / 9",caption:t.caption})}function XC(t){const e=hr(t.src);if(!e)return"";const n=Um(e)||e;return nr(`Plotly: ${n}`,{width:t.width,height:t.height||"480",caption:t.caption})}function qm(t,{kind:e,key:n,variant:r,display:i}={}){const o=String(t||"").trim()||"?",s=["studio-ref-pill"];r&&s.push(`studio-ref-pill--${r}`),i&&s.push("studio-ref-pill--display");const l=[`class="${s.join(" ")}"`];return e&&(l.push(`data-cite-check="${Ie(e)}"`),l.push(`data-key="${Ie(String(n||"").trim())}"`)),r==="latex"&&l.push('title="LaTeX (MathJax not available in Studio preview)"'),`<span ${l.join(" ")}>${Se(o)}</span>`}function yc(t,e){const n=String(e||"").trim();return qm(n||"?",{kind:t,key:n})}function ZC(t){return yc("xcite",t.key)}function QC(t){return yc("cite",t.key)}function ev(t){return Se(String(t||"").trim()).replace(/\r\n|\r|\n/g,"<br>")}function tv(t){const e=String(t.lemma||"").trim();if(!e)return"";const n=String(t.locale||"").trim().toLowerCase(),r=String(t.meta||"").trim(),i=String(t.country||r||n).trim(),o=String(t.note||"").trim(),s=String(t.source||"").trim(),l=String(t.url||"").trim(),a=String(t.accessed||"").trim(),c=String(t.cite_extra||"").trim(),u=String(t.link_label||l).trim(),d=[`<article class="sov-card${n?` sov-card--${Ie(n)}`:""}" role="listitem">`,'<div class="sov-card__head">'];if(n&&d.push(`<span class="sov-card__flag" title="${Ie(i)}"><span class="fi fi-${Ie(n)}" role="img" aria-label="${Ie(i)}"></span></span>`),r&&d.push(`<span class="sov-card__meta">${Se(r)}</span>`),d.push("</div>"),d.push(`<p class="sov-card__lemma">${Se(e)}</p>`),t.def&&d.push(`<div class="sov-card__def">${ev(t.def)}</div>`),o&&d.push(`<p class="sov-card__note">${o}</p>`),s){let p=`${Se(s)}, s.v. &ldquo;${Se(e)},&rdquo;`;l&&(p+=` <a href="${Ie(l)}">${Se(u)}</a>`),a&&(p+=`, accessed ${Se(a)}`),p+=".",c&&(p+=` ${Se(c)}`),d.push(`<p class="sov-card__cite">${p}</p>`)}return d.push("</article>"),d.join("")}function nv(t){return String(t||"").replace(/(?:<article\b[^>]*\bsov-card\b[\s\S]*?<\/article>\s*){2,}/g,e=>/\bsov-grid\b/.test(e)?e:`<div class="sov-grid" role="list">${e.trim()}</div>
265
+ `)}function rv(t){const e=String(t.body||"").trim();if(!e)return"";const n=String(t.handle||"").trim().replace(/^@/,""),r=String(t.icon||"chat").trim()||"chat",i=String(t.url||"").trim(),o=String(t.date||"").trim(),s=String(t.note||"").trim(),l=String(t.name||"").trim(),a=i.replace(/^https?:\/\//,""),c=['<article class="sov-tweet article-tweet">','<div class="sov-tweet__head article-tweet__head">',`<span class="sov-tweet__avatar article-tweet__avatar" aria-hidden="true"><span class="material-symbols-outlined">${Se(r)}</span></span>`,'<span class="sov-tweet__id article-tweet__id">'];if(l&&c.push(`<span class="sov-tweet__name article-tweet__name">${Se(l)}</span>`),n&&c.push(`<span class="sov-tweet__handle article-tweet__handle">@${Se(n)}</span>`),c.push("</span></div>"),c.push(`<p class="sov-tweet__body article-tweet__body">${e}</p>`),i||o){let u="";i&&(u+=`<a href="${Ie(i)}">${Se(a)}</a>`),i&&o&&(u+=" | "),o&&(u+=Se(o)),c.push(`<p class="sov-tweet__cite article-tweet__cite">${u}</p>`)}return s&&c.push(`<p class="sov-tweet__note article-tweet__note">${s}</p>`),c.push("</article>"),c.join("")}function qd(t){const e=String(t||"").trim();if(!e)return'<div class="article-note"></div>';let n="";try{n=oe.parse(e,{gfm:!0,breaks:!1})}catch{n=`<p>${Se(e)}</p>`}return`<div class="article-note">${n}</div>`}function iv(t,e){return qm(String(t||"").trim(),{variant:"latex",display:!!e})}function Wd(t){return String(t||"").replace(/\\\s/g,"\\\\ ")}function ov(t){const e=[];let n=String(t||"");const r=(i,o)=>{const s=e.length;return e.push({display:i,math:o}),`MATH${s}`};return n=n.replace(/\$\$([\s\S]+?)\$\$/g,(i,o)=>r(!0,Wd(o))),n=n.replace(/\\\[([\s\S]+?)\\\]/g,(i,o)=>r(!0,Wd(o))),n=n.replace(/\\\(([\s\S]+?)\\\)/g,(i,o)=>r(!1,o)),n=n.replace(/(^|[^\\$])\$(?!\$)([^$\n]+?)\$(?!\$)/g,(i,o,s)=>o+r(!1,s)),{text:n,store:e}}function sv(t,e){return String(t||"").replace(/\uE000MATH(\d+)\uE001/g,(n,r)=>{const i=e[Number(r)];return i?iv(i.math,i.display):""})}const lv={"figure.html":WC,"cut-in.html":KC,"youtube.html":YC,"youtube-short.html":JC,"video.html":GC,"plotly.html":XC,"xcite.html":ZC,"cite.html":QC,"dict-card.html":tv,"tweet.html":rv};function av(t){let e=String(t||"");return e=e.replace(/\{%-?\s*include\s+article-note(?:\.html)?\b(?:(?!%\})[\s\S])*?-?%\}\s*([\s\S]*?)\s*\{%-?\s*endinclude\s*-?%\}/gi,(n,r)=>qd(r)),e=e.replace(/<div\s+([^>]*\barticle-note\b[^>]*)>([\s\S]*?)<\/div>/gi,(n,r,i)=>qd(i)),e=e.replace(/\{%-?\s*cite\s+([^\s%]+)[\s\S]*?-?%\}/g,(n,r)=>yc("cite",r)),e=e.replace(/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g,(n,r,i)=>{const o=lv[r];return o?o(qC(i)):`<div class="studio-unknown-include" data-include="${Ie(r)}"></div>`}),e}function cv(t){const e=ov(String(t||"")),n=av(e.text);let r;try{r=oe.parse(n,{gfm:!0,breaks:!1})}catch{r=`<p>${Se(n)}</p>`}return nv(sv(r,e.store))}function kn(t,e,n=1){return String(t||"").localeCompare(String(e||""),void 0,{sensitivity:"base",numeric:!0})*n}function Kd(t,e,n=1){const r=String(t||""),i=String(e||"");return!r&&!i?0:r?i?r.localeCompare(i)*n:-1:1}const es=[{id:"date-desc",label:"Date | newest first",compare:(t,e)=>Kd(t.date,e.date,-1)||kn(t.title||t.name,e.title||e.name)},{id:"date-asc",label:"Date | oldest first",compare:(t,e)=>Kd(t.date,e.date,1)||kn(t.title||t.name,e.title||e.name)},{id:"title-asc",label:"Title | A–Z",compare:(t,e)=>kn(t.title||t.name,e.title||e.name,1)},{id:"title-desc",label:"Title | Z–A",compare:(t,e)=>kn(t.title||t.name,e.title||e.name,-1)},{id:"path-asc",label:"Path | A–Z",compare:(t,e)=>kn(t.path||t.name,e.path||e.name,1)},{id:"path-desc",label:"Path | Z–A",compare:(t,e)=>kn(t.path||t.name,e.path||e.name,-1)},{id:"key-asc",label:"Key | A–Z",compare:(t,e)=>kn(t.key||t.name,e.key||e.name,1)}],ts="date-desc",ns=[{id:"10",label:"10",size:10},{id:"20",label:"20",size:20},{id:"30",label:"30",size:30},{id:"all",label:"ALL",size:null}],rs="10",Wm="studio-list-sort:",Km="studio-list-page-size:";function uv(t){return es.find(e=>e.id===t)||es[0]}function dv(t){return ns.find(e=>e.id===t)||ns[0]}function Ym(t){const e=t==null?void 0:t.tags;return Array.isArray(e)?e.map(n=>String(n??"").trim()).filter(Boolean):typeof e=="string"&&e.trim()?[e.trim()]:[]}function fv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>[r.title,r.name,r.key,r.path,r.date,Ym(r).join(" ")].filter(Boolean).join(`
266
+ `).toLowerCase().includes(n)):t.slice()}function pv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>Ym(r).some(i=>i.toLowerCase()===n)):t.slice()}function hv(t,{query:e="",sortId:n=ts,tag:r=""}={}){const i=pv(fv(t,e),r),o=uv(n);return i.sort((s,l)=>o.compare(s,l))}function mv(t,{pageSizeId:e=rs,page:n=1}={}){const r=dv(e),i=t.length,o=r.size;if(o==null||o<=0)return{items:t.slice(),page:1,pageCount:1,pageSize:null,total:i,from:i?1:0,to:i};const s=Math.max(1,Math.ceil(i/o)),l=Math.min(Math.max(1,Number(n)||1),s),a=(l-1)*o,c=t.slice(a,a+o);return{items:c,page:l,pageCount:s,pageSize:o,total:i,from:i?a+1:0,to:a+c.length}}function gv(t,e=ts){try{const n=localStorage.getItem(Wm+t);if(n&&es.some(r=>r.id===n))return n}catch{}return e}function yv(t,e){try{localStorage.setItem(Wm+t,e)}catch{}}function bv(t,e=rs){try{const n=localStorage.getItem(Km+t);if(n&&ns.some(r=>r.id===n))return n}catch{}return e}function kv(t,e){try{localStorage.setItem(Km+t,e)}catch{}}const Yd={posts:["date"],articles:["date"],resources:["category","type","language"],bibliography:["key"],products:["company","start_date","end_date"],projects:["status","start_date","end_date"],jobs:["company","engagement","start","end"]},xv=new Set(["name","filename"]);function Sv(t){const e=String(t||"").split("/").filter(Boolean);return e.length?e[e.length-1]:""}function wv(t,e){if(t==="path")return String(e.path||"").split("/").filter(Boolean).join(" | ")||"";const n=e==null?void 0:e[t];return n==null?"":Array.isArray(n)?n.map(r=>String(r??"").trim()).filter(Boolean).join(", "):String(n).trim()}function Cv(t){if(Array.isArray(t==null?void 0:t.listMetaFields)&&t.listMetaFields.length)return t.listMetaFields.map(String);const e=t==null?void 0:t.name;return e&&Yd[e]?Yd[e].slice():[]}function vv(t,e){const n=Array.isArray(e)?e.map(String):Cv(e),r=[];for(const o of n){if(xv.has(o))continue;const s=wv(o,t);s&&r.push(s)}const i=String((t==null?void 0:t.name)||"").trim()||Sv(t==null?void 0:t.path);return i&&r[r.length-1]!==i&&r.push(i),r.join(" | ")}const Mv={lineWidth:100,noRefs:!0,sortKeys:!1};function mr(t){return!t||t.format!=="yaml"?null:t.list?"list":t.root_key||(t.fields||[]).length?"map":"source"}function St(t){const e=un.dump(t??null,Mv);return e.endsWith(`
267
+ `)?e:e+`
268
+ `}function Zr(t){try{return un.load(t)}catch(e){const n=new Error((e==null?void 0:e.message)||"Invalid YAML");throw n.cause=e,n}}function bc(t){const e={};for(const n of t||[])!(n!=null&&n.name)||n.hidden||(Object.prototype.hasOwnProperty.call(n,"default")?e[n.name]=Tv(n.default):n.list?e[n.name]=[]:n.type==="boolean"?e[n.name]=!1:e[n.name]="");return e}function Tv(t){if(t==null||typeof t!="object")return t;try{return structuredClone(t)}catch{return JSON.parse(JSON.stringify(t))}}function _n(t,e){if(!t||typeof t!="object"||Array.isArray(t))return t;const n=new Set((e||[]).map(i=>i.name).filter(Boolean)),r={...t};for(const i of Object.keys(r)){if(!n.has(i))continue;const o=r[i];(o===""||o==null||Array.isArray(o)&&o.length===0)&&delete r[i]}return r}function Jm(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}):[]}function rr(t){return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}const xt="content/media",Jd=25*1024*1024,Av=/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i,Ev=/\.(mp4|webm|mov|m4v)$/i,Nv=/\.html?$/i,Gm=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Ov(t){var n;const e=String(((n=t==null?void 0:t.media)==null?void 0:n.input)||xt).replace(/\/+$/,"");return e===xt||e.startsWith(`${xt}/`),xt}function Ms(t){const e=String(t||"");return e.startsWith("content/media")?e.replace(/^content/,"")||"/media":""}function Xm(t){return Av.test(String(t||""))}function Zm(t){return Ev.test(String(t||""))}function Qm(t){return Nv.test(String(t||""))}function eg(t){return Xm(t)?"image":Zm(t)?"video":Qm(t)?"html":null}function tg(t){const e=Number(t)||0;return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Lv(t){const e=String(t||"").split(/[/\\]/).pop().trim();if(!e)return null;const n=e.replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"");return Gm.test(n)?n:null}function Iv(t){const e=String(t||"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"");return!Gm.test(e)||e===".gitkeep"?null:e}function Rv(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{const i=String(r.result||""),o=i.indexOf(",");e(o>=0?i.slice(o+1):i)},r.onerror=()=>n(r.error||new Error("read_failed")),r.readAsDataURL(t)})}function Dv(t,e=xt){const r=String(t).split("/").filter(Boolean),i=e.split("/").filter(Boolean),o=[];let s="";for(let l=0;l<r.length;l++){s=s?`${s}/${r[l]}`:r[l];const a=l===i.length-1&&s===e;!(l>=i.length-1)&&!a||o.push({label:a||s===e?"media":r[l],path:s})}return o.length||o.push({label:"media",path:e}),o}function Pv(t){const{api:e,state:n,el:r,materialIcon:i,resolveMediaUrl:o,render:s,captureError:l,clearError:a,goHome:c}=t,u=n.mediaPath||xt,d=n.mediaItems||[],p=Dv(u),h=r("nav",{className:"media-breadcrumb","aria-label":"Media path"});p.forEach((w,T)=>{T>0&&h.append(r("span",{className:"media-breadcrumb-sep",text:"/"})),T===p.length-1?h.append(r("span",{className:"media-breadcrumb-current",text:w.label})):h.append(r("button",{className:"media-breadcrumb-link",type:"button",text:w.label,onClick:()=>void gr(w.path,t)}))});const g=r("input",{type:"file",className:"media-file-input",multiple:"multiple",accept:"image/*,video/*,.html,.svg,.pdf",hidden:!0,onChange:async w=>{const T=Array.from(w.target.files||[]);w.target.value="",T.length&&await jv(T,t)}}),b=r("div",{className:"media-toolbar"},[r("button",{className:"btn btn-nav",type:"button",title:"Back to Studio map",onClick:()=>c()},[i("chevron_left","btn-nav-icon"),r("span",{text:"Studio map"})]),r("span",{className:"spacer"}),r("button",{className:"btn",type:"button",text:"New folder",disabled:!!n.mediaBusy,onClick:()=>void Hv(t)}),r("button",{className:"btn btn-primary",type:"button",text:n.mediaBusy?"Working…":"Upload",disabled:!!n.mediaBusy,onClick:()=>g.click()}),g]);let x;if(n.mediaLoading)x=r("p",{className:"loading-msg",text:"Loading media…"});else if(!d.length)x=r("p",{className:"empty-msg",text:"This folder is empty. Upload a file or create a subfolder."});else{const w=d.map(T=>$v(T,t));x=r("div",{className:"media-grid"},w)}return r("div",{className:"pane media-pane"},[r("header",{className:"media-header"},[r("h1",{className:"media-title",text:"Media"}),h]),b,x])}function $v(t,e){const{el:n,materialIcon:r,resolveMediaUrl:i,state:o}=e,s=t.type==="dir",l=s?null:eg(t.name),a=t.public_path||(s?null:Ms(t.path)),c=!s&&Xm(t.name)&&a?i(a):"";let u;if(s)u=n("span",{className:"media-thumb media-thumb--folder"},[r("folder","media-thumb-icon")]);else if(c){const b=n("img",{className:"media-thumb-img",src:c,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});b.addEventListener("error",()=>{b.replaceWith(n("span",{className:"media-thumb media-thumb--file"},[r("image","media-thumb-icon")]))}),u=n("span",{className:"media-thumb media-thumb--image"},[b])}else Zm(t.name)?u=n("span",{className:"media-thumb media-thumb--file"},[r("movie","media-thumb-icon")]):Qm(t.name)?u=n("span",{className:"media-thumb media-thumb--file"},[r("html","media-thumb-icon")]):u=n("span",{className:"media-thumb media-thumb--file"},[r("draft","media-thumb-icon")]);const d=[];!s&&t.size&&d.push(tg(t.size)),a&&d.push(a);const p=s?()=>void gr(t.path,e):l?b=>zv(t,b.currentTarget,e):()=>void ig(a,e),h=s?`Open ${t.name}`:l?`Preview ${t.name}`:`Copy ${a}`,g=!s&&a?Bv(t,a,e):null;return n("div",{className:"media-row"+(s?" media-row--dir":"")+(l?" media-row--preview":""),role:"button",tabindex:o.mediaBusy?"-1":"0",title:h,"aria-disabled":o.mediaBusy?"true":"false",onClick:b=>{o.mediaBusy||b.target.closest(".media-ops")||p(b)},onKeydown:b=>{o.mediaBusy||(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),p(b))}},[u,n("span",{className:"media-row-body"},[n("span",{className:"media-row-name",text:t.name}),n("span",{className:"media-row-meta",text:d.join(" · ")||(s?"Folder":"")})]),g].filter(Boolean))}function Bv(t,e,n){const{el:r,materialIcon:i,state:o}=n,s=!!o.mediaBusy,l=r("button",{className:"btn btn-icon media-op-btn media-copy-btn",type:"button",title:`Copy ${e}`,"aria-label":`Copy path ${e}`,disabled:s,onClick:c=>{c.stopPropagation(),ig(e,n)}},[i("content_copy")]),a=r("button",{className:"btn btn-icon media-op-btn media-delete-btn",type:"button",title:`Delete ${t.name}`,"aria-label":`Delete ${t.name}`,disabled:s,onClick:c=>{c.stopPropagation(),Fv(t,n)}},[i("delete")]);return r("div",{className:"media-ops",role:"group","aria-label":"Operations"},[l,a])}let kt=null,Sa=null;function _v(t,e){if(kt)return kt;const n=t("img",{className:"figure-lightbox-img",alt:""}),r=t("video",{className:"figure-lightbox-video",controls:!0,playsinline:!0}),i=t("iframe",{className:"figure-lightbox-frame",title:"Media preview"}),o=t("p",{className:"figure-lightbox-caption"});n.hidden=!0,r.hidden=!0,i.hidden=!0,o.hidden=!0,r.controls=!0;const s=t("button",{type:"button",className:"figure-lightbox-close","data-lightbox-close":"true","aria-label":"Close",onClick:a=>{a.preventDefault(),Ol()}},[e("close")]),l=t("div",{id:"figure-lightbox",className:"figure-lightbox",role:"dialog","aria-modal":"true","aria-label":"Media preview","aria-hidden":"true"},[t("div",{className:"figure-lightbox-backdrop","data-lightbox-close":"true",tabindex:"-1",onClick:()=>Ol()}),t("div",{className:"figure-lightbox-panel"},[s,n,r,i,o])]);return l.hidden=!0,document.body.append(l),document.addEventListener("keydown",a=>{!kt||kt.root.hidden||a.key==="Escape"&&(a.preventDefault(),Ol())}),kt={root:l,img:n,video:r,frame:i,caption:o,closeBtn:s},kt}function ng(t){t.img.removeAttribute("src"),t.img.alt="",t.img.hidden=!0,t.video.pause(),t.video.removeAttribute("src"),t.video.load(),t.video.hidden=!0,t.frame.removeAttribute("src"),t.frame.hidden=!0,t.caption.textContent="",t.caption.hidden=!0}function rg(t,e){t.root.hidden=!e,t.root.setAttribute("aria-hidden",String(!e)),document.documentElement.classList.toggle("figure-lightbox-open",e),document.body.classList.toggle("figure-lightbox-open",e)}function Ol(){if(!kt||kt.root.hidden)return;ng(kt),rg(kt,!1);const t=Sa;if(Sa=null,t&&typeof t.focus=="function")try{t.focus()}catch{}}function zv(t,e,n){const{el:r,materialIcon:i,resolveMediaUrl:o}=n,s=eg(t.name),l=t.public_path||Ms(t.path),a=l?o(l):"";if(!s||!a)return;const c=_v(r,i);Sa=e||null,ng(c),s==="image"?(c.img.hidden=!1,c.img.referrerPolicy="no-referrer",c.img.alt=t.name||"",c.img.src=a):s==="video"?(c.video.hidden=!1,c.video.referrerPolicy="no-referrer",c.video.src=a):(c.frame.hidden=!1,c.frame.title=t.name||"HTML preview",c.frame.src=a),c.caption.textContent=t.name||"",c.caption.hidden=!t.name,rg(c,!0),c.closeBtn.focus()}async function ig(t,e){const{state:n,render:r,captureError:i,clearError:o}=e;if(t){o();try{await navigator.clipboard.writeText(t),n.status=`Copied ${t}`}catch(s){i(s),n.status=t}r()}}async function Fv(t,e){const{api:n,state:r,render:i,captureError:o,clearError:s}=e,l=t==null?void 0:t.path;if(!l||t.type==="dir")return;const a=t.name||String(l).split("/").pop()||l;if(window.confirm(`Delete ${a}?
269
+
270
+ This commits a deletion to main and cannot be undone from Studio.`)){s(),r.mediaBusy=!0,r.status=`Deleting ${l}…`,i();try{let c=t.sha||null;c||(c=(await n.getFile(l)).sha),await n.deleteFile({path:l,sha:c,message:`studio: delete ${l}`}),r.mediaBusy=!1,r.status=`Deleted ${l}`,await gr(r.mediaPath,e)}catch(c){r.mediaBusy=!1,o(c),i()}}}async function gr(t,e){const{api:n,state:r,render:i,captureError:o,clearError:s}=e;s(),r.mediaPath=t||xt,r.mediaLoading=!0,r.mediaBusy=!1,r.status=`Loading ${r.mediaPath}…`,i();try{const l=await n.listMedia(r.mediaPath);r.mediaItems=l.items||[],r.mediaPath=l.path||r.mediaPath,r.mediaLoading=!1;const a=r.mediaItems.filter(u=>u.type==="dir").length,c=r.mediaItems.filter(u=>u.type==="file").length;r.status=`${a} folders · ${c} files`}catch(l){r.mediaItems=[],r.mediaLoading=!1,o(l)}i()}async function Hv(t){const{api:e,state:n,render:r,captureError:i,clearError:o}=t,s=window.prompt("New folder name (letters, numbers, .-_)");if(s==null)return;const l=Iv(s);if(!l){n.error="Invalid folder name",n.status="",r();return}const a=`${n.mediaPath||xt}/${l}`;o(),n.mediaBusy=!0,n.status=`Creating ${l}…`,r();try{await e.createMediaFolder({path:a,message:`studio: mkdir ${a}`}),n.mediaBusy=!1,n.status=`Created ${Ms(a)||a}`,await gr(n.mediaPath,t)}catch(c){n.mediaBusy=!1,i(c),r()}}async function jv(t,e){const{api:n,state:r,render:i,captureError:o,clearError:s}=e;s();const l=r.mediaPath||xt;let a=0;r.mediaBusy=!0;for(const c of t){const u=Lv(c.name);if(!u){r.error=`Skipped invalid name: ${c.name}`;continue}if(c.size>Jd){r.error=`${u} exceeds ${tg(Jd)} (GitHub Contents API soft limit in Studio)`;continue}r.status=`Uploading ${u}…`,i();try{const d=await Rv(c),p=`${l}/${u}`,h=await n.uploadMedia({path:p,content_base64:d,message:`studio: upload ${p}`});a+=1,r.status=`Uploaded ${h.public_path||Ms(p)}`}catch(d){o(d),r.mediaBusy=!1,i();return}}r.mediaBusy=!1,a&&(r.status=a===1?r.status:`Uploaded ${a} files`),await gr(l,e)}const Vv="pk_test_c291bmQtc3F1aXJyZWwtNDgzMC5jbGVyay5hY2NvdW50cy5kZXYk",Zt="/studio/",Gd="",og={forceRedirectUrl:Zt,fallbackRedirectUrl:Zt,signInForceRedirectUrl:Zt,signInFallbackRedirectUrl:Zt,signUpForceRedirectUrl:Zt,signUpFallbackRedirectUrl:Zt};function Uv(t){const e=String(t).replace(/^pk_(test|live)_/,"");if(!e)return"";try{const n="=".repeat((4-e.length%4)%4),r=(e+n).replace(/-/g,"+").replace(/_/g,"/");return atob(r).replace(/\$$/,"").trim()}catch{return""}}function Xd(t,e={}){return new Promise((n,r)=>{const i=document.querySelector(`script[src="${t}"]`);if(i){if(i.dataset.loaded==="1")return n();i.addEventListener("load",()=>n(),{once:!0}),i.addEventListener("error",()=>r(new Error(`Failed to load ${t}`)),{once:!0});return}const o=document.createElement("script");o.src=t,o.async=!0,o.defer=!0,o.crossOrigin="anonymous";for(const[s,l]of Object.entries(e))if(s==="dataset"&&l&&typeof l=="object")for(const[a,c]of Object.entries(l))o.dataset[a]=c;else l!=null&&o.setAttribute(s,l);o.onload=()=>{o.dataset.loaded="1",n()},o.onerror=()=>r(new Error(`Failed to load ${t}`)),document.head.appendChild(o)})}async function qv(t){if(window.Clerk&&typeof window.Clerk.load=="function"&&window.__internal_ClerkUICtor)return window.Clerk;const e="".replace(/^https?:\/\//,"").replace(/\/$/,"")||Uv(t);if(!e)throw new Error("Cannot resolve Clerk Frontend API host from publishable key");const n=`https://${e}/npm`;await Xd(`${n}/@clerk/ui@1/dist/ui.browser.js`),await Xd(`${n}/@clerk/clerk-js@6/dist/clerk.browser.js`,{dataset:{clerkPublishableKey:t}});for(let r=0;r<80;r++){if(window.Clerk&&typeof window.Clerk.load=="function"&&window.__internal_ClerkUICtor)return window.Clerk;await new Promise(o=>setTimeout(o,25))}throw new Error("Clerk / ClerkUI global missing after script load")}async function Wv(){const t=await qv(Vv);return await t.load({clerkUICtor:window.__internal_ClerkUICtor,...og}),zg(async()=>t.session?t.session.getToken():null),t}const lt=document.getElementById("app"),m={schema:null,session:null,collection:null,items:[],file:null,sha:null,fields:{},body:"",yamlDoc:null,yamlList:null,yamlUiMode:"structured",bodyMode:"visual",lastEditorMode:"visual",baseline:null,dirty:!1,saving:!1,status:"",error:"",errorCode:"",errorDetail:"",listLoading:!1,fileLoading:!1,previewHtml:"",bodyEditor:null,insertMenuOpen:!1,aiProofHint:"",aiProofBusy:!1,aiProofSelection:null,navOpenGroups:new Set,navMenuOpen:!1,themeMenuOpen:!1,listQueryByCollection:Object.create(null),listSortByCollection:Object.create(null),listPageSizeByCollection:Object.create(null),listPageByCollection:Object.create(null),navCountByCollection:Object.create(null),treeCacheByCollection:Object.create(null),treePrefetchGen:0,frontMatterOpen:null,mediaOpen:!1,mediaPath:"content/media",mediaItems:[],mediaLoading:!1,mediaBusy:!1},Kv={figure:"image",cutIn:"transition_push",youtube:"smart_display",youtubeShort:"mobile_screen_share",video:"videocam",plotly:"analytics",xcite:"format_quote",cite:"bookmark",articleNote:"sticky_note_2",poem:"history_edu"},wa={Writing:"edit_note",References:"menu_book",Portfolio:"work",Media:"photo_library",Pages:"description","CV Summary":"badge",Presentation:"campaign",Profile:"person"},Yv=[{label:"Default",value:""},{label:"Primary",value:"var(--primary)"},{label:"Secondary",value:"var(--secondary)"},{label:"Tertiary",value:"var(--tertiary)"},{label:"Muted",value:"var(--on-surface-variant)"},{label:"Error",value:"var(--error)"}],Jv={Writing:"Articles and Portuguese rascunhos",References:"Source cards and bibliography entries",Portfolio:"Products, projects, and CV jobs",Media:"Upload and browse content/media — cite /media/… in includes",Pages:"Listing page headers and furniture copy","CV Summary":"Public and PDF CV summary variants",Presentation:"Home catch phrase and CV side notes",Profile:"Contacts, education, languages, and skills"};function Ti(t){return String(t||"").split("/").filter(Boolean).join(" | ")}function sg(t){return Jv[t]||`Browse ${t} collections`}function kc(t){return"nav-group-"+String(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function lg(t){var i;const e=!m.navOpenGroups.has(t);e?m.navOpenGroups.add(t):m.navOpenGroups.delete(t);const n=document.getElementById(kc(t));if(!n)return;n.hidden=!e;const r=(i=n.closest(".studio-nav-group"))==null?void 0:i.querySelector(".studio-nav-group-toggle");if(r){r.setAttribute("aria-expanded",e?"true":"false");const o=r.querySelector(".material-symbols-outlined");o&&(o.textContent=e?"expand_more":"chevron_right")}}function ag(t){const e=cg(t.description);if(e)return e;const n=Ti(t.path)||t.name;return t.type==="file"?`Open ${t.label} | ${n}`:`List entries in ${t.label} | ${n}`}function cg(t){let e=String(t||"").trim();if(!e)return"";const n=[/\s*The filename uses Key as YYYY-MM-DD-key[^.]*\./gi,/\s*Also the filename stem:[^.]*\./gi,/\s*Also the filename:[^.]*\./gi,/\s*Must match the YYYY-MM-DD in the filename[^.]*\./gi,/\s*;?\s*must match the YYYY-MM-DD in the filename\./gi,/\s*The Updated date is read from Git, never set here\./gi,/\s*ASCII kebab-case\./gi,/\s*\(44 characters total for the key segment is a good ceiling\)\.?/gi,/Metadata-first forms[^.]*\./gi,/TipTap with Liquid blocks[^.]*\./gi,/preview via content-runtime contract\.?/gi,/Paste Liquid \{%\s*include\s*%\} markers[^.]*\./gi,/Do not use rich-text:[^.]*\./gi,/its Editor mode rewrites URLs inside includes\.?/gi,/Markdown source \(code editor\)\.?/gi];for(const r of n)e=e.replace(r,"");return e=e.replace(/\s{2,}/g," ").replace(/\s+\./g,".").trim(),/filename|YYYY-MM-DD-key|content-runtime|autolink|TipTap/i.test(e)?"":e}function Zd(t){return cg(t==null?void 0:t.description)}function Ct(t){var i,o;const e=String((t==null?void 0:t.message)||t||"Request failed"),n=[];t!=null&&t.status&&n.push(`HTTP ${t.status}`);const r=(i=t==null?void 0:t.data)==null?void 0:i.detail;if(r)n.push(String(r));else if(t!=null&&t.data&&typeof t.data=="object")try{n.push(JSON.stringify(t.data,null,2))}catch{}else t!=null&&t.stack&&!String(t.stack).includes(e)&&n.push(String(t.stack).split(`
271
+ `).slice(0,6).join(`
272
+ `));m.error=e,m.errorCode=String((t==null?void 0:t.code)||((o=t==null?void 0:t.data)==null?void 0:o.error)||""),m.errorDetail=n.join(`
273
+ `).trim(),m.status=""}function at(){m.error="",m.errorCode="",m.errorDetail=""}function Ll(){var t;return m.mediaOpen?"Media":(t=m.collection)!=null&&t.label?m.collection.label:"Home"}function xc(){m.navMenuOpen=!1}function Sc(){var t,e;vt(),m.collection=null,m.file=null,m.baseline=null,m.items=[],m.yamlDoc=null,m.yamlList=null,m.listLoading=!1,m.fileLoading=!1,m.dirty=!1,m.insertMenuOpen=!1,m.mediaOpen=!1,m.mediaItems=[],m.mediaLoading=!1,m.mediaBusy=!1,xc(),at(),m.status=((t=m.session)==null?void 0:t.email)||((e=m.session)==null?void 0:e.userId)||"",Q(),hg()}function ug(){return{api:Je,state:m,el:k,materialIcon:_e,resolveMediaUrl:mg,render:()=>Q(),captureError:Ct,clearError:at,goHome:Sc}}async function dg(t){vt(),m.collection=null,m.file=null,m.baseline=null,m.items=[],m.insertMenuOpen=!1,m.dirty=!1,m.mediaOpen=!0,m.navOpenGroups.add("Media"),xc();const e=Ov(m.schema);await gr(e,ug())}function _e(t,e=""){return k("span",{className:"material-symbols-outlined"+(e?` ${e}`:""),text:t,"aria-hidden":"true"})}function Ts({size:t=40,label:e=""}={}){return k("span",{className:"studio-mark",...e?{role:"img","aria-label":e}:{"aria-hidden":"true"},html:`<svg class="studio-mark-svg" viewBox="0 0 32 32" width="${t}" height="${t}" focusable="false"><polygon class="studio-mark-primary" points="16,1 24,5 13,14 2,17 2,9"/><polygon class="studio-mark-secondary" points="24,5 30,9 30,23 22,28 19,18 13,14"/><polygon class="studio-mark-tertiary" points="2,17 13,14 19,18 22,28 16,31 2,23"/><polygon class="studio-mark-frame" points="16,1 30,9 30,23 16,31 2,23 2,9"/></svg>`})}function Qd(t){const e=t.title||t.name||"Entry",n=Ti(t.path);return n?`Open ${e} | ${n}`:`Open ${e}`}function Gv(){var e;const t=(e=m.collection)==null?void 0:e.name;return t&&m.listQueryByCollection[t]||""}function Xv(){var n;const t=(n=m.collection)==null?void 0:n.name;if(!t)return ts;if(m.listSortByCollection[t])return m.listSortByCollection[t];const e=gv(t,ts);return m.listSortByCollection[t]=e,e}function Zv(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listSortByCollection[e]=t,yv(e,t),wc())}function Qv(){var n;const t=(n=m.collection)==null?void 0:n.name;if(!t)return rs;if(m.listPageSizeByCollection[t])return m.listPageSizeByCollection[t];const e=bv(t,rs);return m.listPageSizeByCollection[t]=e,e}function eM(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listPageSizeByCollection[e]=t,kv(e,t),wc())}function ef(){var e;const t=(e=m.collection)==null?void 0:e.name;return t?Math.max(1,Number(m.listPageByCollection[t])||1):1}function Il(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listPageByCollection[e]=Math.max(1,Number(t)||1))}function wc(){var e;const t=(e=m.collection)==null?void 0:e.name;t&&(m.listPageByCollection[t]=1)}function fg(t,e){t!=null&&t.name&&(m.navCountByCollection[t.name]=Math.max(0,Number(e)||0))}function pg(t,e){if(!(t!=null&&t.name))return;const n=Array.isArray(e)?e:[];m.treeCacheByCollection[t.name]={items:n},fg(t,n.length)}function tM(t){if(!(t!=null&&t.name))return null;const e=m.treeCacheByCollection[t.name];return e?e.items:null}function Cc(t){if(!t){m.treeCacheByCollection=Object.create(null);return}delete m.treeCacheByCollection[t]}function nM(t=m.schema){return((t==null?void 0:t.collections)||[]).filter(e=>e&&e.type!=="file"&&e.path)}function rM(t){return[...t].sort((e,n)=>{const r=e.group==="Writing"?0:1,i=n.group==="Writing"?0:1;return r!==i?r-i:String(e.label||e.name).localeCompare(String(n.label||n.name))})}function hg(){const t=++m.treePrefetchGen,e=()=>{iM(t)};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:2500}):setTimeout(e,400)}async function iM(t){const e=rM(nM()).filter(n=>!m.treeCacheByCollection[n.name]);for(const n of e){if(t!==m.treePrefetchGen)return;try{const r=await Je.tree(n.path);if(t!==m.treePrefetchGen)return;m.treeCacheByCollection[n.name]||(pg(n,r.items||[]),m.file||Q())}catch{}await new Promise(r=>setTimeout(r,60))}}function mg(t){const e=String(t||"").trim();return e?/^https?:\/\//i.test(e)?e:e.startsWith("/media/")?`${Gd.replace(/\/$/,"")}${e}`:e.startsWith("media/")?`${Gd.replace(/\/$/,"")}/${e}`:(e.startsWith("/"),e):""}function tf(){return k("span",{className:"ledger-thumb placeholder",title:"No thumbnail","aria-label":"No thumbnail"},[k("span",{className:"material-symbols-outlined",text:"web_asset_off","aria-hidden":"true"})])}function nf(t){const e=mg(t.thumbnail);if(!e)return tf();const n=k("img",{className:"ledger-thumb",src:e,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});return n.addEventListener("error",()=>{n.replaceWith(tf())}),n}function ve(t,e=document){return e.querySelector(t)}function k(t,e={},n=[]){const r=document.createElement(t);for(const[i,o]of Object.entries(e))i==="className"?r.className=o:i==="text"?r.textContent=o:i==="html"?r.innerHTML=o:i==="htmlFor"?r.htmlFor=o:i.startsWith("on")&&typeof o=="function"?r.addEventListener(i.slice(2).toLowerCase(),o):i==="checked"||i==="selected"||i==="disabled"||i==="multiple"||i==="open"?r[i]=!!o:o===!1||o==null||(o===!0?r.setAttribute(i,""):r.setAttribute(i,o));for(const i of[].concat(n))i==null||i===!1||r.append(i.nodeType?i:document.createTextNode(String(i)));return r}const gg="studio-theme",is={light:"light_mode",dark:"dark_mode",system:"routine"};function fi(){const t=localStorage.getItem(gg);return t==="light"||t==="dark"||t==="system"?t:"system"}function oM(){const t=fi();return t==="dark"?"dark":t==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function sM(t){localStorage.setItem(gg,t),Ca(),pi()}function Ca(){document.documentElement.setAttribute("data-theme",oM())}function lM(){Ca();const t=window.matchMedia("(prefers-color-scheme: dark)");typeof t.addEventListener=="function"&&t.addEventListener("change",()=>{fi()==="system"&&Ca()})}function pi(){const t=fi(),e=document.querySelector("[data-studio-theme-icon]");e&&(e.textContent=is[t]||is.system);for(const i of document.querySelectorAll("[data-theme-choice]")){const s=i.getAttribute("data-theme-choice")===t;i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-selected",s)}const n=document.querySelector("[data-studio-action='theme-menu']"),r=document.getElementById("studio-theme-menu");n&&r&&(n.setAttribute("aria-expanded",m.themeMenuOpen?"true":"false"),r.hidden=!m.themeMenuOpen)}function aM(){const t=[{id:"light",label:"Light",icon:"light_mode"},{id:"dark",label:"Dark",icon:"dark_mode"},{id:"system",label:"System",icon:"routine"}],e=k("div",{className:"studio-theme-menu-panel",id:"studio-theme-menu",role:"menu","aria-label":"Choose color theme",hidden:!m.themeMenuOpen},t.map(r=>k("button",{className:"studio-theme-choice",type:"button",role:"menuitemradio","data-theme-choice":r.id,"aria-checked":fi()===r.id?"true":"false",onClick:i=>{i.stopPropagation(),sM(r.id),m.themeMenuOpen=!1,pi();const o=ve("#preview-frame");o&&wg(o)}},[_e(r.icon),k("span",{text:r.label})]))),n=k("button",{className:"btn btn-tool",type:"button",title:"Theme","aria-label":"Theme","data-studio-action":"theme-menu","aria-haspopup":"true","aria-expanded":m.themeMenuOpen?"true":"false","aria-controls":"studio-theme-menu",onClick:r=>{r.stopPropagation(),m.themeMenuOpen=!m.themeMenuOpen,pi()}},[k("span",{className:"material-symbols-outlined","data-studio-theme-icon":"true",text:is[fi()]||is.system,"aria-hidden":"true"}),k("span",{className:"btn-label",text:"Theme"})]);return k("div",{className:"studio-theme-menu"},[n,e])}function cM(){const t=String(window.location.hostname||"");return t==="localhost"||t==="127.0.0.1"||t==="[::1]"}function yg(t=m.collection){var e;return!t||t.type!=="collection"?!1:((e=t.operations)==null?void 0:e.create)!==!1}function vc(t=m.collection){var e;return t?((e=t.operations)==null?void 0:e.delete)===!0:!1}function uM(t){return String(t||"").trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function dM(t,e){const n=new Date,r=String(n.getFullYear()),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0");return String(t||"{key}.md").replaceAll("{year}",r).replaceAll("{month}",i).replaceAll("{day}",o).replaceAll("{key}",e)}function fM(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Xi({className:t,title:e,ariaLabel:n,action:r=null,disabled:i=!1,onClick:o,icon:s,label:l=null,spinning:a=!1}){const c=[k("span",{className:"material-symbols-outlined"+(a?" studio-icon-spin":""),text:s,"aria-hidden":"true"})];return l&&c.push(k("span",{className:"btn-label",text:l})),k("button",{className:t,type:"button",title:e,"aria-label":n,"data-studio-action":r,disabled:i,onClick:o},c)}function pM({brand:t=null,menuToggle:e=null}={}){const n=m.saving?"Saving…":m.dirty?"Save":"Saved",r=m.saving?"progress_activity":m.dirty?"save":"check",i=m.error?"Error":m.status||"",o=k("div",{className:"studio-toolbar-brand"},[t,i?k("span",{className:"status-pill studio-toolbar-status"+(m.error?" error":""),text:i,title:m.error||m.errorDetail||m.status||""}):null]),s=[aM(),Xi({className:"btn btn-tool",title:"Revert all edits to the last loaded or saved version",ariaLabel:"Discard edits",action:"discard",disabled:!m.file||!m.dirty||!m.baseline,onClick:()=>iT(),icon:"undo",label:"Revert"}),Xi({className:"btn btn-tool btn-primary",title:m.saving?"Saving this draft":m.dirty?"Commit this draft":"No edits to commit yet",ariaLabel:n,action:"save",disabled:m.saving||!m.file||!m.dirty,onClick:()=>aT(),icon:r,label:n,spinning:m.saving})];m.file&&vc()&&s.push(Xi({className:"btn btn-tool btn-danger",title:"Delete this entry from the repository",ariaLabel:"Delete entry",action:"delete",onClick:()=>lT(),icon:"delete",label:"Delete"})),cM()&&s.push(Xi({className:"btn btn-tool btn-reexport",title:"Export content JSON locally and reload",ariaLabel:"Export locally",action:"reexport",onClick:()=>oT(),icon:"sync",label:"Export"}));const l=[o,k("span",{className:"spacer","aria-hidden":"true"}),...s];return e&&l.push(e),k("header",{className:"studio-toolbar studio-icon-bar"},l)}function bg(t){var r,i;if(!t||t.dev||!t.user)return"";const e=(r=t.user.primaryEmailAddress)==null?void 0:r.emailAddress;return e||((i=(t.user.emailAddresses||[])[0])==null?void 0:i.emailAddress)||""}function hi(t){if(t&&!t.dev&&t.user){hM(t,m.error||"Studio API session failed while you are signed in.");return}lt.innerHTML="";const e=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Ts({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Sign in to edit"}),k("p",{text:"Studio is for site admins only. Anyone may register; access is granted after review."}),k("div",{id:"clerk-sign-in"})]);lt.append(e),t&&!t.dev?t.mountSignIn(ve("#clerk-sign-in"),{...og}):ve("#clerk-sign-in").append(k("p",{className:"status-pill",text:"No VITE_CLERK_PUBLISHABLE_KEY — using API bypass if enabled."}),k("button",{className:"btn btn-primary",text:"Continue",onClick:()=>so(t)}))}function hM(t,e){lt.innerHTML="";const n=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Ts({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Studio API unavailable"}),k("p",{className:"status-pill error",text:e}),k("p",{text:"You are signed in with Clerk, but /api/studio/session did not succeed. Local jekyll serve has no Pages Functions — use a Pages preview, wrangler pages dev, or STUDIO_DEV_BYPASS against a running Function."}),k("button",{className:"btn",type:"button",text:"Sign out",onClick:async()=>{if(t&&!t.dev&&t.signOut){await t.signOut({redirectUrl:Zt});return}hi(t)}})]);lt.append(n)}function mM(t,e){const n=e||bg(t)||"the address you used to register";lt.innerHTML="";const r=k("p",{className:"pending-copy"});r.append(document.createTextNode("Thank you for your registration. Your profile is being transferred to the site administration to be reviewed as a potential contributor. You will be contacted via "));const i=document.createElement("strong");i.textContent=n,r.append(i),r.append(document.createTextNode("."));const o=k("div",{className:"auth-gate auth-gate--pending"},[k("div",{className:"studio-brand"},[Ts({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Registration received"}),r,k("p",{className:"pending-signoff",text:"Have a nice one! ✍️"}),k("button",{className:"btn",type:"button",text:"Sign out",onClick:async()=>{if(t&&!t.dev&&t.signOut){await t.signOut({redirectUrl:Zt});return}hi(t)}})]);lt.append(o)}const gM=["Writing","Portfolio","References","Pages","CV Summary","Presentation","Profile"];function kg(t){const e=new Map;for(const r of t.collections)e.has(r.group)||e.set(r.group,[]),e.get(r.group).push(r);const n=new Map;for(const r of gM)e.has(r)&&n.set(r,e.get(r));for(const[r,i]of e)n.has(r)||n.set(r,i);return n}function yM(){const t="Media",e=m.navOpenGroups.has(t),n=k("div",{className:"studio-nav-group-items",id:kc(t),role:"region","aria-label":t});e||(n.hidden=!0),n.append(k("button",{className:"nav-item",type:"button",text:"Library",title:"Browse and upload under content/media","aria-current":m.mediaOpen?"page":null,onClick:()=>dg()}));const r=k("button",{className:"studio-nav-group-toggle",type:"button",title:sg(t),"aria-expanded":e?"true":"false","aria-controls":n.id,onClick:()=>{lg(t)}},[k("span",{className:"material-symbols-outlined",text:e?"expand_more":"chevron_right","aria-hidden":"true"}),k("span",{className:"nav-group-label",text:t})]);return k("div",{className:"studio-nav-group"},[r,n])}function bM(){if(!m.error||!m.file&&!m.mediaOpen)return null;const t=[];if(m.errorCode==="conflict"&&m.file){const e=m.file;t.push(k("button",{className:"btn",type:"button",text:"Reload from GitHub",title:"Replace this screen with the file currently on GitHub",onClick:()=>Os(e)}))}return t.push(k("button",{className:"btn",type:"button",text:"Dismiss",onClick:()=>{at(),Q()}})),k("div",{className:"studio-error-banner",role:"alert"},[k("p",{className:"studio-error-message",text:m.error}),k("div",{className:"studio-error-actions"},t)])}function Q(){var a;lt.innerHTML="";const t=kg(m.schema),e=!!m.navMenuOpen,n=k("button",{className:"studio-brand studio-brand-home studio-brand-toolbar",type:"button",title:"Studio home","aria-current":!m.collection&&!m.mediaOpen?"page":null,onClick:()=>Sc()},[Ts({size:22}),k("span",{className:"studio-brand-copy"},[k("span",{className:"studio-brand-name",text:"Studio"})])]),r=k("button",{className:"studio-nav-menu-toggle",type:"button",title:e?"Close collections menu":"Open collections menu","aria-label":e?`Close menu (${Ll()})`:`Open menu (${Ll()})`,"aria-expanded":e?"true":"false","aria-controls":"studio-nav-panel",onClick:()=>{m.navMenuOpen=!m.navMenuOpen,Q()}},[k("span",{className:"studio-nav-menu-label sr-only",text:Ll()}),k("span",{className:"material-symbols-outlined",text:e?"close":"menu","aria-hidden":"true"})]),i=k("div",{className:"studio-nav-panel",id:"studio-nav-panel"});i.append(yM());for(const[c,u]of t){const d=m.navOpenGroups.has(c),p=k("div",{className:"studio-nav-group-items",id:kc(c),role:"region","aria-label":c});d||(p.hidden=!0);for(const g of u){const b=m.navCountByCollection[g.name],x=[k("span",{className:"nav-item-label",text:g.label})];b!=null&&x.push(k("span",{className:"nav-item-count",text:String(b)})),p.append(k("button",{className:"nav-item",type:"button",title:ag(g),"aria-current":((a=m.collection)==null?void 0:a.name)===g.name?"page":null,onClick:()=>Ns(g)},x))}const h=k("button",{className:"studio-nav-group-toggle",type:"button",title:sg(c),"aria-expanded":d?"true":"false","aria-controls":p.id,onClick:()=>{lg(c)}},[k("span",{className:"material-symbols-outlined",text:d?"expand_more":"chevron_right","aria-hidden":"true"}),k("span",{className:"nav-group-label",text:c})]);i.append(k("div",{className:"studio-nav-group"},[h,p]))}const o=k("nav",{className:"studio-nav"+(e?" is-open":""),"aria-label":"Collections"},[i]),s=pM({brand:n,menuToggle:r}),l=k("div",{className:"studio-main"},[bM(),kM(),k("div",{className:"studio-body"+(m.file?"":" list-only"),id:"studio-body"})]);lt.append(k("div",{className:"studio-shell"},[s,o,l])),Sn(),pi(),window.__studioMenuDismissBound||(window.__studioMenuDismissBound=!0,document.addEventListener("click",()=>{m.themeMenuOpen&&(m.themeMenuOpen=!1,pi())}))}function kM(){var e,n;const t=[k("span",{className:"studio-crumb",text:"Studio"})];if(m.mediaOpen&&!m.collection)t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Media"}));else if(m.collection){const r=m.collection.group||"Content",i=m.collection.label||m.collection.name;if(t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb",text:r}),k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb"+(m.file?"":" is-current"),text:i})),m.file){const o=((e=m.fields)==null?void 0:e.title)||((n=m.fields)==null?void 0:n.key)||String(m.file).split("/").pop()||"Entry";t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:o}))}}else t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Map"}));return k("nav",{className:"studio-breadcrumb","aria-label":"Location"},t)}function He(){m.dirty=!0,Ma(),jM()}function Mc(){var t;return!m.file||fr()||m.aiProofBusy?!1:!!String(((t=m.fields)==null?void 0:t.language)||"").trim()}function va(){const t=m.aiProofBusy,e=Mc()&&!t;for(const n of["correct","refine"]){const r=document.querySelector(`[data-studio-action='${n}']`);if(!r)continue;r.disabled=!e;const i=r.querySelector(".editor-ai-proof-label");i&&(t?i.textContent="Working…":i.textContent=n==="refine"?"Refine":"Correct")}}function Qr(){m.insertMenuOpen=!1;const t=ve("#insert-menu");t&&(t.hidden=!0);for(const e of document.querySelectorAll(".editor-insert-btn[aria-haspopup='menu']"))e.setAttribute("aria-expanded","false")}function oo(t){m.aiProofHint=t;const e=ve("#ai-proof-hint");e&&(e.textContent=t,e.hidden=!t),clearTimeout(m._aiProofHintTimer),t&&(m._aiProofHintTimer=setTimeout(()=>{m.aiProofHint="";const n=ve("#ai-proof-hint");n&&(n.textContent="",n.hidden=!0)},3200))}function xg(){var t;if(m.bodyMode==="source"){const e=ve("#body-source");if(!e)return null;const n=e.selectionStart,r=e.selectionEnd;if(!Number.isInteger(n)||!Number.isInteger(r)||n===r)return null;cn();const i=m.body||"";return{kind:"source",start:n,end:r,text:i.slice(n,r)}}if(m.bodyMode==="visual"&&((t=m.bodyEditor)!=null&&t.editor)){const e=m.bodyEditor.editor,{from:n,to:r,empty:i}=e.state.selection;if(i||n===r)return null;const o=e.state.doc.textBetween(n,r,`
274
+
275
+ `);return String(o).trim()?{kind:"visual",from:n,to:r,text:o}:null}return null}function rf(t,e){const n=Array.isArray(e)?[...e]:[];n.sort((i,o)=>(o.start||0)-(i.start||0));let r=t;for(const i of n){const o=Number(i.start),s=Number(i.end);if(!Number.isInteger(o)||!Number.isInteger(s)||s<o)continue;const l=String(i.original??""),a=String(i.replacement??"");r.slice(o,s)===l&&(r=r.slice(0,o)+a+r.slice(s))}return r}function xM(t,e){var n;if(t.kind==="source"){const r=m.body||"";m.body=r.slice(0,t.start)+e+r.slice(t.end);const i=ve("#body-source");if(i){i.value=m.body;const o=t.start+e.length;i.focus(),i.setSelectionRange(o,o)}He(),pn();return}t.kind==="visual"&&((n=m.bodyEditor)!=null&&n.editor)&&(m.bodyEditor.editor.chain().focus().insertContentAt({from:t.from,to:t.to},e).run(),cn(),He(),pn())}function SM(){var n;const t=m.aiProofSelection||xg();if(m.aiProofSelection=null,t)return t;cn();const e=m.body||"";if(!String(e).trim())return null;if(m.bodyMode==="source")return{kind:"source",start:0,end:e.length,text:e,wholeBody:!0};if(m.bodyMode==="visual"&&((n=m.bodyEditor)!=null&&n.editor)){const r=m.bodyEditor.editor,i=0,o=r.state.doc.content.size;return{kind:"visual",from:i,to:o,text:e,wholeBody:!0}}return null}async function wM(t){var l,a;if(Qr(),oo(""),!Mc()){oo("Set language in front matter before AI Proof."),Ma();return}const e=SM();if(!e){oo("Body is empty.");return}cn();const n=String(m.fields.language||"").trim(),r=m.body||"";let i=null;t==="refine"&&e.kind==="source"&&!e.wholeBody&&(i={before:r.slice(Math.max(0,e.start-2e3),e.start),after:r.slice(e.end,Math.min(r.length,e.end+2e3))});const o=e.kind==="source"?{start:e.start,end:e.end}:{start:0,end:e.text.length},s=e.wholeBody?"body":"selection";m.aiProofBusy=!0,m.status=t==="refine"?`Refining ${s}…`:`Correcting ${s}…`,va();try{const c=await Je.rewrite({mode:t,path:m.file,language:n,text:e.text,selection:o,context:i}),u=Array.isArray(c.patches)?c.patches:[],d=c.stats||{};if(!u.length){Number(d.proposed)>0?m.status=`No safe changes to apply (${d.proposed} proposed, all dropped).`:m.status=`No changes proposed for the ${s}.`;return}let p;if(e.kind==="visual"&&e.wholeBody){if(p=rf(r,u),p===r){m.status=`No changes proposed for the ${s}.`;return}m.body=p,(a=(l=m.bodyEditor)==null?void 0:l.setMarkdown)==null||a.call(l,p),He(),pn()}else{if(p=rf(e.text,u),p===e.text){m.status=`No changes proposed for the ${s}.`;return}xM(e,p)}const h=Number(d.dropped)>0?`, ${d.dropped} dropped`:"";m.status=t==="refine"?`Refined ${s} (${u.length}${h}).`:`Corrected ${s} (${u.length}${h}).`}catch(c){Ct(c);const u=m.error;m.error=u?`AI Proof failed. ${u}`:"AI Proof failed."}finally{m.aiProofBusy=!1,va(),Ma()}}function Ma(){const t=document.querySelector("[data-studio-action='save']"),e=document.querySelector("[data-studio-action='discard']");if(t){const n=m.saving?"Saving…":m.dirty?"Save":"Saved";t.disabled=m.saving||!m.file||!m.dirty,t.title=m.saving?"Saving this draft":m.dirty?"Commit this draft":"No edits to commit yet",t.setAttribute("aria-label",n);const r=t.querySelector(".material-symbols-outlined");r&&(r.textContent=m.saving?"progress_activity":m.dirty?"save":"check",r.classList.toggle("studio-icon-spin",m.saving));const i=t.querySelector(".btn-label");i&&(i.textContent=n)}e&&(e.disabled=!m.file||!m.dirty||!m.baseline),va()}function Sn(){const t=ve("#studio-body");if(!t)return;t.innerHTML="";const e=m.file&&!fr()?` view-${m.bodyMode}`:"";if(t.className="studio-body"+(m.file?"":" list-only")+e,m.fileLoading){t.append(k("div",{className:"pane"},[k("p",{className:"loading-msg",text:"Loading content…"})]));return}if(!m.collection){if(m.mediaOpen){t.append(Pv(ug()));return}t.append(OM());return}if(!m.file){t.append(IM());return}if(fr()){t.append(NM(),lf()),pn();return}t.append(FM(),lf()),GM(),pn()}function fr(t=m.collection){return(t==null?void 0:t.format)==="yaml"}function CM(){const t=m.collection,e=mr(t);try{if(e==="list")m.body=St(m.yamlList||[]);else if(e==="map")if(t.root_key){const n=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};n[t.root_key]=_n({...m.fields},t.fields),m.body=St(n)}else m.body=St(_n({...m.fields},t.fields))}catch(n){Ct(n)}}function vM(){const t=m.collection,e=mr(t);at();try{const n=Zr(m.body);if(e==="list")m.yamlList=Jm(n),m.fields={};else if(e==="map"){if(t.root_key){const r=rr(n);m.yamlDoc=r,m.fields=rr(r[t.root_key])}else m.yamlDoc=null,m.fields=rr(n);m.yamlList=null}return!0}catch(n){return Ct(n),m.status="Invalid YAML — fix source before switching",!1}}function of(t){if(t===m.yamlUiMode)return;if(t==="source"){CM(),m.yamlUiMode="source",Q();return}const e=ve("#yaml-source");if(e&&(m.body=e.value),!vM()){Q();return}m.yamlUiMode="structured",Q()}function MM(t){const e=m.yamlUiMode==="structured"&&t!=="source";return t==="list"||t==="map"?k("div",{className:"editor-chrome yaml-chrome"},[k("div",{className:"editor-mode-tabs",role:"tablist","aria-label":"YAML editor mode"},[k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Fields",title:"Structured field editors","aria-selected":e?"true":"false",onClick:()=>of("structured")}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"YAML",title:"Raw YAML source","aria-selected":e?"false":"true",onClick:()=>of("source")})]),k("p",{className:"yaml-chrome-hint",text:t==="list"?"List of entries in one YAML file. Reorder, add, or remove items.":"Structured YAML fields — not a Markdown article body."})]):k("div",{className:"editor-chrome yaml-chrome"},[k("p",{className:"yaml-chrome-hint",text:"Free-form YAML — edit the source directly."})])}function TM(){const t=m.collection,e=As(t),n=Array.isArray(m.yamlList)?m.yamlList:[],r=k("div",{className:"yaml-list",id:"yaml-list"});return n.forEach((i,o)=>{(!i||typeof i!="object"||Array.isArray(i))&&(n[o]={});const s=n[o],l=k("div",{className:"yaml-list-item"}),a=e[0],c=a?s[a.name]||`${t.label} ${o+1}`:`${t.label} ${o+1}`;l.append(k("div",{className:"yaml-list-item-head"},[k("span",{className:"yaml-list-item-index",text:String(c)}),k("div",{className:"yaml-list-item-actions"},[k("button",{className:"btn yaml-list-btn",type:"button",text:"↑",title:"Move up",disabled:o===0,onClick:()=>{if(o===0)return;const d=[...n];[d[o-1],d[o]]=[d[o],d[o-1]],m.yamlList=d,He(),Q()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"↓",title:"Move down",disabled:o===n.length-1,onClick:()=>{if(o>=n.length-1)return;const d=[...n];[d[o],d[o+1]]=[d[o+1],d[o]],m.yamlList=d,He(),Q()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{m.yamlList=n.filter((d,p)=>p!==o),He(),Q()}})])]));const u=k("div",{className:"form-grid yaml-list-item-fields"});for(const d of e)u.append(Es(d,{target:s,idPrefix:`yml-${o}-`,onChange:()=>{He()}}));l.append(u),r.append(l)}),r.append(k("button",{className:"btn btn-primary",type:"button",text:"Add item",onClick:()=>{m.yamlList=[...m.yamlList||[],bc(e)],He(),Q()}})),n.length||r.prepend(k("p",{className:"yaml-empty",text:"No items yet. Add one to start this list."})),r}function AM(){const t=k("div",{className:"form-grid",id:"yaml-form"});for(const e of As(m.collection))t.append(Es(e));return t}function EM(){return k("div",{className:"field yaml-source-stack"},[k("label",{className:"field-heading",text:"YAML source"}),k("textarea",{id:"yaml-source",className:"yaml-source editor-surface",text:m.body,"aria-label":"YAML source",spellcheck:"false",onInput:t=>{m.body=t.target.value,He(),pn()}})])}function NM(){const t=m.collection,e=mr(t)||"source",n=m.yamlUiMode==="structured"&&(e==="list"||e==="map"),r=t.type==="file"?"Map":"List",i=k("div",{className:"yaml-editor-body"});return n&&e==="list"?i.append(TM()):n&&e==="map"?i.append(AM()):i.append(EM()),k("div",{className:"pane pane-editor pane-yaml"},[k("button",{className:"btn btn-nav",type:"button",title:`Back to ${r}`,onClick:()=>{if(vt(),t.type==="file"){Sc();return}m.file=null,m.baseline=null,m.dirty=!1,m.insertMenuOpen=!1,Q()}},[_e("chevron_left","btn-nav-icon"),k("span",{text:r})]),k("header",{className:"yaml-editor-header"},[k("h1",{className:"yaml-editor-title",text:t.label}),k("p",{className:"yaml-editor-path",text:Ti(m.file||t.path)})]),MM(e),i])}function OM(){const t=kg(m.schema),e=[LM()];for(const[n,r]of t){const i=r.map(o=>k("button",{className:"studio-map-card",type:"button",title:ag(o),onClick:()=>{m.navOpenGroups.add(n),Ns(o)}},[_e(o.type==="file"?"draft":wa[n]||"folder_open","studio-map-card-icon"),k("span",{className:"studio-map-card-body"},[k("span",{className:"studio-map-card-title",text:o.label}),k("span",{className:"studio-map-card-meta",text:Ti(o.path)||o.name})])]));e.push(k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[_e(wa[n]||"folder","studio-map-group-icon"),k("h2",{className:"studio-map-group-label",text:n})]),k("div",{className:"studio-map-grid"},i)]))}return k("div",{className:"pane studio-map"},[k("span",{className:"studio-shard studio-shard--lead","aria-hidden":"true"}),k("span",{className:"studio-shard studio-shard--beta studio-shard--trail","aria-hidden":"true"}),k("div",{className:"studio-map-board",role:"navigation","aria-label":"Collections map"},e)])}function LM(){return k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[_e(wa.Media,"studio-map-group-icon"),k("h2",{className:"studio-map-group-label",text:"Media"})]),k("div",{className:"studio-map-grid"},[k("button",{className:"studio-map-card",type:"button",title:"Browse and upload under content/media",onClick:()=>dg()},[_e("photo_library","studio-map-card-icon"),k("span",{className:"studio-map-card-body"},[k("span",{className:"studio-map-card-title",text:"Library"}),k("span",{className:"studio-map-card-meta",text:Ti("content/media")})])])])])}function IM(){const t=Gv(),e=Xv(),n=Qv(),r=nT(),i=hv(m.items,{query:t,sortId:e}),o=mv(i,{pageSizeId:n,page:ef()});o.page!==ef()&&Il(o.page);const s=o.items,l=zM(m.collection,{entryCount:m.listLoading?null:m.items.length});if(m.listLoading)return k("div",{className:"pane"},[l,k("p",{className:"loading-msg",text:"Loading content…"})]);if(m.error&&!m.items.length)return k("div",{className:"pane"},[l,k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:m.error}),m.errorDetail?k("pre",{className:"list-error-detail",text:m.errorDetail}):null])]);const a=s.map(T=>PM(T,r)),c=k("input",{className:"list-search-input",type:"search",value:t,placeholder:"Search title, key, path…","aria-label":"Search entries",title:"Filter this list by title, key, filename, or path",onInput:T=>{var Y;const R=(Y=m.collection)==null?void 0:Y.name;if(!R)return;m.listQueryByCollection[R]=T.target.value,wc(),Sn();const $=ve("#list-search-input");if($){$.focus();const ne=$.value.length;$.setSelectionRange(ne,ne)}}});c.id="list-search-input";const u=k("select",{className:"list-sort-select","aria-label":"Sort entries",title:"Sort entries in this collection",onChange:T=>{Zv(T.target.value),Sn()}});for(const T of es)u.append(k("option",{value:T.id,text:T.label,selected:T.id===e}));const d=k("select",{className:"list-page-size-select","aria-label":"Entries per page",title:"How many entries to show per page",onChange:T=>{eM(T.target.value),Sn()}});for(const T of ns)d.append(k("option",{value:T.id,text:T.label,selected:T.id===n}));const p=k("div",{className:"list-controls"},[c,k("label",{className:"list-sort-label"},[k("span",{className:"list-sort-caption",text:"Sort"}),u]),k("label",{className:"list-sort-label"},[k("span",{className:"list-sort-caption",text:"Show"}),d])]);let h=null;i.length||(m.error?h=k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:m.error}),m.errorDetail?k("pre",{className:"list-error-detail",text:m.errorDetail}):null]):m.items.length===0?h=k("p",{className:"list-empty",text:"No entries in this collection."}):h=k("p",{className:"list-empty",text:"No entries match this search."}));const b=o.pageSize!=null&&o.pageCount>1&&i.length>0?k("div",{className:"list-pager",role:"navigation","aria-label":"List pages"},[k("button",{className:"btn list-pager-btn",type:"button",text:"Prev",title:"Previous page",disabled:o.page<=1,onClick:()=>{o.page<=1||(Il(o.page-1),Sn())}}),k("span",{className:"list-pager-status",text:`Page ${o.page} of ${o.pageCount}`}),k("button",{className:"btn list-pager-btn",type:"button",text:"Next",title:"Next page",disabled:o.page>=o.pageCount,onClick:()=>{o.page>=o.pageCount||(Il(o.page+1),Sn())}})]):null;let x="";if(m.items.length>0){const T=t;if(!i.length)x=T?`0 of ${m.items.length}`:"";else if(o.pageSize==null)x=T?`${i.length} of ${m.items.length}`:"";else{const R=`${o.from}–${o.to} of ${i.length}`;x=T?`${R} (filtered from ${m.items.length})`:R}}const w=r?k("div",{className:"ledger-columns","aria-hidden":"true"},[k("span",{className:"ledger-col-thumb"}),k("span",{className:"ledger-col-manuscript",text:"Manuscript"}),k("span",{className:"ledger-col-ops",text:"Operations"})]):null;return k("div",{className:"pane"},[l,p,x?k("p",{className:"list-count",text:x}):null,w,k("div",{className:"ledger-list"},a.length?a:[h]),b])}function RM(t){const e=String((t==null?void 0:t.language)||"").trim();return e?k("span",{className:"ledger-lang",text:e.toUpperCase(),title:`Language: ${e}`}):null}function DM(t,{open:e}){const n=vc(),r=t.title||t.name||"entry",i=k("button",{className:"btn btn-icon ledger-op-btn ledger-edit-btn",type:"button",title:`Edit ${r}`,"aria-label":`Edit ${r}`,onClick:s=>{s.stopPropagation(),e()}},[_e("edit")]),o=n?k("button",{className:"btn btn-icon ledger-op-btn ledger-delete-btn",type:"button",title:`Delete ${r}`,"aria-label":`Delete ${r}`,onClick:s=>{s.stopPropagation(),Mg(t.path,t.sha)}},[_e("delete")]):null;return k("div",{className:"ledger-ops",role:"group","aria-label":"Operations"},[i,o])}function PM(t,e){const n=vv(t,m.collection),r=()=>Os(t.path),i=DM(t,{open:r});if(!e){const l=k("div",{className:"ledger-copy"},[k("div",{className:"ledger-title",text:t.title||t.name}),n?k("div",{className:"ledger-meta",text:n}):null]);return k("div",{className:"ledger-row ledger-row--plain",role:"button",tabindex:"0",title:Qd(t),onClick:r,onKeydown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r())}},[nf(t),l,i])}const o=k("div",{className:"ledger-title-row"},[Cg(t),k("div",{className:"ledger-title",text:t.title||t.name})]),s=k("div",{className:"ledger-copy"},[o,n?k("div",{className:"ledger-meta",text:n}):null]);return k("div",{className:"ledger-row ledger-row--writing",role:"button",tabindex:"0",title:Qd(t),onClick:r,onKeydown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),r())}},[nf(t),s,i])}function As(t){return(t.fields||[]).filter(e=>!e.hidden&&!Tf(e)&&e.name!=="layout")}function $M(t){const e=(t.fields||[]).filter(n=>Tf(n));return e.length?e:t.format==="raw"&&!t.root_key?[{name:"body",label:"Content",component:"markdown_body"}]:[]}function sf(t,e){return((t==null?void 0:t.fields)||[]).some(n=>n.name===e)}function BM(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="boolean"?!0:String(t).trim()!==""}function _M(){var t;if(m.frontMatterOpen!=null)return!!m.frontMatterOpen;if(m.dirty)return!0;for(const e of As(m.collection))if(e.required&&!BM((t=m.fields)==null?void 0:t[e.name]))return!0;return!1}function zM(t,{entryCount:e=null}={}){const n=(t==null?void 0:t.group)||"Content",r=(t==null?void 0:t.label)||(t==null?void 0:t.name)||"Index",i=[k("h1",{className:"list-pane-title",text:r})];return e!=null&&e>=0&&i.push(k("span",{className:"list-pane-count",text:e===1?"1 entry":`${e} entries`})),yg(t)&&i.push(k("button",{className:"btn btn-tool btn-primary list-new-btn",type:"button",title:`Add a new ${r} entry`,"aria-label":`New ${r} entry`,onClick:()=>sT()},[_e("add"),k("span",{className:"btn-label",text:"New"})])),k("header",{className:"list-register"},[k("p",{className:"list-register-kicker"},[k("span",{className:"list-register-mark","aria-hidden":"true"}),k("span",{text:`Register // ${n}`}),k("span",{className:"list-register-sep","aria-hidden":"true",text:"/"}),k("span",{text:`${r} index`})]),k("div",{className:"list-register-title-row"},i)])}function FM(){const t=As(m.collection),e=$M(m.collection),n=k("div",{className:"form-grid",id:"meta-form"});for(const a of t)n.append(Es(a));const r=_M(),i=t.length>0?k("details",{className:"front-matter",open:r,onToggle:a=>{m.frontMatterOpen=!!a.target.open}},[k("summary",{className:"front-matter-summary"},[k("span",{className:"front-matter-summary-label",text:"Front-matter"}),k("span",{className:"front-matter-summary-hint",text:r?"Collapse":"Expand"})]),n]):null,o=k("div",{className:"field body-editor-stack",id:"body-wrap"});if(e.length){const a=e[0],c=m.bodyMode,d=c==="visual"||c==="preview",p=c==="source",h=k("div",{id:"tiptap-host",className:"tiptap editor-surface"});d||(h.hidden=!0);const g=k("textarea",{id:"body-source",className:"body-source editor-surface",text:m.body,"aria-label":"Markdown source",onInput:b=>{m.body=b.target.value,He(),pn()}});if(p||(g.hidden=!0),o.append(k("label",{text:a.label||"Body"}),VM(c),k("div",{className:"editor-pane-fill"},[h,g])),e.length>1)for(const b of e.slice(1))o.append(k("label",{text:b.label||b.name,style:"margin-top:1rem"}),k("textarea",{"data-extra-body":b.name,text:m.fields[b.name]||"",onInput:x=>{m.fields[b.name]=x.target.value,He()}}))}const s=e.length>0?HM(m.body):null,l=[];if(sf(m.collection,"published")&&l.push(Cg(m.fields)),!sf(m.collection,"language")){const a=RM(m.fields);a&&l.push(a)}return k("div",{className:"pane pane-editor"},[k("div",{className:"editor-mast"},[k("div",{className:"editor-mast-lead"},[k("button",{className:"btn btn-back",type:"button",title:"Back to collection list","aria-label":"Back to collection list",onClick:()=>{vt(),m.file=null,m.baseline=null,m.dirty=!1,m.insertMenuOpen=!1,m.frontMatterOpen=null,Q()}},[_e("chevron_left","btn-nav-icon")]),l.length?k("div",{className:"editor-mast-pills"},l):null])]),i,o,s])}function Sg(t){const e=String(t||""),n=e.length,r=e.trim(),i=r?r.split(/\s+/).filter(Boolean).length:0,o=r?r.split(/\n\s*\n/).filter(s=>s.trim()).length:0;return{chars:n,words:i,paras:o}}function HM(t){const{chars:e,words:n,paras:r}=Sg(t);return k("div",{className:"editor-body-stats",id:"editor-body-stats"},[k("span",{text:`Chars: ${e}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Words: ${n}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Paras: ${r}`})])}function jM(){const t=ve("#editor-body-stats");if(!t)return;const{chars:e,words:n,paras:r}=Sg(m.body);t.replaceChildren(k("span",{text:`Chars: ${e}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Words: ${n}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Paras: ${r}`}))}function VM(t){const e=t==="visual",n=t==="source",r=t==="preview",i=k("div",{className:"editor-mode-tabs",role:"tablist","aria-label":"Editor mode"},[k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Visual",title:"Rich text with Liquid blocks","aria-selected":e?"true":"false",onClick:()=>{e||(cn(),m.bodyMode="visual",m.lastEditorMode="visual",Qr(),Q())}}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Source",title:"Edit raw Markdown source","aria-selected":n?"true":"false",onClick:()=>{n||(cn(),m.bodyMode="source",m.lastEditorMode="source",Qr(),Q())}}),k("button",{className:"editor-mode-tab editor-mode-tab--preview",type:"button",role:"tab",text:"Preview",title:"Rendered side preview (small screens)","aria-selected":r?"true":"false",onClick:()=>{r||(cn(),(m.bodyMode==="visual"||m.bodyMode==="source")&&(m.lastEditorMode=m.bodyMode),m.bodyMode="preview",Qr(),Q())}})]),o=k("div",{className:"editor-chrome-row"},[i,k("div",{className:"editor-chrome-actions"},[e||n?WM():null,e?qM():null])]);return k("div",{className:"editor-chrome"},[o,k("p",{id:"ai-proof-hint",className:"ai-proof-hint",text:m.aiProofHint||"",hidden:!m.aiProofHint,"aria-live":"polite"}),e?KM():null])}function UM(t){const e={};if(t.name==="figure")e.src=prompt("Image URL (HTTPS or /media/…)")||"",e.caption=prompt("Caption")||"";else if(t.name==="youtube")e.id=prompt("YouTube id")||"";else if(t.name==="xcite"||t.name==="cite")e.key=prompt("Key")||"";else for(const n of t.fields){const r=prompt(n);r&&(e[n]=r)}return e}function qM(){const t=k("div",{className:"editor-insert-menu",id:"insert-menu",role:"menu"});m.insertMenuOpen||(t.hidden=!0);for(const e of dr.filter(n=>!n.blockBody))t.append(k("button",{className:"editor-insert-item",type:"button",role:"menuitem",title:e.label,onClick:()=>{const n=UM(e);Qr(),m.bodyEditor?m.bodyEditor.insertInclude(e.name,n):Sn()}},[_e(Kv[e.name]||"add","editor-insert-icon"),k("span",{text:e.label})]));return k("div",{className:"editor-insert"},[k("button",{className:"btn editor-insert-btn",type:"button","aria-haspopup":"menu","aria-expanded":m.insertMenuOpen?"true":"false",title:"Insert a Liquid include block",onClick:e=>{e.stopPropagation();const n=!m.insertMenuOpen;m.insertMenuOpen=n;const r=ve("#insert-menu"),i=e.currentTarget;r&&(r.hidden=!n),i.setAttribute("aria-expanded",n?"true":"false")}},[_e("add"),k("span",{text:"Insert"}),_e("expand_more","editor-insert-caret")]),t])}function WM(){return k("div",{className:"editor-ai-proof"},[{action:"correct",label:"Correct",icon:"check",title:"Spelling, grammar, idiom, and punctuation (selection or full body)"},{action:"refine",label:"Refine",icon:"edit",title:"Clarity and flow (selection or full body), using writing guidelines"}].map(e=>k("button",{className:"btn editor-insert-btn",type:"button",title:e.title,"data-studio-action":e.action,disabled:!Mc()||m.aiProofBusy,onMouseDown:n=>{n.preventDefault(),m.aiProofSelection=xg()},onClick:()=>{oo(""),wM(e.action)}},[_e(e.icon),k("span",{className:"editor-ai-proof-label",text:m.aiProofBusy?"Working…":e.label})])))}function ht(){var t,e;return(e=(t=m.bodyEditor)==null?void 0:t.editor)==null?void 0:e.chain().focus()}function rt(t){return k("button",{className:"editor-toolbar-btn",type:"button",title:t.title,"aria-label":t.title,onClick:t.onClick},[t.icon?_e(t.icon):null,t.text?k("span",{text:t.text}):null])}function Rl(){return k("span",{className:"editor-toolbar-sep","aria-hidden":"true"})}function KM(){const t=k("select",{className:"editor-toolbar-select",title:"Text color","aria-label":"Text color",onChange:e=>{const n=ht();if(!n)return;const r=e.target.value;r?n.setColor(r).run():n.unsetColor().run()}});for(const e of Yv)t.append(k("option",{value:e.value,text:e.label}));return k("div",{className:"editor-format-toolbar",role:"toolbar","aria-label":"Formatting"},[rt({title:"Paragraph",icon:"notes",onClick:()=>{var e;return(e=ht())==null?void 0:e.setParagraph().run()}}),rt({title:"Heading 1",text:"H1",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:1}).run()}}),rt({title:"Heading 2",text:"H2",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:2}).run()}}),rt({title:"Heading 3",text:"H3",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:3}).run()}}),rt({title:"Heading 4",text:"H4",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:4}).run()}}),rt({title:"Blockquote",icon:"format_quote",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBlockquote().run()}}),Rl(),rt({title:"Bold",icon:"format_bold",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBold().run()}}),rt({title:"Italic",icon:"format_italic",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleItalic().run()}}),rt({title:"Strikethrough",icon:"format_strikethrough",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleStrike().run()}}),Rl(),t,Rl(),rt({title:"Lowercase",text:"aa",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("lower")}}),rt({title:"Uppercase",text:"AA",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("upper")}}),rt({title:"Title case",text:"Aa",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("title")}})])}function YM(t,e){return t===!0||t==="true"?!0:t===!1||t==="false"?!1:e===!0||e==="true"}function Es(t,e={}){var a;const n=t.name,r=e.target||m.fields,i=e.onChange||(()=>{He()}),o=r[n]??t.default??"",s=k("div",{className:"field"+(n==="title"?" field--title":"")}),l=`field-${e.idPrefix||""}${n}`;if(s.append(k("label",{className:"field-heading",text:t.label||n,htmlFor:l})),t.type==="boolean"){const c=Object.prototype.hasOwnProperty.call(r,n)?r[n]:t.default,u=YM(c,t.default),d=k("input",{id:l,type:"checkbox",className:"field-checkbox",checked:u,onChange:h=>{r[n]=!!h.target.checked,i()}}),p=Zd(t);return s.classList.add("field--boolean"),s.append(k("label",{className:"field-check-row",htmlFor:l},[d,k("span",{className:"field-check-text",text:p||"On"})])),s}if(t.type==="select"&&((a=t.options)!=null&&a.values)){const c=!!t.options.multiple,u=k("select",{id:l,multiple:c,onChange:d=>{c?r[n]=[...d.target.selectedOptions].map(p=>p.value):r[n]=d.target.value,i()}});for(const d of t.options.values){const p=typeof d=="object"?d.value:d,h=c?String(o).includes(p)||Array.isArray(o)&&o.includes(p):String(o)===String(p);u.append(k("option",{value:p,text:p,selected:h}))}s.append(u)}else if(t.type==="object"&&t.list)Array.isArray(r[n])||(r[n]=Array.isArray(o)?o:[]),s.append(JM(t,r[n],{onChange:c=>{r[n]=c,He(),Q()},idPrefix:`${e.idPrefix||""}${n}-`}));else if(t.list&&(t.type==="string"||!t.type)){const c=Array.isArray(o)?o.join(`
276
+ `):String(o||"");s.append(k("textarea",{id:l,text:c,placeholder:"One item per line",onInput:u=>{r[n]=u.target.value.split(`
277
+ `).map(d=>d.trim()).filter(Boolean),i()}}))}else t.type==="text"||t.type==="image"?s.append(k(t.type==="text"?"textarea":"input",{id:l,type:t.type==="image"?"url":void 0,value:o,text:t.type==="text"?o:void 0,placeholder:t.type==="image"?"https://… or /media/images/…":void 0,onInput:c=>{r[n]=c.target.value,i()}})):s.append(k("input",{id:l,type:t.type==="number"?"number":t.type==="date"?"date":"text",value:o,onInput:c=>{r[n]=c.target.value,i()}}));if(t.description){const c=Zd(t);c&&s.append(k("p",{className:"hint",text:c}))}return s}function JM(t,e,{onChange:n,idPrefix:r}){const i=Array.isArray(e)?e:[],o=k("div",{className:"yaml-object-list"}),s=l=>{n(l,{structural:!0})};return i.forEach((l,a)=>{(!l||typeof l!="object"||Array.isArray(l))&&(i[a]={});const c=i[a],u=k("div",{className:"yaml-list-item"});u.append(k("div",{className:"yaml-list-item-head"},[k("span",{className:"yaml-list-item-index",text:`${t.label||t.name} ${a+1}`}),k("div",{className:"yaml-list-item-actions"},[k("button",{className:"btn yaml-list-btn",type:"button",text:"↑",title:"Move up",disabled:a===0,onClick:()=>{if(a===0)return;const p=[...i];[p[a-1],p[a]]=[p[a],p[a-1]],s(p)}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"↓",title:"Move down",disabled:a===i.length-1,onClick:()=>{if(a>=i.length-1)return;const p=[...i];[p[a],p[a+1]]=[p[a+1],p[a]],s(p)}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{s(i.filter((p,h)=>h!==a))}})])]));const d=k("div",{className:"form-grid yaml-list-item-fields"});for(const p of t.fields||[])p.hidden||d.append(Es(p,{target:c,idPrefix:`${r}${a}-`,onChange:()=>{He()}}));u.append(d),o.append(u)}),o.append(k("button",{className:"btn",type:"button",text:`Add ${t.label||"item"}`,onClick:()=>{s([...i,bc(t.fields||[])])}})),o}function lf(){const t=typeof window<"u"&&window.innerWidth?`${Math.round(window.innerWidth)}px`:"",e=[k("span",{className:"preview-pane-label",text:"Preview"})];return t&&e.push(k("span",{className:"preview-pane-sep","aria-hidden":"true",text:"·"}),k("span",{className:"preview-pane-meta",text:`Viewport ${t}`})),k("div",{className:"pane pane-preview"},[k("div",{className:"preview-pane-head"},e),k("div",{className:"preview-folio"},[k("div",{className:"preview-frame",id:"preview-frame",html:m.previewHtml})])])}function GM(){const t=ve("#tiptap-host");if(!t)return;if(vt(),m.bodyMode==="source"){t.hidden=!0;return}t.hidden=!1;const e=(m.bodyMode==="preview"&&m.lastEditorMode==="source",m.body);m.bodyEditor=aC(t,{content:e,onUpdate:n=>{m.body=n,He(),pn()}})}function cn(){var r;let t=null;m.bodyEditor&&m.bodyMode!=="source"&&(t=m.bodyEditor.getMarkdown());const e=ve("#body-source");if(e&&m.bodyMode==="source"&&(t=e.value),t==null)return;const n=(r=m.baseline)==null?void 0:r.body;if(typeof n=="string"&&t===sC(n)){m.body=n;return}m.body=t}function vt(){m.bodyEditor&&(m.bodyEditor.destroy(),m.bodyEditor=null)}const Or=new Map,Yn=new Map,XM=1e3;async function ZM(t,e){const n=String(e||"").trim();if(!n)return!1;try{const r=t==="xcite"?await Je.searchXcite(n):await Je.searchCite(n),i=(r==null?void 0:r.results)||[],o=n.toLowerCase();return i.some(s=>String(s.key||"").trim().toLowerCase()===o)}catch{return!1}}function Zi(t,e){t.classList.remove("studio-ref-pill--ok","studio-ref-pill--missing"),e==="ok"?t.classList.add("studio-ref-pill--ok"):e==="missing"&&t.classList.add("studio-ref-pill--missing")}function QM(t){if(!t)return;const e=new Set,n=new Map;for(const r of t.querySelectorAll("[data-cite-check]")){const i=r.getAttribute("data-cite-check")||"cite",o=String(r.getAttribute("data-key")||"").trim(),s=`${i}:${o}`;if(e.add(s),n.has(s)||n.set(s,[]),n.get(s).push(r),!o){Zi(r,"missing");continue}const l=Yn.get(s);l==="ok"||l==="missing"?Zi(r,l):Zi(r,null)}for(const r of[...Yn.keys()])if(!e.has(r)){Yn.delete(r);const i=Or.get(r);i&&clearTimeout(i),Or.delete(r)}for(const[r,i]of n){const o=r.slice(r.indexOf(":")+1),s=r.startsWith("xcite:")?"xcite":"cite";o&&(Yn.get(r)==="ok"||Yn.get(r)==="missing"||Or.has(r)||Or.set(r,setTimeout(async()=>{Or.delete(r);const a=await ZM(s,o)?"ok":"missing";Yn.set(r,a);const c=ve("#preview-frame");if(c)for(const u of c.querySelectorAll(`[data-cite-check="${s}"][data-key="${CSS.escape(o)}"]`))Zi(u,a)},XM)))}}function pn(){const t=ve("#preview-frame");if(fr()?m.previewHtml=eT():m.previewHtml=cv(m.body||""),t){const e=t.scrollTop,n=t.scrollLeft;t.innerHTML=m.previewHtml,t.scrollTop=e,t.scrollLeft=n,fr()||(QM(t),Promise.resolve(wg(t)).then(()=>{ve("#preview-frame")===t&&(t.scrollTop=e,t.scrollLeft=n)}))}}function af(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function eT(){const t=m.collection,e=mr(t);let n="";try{if(m.yamlUiMode==="source"||e==="source")n=m.body||"";else if(e==="list")n=St(m.yamlList||[]);else if(e==="map"&&t.root_key){const r=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};r[t.root_key]=_n({...m.fields},t.fields),n=St(r)}else e==="map"?n=St(_n({...m.fields},t.fields)):n=m.body||""}catch(r){return`<p class="yaml-preview-error">${af(r.message||r)}</p>`}return`<pre class="yaml-preview-pre">${af(n)}</pre>`}let Lr=null;function tT(){return window.mermaid?Promise.resolve(window.mermaid):Lr||(Lr=Og(()=>import("https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"),[]).then(t=>{const e=t.default;return window.mermaid=e,e.initialize({startOnLoad:!1,theme:document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default",securityLevel:"strict"}),e}).catch(t=>{throw Lr=null,t}),Lr)}function Dl(t,e){const n=t.dataset.mermaidSource||t.textContent||"";t.dataset.mermaidSource=n,t.className="studio-mermaid-fallback",t.removeAttribute("data-processed");const r=e?`Mermaid: ${e}
278
+
279
+ `:`Mermaid (unrendered)
280
+
281
+ `;t.innerHTML="";const i=document.createElement("pre");i.className="studio-mermaid-fallback__pre",i.textContent=r+n,t.append(i)}async function wg(t){if(!t)return;const e=[];if(t.querySelectorAll("pre code.language-mermaid").forEach(r=>{const i=r.textContent||"",o=document.createElement("div");o.className="mermaid studio-mermaid",o.dataset.mermaidSource=i,o.textContent=i;const s=r.closest("pre");s?s.replaceWith(o):r.replaceWith(o),e.push(o)}),t.querySelectorAll(".mermaid[data-mermaid-source], .studio-mermaid-fallback[data-mermaid-source]").forEach(r=>{e.includes(r)||e.push(r)}),!e.length)return;let n;try{n=await tT()}catch(r){for(const i of e)Dl(i,(r==null?void 0:r.message)||"failed to load Mermaid");return}n.initialize({startOnLoad:!1,theme:document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default",securityLevel:"strict"});for(const r of e){const i=r.dataset.mermaidSource||"";r.className="mermaid studio-mermaid",r.removeAttribute("data-processed"),r.innerHTML="",r.textContent=i}try{await n.run({nodes:e})}catch(r){for(const i of e)i.querySelector("svg")||Dl(i,(r==null?void 0:r.message)||"render failed")}for(const r of e)r.classList.contains("studio-mermaid-fallback")||r.querySelector("svg")||Dl(r,"render produced no diagram")}function nT(t=m.collection){const e=t==null?void 0:t.name;return e==="articles"||e==="posts"}function rT(t){const e=t==null?void 0:t.published;return!(e===!1||e==="false")}function Cg(t){const e=rT(t);return k("span",{className:"ledger-status "+(e?"ledger-status--published":"ledger-status--draft"),text:e?"Published":"Draft",title:e?"Published (exported)":"Draft (excluded from export)"})}async function Ns(t){vt(),m.mediaOpen=!1,m.mediaItems=[],m.collection=t,m.file=null,m.baseline=null,m.frontMatterOpen=null,m.items=[],m.insertMenuOpen=!1,xc(),at(),m.listLoading=t.type!=="file",m.fileLoading=t.type==="file",m.status=`Loading ${t.label}…`,Q();try{if(t.type==="file"){await Os(t.path);return}const e=tM(t);if(e){m.items=e,fg(t,e.length),m.listLoading=!1,m.status="",Q();return}const n=await Je.tree(t.path);m.items=n.items||[],pg(t,m.items),m.listLoading=!1,m.status=""}catch(e){m.items=[],m.listLoading=!1,Ct(e)}Q()}async function Os(t){vt(),m.insertMenuOpen=!1,m.fileLoading=!0,m.file=null,m.baseline=null,m.frontMatterOpen=null,m.status=`Opening ${t}…`,at(),m.yamlDoc=null,m.yamlList=null,Q();try{const e=await Je.getFile(t);m.file=t,m.sha=e.sha;const n=Ef(e.content),r=m.collection;if(r.format==="yaml"){m.body=e.content;const i=mr(r);if(i==="list"){const o=Zr(e.content);m.yamlList=Jm(o),m.fields={},m.yamlDoc=null,m.yamlUiMode="structured"}else if(i==="map"){if(r.root_key){const o=rr(Zr(e.content));m.yamlDoc=o,m.fields=rr(o[r.root_key])}else m.yamlDoc=null,m.fields=rr(Zr(e.content));m.yamlList=null,m.yamlUiMode="structured"}else m.fields={},m.yamlList=null,m.yamlUiMode="source"}else r.format==="raw"?(m.body=e.content,m.fields={}):(m.fields={...n.fm},m.body=n.body);m.dirty=!1,m.fileLoading=!1,m.listLoading=!1,m.status=t,vg()}catch(e){m.fileLoading=!1,m.listLoading=!1,m.baseline=null,Ct(e)}Q()}function vg(){m.baseline={fields:structuredClone(m.fields||{}),body:m.body,yamlDoc:m.yamlDoc?structuredClone(m.yamlDoc):null,yamlList:m.yamlList?structuredClone(m.yamlList):null,yamlUiMode:m.yamlUiMode,sha:m.sha}}function iT(){if(!m.file||!m.baseline)return;const t=m.baseline;vt(),m.fields=structuredClone(t.fields||{}),m.body=t.body,m.yamlDoc=t.yamlDoc?structuredClone(t.yamlDoc):null,m.yamlList=t.yamlList?structuredClone(t.yamlList):null,m.yamlUiMode=t.yamlUiMode||"structured",m.sha=t.sha,m.dirty=!1,m.insertMenuOpen=!1,m.bodyMode==="preview"||m.bodyMode!=="visual"&&m.bodyMode!=="source"&&(m.bodyMode=m.lastEditorMode||"visual"),at(),m.status=`Reverted ${m.file}`,Q()}async function oT(){m.status="Reexporting…",at(),Q();try{const t=await fetch("/__dev/reexport",{method:"POST",headers:{Accept:"application/json"}});let e={};try{e=await t.json()}catch{e={}}if(!t.ok||!e.ok)throw new Error(e&&e.error||`Export failed: ${t.status}`);m.status="Reexported — reloading…",Q(),setTimeout(()=>{try{const n=new URL(window.location.href);n.searchParams.set("_refresh",String(Date.now())),window.location.replace(n.toString())}catch{window.location.reload()}},200)}catch(t){Ct(t),Q()}}async function sT(){const t=m.collection;if(!yg(t))return;const e=window.prompt(`New ${t.label||"entry"} key (slug):`);if(e==null)return;const n=uM(e);if(!n){m.error="Key must use letters, numbers, or hyphens.",m.errorDetail="",Q();return}const r=dM(t.filename,n),i=`${String(t.path||"").replace(/\/$/,"")}/${r}`,o=bc(t.fields||[]);for(const l of t.fields||[])l!=null&&l.hidden&&l.name&&Object.prototype.hasOwnProperty.call(l,"default")&&(o[l.name]=l.default);o.key=n,o.title||(o.title=n),String(t.filename||"").includes("{year}")&&!o.date&&(o.date=fM());let s;t.format==="yaml"?s=St(_n({...o},t.fields)):s=Of(`---
282
+ ---
283
+
284
+ `,{fields:o,body:`
285
+ `,format:t.format||"yaml-frontmatter"}),s.endsWith(`
286
+ `)||(s+=`
287
+ `),m.status=`Creating ${i}…`,at(),Q();try{let l=!1;try{await Je.getFile(i),l=!0}catch(a){if(a.status!==404&&a.code!=="not_found")throw a}if(l)throw new Error(`${i} already exists`);await Je.putFile({path:i,content:s,sha:null,message:`studio: create ${i}`}),Cc(t.name),m.status=`Created ${i}`,await Ns(t),await Os(i)}catch(l){Ct(l),Q()}}async function Mg(t,e=null){const n=m.collection;if(!vc(n)||!t)return;const r=String(t).split("/").pop()||t;if(window.confirm(`Delete ${r}?
288
+
289
+ This commits a deletion to main and cannot be undone from Studio.`)){m.status=`Deleting ${t}…`,at(),Q();try{let i=e;i||(i=(await Je.getFile(t)).sha),await Je.deleteFile({path:t,sha:i,message:`studio: delete ${t}`}),Cc(n==null?void 0:n.name),m.file===t&&(vt(),m.file=null,m.baseline=null,m.sha=null,m.dirty=!1,m.fields={},m.body=""),m.status=`Deleted ${t}`,n?await Ns(n):Q()}catch(i){Ct(i),Q()}}}async function lT(){m.file&&await Mg(m.file,m.sha)}async function aT(){var t;if(!(!m.file||m.saving)){if(cn(),fr()){const e=ve("#yaml-source");e&&(m.body=e.value)}m.saving=!0,m.status="Saving…",at(),Q();try{let e;const n=m.collection;if(n.format==="raw")e=m.body;else if(n.format==="yaml"){const i=mr(n);if(m.yamlUiMode==="source"||i==="source")Zr(m.body),e=m.body.endsWith(`
290
+ `)?m.body:m.body+`
291
+ `;else if(i==="list")e=St(m.yamlList||[]);else if(i==="map"&&n.root_key){const s=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};s[n.root_key]=_n({...m.fields},n.fields),e=St(s)}else i==="map"?e=St(_n({...m.fields},n.fields)):e=m.body.endsWith(`
292
+ `)?m.body:m.body+`
293
+ `}else{const i=(await Je.getFile(m.file)).content,o={...m.fields};e=Of(i,{fields:o,body:m.body,format:n.format})}e.endsWith(`
294
+ `)||(e+=`
295
+ `);const r=await Je.putFile({path:m.file,content:e,sha:m.sha,message:`studio: update ${m.file}`});m.sha=((t=r.content)==null?void 0:t.sha)||m.sha,m.dirty=!1,at(),m.status=`Saved ${m.file}`,vg(),n!=null&&n.name&&Cc(n.name)}catch(e){Ct(e)}finally{m.saving=!1,Q()}}}async function so(t){var e,n;try{m.session=await Je.session()}catch(r){if((((e=r==null?void 0:r.data)==null?void 0:e.error)||"")==="not_allowlisted"){mM(t,((n=r==null?void 0:r.data)==null?void 0:n.email)||bg(t));return}m.error=`Session failed: ${r.message}`,hi(t),m.error&&lt.append(k("p",{className:"status-pill error",text:m.error}));return}try{m.schema=await Bg()}catch(r){m.error=String(r.message||r),lt.innerHTML="",lt.append(k("p",{className:"auth-gate status-pill error",text:m.error}));return}Q(),hg(),t&&!t.dev&&t.addListener&&t.addListener(({user:r})=>{r||(vt(),hi(t))})}async function cT(){lM();const t=await Wv();if(t.dev){await so(t);return}t.user?await so(t):(hi(t),t.addListener(async({user:e})=>{e&&await so(t)}))}cT().catch(t=>{lt.textContent=String(t.stack||t)});