pandorga 1.4.6 → 1.4.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/assets/css/ledger/home.css +21 -11
- data/lib/pandorga/version.rb +1 -1
- data/scripts/test/render-parity/blocks/project-specimen.json +5 -3
- data/scripts/test/render-parity/blocks/system-card.json +8 -3
- data/scripts/test/test-studio-api-contract.rb +70 -0
- data/scripts/test/test-studio-pipeline-focus.mjs +308 -0
- data/scripts/validate.sh +5 -0
- data/studio/assets/{index-CMVzh8F1.js → index-BJyN-kB3.js} +98 -98
- data/studio/index.html +1 -1
- data/studio-app/src/main.js +126 -32
- metadata +3 -2
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Bg=Object.defineProperty;var _g=(t,e,n)=>e in t?Bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ce=(t,e,n)=>_g(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 zg="modulepreload",Fg=function(t){return"/studio/"+t},Oc={},Hg=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=Fg(c),c in Oc)return;Oc[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":zg,u||(p.as="script"),p.crossOrigin="",p.href=c,a&&p.setAttribute("nonce",a),document.head.appendChild(p),u)return new Promise((m,g)=>{p.addEventListener("load",m),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 jg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pe={},Bi={},Kt={},Lc;function gi(){if(Lc)return Kt;Lc=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 Kt.isNothing=t,Kt.isObject=e,Kt.toArray=n,Kt.repeat=i,Kt.isNegativeZero=o,Kt.extend=r,Kt}var _s,Ic;function yi(){if(Ic)return _s;Ic=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
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)},
|
|
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)},_s=e,_s}var zs,Rc;function Vg(){if(Rc)return zs;Rc=1;const t=gi();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,m=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]),m);d=t.repeat(" ",o.indent)+n((i.line-b+1).toString(),p)+" | "+x.str+`
|
|
4
4
|
`+d}const g=e(i.buffer,l[u],a[u],i.position,m);d+=t.repeat(" ",o.indent)+n((i.line+1).toString(),p)+" | "+g.str+`
|
|
5
5
|
`,d+=t.repeat("-",o.indent+p+3+g.pos)+`^
|
|
6
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]),m);d+=t.repeat(" ",o.indent)+n((i.line+b+1).toString(),p)+" | "+x.str+`
|
|
7
|
-
`}return d.replace(/\n$/,"")}return
|
|
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 m=0;m<a;m++)m%4===0&&m&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(l.charAt(m));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
|
|
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]=
|
|
10
|
-
`,S-1))}function
|
|
7
|
+
`}return d.replace(/\n$/,"")}return zs=r,zs}var Fs,Dc;function Ke(){if(Dc)return Fs;Dc=1;const t=yi(),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 Fs=i,Fs}var Hs,Pc;function hf(){if(Pc)return Hs;Pc=1;const t=yi(),e=Ke();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},Hs=i,Hs}var js,$c;function mf(){if($c)return js;$c=1;const t=Ke();return js=new t("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),js}var Vs,Bc;function gf(){if(Bc)return Vs;Bc=1;const t=Ke();return Vs=new t("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Vs}var qs,_c;function yf(){if(_c)return qs;_c=1;const t=Ke();return qs=new t("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),qs}var Us,zc;function bf(){if(zc)return Us;zc=1;const t=hf();return Us=new t({explicit:[mf(),gf(),yf()]}),Us}var Ws,Fc;function kf(){if(Fc)return Ws;Fc=1;const t=Ke();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 Ws=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"}),Ws}var Ks,Hc;function xf(){if(Hc)return Ks;Hc=1;const t=Ke();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 Ks=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"}),Ks}var Ys,jc;function Sf(){if(jc)return Ys;jc=1;const t=gi(),e=Ke();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 m=c[d];if((m==="-"||m==="+")&&(m=c[++d]),m==="0"){if(d+1===u)return!0;if(m=c[++d],m==="b"){for(d++;d<u;d++){if(m=c[d],m!=="0"&&m!=="1")return!1;p=!0}return p&&isFinite(s(c))}if(m==="x"){for(d++;d<u;d++){if(!n(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}if(m==="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 Ys=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"]}}),Ys}var Js,Vc;function wf(){if(Vc)return Js;Vc=1;const t=gi(),e=Ke(),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 Js=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:i,construct:o,predicate:a,represent:l,defaultStyle:"lowercase"}),Js}var Gs,qc;function Cf(){return qc||(qc=1,Gs=bf().extend({implicit:[kf(),xf(),Sf(),wf()]})),Gs}var Xs,Uc;function vf(){return Uc||(Uc=1,Xs=Cf()),Xs}var Zs,Wc;function Mf(){if(Wc)return Zs;Wc=1;const t=Ke(),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 m=+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,m,g,b,l));return a&&x.setTime(x.getTime()-a),x}function o(s){return s.toISOString()}return Zs=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:i,instanceOf:Date,represent:o}),Zs}var Qs,Kc;function Tf(){if(Kc)return Qs;Kc=1;const t=Ke();function e(n){return n==="<<"||n===null}return Qs=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Qs}var el,Yc;function Af(){if(Yc)return el;Yc=1;const t=Ke(),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 m=0;m<a;m++)m%4===0&&m&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(l.charAt(m));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 el=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:i}),el}var tl,Jc;function Ef(){if(Jc)return tl;Jc=1;const t=Ke(),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 tl=new t("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:i}),tl}var nl,Gc;function Nf(){if(Gc)return nl;Gc=1;const t=Ke(),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 nl=new t("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),nl}var rl,Xc;function Of(){if(Xc)return rl;Xc=1;const t=Ke(),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 rl=new t("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),rl}var il,Zc;function Oa(){return Zc||(Zc=1,il=vf().extend({implicit:[Mf(),Tf()],explicit:[Af(),Ef(),Nf(),Of()]})),il}var Qc;function qg(){if(Qc)return Bi;Qc=1;const t=gi(),e=yi(),n=Vg(),r=Oa(),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]/,m=/[\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 te(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 Q(f){return f>=48&&f<=57?f-48:-1}function ee(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]=ee(f)?1:0,Ee[f]=ee(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 jn(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 Is(f){f.anchorMapTransactions.push(Object.create(null))}function bn(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 Rs(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 br(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 Vn(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 Ei={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&&jn(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 Vt(f){f.totalMergeKeys++,f.maxTotalMergeKeys!==-1&&f.totalMergeKeys>f.maxTotalMergeKeys&&z(f,"merge keys exceeded maxTotalMergeKeys ("+f.maxTotalMergeKeys+")")}function kr(f,S,E,N){t.isObject(E)||z(f,"cannot merge mappings; the provided source object is unacceptable"),Vt(f);const M=Object.keys(E);for(let y=0,C=M.length;y<C;y+=1){const v=M[y];Vt(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)kr(f,S,y[I],E)}else kr(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 xr(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(xr(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&&jn(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 qn(f,S){S===1?f.result+=" ":S>1&&(f.result+=t.repeat(`
|
|
10
|
+
`,S-1))}function Ni(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),qn(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 Sr(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),qn(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 Oi(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=te(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),qn(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 Li(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 Wt=f.input.charCodeAt(f.position+1);$(Wt)&&(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 qt(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=Q(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(xr(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
11
|
`,M?1+v:v):N===c&&M&&(f.result+=`
|
|
12
12
|
`);break}E?R(D)?(O=!0,f.result+=t.repeat(`
|
|
13
13
|
`,M?1+v:v)):O?(O=!1,f.result+=t.repeat(`
|
|
14
14
|
`,v+1)):v===0?M&&(f.result+=" "):f.result+=t.repeat(`
|
|
15
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
|
|
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;)
|
|
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 Ii(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 Ri(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),Wt=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===Wt){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===Wt||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===Wt||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 Di(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 Pi(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 Ds(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 $i(f,S,E,N){const M=br(f);return Is(f),Vn(f,S),f.tag=null,f.anchor=null,f.kind=null,f.result=null,Ri(f,E,N)&&f.kind==="mapping"?(bn(f),!0):(Rs(f),Vn(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=br(f);if(O&&(K===33&&f.tag!==null||K===38&&f.anchor!==null)||!Di(f)&&!Pi(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&&(Ii(f,F)||Ri(f,F,B))||Li(f,B))I=!0;else{const K=f.input.charCodeAt(f.position);D!==null&&W&&!C&&K!==124&&K!==62&&$i(f,D,D.position-D.lineStart,B)||y&&qt(f,B)||Sr(f,B)||Oi(f,B)?I=!0:Ds(f)?(I=!0,(f.tag!==null||f.anchor!==null)&&z(f,"alias node should not have any properties")):Ni(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&&Ii(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 Ps(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&&xr(f),i.call(Ei,y)?Ei[y](f,y,C):jn(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&&m.test(f.input.slice(S,f.position))&&jn(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 wr(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;)Ps(E);return E.documents}function $s(f,S,E){S!==null&&typeof S=="object"&&typeof E>"u"&&(E=S,S=null);const N=wr(f,E);if(typeof S!="function")return N;for(let M=0,y=N.length;M<y;M+=1)S(N[M])}function Bs(f,S){const E=wr(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 Bi.loadAll=$s,Bi.load=Bs,Bi}var ol={},eu;function Ug(){if(eu)return ol;eu=1;const t=gi(),e=yi(),n=Oa(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,o=65279,s=9,l=10,a=13,c=32,u=33,d=34,p=35,m=37,g=38,b=39,x=42,w=44,T=45,R=58,$=61,Y=62,te=63,j=64,Q=91,ee=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 jn(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 Is=1,bn=2;function Rs(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=jn(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==='"'?bn:Is,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 br(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
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
|
|
20
|
-
`+t.repeat(" ",y.indent*C)}function
|
|
19
|
+
`&&(I+=v),I+=A}return I}function Vn(y,C){return`
|
|
20
|
+
`+t.repeat(" ",y.indent*C)}function Ei(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 Vt(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 kr(y){return Vt(y)&&y!==o&&y!==a&&y!==l}function Tt(y,C,v){const O=kr(y),I=O&&!Xe(y);return(v?O:O&&y!==w&&y!==Q&&y!==ee&&y!==Me&&y!==Ee)&&y!==p&&!(C===R&&!I)||kr(C)&&!Xe(C)&&y===p||C===R&&I}function xr(y){return Vt(y)&&y!==o&&!Xe(y)&&y!==T&&y!==te&&y!==R&&y!==w&&y!==Q&&y!==ee&&y!==Me&&y!==Ee&&y!==p&&y!==g&&y!==x&&y!==u&&y!==tt&&y!==$&&y!==Y&&y!==b&&y!==d&&y!==m&&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 qn(y){return/^\n* /.test(y)}const Ni=1,Sr=2,Oi=3,Li=4,qt=5;function Ii(y,C,v,O,I,D,A,B){let F,W=0,K=null,J=!1,X=!1;const Wt=O!==-1;let Cr=-1,vr=xr(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),!Vt(W))return qt;vr=vr&&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,Wt&&(X=X||F-Cr-1>O&&y[Cr+1]!==" ",Cr=F);else if(!Vt(W))return qt;vr=vr&&Tt(W,K,B),K=W}X=X||Wt&&F-Cr-1>O&&y[Cr+1]!==" "}return!J&&!X?vr&&!A&&!I(y)?Ni:D===bn?qt:Sr:v>9&&qn(y)?qt:A?D===bn?qt:Sr:X?Li:Oi}function Ri(y,C,v,O,I){y.dump=(function(){if(C.length===0)return y.quotingType===bn?'""':"''";if(!y.noCompatMode&&(De.indexOf(C)!==-1||z.test(C)))return y.quotingType===bn?'"'+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 Ei(y,W)}switch(Ii(C,B,y.indent,A,F,y.quotingType,y.forceQuotes&&!O,I)){case Ni:return C;case Sr:return"'"+C.replace(/'/g,"''")+"'";case Oi:return"|"+Di(C,y.indent)+Pi(br(C,D));case Li:return">"+Di(C,y.indent)+Pi(br(Ds(C,A),D));case qt:return'"'+Ut(C)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Di(y,C){const v=qn(y)?String(C):"",O=y[y.length-1]===`
|
|
21
21
|
`,D=O&&(y[y.length-2]===`
|
|
22
22
|
`||y===`
|
|
23
23
|
`)?"+":O?"":"-";return v+D+`
|
|
24
|
-
`}function
|
|
25
|
-
`?y.slice(0,-1):y}function
|
|
26
|
-
`);return B=B!==-1?B:y.length,v.lastIndex=B
|
|
24
|
+
`}function Pi(y){return y[y.length-1]===`
|
|
25
|
+
`?y.slice(0,-1):y}function Ds(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,$i(y.slice(0,B),C)})(),I=y[0]===`
|
|
27
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
|
-
`:"")
|
|
28
|
+
`:"")+$i(F,C),I=D}return O}function $i(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
29
|
`+y.slice(I,D),I=D+1),A=B;return F+=`
|
|
30
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&&
|
|
32
|
-
`:""}return
|
|
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=
|
|
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&&Vt(v)?(C+=y[O],v>=65536&&(C+=y[O+1])):C+=I||Mt(v)}return C}function Ps(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 wr(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+=Vn(y,C)),y.dump&&l===y.dump.charCodeAt(0)?I+="-":I+="- ",I+=y.dump)}y.tag=D,y.dump=I||"[]"}function $s(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 Bs(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+=Vn(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+=Vn(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?(Bs(y,C,y.dump,I),J&&(y.dump="&ref_"+K+y.dump)):($s(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?wr(y,C-1,y.dump,I):wr(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 String]")y.tag!=="?"&&Ri(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 Rs(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 ol.dump=M,ol}var tu;function Wg(){if(tu)return Pe;tu=1;const t=qg(),e=Ug();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=Ke(),Pe.Schema=hf(),Pe.FAILSAFE_SCHEMA=bf(),Pe.JSON_SCHEMA=Cf(),Pe.CORE_SCHEMA=vf(),Pe.DEFAULT_SCHEMA=Oa(),Pe.load=t.load,Pe.loadAll=t.loadAll,Pe.dump=e.dump,Pe.YAMLException=yi(),Pe.types={binary:Af(),float:wf(),map:yf(),null:kf(),pairs:Nf(),set:Of(),timestamp:Mf(),bool:xf(),int:Sf(),merge:Tf(),omap:Ef(),seq:gf(),str:mf()},Pe.safeLoad=n("safeLoad","load"),Pe.safeLoadAll=n("safeLoadAll","loadAll"),Pe.safeDump=n("safeDump","dump"),Pe}var Kg=Wg();const dn=jg(Kg),{Type:CT,Schema:vT,FAILSAFE_SCHEMA:MT,JSON_SCHEMA:TT,CORE_SCHEMA:AT,DEFAULT_SCHEMA:ET,load:NT,loadAll:OT,dump:LT,YAMLException:IT,types:RT,safeLoad:DT,safeLoadAll:PT,safeDump:$T}=dn;async function Yg(){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 Jg(dn.load(n))}}catch{}throw new Error("Could not load studio/schema.yml")}function Jg(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 Lf(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 If=async()=>null;function Gg(t){If=t}async function nt(t,e={}){const n=await If(),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 ze={session:()=>nt("session"),tree:t=>nt(`tree?path=${encodeURIComponent(t)}`),getFile:t=>nt(`file?path=${encodeURIComponent(t)}`),putFile:({path:t,content:e,message:n,sha:r})=>nt("file",{method:"PUT",body:JSON.stringify({path:t,content:e,message:n,sha:r})}),deleteFile:({path:t,message:e,sha:n})=>nt("file",{method:"DELETE",body:JSON.stringify({path:t,message:e,sha:n})}),listMedia:t=>nt(`media?path=${encodeURIComponent(t||"content/media")}`),uploadMedia:({path:t,content_base64:e,message:n})=>nt("media",{method:"POST",body:JSON.stringify({path:t,content_base64:e,message:n})}),createMediaFolder:({path:t,message:e})=>nt("media/folder",{method:"POST",body:JSON.stringify({path:t,message:e})}),searchXcite:t=>nt(`search/xcite?q=${encodeURIComponent(t||"")}`),searchCite:t=>nt(`search/cite?q=${encodeURIComponent(t||"")}`),rewrite:t=>nt("rewrite",{method:"POST",body:JSON.stringify(t)}),pipelineStatus:(t=null,e=null)=>{const n=new URLSearchParams;t&&n.set("sha",String(t)),e&&n.set("workflow",String(e));const r=n.toString();return nt(r?`pipeline-status?${r}`:"pipeline-status")}};function Rf(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=Df(r);return{fmLines:l,fm:a,body:s,hasFm:!0,rawFm:r,blankAfterFm:o}}function Df(t){try{const n=dn.load(t,{schema:dn.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 nu(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 ti(t){return!!(t===""||t==null||Array.isArray(t)&&t.length===0)}function Fl(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Xg(t){const e=String(t||"").replace(/\r\n/g,`
|
|
34
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
|
|
36
|
-
`):[`${t}: ${
|
|
37
|
-
`)}function
|
|
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 Hl(t,e){return Array.isArray(e)&&e.every(n=>n==null||typeof n!="object")?[`${t}:`,...e.map(n=>` - ${nu(n)}`)]:e&&typeof e=="object"?dn.dump({[t]:e},{schema:dn.JSON_SCHEMA,lineWidth:-1,noRefs:!0}).replace(/\n$/,"").split(`
|
|
36
|
+
`):[`${t}: ${nu(e)}`]}function Zg(t,e){const n={...t};for(const[i,o]of Object.entries(e||{}))ti(o)?ti(t[i])||delete n[i]:n[i]=o;const r=new Set([...Object.keys(t),...Object.keys(n)]);for(const i of r)if(!Fl(t[i],n[i]))return!0;return!1}function Qg(t,e){const n=Df(t),r={...n};for(const[u,d]of Object.entries(e||{}))ti(d)?ti(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=>Fl(n[u],r[u])))return String(t||"").replace(/\n$/,"");const l=Xg(t),a=new Set,c=[];for(const u of l)Object.prototype.hasOwnProperty.call(r,u.key)&&(a.add(u.key),Fl(n[u.key],r[u.key])?c.push(...u.lines):c.push(...Hl(u.key,r[u.key])));for(const[u,d]of Object.entries(r))a.has(u)||c.push(...Hl(u,d));return c.join(`
|
|
37
|
+
`)}function Pf(t,{fields:e,body:n,format:r}){if(r==="raw"||r==="yaml")return n.endsWith(`
|
|
38
38
|
`)?n:n+`
|
|
39
|
-
`;const i=
|
|
39
|
+
`;const i=Rf(t),{rawFm:o,hasFm:s,blankAfterFm:l}=i,a=String(n||"").replace(/^(?:\r?\n)+/,"");if(s&&!Zg(i.fm,e)&&a===String(i.body||"").replace(/^(?:\r?\n)+/,""))return t;const c=["---"];if(s){const m=Qg(o,e);m&&c.push(m)}else for(const[m,g]of Object.entries(e||{}))ti(g)||c.push(...Hl(m,g));c.push("---");const u=String(n||"").replace(/^(?:\r?\n)+/,""),d=u.endsWith(`
|
|
40
40
|
`)?u:u+`
|
|
41
41
|
`,p=l?`
|
|
42
42
|
|
|
43
43
|
`:`
|
|
44
44
|
`;return c.join(`
|
|
45
|
-
`)+p+d}var eu=Object.defineProperty,qg=(t,e)=>{let n={};for(var r in t)eu(n,r,{get:t[r],enumerable:!0});return eu(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 If(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&&Pf(s.charCodeAt(a-1))&&Df(s.charCodeAt(a))&&n--,n}if(i.content.size||o.content.size){let s=If(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Rf(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&&Pf(c.charCodeAt(d-1))&&Df(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=Rf(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Df(t){return t>=56320&&t<57344}function Pf(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 If(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Rf(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 so(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(!so(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!so(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ue=class zl{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&&so(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 zl.none;if(e instanceof zl)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=Bf(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 _($f(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 $f(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($f(o.content,e-i-1,n-i-1)))}function Bf(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=Bf(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 Wg(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 _f(t,e,n,0)}function _f(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=_f(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}=Kg(n,t);return En(o,Ff(t,s,l,e,r))}else return En(o,lo(t,e,r))}function zf(t,e){if(!e.type.compatibleContent(t.type))throw new ti("Cannot join "+e.type.name+" onto "+t.type.name)}function Fl(t,e,n){let r=t.node(n);return zf(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 Ff(t,e,n,r,i){let o=t.depth>i&&Fl(t,e,i+1),s=r.depth>i&&Fl(n,r,i+1),l=[];return _r(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(zf(o,s),An(En(o,Ff(t,e,n,r,i+1)),l)):(o&&An(En(o,lo(t,e,i+1)),l),_r(e,n,i,l),s&&An(En(s,lo(n,r,i+1)),l)),_r(r,null,i,l),new L(l)}function lo(t,e,n){let r=[];if(_r(null,t,n,r),t.depth>n){let i=Fl(t,e,n+1);An(En(i,lo(t,e,n+1)),r)}return _r(e,null,n,r),new L(r)}function Kg(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 ao(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=tu.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 tu.set(e,r=new Yg);let i=r.elts[r.i]=ni.resolve(e,n);return r.i=(r.i+1)%Jg,i}}class Yg{constructor(){this.elts=[],this.i=0}}const Jg=12,tu=new WeakMap;class ao{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 Gg=Object.create(null);let Nn=class Hl{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&&so(this.attrs,n||e.defaultAttrs||Gg)&&ue.sameSet(this.marks,r||ue.none)}copy(e=null){return e==this.content?this:new Hl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Hl(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 Wg(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()+")"),Hf(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),nu(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];nu(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 co 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):Hf(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 co(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new co(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 Hf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function nu(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 Xg(e,n);if(r.next==null)return In.empty;let i=jf(r);r.next&&r.err("Unexpected trailing text");let o=iy(ry(i));return oy(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 Xg{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 jf(t){let e=[];do e.push(Zg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Zg(t){let e=[];do e.push(Qg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Qg(t){let e=ny(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=ey(t,e);else break;return e}function ru(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function ey(t,e){let n=ru(t),r=n;return t.eat(",")&&(t.next!="}"?r=ru(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function ty(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 ny(t){if(t.eat("(")){let e=jf(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=ty(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 ry(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 Vf(t,e){return e-t}function iu(t,e){let n=[];return r(e),n.sort(Vf);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 iy(t){let e=Object.create(null);return n(iu(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]);iu(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(Vf);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function oy(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 Uf(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 qf(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 Wf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ly(t,r,e[r]);return n}let ou=class Kf{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=Wf(e,r.attrs),this.defaultAttrs=Uf(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:qf(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 Kf(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 sy(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 ly{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?sy(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class is{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Wf(e,i.attrs),this.excluded=null;let o=Uf(this.attrs);this.instance=o?new ue(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ue(this,qf(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new is(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 Yf{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=ou.compile(this.spec.nodes,this),this.marks=is.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?su(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==""?[]:su(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 ou){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 co(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 su(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 ay(t){return t.tag!=null}function cy(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(ay(i))this.tags.push(i);else if(cy(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 au(this,n,!1);return r.addAll(e,ue.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new au(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(fy(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=cu(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=cu(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 Jf={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},uy={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Gf={ol:!0,ul:!0},ri=1,jl=2,zr=4;function lu(t,e,n){return e!=null?(e?ri:0)|(e==="full"?jl:0):t&&t.whitespace=="pre"?ri|jl: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&&!Jf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class au{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=lu(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&jl?"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;
|
|
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):uu(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=lu(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):uu(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 dy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Gf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function fy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cu(t){let e={};for(let n in t)e[n]=t[n];return e}function uu(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}=Zi(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&&Zi(zi(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Zi(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=du(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return du(e.marks)}}function du(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 fu=new WeakMap;function py(t){let e=fu.get(t);return e===void 0&&fu.set(t,e=hy(t)),e}function hy(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 Zi(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=py(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:m,contentDOM:g}=Zi(t,p,n,r);if(a.appendChild(m),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const Xf=65535,Zf=Math.pow(2,16);function my(t,e){return t+e*Zf}function pu(t){return t&Xf}function gy(t){return(t-(t&Xf))/Zf}const Qf=1,ep=2,Qi=4,tp=8;class Vl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&tp)>0}get deletedBefore(){return(this.delInfo&(Qf|Qi))>0}get deletedAfter(){return(this.delInfo&(ep|Qi))>0}get deletedAcross(){return(this.delInfo&Qi)>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=pu(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+gy(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,m=a+i+(p<0?0:u);if(r)return m;let g=e==(n<0?a:d)?null:my(l/3,e-a),b=0;return c&&(b|=e==a?ep:e==d?Qf:Qi,(n<0?e!=a:e!=d)&&(b|=tp)),new Vl(m,b,g)}i+=u-c}return r?e+i:new Vl(e+i,0,null)}touches(e,n){let r=0,i=pu(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 Vl(e,i,null)}}const sl=Object.create(null);class He{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 Ea(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(Ea(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return L.fromArray(r)}class en extends He{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 _(Ea(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))}}He.jsonID("addMark",en);class dt extends He{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 _(Ea(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))}}He.jsonID("removeMark",dt);class tn extends He{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))}}He.jsonID("addNodeMark",tn);class Rn extends He{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))}}He.jsonID("removeNodeMark",Rn);class me extends He{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Ul(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;He.jsonID("replace",me);class Te extends He{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&&(Ul(e,this.from,this.gapFrom)||Ul(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)}}He.jsonID("replaceAround",Te);function Ul(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 yy(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),m=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=m:i.push(s=new dt(p,m,d[b])));l&&l.to==p?l.to=m:o.push(l=new en(p,m,r))}}),i.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function by(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 is){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 m=0;m<i.length;m++){let g=i[m];g.step==o-1&&d.eq(i[m].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 Na(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,m=/\r?\n|\r/g,g;for(;p=m.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 ky(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||!ky(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function xy(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,m=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)),m++):c++;t.step(new Te(a,c,s,l,new _(u.append(p),d,m),u.size-d,!0))}function Oa(t,e,n=null,r=t){let i=Sy(t,e),o=i&&wy(r,e);return o?i.map(hu).concat({type:e,attrs:n}).concat(o.map(hu)):null}function hu(t){return{type:t,attrs:null}}function Sy(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 wy(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 Cy(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 vy(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)&&My(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",g=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!g?c=!1:!m&&g&&(c=!0)}c===!1&&rp(t,s,l,o),Na(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&&np(t,s,l,o),!1}})}function np(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 rp(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 My(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Ty(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 m=d.content.cutByIndex(p,d.childCount),g=r&&r[u+1];g&&(m=m.replaceChild(0,g.type.create(g.attrs)));let b=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!b.type.validContent(m))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 Ay(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 ip(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ey(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 ip(t,e){return!!(t&&e&&!t.isLeaf&&Ey(t,e))}function ss(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&&ip(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 Ny(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);rp(t,u.node(),u.before(),l)}s.inlineContent&&Na(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);np(t,u.node(),u.before(),t.steps.length)}return t}function Oy(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 op(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 ls(t,e,n=e,r=_.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return sp(i,o,r)?new me(e,n,r):new Ly(i,o,r).fit()}function sp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Ly{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=mu(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 gu(e,-1)<=n?!1:(this.unplaced.size>1&&gu(e,1)>r&&r++,this.unplaced=new _(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=mu(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 m=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(lp(b.mark(p.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?m:-1)))}let g=c==l.childCount;g||(m=-1),this.placed=Rr(this.placed,n,L.from(u)),this.frontier[n].match=d,g&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,x=l;b<m;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,m<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 mu(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function lp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,lp(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&&!Iy(n,o.content,s)?l:null}function Iy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Ry(t){return t.spec.defining||t.spec.definingForContent}function gu(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 Dy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(sp(i,o,r))return t.step(new me(e,n,r));let s=cp(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let g=i.node(p).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;s.indexOf(p)>-1?l=p:i.before(p)==m&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,m=0;;m++){let g=p.firstChild;if(c.push(g),m==r.openStart)break;p=g.content}for(let p=u-1;p>=0;p--){let m=c[p],g=Ry(m.type);if(g&&!m.sameMarkup(i.node(Math.abs(l)-1)))u=p;else if(g||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+u+1)%(r.openStart+1),g=c[m];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 _(ap(r.content,0,r.openStart,m),m,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 m=s[p];m<0||(e=i.before(m),n=o.after(m))}}function ap(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(ap(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 Py(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Oy(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new _(L.from(r),0,0))}function $y(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=cp(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 cp(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 He{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)}}He.jsonID("attr",er);class oi extends He{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)}}He.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 up{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=ls(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 Dy(this,e,n,r),this}replaceRangeWith(e,n,r){return Py(this,e,n,r),this}deleteRange(e,n){return $y(this,e,n),this}lift(e,n){return xy(this,e,n),this}join(e,n=1){return Ny(this,e,n),this}wrap(e,n){return Cy(this,e,n),this}setBlockType(e,n=e,r,i=null){return vy(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Ty(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 Ay(this,e,n,r),this}addMark(e,n,r){return yy(this,e,n,r),this}removeMark(e,n,r){return by(this,e,n,r),this}clearIncompatible(e,n,r){return Na(this,e,n,r),this}}const al=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new By(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&&ku(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),ku(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()}}X.prototype.visible=!0;class By{constructor(e,n){this.$from=e,this.$to=n}}let yu=!1;function bu(t){!yu&&!t.parent.inlineContent&&(yu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class q extends X{constructor(e,n=e){bu(e),bu(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 X.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 as(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=X.findFrom(n,r,!0)||X.findFrom(n,-r,!0);if(o)n=o.$head;else return X.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new q(e,n)}}X.jsonID("text",q);class as{constructor(e,n){this.anchor=e,this.head=n}map(e){return new as(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends X{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?X.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 La(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;X.jsonID("node",U);class La{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new as(r,r):new La(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&U.isSelectable(r)?new U(n):X.near(n)}}class Qe extends X{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=X.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}}X.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 ku(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(X.near(t.doc.resolve(s),n))}const xu=1,Fi=2,Su=4;class zy extends up{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|xu)&~Fi,this.storedMarks=null,this}get selectionSet(){return(this.updated&xu)>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(X.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|=Su,this}get scrolledIntoView(){return(this.updated&Su)>0}}function wu(t,e){return!e||!t?t:t.bind(e)}class Dr{constructor(e,n,r){this.name=e,this.init=wu(n.init,r),this.apply=wu(n.apply,r)}}const Fy=[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||X.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=Fy.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 zy(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=X.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 dp(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=dp(i,e,{})),n[r]=i}return n}class fe{constructor(e){this.spec=e,this.props={},e.props&&dp(e.props,this,this.props),this.key=e.key?e.key.key:fp("plugin")}getState(e){return e[this.key]}}const ul=Object.create(null);function fp(t){return t in ul?t+"$"+ ++ul[t]:(ul[t]=0,t+"$")}class xe{constructor(e="key"){this.key=fp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const pp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function hp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const mp=(t,e,n)=>{let r=hp(t,n);if(!r)return!1;let i=Ia(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(vp(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=ls(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")?X.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},Hy=(t,e,n)=>{let r=hp(t,n);if(!r)return!1;let i=Ia(r);return i?gp(t,i,e):!1},jy=(t,e,n)=>{let r=bp(t,n);if(!r)return!1;let i=Ra(r);return i?gp(t,i,e):!1};function gp(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=ls(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 yp=(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=Ia(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 Ia(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 bp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const kp=(t,e,n)=>{let r=bp(t,n);if(!r)return!1;let i=Ra(r);if(!i)return!1;let o=i.nodeAfter;if(vp(t,i,e,1))return!0;if(r.parent.content.size==0&&(or(o,"start")||U.isSelectable(o))){let s=ls(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")?X.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},xp=(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=Ra(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 Ra(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 Vy=(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=ss(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},Uy=(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=ss(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},qy=(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)},Sp=(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 Da(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 Wy=(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=Da(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(X.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},wp=(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=Da(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},Cp=(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 Ky(t){return(e,n)=>{if(e.selection instanceof U&&e.selection.node.isBlock){let{$from:m}=e.selection;return!m.parentOffset||!_t(e.doc,m.pos)?!1:(n&&n(e.tr.split(m.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 m=i.depth;;m--)if(i.node(m).isBlock){c=i.end(m)==i.pos+(i.depth-m),u=i.start(m)==i.pos-(i.depth-m),a=Da(i.node(m-1).contentMatchAt(i.indexAfter(m-1))),s.unshift(c&&a?{type:a}:null),l=m;break}else{if(m==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 m=r.mapping.slice(o),g=m.map(i.before(l)),b=r.doc.resolve(g);a&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,a)&&r.setNodeMarkup(m.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const Yy=Ky(),Jy=(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 Gy(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 vp(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Gy(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 m=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,m,e.pos,m,new _(g,1,0),s.length,!0)),x=b.doc.resolve(m+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:X.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 m=i,g=[];for(;g.push(m),!m.isTextblock;)m=m.lastChild;let b=o,x=1;for(;!b.isTextblock;b=b.firstChild)x++;if(m.canReplace(m.childCount,m.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 Mp(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 Xy=Mp(-1),Zy=Mp(1);function Qy(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&Oa(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Cu(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 Pa(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Pa(pp,mp,yp);Pa(pp,kp,xp);Pa(Sp,wp,Cp,Yy);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function eb(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 tb(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function tb(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 ao(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ao(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Oa(o,n,r,e);return l?(t&&nb(t,e,l,i,n),!0):!1}function nb(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 rb(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?ib(e,n,t,o):ob(e,n,o):!0:!1}}function ib(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 ao(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 ob(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,g=n.endIndex-1,b=n.startIndex;g>b;g--)m-=i.child(g).nodeSize,r.delete(m-1,m+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 sb(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,m=o.end;n(e.tr.step(new Te(p-(c?3:1),m,p,m,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 ql=null;const It=function(t,e,n){let r=ql||(ql=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},lb=function(){ql=null},Dn=function(t,e,n,r){return n&&(vu(t,e,n,r,-1)||vu(t,e,n,r,1))},ab=/^(img|br|input|textarea|hr)$/i;function vu(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)||ab.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 cb(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 ub(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 db(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 cs=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 fb(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pb(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,Mu=typeof document<"u"?document:null,mn=wt&&wt.userAgent||"",Wl=/Edge\/(\d+)/.exec(mn),Tp=/MSIE \d/.exec(mn),Kl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mn),Je=!!(Tp||Kl||Wl),rn=Tp?document.documentMode:Kl?+Kl[1]:Wl?+Wl[1]:0,et=!Je&&/gecko\/(\d+)/i.test(mn);et&&+(/Firefox\/(\d+)/.exec(mn)||[0,0])[1];const Yl=!Je&&/Chrome\/(\d+)/.exec(mn),Re=!!Yl,Ap=Yl?+Yl[1]:0,Fe=!Je&&!!wt&&/Apple Computer/.test(wt.vendor),lr=Fe&&(/Mobile\/\w+/.test(mn)||!!wt&&wt.maxTouchPoints>2),st=lr||(wt?/Mac/.test(wt.platform):!1),Ep=wt?/Win/.test(wt.platform):!1,Dt=/Android \d/.test(mn),us=!!Mu&&"webkitFontSmoothing"in Mu.documentElement.style,hb=us?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mb(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 gb(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 Tu(t,e,n){if(!Jl(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?mb(o):gb(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,m=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let g=s.scrollLeft-p,b=s.scrollTop-m;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 yb(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:Np(t.dom)}}function Np(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 bb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Op(n,r==0?0:r-e)}function Op(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 kb(t){if(t.setActive)return t.setActive();if(Un)return t.focus(Un);let e=Np(t);t.focus(Un==null?{get preventScroll(){return Un={preventScroll:!0},!0}}:void 0),Un||(Un=!1,Op(e,0))}function Lp(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 m=0;m<p.length;m++){let g=p[m];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)?xb(n,i):!n||r?{node:t,offset:o}:Lp(n,i)}function xb(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&&$a(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 $a(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Sb(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function wb(t,e,n){let{node:r,offset:i}=Lp(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 Cb(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 Ip(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($a(e,c))return Ip(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function vb(t,e){let n=t.dom.ownerDocument,r,i=0,o=pb(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(!$a(e,c)||(s=Ip(t.dom,e,c),!s))return null}if(Fe)for(let c=s;r&&c;c=sr(c))c.draggable&&(r=void 0);if(s=Sb(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;us&&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=Cb(t,r,i,e))}l==null&&(l=wb(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Jl(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(Jl(r))return r}return Array.prototype.find.call(n,Jl)||t.getBoundingClientRect()}const Mb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rp(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=us||et;if(we(r))if(s&&(Mb.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 Dp(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 Tb(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Dp(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=Rp(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 Ab=/[\u0590-\u08ac]/;function Eb(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?!Ab.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:Dp(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:g,focusOffset:b}=t.domSelectionRange(),x=g&&!Pn(m,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 Au=null,Eu=null,Nu=!1;function Nb(t,e,n){return Au==e&&Eu==n?Nu:(Au=e,Eu=n,Nu=n=="up"||n=="down"?Tb(t,e,n):Eb(t,e,n))}const lt=0,Ou=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=lt,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 $p||o instanceof Pp&&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 m=0,g=0;m<this.children.length;m++){let b=this.children[m],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||Fe)&&e==n){let{node:m,offset:g}=l;if(we(m)){if(d=!!(g&&m.nodeValue[g-1]==`
|
|
51
|
-
`),d&&g==m.nodeValue.length)for(let b=m,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=m.childNodes[g-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(et&&u.focusNode&&u.focusNode!=a.node&&V(u.focusNode)){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||d&&Fe)&&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 m=document.createRange();m.setEnd(a.node,a.offset),m.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(m)}}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:Ou,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:Ou;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Pp 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==lt&&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 Ob 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!=lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=lt}}slice(e,n,r){let i=on.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Xl(o,n,s,r)),e>0&&(o=Xl(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=zp(u,r,n),c?a=new Lb(e,n,r,i,u,d||null,p,c):n.isText?new ds(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==lt&&e.eq(this.node)&&uo(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 Rb(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;$b(this.node,this.innerDeco,(d,p,m)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!m&&a.syncToMarks(p==this.node.childCount?ue.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,i)},(d,p,m,g)=>{a.syncToMarks(d.marks,r,e,g),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let b;a.findNodeMatch(d,p,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(b=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(d,p,m,b,e)||a.updateNextNode(d,p,m,e,g,i)||a.addNode(d,p,m,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),Bp(this.contentDOM,this.children,e),lr&&Bb(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 Ob(this,o,n,i);e.input.compositionNodes.push(s),this.children=Xl(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=lt}updateOuterDeco(e){if(uo(e,this.outerDeco))return;let n=!V(this.nodeDOM),r=this.dom;this.dom=_p(this.dom,this.nodeDOM,Gl(this.outerDeco,this.node,n),Gl(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 Lu(t,e,n,r,i){zp(r,e,t);let o=new sn(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class ds 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!=lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=lt||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=lt,!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 ds(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 $p extends bi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Lb 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 Bp(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=Iu(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof on){let a=r?r.previousSibling:t.lastChild;Bp(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Iu(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 Gl(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 _p(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}Ib(i,l||Cn[0],s)}return i}function Ib(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 zp(t,e,n){return _p(t,t,Cn,Gl(e,n,!V(t)))}function uo(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 Iu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Rb{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Db(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=lt,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&&uo(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=lt),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)||!uo(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 Pp(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 ds)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Fe||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 $p(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 Db(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 Pb(t,e){return t.type.side-e.type.side}function $b(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(Pb);for(let x=0;x<d.length;x++)n(d[x],c,!!a)}else n(u,c,!!a);let p,m;if(a)m=-1,p=a,a=null;else if(c<t.childCount)m=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,m=-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),m),o=g}}function Bb(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 Xl(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 Ba(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(cs(n)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&U.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&db(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=X.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 m=0;m<n.rangeCount;m++){let g=n.getRangeAt(m);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=_a(t,u,l,d)}return c}function Fp(t){return t.editable?t.hasFocus():jp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function zt(t,e=!1){let n=t.state.selection;if(Hp(t,n),!Fp(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)Fb(t);else{let{anchor:i,head:o}=n,s,l;Ru&&!(n instanceof q)&&(n.$from.parent.inlineContent||(s=Du(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Du(t,n.to))),t.docView.setSelection(i,o,t,e),Ru&&(s&&Pu(s),l&&Pu(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&zb(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Ru=Fe||Re&&Ap<63;function Du(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(Fe&&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",Fe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Pu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function zb(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(()=>{(!Fp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Fb(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&&Je&&rn<=11&&(n.disabled=!0,n.disabled=!1)}function Hp(t,e){if(e instanceof U){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($u(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $u(t)}function $u(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function _a(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||q.between(e,n,r)}function Bu(t){return t.editable&&!t.hasFocus()?!1:jp(t)}function jp(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 Hb(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 Zl(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&&X.findFrom(o,e)}function Jt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function _u(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=Zl(t.state,e);return i&&i instanceof U?Jt(t,i):!1}else if(!(st&&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=Zl(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?jb(t):Vb(t)}function jb(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(Vp(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?Ql(t,n,r):i&&Ql(t,i,o)}function Vb(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(Vp(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&&Ql(t,o,s)}function Vp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ub(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 qb(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 Ql(t,e,n){if(!we(e)){let o,s;(s=Ub(e,n))?(e=s,n=0):(o=qb(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(cs(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 zu(t,e){let n=t.state.doc.resolve(e);if(!(Re||Ep)&&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 Fu(t,e,n){let r=t.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||st&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Zl(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?X.near(s,e):X.findFrom(s,e);return l?Jt(t,l):!1}return!1}function Hu(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 ju(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Wb(t){if(!Fe||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;ju(t,r,"true"),setTimeout(()=>ju(t,r,"false"),20)}return!1}function Kb(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Yb(t,e){let n=e.keyCode,r=Kb(e);if(n==8||st&&n==72&&r=="c")return Hu(t,-1)||qn(t,-1);if(n==46&&!e.shiftKey||st&&n==68&&r=="c")return Hu(t,1)||qn(t,1);if(n==13||n==27)return!0;if(n==37||st&&n==66&&r=="c"){let i=n==37?zu(t,t.state.selection.from)=="ltr"?-1:1:-1;return _u(t,i,r)||qn(t,i)}else if(n==39||st&&n==70&&r=="c"){let i=n==39?zu(t,t.state.selection.from)=="ltr"?1:-1:1;return _u(t,i,r)||qn(t,i)}else{if(n==38||st&&n==80&&r=="c")return Fu(t,-1,r)||qn(t,-1);if(n==40||st&&n==78&&r=="c")return Wb(t)||Fu(t,1,r)||qn(t,1);if(r==(st?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function za(t,e){t.someProp("transformCopied",m=>{e=m(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 m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||zn.fromSchema(t.state.schema),l=Jp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&V(c)&&(u=Yp[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let g=l.createElement(u[m]);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",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
|
|
52
|
-
|
|
53
|
-
`);return{dom:a,text:p,slice:e}}function
|
|
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:m}=t.state,g=zn.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=s.appendChild(document.createElement("p"));b&&x.appendChild(g.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=Zb(n),us&&Qb(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&&!Jb.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=e0(Vu(l,+u[1],+u[2]),u[4]);else if(l=_.maxOpen(Gb(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let m=l.content.firstChild;d<l.openStart&&!m.type.spec.isolating;d++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=Vu(l,d,p)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const Jb=/^(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 Gb(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&&Wp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Kp(s[s.length-1],o.length));let u=qp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return L.from(s)}return t}function qp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,L.from(t));return t}function Wp(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Wp(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(qp(n,t,i+1))))}}function Kp(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Kp(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(L.empty,!0);return t.copy(n.append(r))}function ea(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=ea(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 Vu(t,e,n){return e<t.openStart&&(t=new _(ea(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _(ea(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Yp={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 Jp(){return document.implementation.createHTMLDocument("title")}let Mr=null;function Xb(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 Zb(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Jp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&Yp[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Xb(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 Qb(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 e0(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 qe={},We={},t0={touchstart:!0,touchmove:!0};class n0{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 r0(t){for(let e in qe){let n=qe[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{o0(t,r)&&!Fa(t,r)&&(t.editable||!(r.type in We))&&n(t,r)},t0[e]?{passive:!0}:void 0)}Fe&&t.dom.addEventListener("input",()=>null),ta(t)}function Pt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function i0(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 ta(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Fa(t,r))})}function Fa(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function o0(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 s0(t,e){!Fa(t,e)&&qe[e.type]&&(t.editable||!(e.type in We))&&qe[e.type](t,e)}We.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Qp(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))||Yb(t,n)?n.preventDefault():Pt(t,"key")};We.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};We.keypress=(t,e)=>{let n=e;if(Qp(t)||!n.charCode||n.ctrlKey&&!n.altKey||st&&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 l0(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ha(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 a0(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 c0(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 u0(t,e,n,r,i){return Ha(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?c0(t,n):a0(t,n))}function d0(t,e,n,r){return Ha(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function f0(t,e,n,r){return Ha(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||p0(t,n,r)}function p0(t,e,n){if(n.button!=0)return!1;let r=Gp(t,e,!0),i=t.state.doc;return r?(xi(t,r),r instanceof q&&i.eq(t.state.doc)&&(t.input.mouseDown=new m0(t,r)),!0):!1}function Gp(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 ja(t){return fo(t)}const Xp=st?"metaKey":"ctrlKey";qe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ja(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&l0(n,t.input.lastClick)&&!n[Xp]&&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 h0(t,s,n,!!r):(o=="doubleClick"?d0:f0)(t,s.pos,s.inside,n)?n.preventDefault():Pt(t,"pointer"))};class Zp{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 h0 extends Zp{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[Xp],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"):u0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Fe&&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,X.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 m0 extends Zp{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&&Gp(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))}}qe.touchstart=t=>{t.input.lastTouch=Date.now(),ja(t),Pt(t,"pointer")};qe.touchmove=t=>{t.input.lastTouch=Date.now(),Pt(t,"pointer")};qe.contextmenu=t=>ja(t);function Qp(t,e){return t.composing?!0:Fe&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const g0=Dt?5e3:-1;We.compositionstart=We.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&&Ep&&y0(t)))t.markCursor=t.state.storedMarks||n.marks(),fo(t,!0),t.markCursor=null;else if(fo(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}eh(t,g0)};function y0(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"}We.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++,eh(t,20))};function eh(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>fo(t),e))}function th(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function b0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=cb(e.focusNode,e.focusOffset),r=ub(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 fo(t,e=!1){if(!(Dt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),th(t),e||t.docView&&t.docView.dirty){let n=Ba(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 k0(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=Je&&rn<15||lr&&hb<604;qe.copy=We.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}=za(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):k0(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function x0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function S0(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=Up(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=x0(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 nh(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," "):""}We.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,nh(r),r.getData("text/html"),i,n)?n.preventDefault():S0(t,n)};class rh{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const w0=st?"altKey":"ctrlKey";function ih(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[w0]}qe.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}=za(t,l);(!n.dataTransfer.files.length||!Re||Ap>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 rh(u,ih(t,n),s)};qe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};We.dragover=We.dragenter=(t,e)=>e.preventDefault();We.drop=(t,e)=>{try{C0(t,e,t.dragging)}finally{t.dragging=null}};function C0(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",m=>{o=m(o,t,!1)}):o=Up(t,nh(e.dataTransfer),si?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&ih(t,e));if(t.someProp("handleDrop",m=>m(t,e,o||_.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?op(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:m}=n;m?m.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 m=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,b,x,w)=>m=w),a.setSelection(_a(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}qe.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))};qe.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)};qe.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 We)qe[t]=We[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 po{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 Ve(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof po&&(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 Ve(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 Va{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 Ve(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 Va&&ai(this.attrs,e.attrs)&&ai(this.spec,e.spec)}destroy(){}}class Ve{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ve(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 Ve(e,e,new po(n,r))}static inline(e,n,r,i){return new Ve(e,n,new ln(r,i))}static node(e,n,r,i){return new Ve(e,n,new Va(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ln}get widget(){return this.type instanceof po}}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?ho(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?v0(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=sh(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,ho(u,l,c+1,On)),o+=3}});let s=oh(o?lh(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 Ua(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=Ua;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?Ua(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 v0(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,m,g,b)=>{let x=b-g-(m-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;m>=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),m=p-i,{index:g,offset:b}=r.content.findIndex(d),x=r.maybeChild(g);if(x&&b==d&&b+x.nodeSize==m){let w=l[c+2].mapInner(n,x,u+1,t[c]+o+1,s);w!=$e?(l[c]=d,l[c+1]=m,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=M0(l,t,e,n,i,o,s),u=ho(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 m=u.children[d];for(;p<l.length&&l[p]<m;)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 oh(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 Ve(i.from+e,i.to+e,i.type))}return n}function M0(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 sh(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 lh(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ho(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=sh(t,l,a+n);if(c){o=!0;let u=ho(c,l,n+a+1,r);u!=$e&&i.push(a,a+l.nodeSize,u)}});let s=oh(o?lh(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 Ua(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),Uu(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),Uu(e,i,r.copy(o.from,r.to)));break}}}return e}function Uu(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 T0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},A0=Je&&rn<=11;class E0{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 N0{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new E0,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]);Je&&rn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Fe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),A0&&(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,T0)),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(Bu(this.view)){if(this.suppressingSelectionUpdates)return zt(this.view);if(Je&&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)&&Bu(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 m=p.parentNode;m&&m.nodeName=="LI"&&(!d||I0(e,d)!=m)&&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&&cs(r)&&(c=Ba(e))&&c.eq(X.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),O0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,R0(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(Je&&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 qu=new WeakMap,Wu=!1;function O0(t){if(!qu.has(t)&&(qu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=et,Wu)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."),Wu=!0}}function Ku(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 L0(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Ku(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?Ku(t,n):null}function I0(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 R0(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 D0(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}],cs(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,m=t.someProp("domParser")||nn.fromSchema(t.state.schema),g=p.resolve(l),b=null,x=m.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:P0(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 P0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Fe&&/^(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||Fe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},$0=/^(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 B0(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=Ba(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=D0(t,e,n,i),u=t.state.doc,d=u.slice(c.from,c.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let g=H0(d.content,c.doc.content,c.from,p,m);if(g&&t.input.domChangeCount++,(lr&&t.input.lastIOSEnter>Date.now()-225||Dt)&&i.some(j=>V(j)&&!$0.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=Yu(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)),Je&&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&&F0(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&&z0(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,J=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=Yu(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)||Je&&te.empty&&te.head==R)&&ee.setSelection(te)}return o&&ee.setMeta("composition",o),ee.scrollIntoView()},ne;if(T)if(b.pos==x.pos){Je&&rn<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>zt(t),20));let j=J(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=J(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=()=>J(t.state.tr.insertText(j,R,$));t.someProp("handleTextInput",te=>te(t,R,$,j,ee))||t.dispatch(ee())}else t.dispatch(J());else t.dispatch(J())}function Yu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:_a(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 z0(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 F0(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 H0(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 ah{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 n0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qu),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=Xu(this),Gu(this),this.nodeViews=Zu(this),this.docView=Lu(this.state.doc,Ju(this),pl(this),this.dom,this),this.domObserver=new N0(this,(r,i,o,s)=>B0(this,r,i,o,s)),this.domObserver.start(),r0(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&&ta(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qu),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&&(th(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 m=Zu(this);V0(m,this.nodeViews)&&(this.nodeViews=m,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ta(this),this.editable=Xu(this),Gu(this);let a=pl(this),c=Ju(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&&yb(this);if(s){this.domObserver.stop();let m=d&&(Je||Re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&j0(i.selection,e.selection);if(d){let b=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=b0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Lu(e.doc,c,a,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(m=!0)}let g=this.input.mouseDown;m||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hb(this)&&g.delaySelUpdate())?zt(this,m):(Hp(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&&bb(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)&&Tu(this,n.getBoundingClientRect(),e)}else Tu(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 rh(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(Je){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&&kb(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 vb(this,e)}coordsAtPos(e,n=1){return Rp(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 Nb(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 za(this,e)}destroy(){this.docView&&(i0(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,lb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return s0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Fe&&this.root.nodeType===11&&fb(this.dom.ownerDocument)==this.dom&&L0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ah.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Ju(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"),[Ve.node(0,t.state.doc.content.size,e)]}function Gu(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:Ve.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Xu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function j0(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 Zu(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 V0(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 Qu(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:"'"},mo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},U0=typeof navigator<"u"&&/Mac/.test(navigator.platform),q0=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),mo[Le]=String.fromCharCode(Le);for(var ml in dn)mo.hasOwnProperty(ml)||(mo[ml]=dn[ml]);function W0(t){var e=U0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||q0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?mo: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 K0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Y0=typeof navigator<"u"&&/Win/.test(navigator.platform);function J0(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))K0?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 G0(t){let e=Object.create(null);for(let n in t)e[J0(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 X0(t){return new fe({props:{handleKeyDown:ch(t)}})}function ch(t){let e=G0(t);return function(n,r){let i=W0(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)&&!(Y0&&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 go=200,Ae=function(){};Ae.prototype.append=function(e){return e.length?(e=Ae.from(e),!this.length&&e||e.length<go&&this.leafAppend(e)||this.length<go&&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 Z0(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 uh(e):Ae.empty};var uh=(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<=go)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=go)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 uh([]);var Z0=(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 Q0=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 m=d.step.map(i.slice(o)),g;m&&s.maybeStep(m).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),m;(m=a&&a.merge(p))&&(p=m,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>tk&&(l=ek(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 m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let g=o.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),x=p.selection&&p.selection.map(o.slice(a+1,m));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()>Q0&&(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,m=i.length-1;(p=i.length&&i[m].merge(d))?i[m]=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 ek(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 tk=20;function nk(t,e,n,r){let i=n.getMeta(an),o;if(i)return i.historyState;n.getMeta(dh)&&(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,eo(e)),t.undone,ed(n.mapping.maps),t.prevTime,t.prevComposition):new Gt(t.done,t.undone.addTransform(n,void 0,r,eo(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||!rk(n,t.prevRanges)),c=s?yl(t.prevRanges,n.mapping):ed(n.mapping.maps);return new Gt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,eo(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 rk(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 ed(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 ik(t,e,n){let r=eo(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,td=null;function eo(t){let e=t.plugins;if(td!=e){bl=!1,td=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){bl=!0;break}}return bl}function ok(t){return t.setMeta(dh,!0)}const an=new xe("history"),dh=new xe("closeHistory");function sk(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 nk(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?ph:r=="historyRedo"?hh:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function fh(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=ik(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const ph=fh(!1,!0),hh=fh(!0,!0);function lk(t){return t.getMeta(an)!=null}function fs(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 mh{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,m])=>[p,(...b)=>{const x=this.buildProps(c,n),w=m(...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=mh.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:fs({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 ak=()=>({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),ck=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),uk=()=>({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)),m=d.blockRange(p);if(!m)return;const g=pr(m);if(l.type.isTextblock){const{defaultType:b}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(m.start,b)}(g||g===0)&&e.lift(m,g)})}),!0},dk=t=>e=>t(e),fk=()=>({state:t,dispatch:e})=>wp(t,e),pk=(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},hk=()=>({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 mk=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},gk=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},yk=t=>t.content?/^text(\*|\+)/.test(t.content):!1,nd=(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 yk(r)?n==="left"?t.start()-1:t.end()+1:t.pos},bk=(t,e,n)=>({from:nd(t,n,"left"),to:nd(e,n,"right")}),kk=()=>({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}=bk(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},xk=()=>({commands:t})=>t.keyboardShortcut("Enter"),Sk=()=>({state:t,dispatch:e})=>Wy(t,e);function qa(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function yo(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:qa(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function gh(t,e,n={}){return t.find(r=>r.type===e&&yo(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function rd(t,e,n={}){return!!gh(t,e,n)}function Wa(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(!gh([...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&&rd([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;s<t.parent.childCount&&rd([...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 wk=(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=Wa(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},Ck=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 yh(t){return t instanceof q}function vn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function na(t,e=null){if(!e)return null;const n=X.atStart(t),r=X.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 id(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function bo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function vk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Mk=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(bo()||id())&&r.dom.focus(),vk()&&!bo()&&!id()&&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&&!yh(n.state.selection))return s(),!0;const l=na(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},Tk=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Ak=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),bh=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&&bh(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 bh(n)}function kh(t){return typeof(t==null?void 0:t.nodesBetween)=="function"}function ar(t,e,n){if(kh(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 Yf({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 xh(t){return!("type"in t)}function Sh(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(X.near(t.doc.resolve(s),n))}const Ek=(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,m=!0;const g=xh(l)?l.content:[l];if(g.forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,m=m?x.isBlock:!1}),u===d&&m){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(""):kh(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&&$&&m&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&Sh(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 wh(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 Nk=(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=wh(a.parent.contentMatchAt(a.index()));if(!c)return!1;const u=Object.keys(c.spec.attrs||{}),d=o?Object.fromEntries(Object.entries(o).filter(([m])=>u.includes(m))):{};let p;if(s){const m=ar(s,r.schema);p=c.createAndFill(d,m)}else p=c.createAndFill(d);return p?(n&&(e.insert(a.pos,p),l&&Sh(e,e.steps.length-1,-1)),!0):!1},Ok=()=>({state:t,dispatch:e})=>Vy(t,e),Lk=()=>({state:t,dispatch:e})=>Uy(t,e),Ik=()=>({state:t,dispatch:e})=>mp(t,e),Rk=()=>({state:t,dispatch:e})=>kp(t,e),Ch=(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},Dk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ss(t.doc,t.selection.$from.pos,-1);return r==null||!Ch(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Pk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ss(t.doc,t.selection.$from.pos,1);return r==null||!Ch(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},$k=()=>({state:t,dispatch:e})=>Hy(t,e),Bk=()=>({state:t,dispatch:e})=>jy(t,e);function vh(){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))bo()||vh()?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 zk=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),m=Math.min(i,d+u.nodeSize);l.push({node:u,from:p,to:m})});const a=i-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>yo(u.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}const Fk=(t,e={})=>({state:n,dispatch:r})=>Ft(n,Ce(t,n.schema),e)?qy(n,r):!1,Hk=()=>({state:t,dispatch:e})=>Cp(t,e),jk=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return rb(r)(e,n)},Vk=()=>({state:t,dispatch:e})=>Sp(t,e);function ps(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function od(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 Uk=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const l=ps(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,od(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(od(p.attrs,e))))})})}),a},qk=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Wk=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qe(t.doc);t.setSelection(n)}return!0},Kk=()=>({state:t,dispatch:e})=>yp(t,e),Yk=()=>({state:t,dispatch:e})=>xp(t,e),Jk=()=>({state:t,dispatch:e})=>Jy(t,e),Gk=()=>({state:t,dispatch:e})=>Zy(t,e),Xk=()=>({state:t,dispatch:e})=>Xy(t,e);function ra(t,e,n={},r={}){return ar(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Zk=(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=ra(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});if(s){const u=xh(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 Mh(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 Th(t,e){const n=new up(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Qk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function ex(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 hs(t){return e=>ex(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 Ka(t){return t.map(e=>{const n=H(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Ka(n())]:e}).flat(10)}function Ya(t,e){const n=zn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function ia(t){return typeof t=="function"}function ie(t,e=void 0,...n){return ia(t)?e?t.bind(e)(...n):t(...n):t}function tx(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 Ah(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(m=>{Object.entries(d.attributes).forEach(([g,b])=>{e.push({type:m,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,m])=>{const g={...o,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:c.name,name:p,attribute:g})})}),e}function nx(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 sd(t){const e=[],n=nx(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([...sd(r[i]),...sd(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 rx(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ld(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):rx(n.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function ad(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&tx(n)?!1:n!=null))}function cd(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 ix(t,e){var n;const r=Ah(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=ad({...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(cd))}),m=ie(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(x=>ld(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=ad({...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(cd))}),m=ie(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(b=>ld(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 Yf({topNode:s,nodes:l,marks:a})}function ox(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 Eh(t){const e=jr(Ka(t)),n=ox(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 Nh(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 m;l+=a==null||(m=a.text)===null||m===void 0?void 0:m.slice(Math.max(r,c)-c,i-c)}}),l}function sx(t,e){return Nh(t,{from:0,to:t.content.size},e)}function Oh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function lx(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 Lh(t,e){const n=ps(typeof e=="string"?e:e.name,t.schema);return n==="node"?lx(t,e):n==="mark"?Mh(t,e):{}}function ax(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 cx(t){const e=ax(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 ms(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}})})}),cx(r)}function gs(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=Wa(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 ux=(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]},dx=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 to(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 fx=(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 oa(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=>yo(u.attrs,n,{strict:!1}));let s=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const p=u.pos,m=d.pos;t.doc.nodesBetween(p,m,(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(m,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=>yo(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 px(t,e,n={}){if(!e)return Ft(t,null,n)||oa(t,null,n);const r=ps(e,t.schema);return r==="node"?Ft(t,e,n):r==="mark"?oa(t,e,n):!1}const hx=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const o=hs(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)},mx=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function ud(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 Ih(t){return t instanceof U}var Rh=class Dh{constructor(e){this.position=e}static fromJSON(e){return new Dh(e.position)}toJSON(){return{position:this.position}}};function gx(t,e){const n=e.mapping.mapResult(t.position);return{position:new Rh(n.pos),mapResult:n}}function yx(t){return new Rh(t)}function bx(t,e,n){const{selection:r}=e;let i=null;if(yh(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 m=!p||p.type.allowsMarkType(n),g=!!n.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(n));c=m&&g}return!c}),c})}const kx=(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=Mh(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,m)=>{const g=Math.max(m,u),b=Math.min(m+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 bx(r,n,a)},xx=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Sx=(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})=>Cu(o,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Cu(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wx=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},Cx=(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},vx=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},Mx=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return sb(r)(e,n)};function dd(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 Tx=({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=to(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&&dd(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:wh(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=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,m);if(!m&&!w&&_t(b,x,1,p?[{type:p}]:void 0)&&(w=!0,m=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,m),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&&dd(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return w},Ax=(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 J=l.index(-1)?1:l.index(-2)?2:3;for(let Me=l.depth-J;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={...to(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-(J-1));n.replace(te,l.after(-ne),new _($,4-J,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 m=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...to(d,u.type.name,u.attrs),...e},b={...to(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=m?[{type:s,attrs:T},{type:m,attrs:b}]:[{type:s,attrs:T}];if(!_t(n.doc,l.pos,2))return!1;if(i){const{selection:$,storedMarks:J}=r,{splittableMarks:ne}=o.extensionManager,j=J||$.$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 fd(t){return!t||t==="1"?null:t}function Ph(t,e){return fd(t)===fd(e)}const xl=(t,e)=>{const n=hs(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))||!Ph(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(n.pos),!0},Sl=(t,e)=>{const n=hs(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))||!Ph(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(r),!0};function Ex(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 Nx=(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,m=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 J=hs(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=J??te,Me=!!J&&R.depth>=1&&R.depth-J.depth<=1,tt=!!te;if((Me||tt)&&ye){if(ye.node.type===m)return ne&&tt?a().command(({tr:Ee,dispatch:le})=>{const De=Ex(Ee);return De?(Ee.setSelection(De),le&&le(Ee),!0):!1}).liftListItem(g).run():c.liftListItem(g);if(kl(ye.node.type.name,d)&&m.validContent(ye.node.content))return a().command(()=>(o.setNodeMarkup(ye.pos,m),!0)).command(()=>xl(o,m)).command(()=>Sl(o,m)).run()}return!n||!$||!l?a().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>xl(o,m)).command(()=>Sl(o,m)).run():a().command(()=>{const Ee=u().wrapInList(m,r),le=$.filter(De=>p.includes(De.type.name));return o.ensureMarks(le),Ee?!0:c.clearNodes()}).wrapInList(m,r).command(()=>xl(o,m)).command(()=>Sl(o,m)).run()},Ox=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Ht(t,r.schema);return oa(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Lx=(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})},Ix=(t,e={})=>({state:n,commands:r})=>{const i=Ce(t,n.schema);return Ft(n,i,e)?r.lift(i):r.wrapIn(i,e)},Rx=()=>({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},Dx=(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},Px=(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:m}=s;const g=Wa(a,l,(d=a.marks().find(b=>b.type===l))===null||d===void 0?void 0:d.attrs);g&&(p=g.from,m=g.to),n.removeMark(p,m,l)}else u.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},$x=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},Bx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const l=ps(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,m,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,m=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,m=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}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.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),zx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return Qy(i,e)(n,r)},Fx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return eb(i,e)(n,r)};var Hx=qg({blur:()=>ak,clearContent:()=>ck,clearNodes:()=>uk,command:()=>dk,createParagraphNear:()=>fk,cut:()=>pk,deleteCurrentNode:()=>hk,deleteNode:()=>mk,deleteRange:()=>gk,deleteSelection:()=>kk,enter:()=>xk,exitCode:()=>Sk,extendMarkRange:()=>wk,first:()=>Ck,focus:()=>Mk,forEach:()=>Tk,insertContent:()=>Ak,insertContentAt:()=>Ek,insertDefaultBlock:()=>Nk,joinBackward:()=>Ik,joinDown:()=>Lk,joinForward:()=>Rk,joinItemBackward:()=>Dk,joinItemForward:()=>Pk,joinTextblockBackward:()=>$k,joinTextblockForward:()=>Bk,joinUp:()=>Ok,keyboardShortcut:()=>zk,lift:()=>Fk,liftEmptyBlock:()=>Hk,liftListItem:()=>jk,newlineInCode:()=>Vk,resetAttributes:()=>Uk,scrollIntoView:()=>qk,selectAll:()=>Wk,selectNodeBackward:()=>Kk,selectNodeForward:()=>Yk,selectParentNode:()=>Jk,selectTextblockEnd:()=>Gk,selectTextblockStart:()=>Xk,setContent:()=>Zk,setMark:()=>kx,setMeta:()=>xx,setNode:()=>Sx,setNodeSelection:()=>wx,setTextDirection:()=>Cx,setTextSelection:()=>vx,sinkListItem:()=>Mx,splitBlock:()=>Tx,splitListItem:()=>Ax,toggleList:()=>Nx,toggleMark:()=>Ox,toggleNode:()=>Lx,toggleWrap:()=>Ix,undoInputRule:()=>Rx,unsetAllMarks:()=>Dx,unsetMark:()=>Px,unsetTextDirection:()=>$x,updateAttributes:()=>Bx,updateDecorations:()=>_x,wrapIn:()=>zx,wrapInList:()=>Fx});const Tr=new WeakMap;function jx(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 Vx=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 Ux(t){return t.kind==="widget"}function $h(t,e){const n=[],r=new Set;for(const i of t)i.kind==="widget"&&Ux(i)&&r.add(i.key),n.push(i.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function qx(t,e,n){const{decorations:r,widgetKeys:i}=$h(e,n);return{set:re.create(t,r),widgetKeys:i}}function Bh({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function Wx({decorations:t,from:e,to:n,docSize:r,extensionName:i,warnedExtensions:o}){return t.filter(s=>Bh({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 Kx(t){var e;const n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function _h(t){return t.jsonID==="attr"}function Yx(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||_h(t))return!0;const n=t;return typeof n.from=="number"&&typeof n.to=="number"}function Jx(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 Gx(t,e){if(t.steps.some(o=>!Yx(o)))return{type:"full"};const n=ms(t).map(({newRange:o})=>o);t.steps.forEach((o,s)=>{if(!_h(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=Jx(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 zh(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 Xx(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:zh(o,n.mapping,n.doc,s),widgetKeys:s}}function pd(t,e){const n=Object.values(e).flatMap(r=>r.find());return re.create(t,n)}function hd(t){const e=new Set;for(const n of Object.values(t))for(const r of n)e.add(r);return e}function Zx(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 Qx(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}const eS=new Set;var tS=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})=>Zx(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:eS}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:hd(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 jx(t,()=>{for(const{name:p,spec:m}of e){const g=l||a===p;if(Qx(m,{editor:t,tr:n,oldState:i,newState:o},g))if(m.update==="changedRanges"&&n.docChanged&&!g){const b=this.applyChangedRangesRecompute(p,m,r,n,o);c[p]=b.set,u[p]=b.widgetKeys,d.add(p)}else{const{set:b,widgetKeys:x}=this.buildFullSet(p,m,o);c[p]=b,u[p]=x,d.add(p)}else{const b=Xx(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:hd(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=Gx(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=zh(a,r.mapping,r.doc,c);const d=i.doc.content.size;for(const{from:p,to:m}of o){const g=u.find(p,m).filter(w=>Bh({position:w.from,from:p,to:m,docSize:d}));for(const w of g){const T=Kx(w);T&&c.delete(T)}u=u.remove(g);const{decorations:b,widgetKeys:x}=$h(Wx({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:p,to:m})),from:p,to:m,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 qx(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]]:pd(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):pd(n.doc,r)}};function nS(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 rS(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 iS(t){return typeof t=="number"}function oS(t){return Object.prototype.toString.call(t).slice(8,-1)}function ji(t){return oS(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 md(t,e,n){const r=t.split(`
|
|
45
|
+
`)+p+d}var ru=Object.defineProperty,ey=(t,e)=>{let n={};for(var r in t)ru(n,r,{get:t[r],enumerable:!0});return ru(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 $f(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&&zf(s.charCodeAt(a-1))&&_f(s.charCodeAt(a))&&n--,n}if(i.content.size||o.content.size){let s=$f(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Bf(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&&zf(c.charCodeAt(d-1))&&_f(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=Bf(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function _f(t){return t>=56320&&t<57344}function zf(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 $f(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Bf(this,e,n,r)}findIndex(e){if(e==0)return _i(0,e);if(e==this.size)return _i(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?_i(n+1,o):_i(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 sl={index:0,offset:0};function _i(t,e){return sl.index=t,sl.offset=e,sl}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 jl{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 jl.none;if(e instanceof jl)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ue.none=[];class ni 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=Hf(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 _(Ff(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 Ff(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(Ff(o.content,e-i-1,n-i-1)))}function Hf(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=Hf(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 ty(t,e,n){if(n.openStart>t.depth)throw new ni("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ni("Inconsistent open depths");return jf(t,e,n,0)}function jf(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=jf(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 Nn(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=ny(n,t);return Nn(o,qf(t,s,l,e,r))}else return Nn(o,ao(t,e,r))}function Vf(t,e){if(!e.type.compatibleContent(t.type))throw new ni("Cannot join "+e.type.name+" onto "+t.type.name)}function Vl(t,e,n){let r=t.node(n);return Vf(r,e.node(n)),r}function En(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 zr(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&&(En(t.nodeAfter,r),o++));for(let l=o;l<s;l++)En(i.child(l),r);e&&e.depth==n&&e.textOffset&&En(e.nodeBefore,r)}function Nn(t,e){if(!t.type.validContent(e))throw new ni("Invalid content for node "+t.type.name);return t.copy(e)}function qf(t,e,n,r,i){let o=t.depth>i&&Vl(t,e,i+1),s=r.depth>i&&Vl(n,r,i+1),l=[];return zr(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(Vf(o,s),En(Nn(o,qf(t,e,n,r,i+1)),l)):(o&&En(Nn(o,ao(t,e,i+1)),l),zr(e,n,i,l),s&&En(Nn(s,ao(n,r,i+1)),l)),zr(r,null,i,l),new L(l)}function ao(t,e,n){let r=[];if(zr(null,t,n,r),t.depth>n){let i=Vl(t,e,n+1);En(Nn(i,ao(t,e,n+1)),r)}return zr(e,null,n,r),new L(r)}function ny(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 ri{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 ri(n,r,o)}static resolveCached(e,n){let r=iu.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 iu.set(e,r=new ry);let i=r.elts[r.i]=ri.resolve(e,n);return r.i=(r.i+1)%iy,i}}class ry{constructor(){this.elts=[],this.i=0}}const iy=12,iu=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 oy=Object.create(null);let On=class ql{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||oy)&&ue.sameSet(this.marks,r||ue.none)}copy(e=null){return e==this.content?this:new ql(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ql(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 ty(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 ri.resolveCached(this,e)}resolveNoCache(e){return ri.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()+")"),Uf(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),ou(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];ou(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)}};On.prototype.text=void 0;class uo extends On{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):Uf(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 Uf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function ou(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 Rn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new sy(e,n);if(r.next==null)return Rn.empty;let i=Wf(r);r.next&&r.err("Unexpected trailing text");let o=py(fy(i));return hy(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
|
+
`)}}Rn.empty=new Rn(!0);class sy{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 Wf(t){let e=[];do e.push(ly(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ly(t){let e=[];do e.push(ay(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ay(t){let e=dy(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=cy(t,e);else break;return e}function su(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function cy(t,e){let n=su(t),r=n;return t.eat(",")&&(t.next!="}"?r=su(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function uy(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 dy(t){if(t.eat("(")){let e=Wf(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=uy(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 fy(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 Kf(t,e){return e-t}function lu(t,e){let n=[];return r(e),n.sort(Kf);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 py(t){let e=Object.create(null);return n(lu(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]);lu(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Rn(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Kf);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function hy(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 Yf(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 Jf(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 Gf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new gy(t,r,e[r]);return n}let au=class Xf{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=Gf(e,r.attrs),this.defaultAttrs=Yf(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==Rn.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:Jf(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new On(this,this.computeAttrs(e),L.from(n),ue.setFrom(r))}createChecked(e=null,n,r){return n=L.from(n),this.checkContent(n),new On(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 On(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 Xf(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 my(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 gy{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?my(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=Gf(e,i.attrs),this.excluded=null;let o=Yf(this.attrs);this.instance=o?new ue(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ue(this,Jf(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 Zf{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=au.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]=Rn.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?cu(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==""?[]:cu(this,s.split(" "))}this.nodeFromJSON=i=>On.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 au){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 cu(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 yy(t){return t.tag!=null}function by(t){return t.style!=null}class rn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(yy(i))this.tags.push(i);else if(by(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 du(this,n,!1);return r.addAll(e,ue.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new du(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(Sy(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=fu(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=fu(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rn(e,rn.schemaRules(e)))}}const Qf={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},ky={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ep={ol:!0,ul:!0},ii=1,Ul=2,Fr=4;function uu(t,e,n){return e!=null?(e?ii:0)|(e==="full"?Ul:0):t&&t.whitespace=="pre"?ii|Ul:n&~Fr}class zi{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&Fr?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&ii)){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&&!Qf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class du{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=uu(null,n.preserveWhitespace,0)|(r?Fr:0);i?o=new zi(i.type,i.attrs,ue.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new zi(null,null,ue.none,!0,null,s):o=new zi(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&Ul?"full":this.localPreserveWS||(i.options&ii)>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;ep.hasOwnProperty(s)&&this.parser.normalizeLists&&xy(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ky.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(Qf.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):pu(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=uu(e,o,s.options);s.options&Fr&&s.content.length==0&&(l|=Fr);let a=ue.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):pu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zi(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|=ii)}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 xy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ep.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Sy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function fu(t){let e={};for(let n in t)e[n]=t[n];return e}function pu(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 Fn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fi(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 Fi(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Qi(Fi(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(Fi(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 Fn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hu(e.marks)}}function hu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fi(t){return t.document||window.document}const mu=new WeakMap;function wy(t){let e=mu.get(t);return e===void 0&&mu.set(t,e=Cy(t)),e}function Cy(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=wy(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:m,contentDOM:g}=Qi(t,p,n,r);if(a.appendChild(m),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const tp=65535,np=Math.pow(2,16);function vy(t,e){return t+e*np}function gu(t){return t&tp}function My(t){return(t-(t&tp))/np}const rp=1,ip=2,eo=4,op=8;class Wl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&op)>0}get deletedBefore(){return(this.delInfo&(rp|eo))>0}get deletedAfter(){return(this.delInfo&(ip|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=gu(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+My(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,m=a+i+(p<0?0:u);if(r)return m;let g=e==(n<0?a:d)?null:vy(l/3,e-a),b=0;return c&&(b|=e==a?ip:e==d?rp:eo,(n<0?e!=a:e!=d)&&(b|=op)),new Wl(m,b,g)}i+=u-c}return r?e+i:new Wl(e+i,0,null)}touches(e,n){let r=0,i=gu(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 oi{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 oi(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 oi;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 Wl(e,i,null)}}const ll=Object.create(null);class He{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=ll[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 ll)throw new RangeError("Duplicate use of step JSON ID "+e);return ll[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 ni)return ke.fail(o.message);throw o}}}function La(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(La(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return L.fromArray(r)}class tn extends He{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 _(La(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 tn(n.pos,r.pos,this.mark)}merge(e){return e instanceof tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tn(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 tn(n.from,n.to,e.markFromJSON(n.mark))}}He.jsonID("addMark",tn);class dt extends He{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 _(La(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 tn(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))}}He.jsonID("removeMark",dt);class nn extends He{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 nn(this.pos,n.marks[i]);return new nn(this.pos,this.mark)}}return new Dn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nn(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 nn(n.pos,e.markFromJSON(n.mark))}}He.jsonID("addNodeMark",nn);class Dn extends He{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 nn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Dn(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 Dn(n.pos,e.markFromJSON(n.mark))}}He.jsonID("removeNodeMark",Dn);class me extends He{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Kl(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;He.jsonID("replace",me);class Te extends He{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&&(Kl(e,this.from,this.gapFrom)||Kl(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)}}He.jsonID("replaceAround",Te);function Kl(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 Ty(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),m=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=m:i.push(s=new dt(p,m,d[b])));l&&l.to==p?l.to=m:o.push(l=new tn(p,m,r))}}),i.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function Ay(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 m=0;m<i.length;m++){let g=i[m];g.step==o-1&&d.eq(i[m].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 Ia(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,m=/\r?\n|\r/g,g;for(;p=m.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 Ey(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hr(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||!Ey(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function Ny(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,m=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)),m++):c++;t.step(new Te(a,c,s,l,new _(u.append(p),d,m),u.size-d,!0))}function Ra(t,e,n=null,r=t){let i=Oy(t,e),o=i&&Ly(r,e);return o?i.map(yu).concat({type:e,attrs:n}).concat(o.map(yu)):null}function yu(t){return{type:t,attrs:null}}function Oy(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 Ly(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 Iy(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 Ry(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)&&Dy(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",g=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!g?c=!1:!m&&g&&(c=!0)}c===!1&&lp(t,s,l,o),Ia(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&&sp(t,s,l,o),!1}})}function sp(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 lp(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 Dy(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Py(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 zt(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 m=d.content.cutByIndex(p,d.childCount),g=r&&r[u+1];g&&(m=m.replaceChild(0,g.type.create(g.attrs)));let b=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!b.type.validContent(m))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 $y(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 mn(t,e){let n=t.resolve(e),r=n.index();return ap(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function By(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 ap(t,e){return!!(t&&e&&!t.isLeaf&&By(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&&ap(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 _y(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);lp(t,u.node(),u.before(),l)}s.inlineContent&&Ia(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);sp(t,u.node(),u.before(),t.steps.length)}return t}function zy(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 cp(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 up(i,o,r)?new me(e,n,r):new Fy(i,o,r).fit()}function up(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Fy{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=bu(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 ku(e,-1)<=n?!1:(this.unplaced.size>1&&ku(e,1)>r&&r++,this.unplaced=new _(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=bu(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new _(Rr(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new _(Rr(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 m=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(dp(b.mark(p.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?m:-1)))}let g=c==l.childCount;g||(m=-1),this.placed=Dr(this.placed,n,L.from(u)),this.frontier[n].match=d,g&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,x=l;b<m;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 _(Rr(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new _(Rr(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||!al(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=al(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=al(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=Dr(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=Dr(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=Dr(this.placed,this.frontier.length,n))}}function Rr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Rr(t.firstChild.content,e-1,n)))}function Dr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Dr(t.lastChild.content,e-1,n)))}function bu(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function dp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,dp(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 al(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&&!Hy(n,o.content,s)?l:null}function Hy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function jy(t){return t.spec.defining||t.spec.definingForContent}function ku(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 Vy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(up(i,o,r))return t.step(new me(e,n,r));let s=pp(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let g=i.node(p).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;s.indexOf(p)>-1?l=p:i.before(p)==m&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,m=0;;m++){let g=p.firstChild;if(c.push(g),m==r.openStart)break;p=g.content}for(let p=u-1;p>=0;p--){let m=c[p],g=jy(m.type);if(g&&!m.sameMarkup(i.node(Math.abs(l)-1)))u=p;else if(g||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+u+1)%(r.openStart+1),g=c[m];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 _(fp(r.content,0,r.openStart,m),m,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 m=s[p];m<0||(e=i.before(m),n=o.after(m))}}function fp(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(fp(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 qy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=zy(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new _(L.from(r),0,0))}function Uy(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=pp(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 pp(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 tr extends He{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 tr(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 tr(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 tr(n.pos,n.attr,n.value)}}He.jsonID("attr",tr);class si extends He{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 si(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 si(n.attr,n.value)}}He.jsonID("docAttr",si);let or=class extends Error{};or=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};or.prototype=Object.create(Error.prototype);or.prototype.constructor=or;or.prototype.name="TransformError";class hp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new oi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new or(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 Vy(this,e,n,r),this}replaceRangeWith(e,n,r){return qy(this,e,n,r),this}deleteRange(e,n){return Uy(this,e,n),this}lift(e,n){return Ny(this,e,n),this}join(e,n=1){return _y(this,e,n),this}wrap(e,n){return Iy(this,e,n),this}setBlockType(e,n=e,r,i=null){return Ry(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Py(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new tr(e,n,r)),this}setDocAttribute(e,n){return this.step(new si(e,n)),this}addNodeMark(e,n){return this.step(new nn(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 Dn(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Dn(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 $y(this,e,n,r),this}addMark(e,n,r){return Ty(this,e,n,r),this}removeMark(e,n,r){return Ay(this,e,n,r),this}clearIncompatible(e,n,r){return Ia(this,e,n,r),this}}const cl=Object.create(null);class G{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Wy(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&&wu(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),wu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new U(e):Gn(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?Gn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Gn(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 Gn(e,e,0,0,1)||new Qe(e)}static atEnd(e){return Gn(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=cl[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 cl)throw new RangeError("Duplicate use of selection JSON ID "+e);return cl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class Wy{constructor(e,n){this.$from=e,this.$to=n}}let xu=!1;function Su(t){!xu&&!t.parent.inlineContent&&(xu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class U extends G{constructor(e,n=e){Su(e),Su(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 U(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 U&&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 U(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 U(e,n)}}G.jsonID("text",U);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 U.between(e.resolve(this.anchor),e.resolve(this.head))}}class q 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 q(o)}content(){return new _(L.from(this.node),0,0)}eq(e){return e instanceof q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Da(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new q(e.resolve(n.anchor))}static create(e,n){return new q(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}q.prototype.visible=!1;G.jsonID("node",q);class Da{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new cs(r,r):new Da(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&q.isSelectable(r)?new q(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 Ky}}G.jsonID("all",Qe);const Ky={map(){return this},resolve(t){return new Qe(t)}};function Gn(t,e,n,r,i,o=!1){if(e.inlineContent)return U.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&&q.isSelectable(l))return q.create(t,n-(i<0?l.nodeSize:0))}else{let a=Gn(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function wu(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 Cu=1,Hi=2,vu=4;class Yy extends hp{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|Cu)&~Hi,this.storedMarks=null,this}get selectionSet(){return(this.updated&Cu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hi,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&Hi)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Hi,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|=vu,this}get scrolledIntoView(){return(this.updated&vu)>0}}function Mu(t,e){return!e||!t?t:t.bind(e)}class Pr{constructor(e,n,r){this.name=e,this.init=Mu(n.init,r),this.apply=Mu(n.apply,r)}}const Jy=[new Pr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Pr("selection",{init(t,e){return t.selection||G.atStart(e.doc)},apply(t){return t.selection}}),new Pr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Pr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ul{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Jy.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 Pr(r.key,r.spec.state,r))})}}class Dt{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 Dt(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 Yy(this)}static create(e){let n=new ul(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Dt(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 ul(this.schema,e.plugins),r=n.fields,i=new Dt(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 ul(e.schema,e.plugins),o=new Dt(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=On.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 mp(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=mp(i,e,{})),n[r]=i}return n}class fe{constructor(e){this.spec=e,this.props={},e.props&&mp(e.props,this,this.props),this.key=e.key?e.key.key:gp("plugin")}getState(e){return e[this.key]}}const dl=Object.create(null);function gp(t){return t in dl?t+"$"+ ++dl[t]:(dl[t]=0,t+"$")}class xe{constructor(e="key"){this.key=gp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function bp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const kp=(t,e,n)=>{let r=bp(t,n);if(!r)return!1;let i=Pa(r);if(!i){let s=r.blockRange(),l=s&&hr(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Ep(t,i,e,-1))return!0;if(r.parent.content.size==0&&(sr(o,"end")||q.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(sr(o,"end")?G.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):q.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},Gy=(t,e,n)=>{let r=bp(t,n);if(!r)return!1;let i=Pa(r);return i?xp(t,i,e):!1},Xy=(t,e,n)=>{let r=wp(t,n);if(!r)return!1;let i=$a(r);return i?xp(t,i,e):!1};function xp(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(U.create(u.doc,o)),n(u.scrollIntoView())}return!0}function sr(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 Sp=(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=Pa(r)}let s=o&&o.nodeBefore;return!s||!q.isSelectable(s)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Pa(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 wp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Cp=(t,e,n)=>{let r=wp(t,n);if(!r)return!1;let i=$a(r);if(!i)return!1;let o=i.nodeAfter;if(Ep(t,i,e,1))return!0;if(r.parent.content.size==0&&(sr(o,"start")||q.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(sr(o,"start")?G.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):q.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},vp=(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=$a(r)}let s=o&&o.nodeAfter;return!s||!q.isSelectable(s)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,o.pos)).scrollIntoView()),!0)};function $a(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 Zy=(t,e)=>{let n=t.selection,r=n instanceof q,i;if(r){if(n.node.isTextblock||!mn(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(q.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Qy=(t,e)=>{let n=t.selection,r;if(n instanceof q){if(n.node.isTextblock||!mn(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},eb=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&hr(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},Mp=(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 Ba(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 tb=(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=Ba(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},Tp=(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=Ba(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(U.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ap=(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(zt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hr(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function nb(t){return(e,n)=>{if(e.selection instanceof q&&e.selection.node.isBlock){let{$from:m}=e.selection;return!m.parentOffset||!zt(e.doc,m.pos)?!1:(n&&n(e.tr.split(m.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof U||e.selection instanceof Qe)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,c=!1,u=!1;for(let m=i.depth;;m--)if(i.node(m).isBlock){c=i.end(m)==i.pos+(i.depth-m),u=i.start(m)==i.pos-(i.depth-m),a=Ba(i.node(m-1).contentMatchAt(i.indexAfter(m-1))),s.unshift(c&&a?{type:a}:null),l=m;break}else{if(m==1)return!1;s.unshift(null)}let d=i.pos,p=zt(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=zt(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&i.node(l).type!=a){let m=r.mapping.slice(o),g=m.map(i.before(l)),b=r.doc.resolve(g);a&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,a)&&r.setNodeMarkup(m.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const rb=nb(),ib=(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(q.create(t.doc,i))),!0)};function ob(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||mn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ep(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&ob(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 m=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,m,e.pos,m,new _(g,1,0),s.length,!0)),x=b.doc.resolve(m+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&mn(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&&hr(d);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(d,p).scrollIntoView()),!0;if(c&&sr(o,"start",!0)&&sr(i,"end")){let m=i,g=[];for(;g.push(m),!m.isTextblock;)m=m.lastChild;let b=o,x=1;for(;!b.isTextblock;b=b.firstChild)x++;if(m.canReplace(m.childCount,m.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 Np(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(U.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const sb=Np(-1),lb=Np(1);function ab(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&Ra(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Tu(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 _a(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}_a(yp,kp,Sp);_a(yp,Cp,vp);_a(Mp,Tp,Ap,rb);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function cb(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 ub(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ub(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=Ra(o,n,r,e);return l?(t&&db(t,e,l,i,n),!0):!1}function db(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&&zt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function fb(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?pb(e,n,t,o):hb(e,n,o):!0:!1}}function pb(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=hr(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return mn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function hb(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,g=n.endIndex-1,b=n.startIndex;g>b;g--)m-=i.child(g).nodeSize,r.delete(m-1,m+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 mb(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,m=o.end;n(e.tr.step(new Te(p-(c?3:1),m,p,m,d,1,!0)).scrollIntoView())}return!0}}const Oe=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},lr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Yl=null;const It=function(t,e,n){let r=Yl||(Yl=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},gb=function(){Yl=null},Pn=function(t,e,n,r){return n&&(Au(t,e,n,r,-1)||Au(t,e,n,r,1))},yb=/^(img|br|input|textarea|hr)$/i;function Au(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)||bi(t)||yb.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 $n(t,e){return e?t.contains(V(e)?e:e.parentNode):!1}function bb(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&&!bi(t))e=Oe(t),t=t.parentNode;else return null}}function kb(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&&!bi(t))e=Oe(t)+1,t=t.parentNode;else return null}}function xb(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 bi(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&&Pn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Sn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Sb(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function wb(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,Eu=typeof document<"u"?document:null,gn=wt&&wt.userAgent||"",Jl=/Edge\/(\d+)/.exec(gn),Op=/MSIE \d/.exec(gn),Gl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gn),Je=!!(Op||Gl||Jl),on=Op?document.documentMode:Gl?+Gl[1]:Jl?+Jl[1]:0,et=!Je&&/gecko\/(\d+)/i.test(gn);et&&+(/Firefox\/(\d+)/.exec(gn)||[0,0])[1];const Xl=!Je&&/Chrome\/(\d+)/.exec(gn),Re=!!Xl,Lp=Xl?+Xl[1]:0,Fe=!Je&&!!wt&&/Apple Computer/.test(wt.vendor),ar=Fe&&(/Mobile\/\w+/.test(gn)||!!wt&&wt.maxTouchPoints>2),st=ar||(wt?/Mac/.test(wt.platform):!1),Ip=wt?/Win/.test(wt.platform):!1,Pt=/Android \d/.test(gn),ds=!!Eu&&"webkitFontSmoothing"in Eu.documentElement.style,Cb=ds?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vb(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 Mb(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 Nu(t,e,n){if(!Zl(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=lr(s);continue}let l=s==o.body,a=l?vb(o):Mb(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,m=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let g=s.scrollLeft-p,b=s.scrollTop-m;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:lr(s)}}function Tb(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:Rp(t.dom)}}function Rp(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=lr(r));return e}function Ab({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Dp(n,r==0?0:r-e)}function Dp(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 Eb(t){if(t.setActive)return t.setActive();if(Un)return t.focus(Un);let e=Rp(t);t.focus(Un==null?{get preventScroll(){return Un={preventScroll:!0},!0}}:void 0),Un||(Un=!1,Dp(e,0))}function Pp(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 m=0;m<p.length;m++){let g=p[m];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)?Nb(n,i):!n||r?{node:t,offset:o}:Pp(n,i)}function Nb(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=Jt(r,1);if(s.top!=s.bottom&&za(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 za(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ob(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Lb(t,e,n){let{node:r,offset:i}=Pp(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 Ib(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 $p(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(za(e,c))return $p(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function Rb(t,e){let n=t.dom.ownerDocument,r,i=0,o=wb(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(!za(e,c)||(s=$p(t.dom,e,c),!s))return null}if(Fe)for(let c=s;r&&c;c=lr(c))c.draggable&&(r=void 0);if(s=Ob(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=Ib(t,r,i,e))}l==null&&(l=Lb(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Zl(t){return t.top<t.bottom||t.left<t.right}function Jt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Zl(r))return r}return Array.prototype.find.call(n,Zl)||t.getBoundingClientRect()}const Db=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Bp(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&&(Db.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Jt(It(r,i,i),n);if(et&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Jt(It(r,i-1,i-1),-1);if(c.top==a.top){let u=Jt(It(r,i,i+1),-1);if(u.top!=a.top)return Mr(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++,Mr(Jt(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 fl(a.getBoundingClientRect(),!1)}if(o==null&&i<Be(r)){let a=r.childNodes[i];if(V(a))return fl(a.getBoundingClientRect(),!0)}return fl(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 Mr(Jt(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 Mr(Jt(c,-1),!0)}return Mr(Jt(we(r)?It(r):r,-n),n>=0)}function Mr(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 fl(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 _p(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 Pb(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return _p(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=Bp(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 $b=/[\u0590-\u08ac]/;function Bb(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?!$b.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:_p(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:g,focusOffset:b}=t.domSelectionRange(),x=g&&!$n(m,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 Ou=null,Lu=null,Iu=!1;function _b(t,e,n){return Ou==e&&Lu==n?Iu:(Ou=e,Lu=n,Iu=n=="up"||n=="down"?Pb(t,e,n):Bb(t,e,n))}const lt=0,Ru=1,Cn=2,ft=3;class ki{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=lt,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&&$n(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)?$n(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 Fp||o instanceof zp&&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 m=0,g=0;m<this.children.length;m++){let b=this.children[m],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||Fe)&&e==n){let{node:m,offset:g}=l;if(we(m)){if(d=!!(g&&m.nodeValue[g-1]==`
|
|
51
|
+
`),d&&g==m.nodeValue.length)for(let b=m,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=m.childNodes[g-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(et&&u.focusNode&&u.focusNode!=a.node&&V(u.focusNode)){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||d&&Fe)&&Pn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Pn(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 m=document.createRange();m.setEnd(a.node,a.offset),m.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(m)}}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?Cn:Ru,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?Cn:ft}r=s}this.dirty=Cn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Cn:Ru;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class zp extends ki{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==lt&&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 zb extends ki{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 sn extends ki{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=Fn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new sn(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!=lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=lt}}slice(e,n,r){let i=sn.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=ea(o,n,s,r)),e>0&&(o=ea(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 ln extends ki{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}=Fn.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=Vp(u,r,n),c?a=new Fb(e,n,r,i,u,d||null,p,c):n.isText?new fs(e,n,r,i,u,p):new ln(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==lt&&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 jb(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Ub(this.node,this.innerDeco,(d,p,m)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!m&&a.syncToMarks(p==this.node.childCount?ue.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,i)},(d,p,m,g)=>{a.syncToMarks(d.marks,r,e,g),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let b;a.findNodeMatch(d,p,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(b=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(d,p,m,b,e)||a.updateNextNode(d,p,m,e,g,i)||a.addNode(d,p,m,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==Cn)&&(s&&this.protectLocalComposition(e,s),Hp(this.contentDOM,this.children,e),ar&&Wb(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||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=Kb(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 zb(this,o,n,i);e.input.compositionNodes.push(s),this.children=ea(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=lt}updateOuterDeco(e){if(fo(e,this.outerDeco))return;let n=!V(this.nodeDOM),r=this.dom;this.dom=jp(this.dom,this.nodeDOM,Ql(this.outerDeco,this.node,n),Ql(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 Du(t,e,n,r,i){Vp(r,e,t);let o=new ln(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class fs extends ln{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!=lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=lt||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=lt,!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 Fp extends ki{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Fb extends ln{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 Hp(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=Pu(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof sn){let a=r?r.previousSibling:t.lastChild;Hp(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Pu(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Hr=function(t){t&&(this.nodeName=t)};Hr.prototype=Object.create(null);const vn=[new Hr];function Ql(t,e,n){if(t.length==0)return vn;let r=n?vn[0]:new Hr,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new Hr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new Hr(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 jp(t,e,n,r){if(n==vn&&r==vn)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=vn[0]),i=a}Hb(i,l||vn[0],s)}return i}function Hb(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 Vp(t,e,n){return jp(t,t,vn,Ql(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 Pu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class jb{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Vb(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=lt,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 sn&&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=sn.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=Cn),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 ln){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=Cn,d.updateChildren(i,s+1),d.dirty=lt),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=ln.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=ln.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 zp(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 sn;)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))&&((Fe||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 Fp(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 Vb(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 sn)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 qb(t,e){return t.type.side-e.type.side}function Ub(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(qb);for(let x=0;x<d.length;x++)n(d[x],c,!!a)}else n(u,c,!!a);let p,m;if(a)m=-1,p=a,a=null;else if(c<t.childCount)m=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,m=-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),m),o=g}}function Wb(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 Kb(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 ea(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 Fa(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&&q.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&xb(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new q(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 m=0;m<n.rangeCount;m++){let g=n.getRangeAt(m);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=Ha(t,u,l,d)}return c}function qp(t){return t.editable?t.hasFocus():Wp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ft(t,e=!1){let n=t.state.selection;if(Up(t,n),!qp(t))return;let r=t.input.mouseDown;if(!e&&Re&&r){let i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Pn(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Jb(t);else{let{anchor:i,head:o}=n,s,l;$u&&!(n instanceof U)&&(n.$from.parent.inlineContent||(s=Bu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Bu(t,n.to))),t.docView.setSelection(i,o,t,e),$u&&(s&&_u(s),l&&_u(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Yb(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const $u=Fe||Re&&Lp<63;function Bu(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(Fe&&i&&i.contentEditable=="false")return pl(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return pl(i);if(o)return pl(o)}}function pl(t){return t.contentEditable="true",Fe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function _u(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Yb(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(()=>{(!qp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Jb(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&&Je&&on<=11&&(n.disabled=!0,n.disabled=!1)}function Up(t,e){if(e instanceof q){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(zu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else zu(t)}function zu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ha(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||U.between(e,n,r)}function Fu(t){return t.editable&&!t.hasFocus()?!1:Wp(t)}function Wp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return $n(t.dom,e.anchorNode)&&(t.editable||$n(t.dom,e.focusNode))}catch{return!1}}function Gb(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Pn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ta(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 Gt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Hu(t,e,n){let r=t.state.selection;if(r instanceof U)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 Gt(t,new U(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ta(t.state,e);return i&&i instanceof q?Gt(t,i):!1}else if(!(st&&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?q.isSelectable(o)?Gt(t,new q(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Gt(t,new U(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof q&&r.node.isInline)return Gt(t,new U(e>0?r.$to:r.$from));{let i=ta(t.state,e);return i?Gt(t,i):!1}}}function jr(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):V(t)&&t.contentEditable=="false"}function Wn(t,e){return e<0?Xb(t):Zb(t)}function Xb(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)&&jr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!V(n))break;let l=n.childNodes[r-1];if(jr(l,-1))i=n,o=--r;else if(we(l))n=l,r=n.nodeValue.length;else break}else{if(Kp(n))break;{let l=n.previousSibling;for(;l&&jr(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?na(t,n,r):i&&na(t,i,o)}function Zb(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(jr(l,1))o=n,s=++r;else break}else{if(Kp(n))break;{let l=n.nextSibling;for(;l&&jr(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&&na(t,o,s)}function Kp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Qb(t,e){for(;t&&e==t.childNodes.length&&!bi(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 e0(t,e){for(;t&&!e&&!bi(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 na(t,e,n){if(!we(e)){let o,s;(s=Qb(e,n))?(e=s,n=0):(o=e0(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&&Ft(t)},50)}function ju(t,e){let n=t.state.doc.resolve(e);if(!(Re||Ip)&&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 Vu(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||st&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=ta(t.state,e);if(s&&s instanceof q)return Gt(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?Gt(t,l):!1}return!1}function qu(t,e){if(!(t.state.selection instanceof U))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 Uu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function t0(t){if(!Fe||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;Uu(t,r,"true"),setTimeout(()=>Uu(t,r,"false"),20)}return!1}function n0(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function r0(t,e){let n=e.keyCode,r=n0(e);if(n==8||st&&n==72&&r=="c")return qu(t,-1)||Wn(t,-1);if(n==46&&!e.shiftKey||st&&n==68&&r=="c")return qu(t,1)||Wn(t,1);if(n==13||n==27)return!0;if(n==37||st&&n==66&&r=="c"){let i=n==37?ju(t,t.state.selection.from)=="ltr"?-1:1:-1;return Hu(t,i,r)||Wn(t,i)}else if(n==39||st&&n==70&&r=="c"){let i=n==39?ju(t,t.state.selection.from)=="ltr"?1:-1:1;return Hu(t,i,r)||Wn(t,i)}else{if(n==38||st&&n==80&&r=="c")return Vu(t,-1,r)||Wn(t,-1);if(n==40||st&&n==78&&r=="c")return t0(t)||Vu(t,1,r)||Wn(t,1);if(r==(st?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ja(t,e){t.someProp("transformCopied",m=>{e=m(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 m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||Fn.fromSchema(t.state.schema),l=Qp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&V(c)&&(u=Zp[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let g=l.createElement(u[m]);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",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
|
|
52
|
+
|
|
53
|
+
`);return{dom:a,text:p,slice:e}}function Yp(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:m}=t.state,g=Fn.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=s.appendChild(document.createElement("p"));b&&x.appendChild(g.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=l0(n),ds&&a0(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")||rn.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!i0.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=c0(Wu(l,+u[1],+u[2]),u[4]);else if(l=_.maxOpen(o0(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let m=l.content.firstChild;d<l.openStart&&!m.type.spec.isolating;d++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=Wu(l,d,p)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const i0=/^(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 o0(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&&Gp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Xp(s[s.length-1],o.length));let u=Jp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return L.from(s)}return t}function Jp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,L.from(t));return t}function Gp(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Gp(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(Jp(n,t,i+1))))}}function Xp(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Xp(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(L.empty,!0);return t.copy(n.append(r))}function ra(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=ra(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 Wu(t,e,n){return e<t.openStart&&(t=new _(ra(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _(ra(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Zp={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 Qp(){return document.implementation.createHTMLDocument("title")}let Tr=null;function s0(t){let e=window.trustedTypes;if(!e)return t;if(!Tr){if(Tr=e.defaultPolicy)try{return Tr.createHTML(t)}catch{}Tr=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Tr.createHTML(t)}function l0(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Qp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&Zp[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=s0(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 a0(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 c0(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={},We={},u0={touchstart:!0,touchmove:!0};class d0{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 f0(t){for(let e in Ue){let n=Ue[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{h0(t,r)&&!Va(t,r)&&(t.editable||!(r.type in We))&&n(t,r)},u0[e]?{passive:!0}:void 0)}Fe&&t.dom.addEventListener("input",()=>null),ia(t)}function $t(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function p0(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 ia(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Va(t,r))})}function Va(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function h0(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 m0(t,e){!Va(t,e)&&Ue[e.type]&&(t.editable||!(e.type in We))&&Ue[e.type](t,e)}We.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!rh(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Pt&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ar&&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,Sn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||r0(t,n)?n.preventDefault():$t(t,"key")};We.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};We.keypress=(t,e)=>{let n=e;if(rh(t)||!n.charCode||n.ctrlKey&&!n.altKey||st&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!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 xi(t){return{left:t.clientX,top:t.clientY}}function g0(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function qa(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 Si(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 y0(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&q.isSelectable(r)?(Si(t,new q(n)),!0):!1}function b0(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof q&&(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(q.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?(Si(t,q.create(t.state.doc,i)),!0):!1}function k0(t,e,n,r,i){return qa(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?b0(t,n):y0(t,n))}function x0(t,e,n,r){return qa(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function S0(t,e,n,r){return qa(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||w0(t,n,r)}function w0(t,e,n){if(n.button!=0)return!1;let r=eh(t,e,!0),i=t.state.doc;return r?(Si(t,r),r instanceof U&&i.eq(t.state.doc)&&(t.input.mouseDown=new v0(t,r)),!0):!1}function eh(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?U.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 U.create(r,l+1,l+1+s.content.size);if(n&&q.isSelectable(s))return q.create(r,l)}return null}function Ua(t){return po(t)}const th=st?"metaKey":"ctrlKey";Ue.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ua(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&g0(n,t.input.lastClick)&&!n[th]&&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(xi(n));s&&(o=="singleClick"?t.input.mouseDown=new C0(t,s,n,!!r):(o=="doubleClick"?x0:S0)(t,s.pos,s.inside,n)?n.preventDefault():$t(t,"pointer"))};class nh{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 C0 extends nh{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[th],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 q&&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()),$t(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||Ft(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(xi(e))),this.updateAllowDefault(e),this.allowDefault||!n?$t(this.view,"pointer"):k0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Fe&&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)?(Si(this.view,G.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):$t(this.view,"pointer")}move(e){this.updateAllowDefault(e),$t(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 v0 extends nh{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(),$t(this.view,"pointer");let n=this.view.posAtCoords(xi(e)),r=n&&eh(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];Si(this.view,U.create(i,s,l))}}Ue.touchstart=t=>{t.input.lastTouch=Date.now(),Ua(t),$t(t,"pointer")};Ue.touchmove=t=>{t.input.lastTouch=Date.now(),$t(t,"pointer")};Ue.contextmenu=t=>Ua(t);function rh(t,e){return t.composing?!0:Fe&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const M0=Pt?5e3:-1;We.compositionstart=We.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof U&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Re&&Ip&&T0(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}ih(t,M0)};function T0(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"}We.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++,ih(t,20))};function ih(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>po(t),e))}function oh(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function A0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=bb(e.focusNode,e.focusOffset),r=kb(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(!(Pt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),oh(t),e||t.docView&&t.docView.dirty){let n=Fa(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 E0(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 li=Je&&on<15||ar&&Cb<604;Ue.copy=We.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=li?null:n.clipboardData,s=r.content(),{dom:l,text:a}=ja(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):E0(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function N0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function O0(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?ai(t,r.value,null,i,e):ai(t,r.textContent,r.innerHTML,i,e)},50)}function ai(t,e,n,r,i){let o=Yp(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=N0(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 sh(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," "):""}We.paste=(t,e)=>{let n=e;if(t.composing&&!Pt)return;let r=li?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ai(t,sh(r),r.getData("text/html"),i,n)?n.preventDefault():O0(t,n)};class lh{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const L0=st?"altKey":"ctrlKey";function ah(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[L0]}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(xi(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof q?i.to-1:i.to))){if(r&&r.mightDrag)s=q.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=q.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=ja(t,l);(!n.dataTransfer.files.length||!Re||Lp>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(li?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",li||n.dataTransfer.setData("text/plain",c),t.dragging=new lh(u,ah(t,n),s)};Ue.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};We.dragover=We.dragenter=(t,e)=>e.preventDefault();We.drop=(t,e)=>{try{I0(t,e,t.dragging)}finally{t.dragging=null}};function I0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(xi(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",m=>{o=m(o,t,!1)}):o=Yp(t,sh(e.dataTransfer),li?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&ah(t,e));if(t.someProp("handleDrop",m=>m(t,e,o||_.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?cp(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:m}=n;m?m.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&&q.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new q(p));else{let m=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,b,x,w)=>m=w),a.setSelection(Ha(t,p,a.doc.resolve(m)))}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())&&Ft(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(Pt&&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,Sn(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 We)Ue[t]=We[t];function ci(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||Ln,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 Ve(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&&ci(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class an{constructor(e,n){this.attrs=e,this.spec=n||Ln}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 Ve(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof an&&ci(this.attrs,e.attrs)&&ci(this.spec,e.spec)}static is(e){return e.type instanceof an}destroy(){}}class Wa{constructor(e,n){this.attrs=e,this.spec=n||Ln}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 Ve(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 Wa&&ci(this.attrs,e.attrs)&&ci(this.spec,e.spec)}destroy(){}}class Ve{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ve(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 Ve(e,e,new ho(n,r))}static inline(e,n,r,i){return new Ve(e,n,new an(r,i))}static node(e,n,r,i){return new Ve(e,n,new Wa(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof an}get widget(){return this.type instanceof ho}}const Xn=[],Ln={};class re{constructor(e,n){this.local=e.length?e:Xn,this.children=n.length?n:Xn}static create(e,n){return n.length?mo(n,e,0,Ln):$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||Ln)}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?R0(this.children,s||[],e,n,r,i,o):s?new re(s.sort(In),Xn):$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=uh(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,Ln)),o+=3}});let s=ch(o?dh(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(In):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 an){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(In),Xn);return r?new en([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 Ka(this.localsInner(e))}localsInner(e){if(this==$e)return Xn;if(e.inlineContent||!this.local.some(an.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof an||n.push(this.local[r]);return n}forEachSet(e){e(this)}}re.empty=new re([],[]);re.removeOverlap=Ka;const $e=re.empty;class en{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ln));return en.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 en?r=r.concat(o.members):r.push(o))}return en.from(r)}eq(e){if(!(e instanceof en)||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?Ka(r?n:n.sort(In)):Xn}static from(e){switch(e.length){case 0:return $e;case 1:return e[0];default:return new en(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 R0(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,m,g,b)=>{let x=b-g-(m-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;m>=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),m=p-i,{index:g,offset:b}=r.content.findIndex(d),x=r.maybeChild(g);if(x&&b==d&&b+x.nodeSize==m){let w=l[c+2].mapInner(n,x,u+1,t[c]+o+1,s);w!=$e?(l[c]=d,l[c+1]=m,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=D0(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 m=u.children[d];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new re(e.sort(In),l)}function ch(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 Ve(i.from+e,i.to+e,i.type))}return n}function D0(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 uh(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 dh(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=uh(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=ch(o?dh(t):t,-n).sort(In);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 In(t,e){return t.from-e.from||t.to-e.to}function Ka(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),Ku(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),Ku(e,i,r.copy(o.from,r.to)));break}}}return e}function Ku(t,e,n){for(;e<t.length&&In(n,t[e])>0;)e++;t.splice(e,0,n)}function hl(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])),en.from(e)}const P0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$0=Je&&on<=11;class B0{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 _0{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new B0,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]);Je&&on<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Fe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),$0&&(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,P0)),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(Fu(this.view)){if(this.suppressingSelectionUpdates)return Ft(this.view);if(Je&&on<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pn(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=lr(o))n.add(o);for(let o=e.anchorNode;o;o=lr(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)&&Fu(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 m=p.parentNode;m&&m.nodeName=="LI"&&(!d||H0(e,d)!=m)&&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=Fa(e))&&c.eq(G.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ft(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),z0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,j0(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ft(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(Je&&on<=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 Yu=new WeakMap,Ju=!1;function z0(t){if(!Yu.has(t)&&(Yu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=et,Ju)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."),Ju=!0}}function Gu(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Pn(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function F0(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Gu(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?Gu(t,n):null}function H0(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 j0(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 V0(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&&$n(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,m=t.someProp("domParser")||rn.fromSchema(t.state.schema),g=p.resolve(l),b=null,x=m.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:q0(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 q0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Fe&&/^(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||Fe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},U0=/^(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 W0(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,Q=Fa(t,j);if(Q&&!t.state.selection.eq(Q)){if(Re&&Pt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",ye=>ye(t,Sn(13,"Enter"))))return;let ee=t.state.tr.setSelection(Q);j=="pointer"?ee.setMeta("pointer",!0):j=="key"&&ee.scrollIntoView(),o&&ee.setMeta("composition",o),t.dispatch(ee)}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=V0(t,e,n,i),u=t.state.doc,d=u.slice(c.from,c.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let g=G0(d.content,c.doc.content,c.from,p,m);if(g&&t.input.domChangeCount++,(ar&&t.input.lastIOSEnter>Date.now()-225||Pt)&&i.some(j=>V(j)&&!U0.test(j.nodeName))&&(!g||g.endA>=g.endB)&&t.someProp("handleKeyDown",j=>j(t,Sn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!g)if(r&&a instanceof U&&!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=Xu(t,t.state.doc,c.sel);if(j&&!j.eq(t.state.selection)){let Q=t.state.tr.setSelection(j);o&&Q.setMeta("composition",o),t.dispatch(Q)}}return}t.state.selection.from<t.state.selection.to&&g.start==g.endB&&t.state.selection instanceof U&&(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)),Je&&on<=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((ar&&t.input.lastIOSEnter>Date.now()-225&&(!T||i.some(j=>j.nodeName=="DIV"||j.nodeName=="P"))||!T&&J0(c.doc,b.pos,x.pos))&&t.someProp("handleKeyDown",j=>j(t,Sn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>g.start&&Y0(u,g.start,g.endA,b,x)&&t.someProp("handleKeyDown",j=>j(t,Sn(8,"Backspace")))){Pt&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&g.endB==g.start&&(t.input.lastChromeDelete=Date.now()),Pt&&!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,Sn(13,"Enter"))})},20));let R=g.start,$=g.endA,Y=j=>{let Q=j||t.state.tr.replace(R,$,c.doc.slice(g.start-c.from,g.endB-c.from));if(c.sel){let ee=Xu(t,Q.doc,c.sel);ee&&!(Re&&t.composing&&ee.empty&&(g.start!=g.endB||t.input.lastChromeDelete<Date.now()-100)&&(ee.head==R||ee.head==Q.mapping.map($)-1)||Je&&ee.empty&&ee.head==R)&&Q.setSelection(ee)}return o&&Q.setMeta("composition",o),Q.scrollIntoView()},te;if(T)if(b.pos==x.pos){Je&&on<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ft(t),20));let j=Y(t.state.tr.delete(R,$)),Q=u.resolve(g.start).marksAcross(u.resolve(g.endA));Q&&j.ensureMarks(Q),t.dispatch(j)}else if(g.endA==g.endB&&(te=K0(b.parent.content.cut(b.parentOffset,x.parentOffset),w.parent.content.cut(w.parentOffset,g.endA-w.start())))){let j=Y(t.state.tr);te.type=="add"?j.addMark(R,$,te.mark):j.removeMark(R,$,te.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),Q=()=>Y(t.state.tr.insertText(j,R,$));t.someProp("handleTextInput",ee=>ee(t,R,$,j,Q))||t.dispatch(Q())}else t.dispatch(Y());else t.dispatch(Y())}function Xu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ha(t,e.resolve(n.anchor),e.resolve(n.head))}function K0(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 Y0(t,e,n,r,i){if(n-e<=i.pos-r.pos||ml(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(ml(o,!0,!0));return!s.parent.isTextblock||s.pos>n||ml(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function J0(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 ml(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 G0(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 fh{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 d0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(nd),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=ed(this),Qu(this),this.nodeViews=td(this),this.docView=Du(this.state.doc,Zu(this),hl(this),this.dom,this),this.domObserver=new _0(this,(r,i,o,s)=>W0(this,r,i,o,s)),this.domObserver.start(),f0(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&&ia(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nd),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&&(oh(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 m=td(this);Z0(m,this.nodeViews)&&(this.nodeViews=m,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ia(this),this.editable=ed(this),Qu(this);let a=hl(this),c=Zu(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&&Tb(this);if(s){this.domObserver.stop();let m=d&&(Je||Re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&X0(i.selection,e.selection);if(d){let b=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=A0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Du(e.doc,c,a,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(m=!0)}let g=this.input.mouseDown;m||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gb(this)&&g.delaySelUpdate())?Ft(this,m):(Up(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&&Ab(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!$n(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof q){let n=this.docView.domAfterPos(this.state.selection.from);V(n)&&Nu(this,n.getBoundingClientRect(),e)}else Nu(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 lh(e.slice,e.move,i<0?void 0:q.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(Je){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&&Eb(this.dom),Ft(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 Rb(this,e)}coordsAtPos(e,n=1){return Bp(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 _b(this,n||this.state,e)}pasteHTML(e,n){return ai(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ai(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ja(this,e)}destroy(){this.docView&&(p0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return m0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Fe&&this.root.nodeType===11&&Sb(this.dom.ownerDocument)==this.dom&&F0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}fh.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Zu(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"),[Ve.node(0,t.state.doc.content.size,e)]}function Qu(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:Ve.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ed(t){return!t.someProp("editable",e=>e(t.state)===!1)}function X0(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 td(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 Z0(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 nd(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 fn={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:'"'},Q0=typeof navigator<"u"&&/Mac/.test(navigator.platform),ek=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Le=0;Le<10;Le++)fn[48+Le]=fn[96+Le]=String(Le);for(var Le=1;Le<=24;Le++)fn[Le+111]="F"+Le;for(var Le=65;Le<=90;Le++)fn[Le]=String.fromCharCode(Le+32),go[Le]=String.fromCharCode(Le);for(var gl in fn)go.hasOwnProperty(gl)||(go[gl]=fn[gl]);function tk(t){var e=Q0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ek&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?go:fn)[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 nk=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rk=typeof navigator<"u"&&/Win/.test(navigator.platform);function ik(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))nk?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 ok(t){let e=Object.create(null);for(let n in t)e[ik(n)]=t[n];return e}function yl(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 sk(t){return new fe({props:{handleKeyDown:ph(t)}})}function ph(t){let e=ok(t);return function(n,r){let i=tk(r),o,s=e[yl(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[yl(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(rk&&r.ctrlKey&&r.altKey)&&(o=fn[r.keyCode])&&o!=i){let l=e[yl(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 lk(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 hh(e):Ae.empty};var hh=(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 hh([]);var lk=(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 ak=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 m=d.step.map(i.slice(o)),g;m&&s.maybeStep(m).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),m;(m=a&&a.merge(p))&&(p=m,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>uk&&(l=ck(l,c),s-=c),new ut(l.append(o),s)}remapping(e,n){let r=new oi;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 m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let g=o.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),x=p.selection&&p.selection.map(o.slice(a+1,m));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()>ak&&(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,m=i.length-1;(p=i.length&&i[m].merge(d))?i[m]=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 ck(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 Xt{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const uk=20;function dk(t,e,n,r){let i=n.getMeta(cn),o;if(i)return i.historyState;n.getMeta(mh)&&(t=new Xt(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(cn))return s.getMeta(cn).redo?new Xt(t.done.addTransform(n,void 0,r,to(e)),t.undone,rd(n.mapping.maps),t.prevTime,t.prevComposition):new Xt(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||!fk(n,t.prevRanges)),c=s?bl(t.prevRanges,n.mapping):rd(n.mapping.maps);return new Xt(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 Xt(t.done.rebased(n,o),t.undone.rebased(n,o),bl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Xt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),bl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function fk(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 rd(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 bl(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 pk(t,e,n){let r=to(e),i=cn.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 Xt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(cn,{redo:n,historyState:a})}let kl=!1,id=null;function to(t){let e=t.plugins;if(id!=e){kl=!1,id=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){kl=!0;break}}return kl}function hk(t){return t.setMeta(mh,!0)}const cn=new xe("history"),mh=new xe("closeHistory");function mk(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new fe({key:cn,state:{init(){return new Xt(ut.empty,ut.empty,null,0,-1)},apply(e,n,r){return dk(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?yh:r=="historyRedo"?bh:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function gh(t,e){return(n,r)=>{let i=cn.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=pk(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const yh=gh(!1,!0),bh=gh(!0,!0);function gk(t){return t.getMeta(cn)!=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 nr=class kh{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,m])=>[p,(...b)=>{const x=this.buildProps(c,n),w=m(...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=kh.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 yk=()=>({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),bk=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),kk=()=>({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)),m=d.blockRange(p);if(!m)return;const g=hr(m);if(l.type.isTextblock){const{defaultType:b}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(m.start,b)}(g||g===0)&&e.lift(m,g)})}),!0},xk=t=>e=>t(e),Sk=()=>({state:t,dispatch:e})=>Tp(t,e),wk=(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 U(r.doc.resolve(Math.max(s-1,0)))),!0},Ck=()=>({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 vk=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},Mk=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Tk=t=>t.content?/^text(\*|\+)/.test(t.content):!1,od=(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 Tk(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Ak=(t,e,n)=>({from:od(t,n,"left"),to:od(e,n,"right")}),Ek=()=>({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}=Ak(l,a,t.schema);n.deleteRange(c,u)}),n.selection.empty||n.setSelection(U.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},Nk=()=>({commands:t})=>t.keyboardShortcut("Enter"),Ok=()=>({state:t,dispatch:e})=>tb(t,e);function Ya(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]:Ya(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function xh(t,e,n={}){return t.find(r=>r.type===e&&bo(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function sd(t,e,n={}){return!!xh(t,e,n)}function Ja(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(!xh([...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&&sd([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;s<t.parent.childCount&&sd([...t.parent.child(s).marks],e,n);)l+=t.parent.child(s).nodeSize,s+=1;return{from:o,to:l}}function jt(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 Lk=(t,e)=>({tr:n,state:r,dispatch:i})=>{const o=jt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=Ja(a,o,e);if(d&&d.from<=c&&d.to>=u){const p=U.create(s,d.from,d.to);n.setSelection(p)}}return!0},Ik=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 Sh(t){return t instanceof U}function Mn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function oa(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"?U.create(t,Mn(0,i,o),Mn(t.content.size,i,o)):U.create(t,Mn(e,i,o),Mn(e,i,o))}function ld(){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 Rk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Dk=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(ko()||ld())&&r.dom.focus(),Rk()&&!ko()&&!ld()&&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&&!Sh(n.state.selection))return s(),!0;const l=oa(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},Pk=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),$k=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),wh=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&&wh(r)}return t};function ji(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 wh(n)}function Ch(t){return typeof(t==null?void 0:t.nodesBetween)=="function"}function cr(t,e,n){if(Ch(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),cr("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,l="";const a=new Zf({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?rn.fromSchema(a).parseSlice(ji(t),n.parseOptions):rn.fromSchema(a).parse(ji(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=rn.fromSchema(e);return n.slice?o.parseSlice(ji(t),n.parseOptions).content:o.parse(ji(t),n.parseOptions)}return cr("",e,n)}function vh(t){return!("type"in t)}function Mh(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 Bk=(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{cr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){a(x)}try{var s;l=cr(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,m=!0;const g=vh(l)?l.content:[l];if(g.forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,m=m?x.isBlock:!1}),u===d&&m){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(""):Ch(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&&$&&m&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&Mh(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 Th(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 _k=(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=Th(a.parent.contentMatchAt(a.index()));if(!c)return!1;const u=Object.keys(c.spec.attrs||{}),d=o?Object.fromEntries(Object.entries(o).filter(([m])=>u.includes(m))):{};let p;if(s){const m=cr(s,r.schema);p=c.createAndFill(d,m)}else p=c.createAndFill(d);return p?(n&&(e.insert(a.pos,p),l&&Mh(e,e.steps.length-1,-1)),!0):!1},zk=()=>({state:t,dispatch:e})=>Zy(t,e),Fk=()=>({state:t,dispatch:e})=>Qy(t,e),Hk=()=>({state:t,dispatch:e})=>kp(t,e),jk=()=>({state:t,dispatch:e})=>Cp(t,e),Ah=(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},Vk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ls(t.doc,t.selection.$from.pos,-1);return r==null||!Ah(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},qk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ls(t.doc,t.selection.$from.pos,1);return r==null||!Ah(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Uk=()=>({state:t,dispatch:e})=>Gy(t,e),Wk=()=>({state:t,dispatch:e})=>Xy(t,e);function Eh(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Kk(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()||Eh()?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 Yk=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=Kk(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 Ht(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),m=Math.min(i,d+u.nodeSize);l.push({node:u,from:p,to:m})});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 Jk=(t,e={})=>({state:n,dispatch:r})=>Ht(n,Ce(t,n.schema),e)?eb(n,r):!1,Gk=()=>({state:t,dispatch:e})=>Ap(t,e),Xk=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return fb(r)(e,n)},Zk=()=>({state:t,dispatch:e})=>Mp(t,e);function hs(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ad(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 Qk=(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=jt(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,ad(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(ad(p.attrs,e))))})})}),a},ex=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),tx=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qe(t.doc);t.setSelection(n)}return!0},nx=()=>({state:t,dispatch:e})=>Sp(t,e),rx=()=>({state:t,dispatch:e})=>vp(t,e),ix=()=>({state:t,dispatch:e})=>ib(t,e),ox=()=>({state:t,dispatch:e})=>lb(t,e),sx=()=>({state:t,dispatch:e})=>sb(t,e);function sa(t,e,n={},r={}){return cr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const lx=(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=sa(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});if(s){const u=vh(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 Nh(t,e){const n=jt(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 Oh(t,e){const n=new hp(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function ax(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function cx(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=>cx(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 Ga(t){return t.map(e=>{const n=H(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Ga(n())]:e}).flat(10)}function Xa(t,e){const n=Fn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function la(t){return typeof t=="function"}function ie(t,e=void 0,...n){return la(t)?e?t.bind(e)(...n):t(...n):t}function ux(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ur(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function Lh(t){const e=[],{nodeExtensions:n,markExtensions:r}=ur(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(m=>{Object.entries(d.attributes).forEach(([g,b])=>{e.push({type:m,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,m])=>{const g={...o,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:c.name,name:p,attribute:g})})}),e}function dx(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 cd(t){const e=[],n=dx(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([...cd(r[i]),...cd(o)]);r[i]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[i]=o}),r},{})}function ui(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 fx(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ud(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):fx(n.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function dd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&ux(n)?!1:n!=null))}function fd(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 px(t,e){var n;const r=Lh(t),{nodeExtensions:i,markExtensions:o}=ur(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=dd({...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(fd))}),m=ie(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(x=>ud(x,u)));const g=H(c,"renderHTML",d);g&&(p.toDOM=x=>g({node:x,HTMLAttributes:ui(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=dd({...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(fd))}),m=ie(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(b=>ud(b,u)));const g=H(c,"renderHTML",d);return g&&(p.toDOM=b=>g({mark:b,HTMLAttributes:ui(b,u)})),[c.name,p]}));return new Zf({topNode:s,nodes:l,marks:a})}function hx(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Vr(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 Ih(t){const e=Vr(Ga(t)),n=hx(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 Rh(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 m;l+=a==null||(m=a.text)===null||m===void 0?void 0:m.slice(Math.max(r,c)-c,i-c)}}),l}function mx(t,e){return Rh(t,{from:0,to:t.content.size},e)}function Dh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function gx(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 Ph(t,e){const n=hs(typeof e=="string"?e:e.name,t.schema);return n==="node"?gx(t,e):n==="mark"?Nh(t,e):{}}function yx(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 bx(t){const e=yx(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}})})}),bx(r)}function ys(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=Ja(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 kx=(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]},xx=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 Kn(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 Sx=(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 aa(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?jt(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,m=d.pos;t.doc.nodesBetween(p,m,(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(m,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 wx(t,e,n={}){if(!e)return Ht(t,null,n)||aa(t,null,n);const r=hs(e,t.schema);return r==="node"?Ht(t,e,n):r==="mark"?aa(t,e,n):!1}const Cx=(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)},vx=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function pd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function xl(t,e){const{nodeExtensions:n}=ur(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 wi(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&&(wi(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function $h(t){return t instanceof q}var Bh=class _h{constructor(e){this.position=e}static fromJSON(e){return new _h(e.position)}toJSON(){return{position:this.position}}};function Mx(t,e){const n=e.mapping.mapResult(t.position);return{position:new Bh(n.pos),mapResult:n}}function Tx(t){return new Bh(t)}function Ax(t,e,n){const{selection:r}=e;let i=null;if(Sh(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 m=!p||p.type.allowsMarkType(n),g=!!n.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(n));c=m&&g}return!c}),c})}const Ex=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:l}=o,a=jt(t,r.schema);if(i)if(s){const c=Nh(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,m)=>{const g=Math.max(m,u),b=Math.min(m+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 Ax(r,n,a)},Nx=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Ox=(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})=>Tu(o,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Tu(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Lx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Mn(t,0,r.content.size),o=q.create(r,i);e.setSelection(o)}return!0},Ix=(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},Rx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=U.atStart(r).from,l=U.atEnd(r).to,a=Mn(i,s,l),c=Mn(o,s,l),u=U.create(r,a,c);e.setSelection(u)}return!0},Dx=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return mb(r)(e,n)};function hd(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 Px=({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 q&&o.node.isBlock)return!l.parentOffset||!zt(s,l.pos)?!1:(r&&(t&&hd(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:Th(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=d&&p?[{type:p,attrs:u}]:void 0;const g=o instanceof U&&!o.empty?Dt.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=zt(b,x,1,m);if(!m&&!w&&zt(b,x,1,p?[{type:p}]:void 0)&&(w=!0,m=p?[{type:p,attrs:u}]:void 0),r){if(w){const T=e.steps.length;if(o instanceof U&&e.deleteSelection(),e.split(e.mapping.slice(T).map(l.pos),1,m),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&&hd(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return w},$x=(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 te=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},Q=((p=s.contentMatch.defaultType)===null||p===void 0?void 0:p.createAndFill(j))||void 0;$=$.append(L.from(s.createAndFill(null,Q)||void 0));const ee=l.before(l.depth-(Y-1));n.replace(ee,l.after(-te),new _($,4-Y,0));let ye=-1;n.doc.nodesBetween(ee,n.doc.content.size,(Me,tt)=>{if(ye>-1)return!1;Me.isTextblock&&Me.content.size===0&&(ye=tt+1)}),ye>-1&&n.setSelection(U.near(n.doc.resolve(ye))),n.scrollIntoView()}return!0}const m=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=m?[{type:s,attrs:T},{type:m,attrs:b}]:[{type:s,attrs:T}];if(!zt(n.doc,l.pos,2))return!1;if(i){const{selection:$,storedMarks:Y}=r,{splittableMarks:te}=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 Q=j.filter(ee=>te.includes(ee.type.name));n.ensureMarks(Q)}return!0};function md(t){return!t||t==="1"?null:t}function zh(t,e){return md(t)===md(e)}const Sl=(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)&&mn(t.doc,n.pos))||!zh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(n.pos),!0},wl=(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)&&mn(t.doc,r))||!zh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(r),!0};function Bx(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return U.between(r,i)}const _x=(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,m=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=>xl(Ee.type.name,d))(b),te=b.from===0&&b.to===s.doc.content.size,j=s.doc.content.content,Q=j.length===1?j[0]:null,ee=te&&Q&&xl(Q.type.name,d)?{node:Q,pos:0}:null,ye=Y??ee,Me=!!Y&&R.depth>=1&&R.depth-Y.depth<=1,tt=!!ee;if((Me||tt)&&ye){if(ye.node.type===m)return te&&tt?a().command(({tr:Ee,dispatch:le})=>{const De=Bx(Ee);return De?(Ee.setSelection(De),le&&le(Ee),!0):!1}).liftListItem(g).run():c.liftListItem(g);if(xl(ye.node.type.name,d)&&m.validContent(ye.node.content))return a().command(()=>(o.setNodeMarkup(ye.pos,m),!0)).command(()=>Sl(o,m)).command(()=>wl(o,m)).run()}return!n||!$||!l?a().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>Sl(o,m)).command(()=>wl(o,m)).run():a().command(()=>{const Ee=u().wrapInList(m,r),le=$.filter(De=>p.includes(De.type.name));return o.ensureMarks(le),Ee?!0:c.clearNodes()}).wrapInList(m,r).command(()=>Sl(o,m)).command(()=>wl(o,m)).run()},zx=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=jt(t,r.schema);return aa(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Fx=(t,e,n={})=>({state:r,commands:i})=>{const o=Ce(t,r.schema),s=Ce(e,r.schema),l=Ht(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})},Hx=(t,e={})=>({state:n,commands:r})=>{const i=Ce(t,n.schema);return Ht(n,i,e)?r.lift(i):r.wrapIn(i,e)},jx=()=>({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},Vx=(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},qx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{extendEmptyMarkRange:o=!1}=e,{selection:s}=n,l=jt(t,r.schema),{$from:a,empty:c,ranges:u}=s;if(!i)return!0;if(c&&o){var d;let{from:p,to:m}=s;const g=Ja(a,l,(d=a.marks().find(b=>b.type===l))===null||d===void 0?void 0:d.attrs);g&&(p=g.from,m=g.to),n.removeMark(p,m,l)}else u.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},Ux=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},Wx=(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=jt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let p,m,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,m=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,m=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}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(x=>{s===x.type&&i&&n.addMark(g,b,s.create({...x.attrs,...e}))}))}),a},Zn=new xe("__tiptap_decorations__"),Kx=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(Zn,{type:"force",name:t}),!0),Yx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return ab(i,e)(n,r)},Jx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return cb(i,e)(n,r)};var Gx=ey({blur:()=>yk,clearContent:()=>bk,clearNodes:()=>kk,command:()=>xk,createParagraphNear:()=>Sk,cut:()=>wk,deleteCurrentNode:()=>Ck,deleteNode:()=>vk,deleteRange:()=>Mk,deleteSelection:()=>Ek,enter:()=>Nk,exitCode:()=>Ok,extendMarkRange:()=>Lk,first:()=>Ik,focus:()=>Dk,forEach:()=>Pk,insertContent:()=>$k,insertContentAt:()=>Bk,insertDefaultBlock:()=>_k,joinBackward:()=>Hk,joinDown:()=>Fk,joinForward:()=>jk,joinItemBackward:()=>Vk,joinItemForward:()=>qk,joinTextblockBackward:()=>Uk,joinTextblockForward:()=>Wk,joinUp:()=>zk,keyboardShortcut:()=>Yk,lift:()=>Jk,liftEmptyBlock:()=>Gk,liftListItem:()=>Xk,newlineInCode:()=>Zk,resetAttributes:()=>Qk,scrollIntoView:()=>ex,selectAll:()=>tx,selectNodeBackward:()=>nx,selectNodeForward:()=>rx,selectParentNode:()=>ix,selectTextblockEnd:()=>ox,selectTextblockStart:()=>sx,setContent:()=>lx,setMark:()=>Ex,setMeta:()=>Nx,setNode:()=>Ox,setNodeSelection:()=>Lx,setTextDirection:()=>Ix,setTextSelection:()=>Rx,sinkListItem:()=>Dx,splitBlock:()=>Px,splitListItem:()=>$x,toggleList:()=>_x,toggleMark:()=>zx,toggleNode:()=>Fx,toggleWrap:()=>Hx,undoInputRule:()=>jx,unsetAllMarks:()=>Vx,unsetMark:()=>qx,unsetTextDirection:()=>Ux,updateAttributes:()=>Wx,updateDecorations:()=>Kx,wrapIn:()=>Yx,wrapInList:()=>Jx});const Ar=new WeakMap;function Xx(t,e){var n;Ar.set(t,((n=Ar.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;const i=((r=Ar.get(t))!==null&&r!==void 0?r:1)-1;i>0?Ar.set(t,i):Ar.delete(t)}}var Zx=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 Qx(t){return t.kind==="widget"}function Fh(t,e){const n=[],r=new Set;for(const i of t)i.kind==="widget"&&Qx(i)&&r.add(i.key),n.push(i.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function eS(t,e,n){const{decorations:r,widgetKeys:i}=Fh(e,n);return{set:re.create(t,r),widgetKeys:i}}function Hh({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function tS({decorations:t,from:e,to:n,docSize:r,extensionName:i,warnedExtensions:o}){return t.filter(s=>Hh({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 nS(t){var e;const n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function jh(t){return t.jsonID==="attr"}function rS(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||jh(t))return!0;const n=t;return typeof n.from=="number"&&typeof n.to=="number"}function iS(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 oS(t,e){if(t.steps.some(o=>!rS(o)))return{type:"full"};const n=gs(t).map(({newRange:o})=>o);t.steps.forEach((o,s)=>{if(!jh(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=iS(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 Vh(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 sS(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:Vh(o,n.mapping,n.doc,s),widgetKeys:s}}function gd(t,e){const n=Object.values(e).flatMap(r=>r.find());return re.create(t,n)}function yd(t){const e=new Set;for(const n of Object.values(t))for(const r of n)e.add(r);return e}function lS(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 aS(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}const cS=new Set;var uS=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const n=Zn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>lS(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=Zn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:cS}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:Zn,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:yd(o)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,i,o)=>{const s=n.getMeta(Zn),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 Xx(t,()=>{for(const{name:p,spec:m}of e){const g=l||a===p;if(aS(m,{editor:t,tr:n,oldState:i,newState:o},g))if(m.update==="changedRanges"&&n.docChanged&&!g){const b=this.applyChangedRangesRecompute(p,m,r,n,o);c[p]=b.set,u[p]=b.widgetKeys,d.add(p)}else{const{set:b,widgetKeys:x}=this.buildFullSet(p,m,o);c[p]=b,u[p]=x,d.add(p)}else{const b=sS(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:yd(u)}}},props:{decorations(n){var r,i;return(r=(i=Zn.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=oS(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=Vh(a,r.mapping,r.doc,c);const d=i.doc.content.size;for(const{from:p,to:m}of o){const g=u.find(p,m).filter(w=>Hh({position:w.from,from:p,to:m,docSize:d}));for(const w of g){const T=nS(w);T&&c.delete(T)}u=u.remove(g);const{decorations:b,widgetKeys:x}=Fh(tS({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:p,to:m})),from:p,to:m,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 eS(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]]:gd(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):gd(n.doc,r)}};function dS(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof q){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 fS(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 Ci(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 pS(t){return typeof t=="number"}function hS(t){return Object.prototype.toString.call(t).slice(8,-1)}function Vi(t){return hS(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function vi(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function bd(t,e,n){const r=t.split(`
|
|
57
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
58
|
`;continue}else return}const p=e.extractItemData(d),{indentLevel:m,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(
|
|
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)>m){b.push(R),o=`${o}${R}
|
|
60
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)>m)b.push(R),o=`${o}${R}
|
|
61
61
|
`,s+=1;else break}let x;const w=b.slice(1);if(w.length>0){const R=w.map($=>$.slice(m+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
|
|
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 kd=4;function xd(t){let e=0;for(const n of t)e=n===" "?e+kd-e%kd:e+1;return e}function qh(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 m=(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(m!=null){const g=x=>{if(!(i!=null&&i.alignNestedToPrefix))return e.indent(x);const w=e.indent(""),T=xd(o);return(xd(w)>=T?w:" ".repeat(T))+x},b=m.split(`
|
|
63
63
|
`).map(x=>g(x||"")).join(`
|
|
64
64
|
`);a+=c.type==="paragraph"?`
|
|
65
65
|
|
|
66
66
|
${b}`:`
|
|
67
|
-
${b}`}}),a}function
|
|
68
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var
|
|
67
|
+
${b}`}}),a}function Uh(t,e){const n={...t};return Vi(t)&&Vi(e)&&Object.keys(e).forEach(r=>{Vi(e[r])&&Vi(t[r])?n[r]=Uh(t[r],e[r]):n[r]=e[r]}),n}function mS(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(m=>{if(m!==s)return!1;d=m}),!d)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==d.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,m)}}),o.docChanged&&e.view.dispatch(o)}var Mi=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 gS=(t,e)=>{if(Ya(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 yS(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:Dt.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function bS(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}=yS({editor:e,from:n,to:r,text:i,insertText:a}),p=u?n+i.length:r,m=ps({state:c.state,transaction:d}),g={from:n-(s[0].length-i.length),to:p},{commands:b,chain:x,can:w}=new nr({editor:e,state:m});return o.handler({state:m,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))||(hk(d),d.setMeta("inputRule",!0),o.undoable&&d.setMeta(l,{transform:d,from:n,to:p,text:i}),c.dispatch(d)),!0)}function kS(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 qi(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=Sx(u)+o;for(const p of s){const m=gS(d,p.find);if(!(!m||!kS(u,m,o))&&bS({editor:n,from:r,to:i,text:o,rule:p,match:m,plugin:l,insertText:a}))return!0}return!1}function xS(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=Xa(L.from(c),s.schema);const{from:u}=a,d=u+c.length;qi({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 qi({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&&qi({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?qi({editor:e,from:s.pos,to:s.pos,text:`
|
|
68
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Za=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:()=>Uh(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}},yn=class Wh extends Za{constructor(...e){super(...e),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Wh(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)}},Kh=class{constructor(t){this.find=t.find,this.handler=t.handler}};const SS=(t,e,n)=>{if(Ya(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 wS(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new nr({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(p,m)=>{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,m),$=Math.min(i,m+T);if(R>=$)return;const Y=p.isText?p.text||"":p.textBetween(R-m,$-m,void 0,"");SS(Y,o.find,s).forEach(te=>{if(te.index===void 0)return;const j=R+te.index+1,Q=j+te[0].length,ee={from:n.tr.mapping.map(j),to:n.tr.mapping.map(Q)},ye=o.handler({state:n,range:ee,match:te,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(ye)})}),d.every(p=>p!==null)}let Yn=null;const CS=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 vS(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:m})=>{const g=c.tr,b=ps({state:c,transaction:g});if(!(!wS({editor:e,state:b,from:Math.max(u-1,0),to:d.b-1,rule:p,pasteEvent:m,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",()=>{Yn===e&&(Yn=null)}),n.map(c=>new fe({view(u){const d=m=>{var g;r=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(m.target)?u.dom.parentElement:null,r&&(Yn=e)},p=()=>{Yn&&(Yn=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=Yn;p!=null&&p.isEditable&&setTimeout(()=>{if(p.isDestroyed)return;const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(u,d)=>{var p;const m=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=d,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(u,d,p)=>{const m=u[0],g=m.getMeta("uiEvent")==="paste"&&!i,b=m.getMeta("uiEvent")==="drop"&&!o,x=m.getMeta("applyPasteRules"),w=!!x;if(!g&&!b&&!w)return;if(w){let{text:$}=x;typeof $=="string"?$=$:$=Xa(L.from($),p.schema);const{from:Y}=x,te=Y+$.length,j=CS($);return a({rule:c,state:p,from:Y,to:{b:te},pasteEvt:j})}const T=d.doc.content.findDiffStart(p.doc.content),R=d.doc.content.findDiffEnd(p.doc.content);if(!(!pS(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=Ih(t),this.schema=px(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:Kn(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=Vr([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Kn(r.name,this.schema)},o=[],s=H(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&H(r,"exitable",i)&&(l.ArrowRight=()=>yn.handleExit({editor:t,mark:r})),s){const p=Object.fromEntries(Object.entries(s()).map(([m,g])=>[m,()=>g({editor:t})]));l={...l,...p}}const a=sk(l);o.push(a);const c=H(r,"addInputRules",i);if(pd(r,t.options.enableInputRules)&&c){const p=c();if(p&&p.length){const m=xS({editor:t,rules:p}),g=Array.isArray(m)?m:[m];o.push(...g)}}const u=H(r,"addPasteRules",i);if(pd(r,t.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const m=vS({editor:t,rules:p});o.push(...m)}}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:Kn(r.name,this.schema)});i&&n.push({name:r.name,addDecorations:i})}),this.decorationManager=new uS({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){return Lh(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ur(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=ui(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 Vr([...this.extensions].reverse()).reduceRight((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Kn(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 Vr([...this.extensions]).reduce((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Kn(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}=ur(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:jt(n.name,this.schema)});if(!i)return[];const o=(s,l,a)=>{const c=ui(s,r);return i()({mark:s,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{mS(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:Kn(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=Ih;bs.sort=Vr;bs.flatten=Ga;var ae=class Yh extends Za{constructor(...e){super(...e),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Yh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};const MS=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=Dh(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})=>Rh(r,{from:a.pos,to:c.pos},l)).join(s??`
|
|
69
69
|
|
|
70
|
-
`)}}})]}}),
|
|
70
|
+
`)}}})]}}),TS=ae.create({name:"commands",addCommands(){return{...Gx}}}),AS=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=Oh(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 m=p+d.nodeSize-2,g=u.oldRange.from<=p&&m<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:p,to:m,newFrom:a.mapping.map(p),newTo:a.mapping.map(m),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,m;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=(m=a.doc.nodeAt(b))===null||m===void 0?void 0:m.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()}}),ES=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})}}})]}}),NS=ae.create({name:"editable",addProseMirrorPlugins(){return[new fe({key:new xe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),OS=new xe("focusEvents"),LS=ae.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new fe({key:OS,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}}}})]}}),IS=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:m}=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||!m.type.isTextblock||m.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()||Eh()?o:i},addProseMirrorPlugins(){return[new fe({key:new xe("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),i=t.some(m=>m.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)||!wi(n.doc))return;const u=n.tr,d=ps({state:n,transaction:u}),{commands:p}=new nr({editor:this.editor,state:d});if(p.clearNodes(),!!u.steps.length)return u}})]}}),RS=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})}}})]}}),DS=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"}}}})]}}),PS=ae.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ur(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 Sd=!1;function $S(t){if(Sd)return;Sd=!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 BS=class $r{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 $r(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 $r(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 $r(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 $r(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 _S=`.ProseMirror {
|
|
71
71
|
position: relative;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -137,81 +137,81 @@ img.ProseMirror-separator {
|
|
|
137
137
|
|
|
138
138
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
139
139
|
display: block;
|
|
140
|
-
}`;var
|
|
140
|
+
}`;var zS=class extends Zx{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:Mx,createMappablePosition:Tx},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=oa(e,this.options.autofocus);this.editorState=Dt.create({doc:e,schema:this.schema,selection:n||void 0})}$S(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():nr.createFakeChain()}can(){return this.commandManager?this.commandManager.can():nr.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=fS(_S,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=la(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?[NS,MS.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),TS,LS,IS,DS.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),ES,RS,AS,PS.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 nr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=sa(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=sa(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Dt.create({doc:n,schema:this.schema,selection:oa(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 la(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 fh(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 Ph(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return wx(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xa(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
141
141
|
|
|
142
|
-
`,textSerializers:n={}}=t||{};return
|
|
142
|
+
`,textSerializers:n={}}=t||{};return mx(this.state.doc,{blockSeparator:e,textSerializers:{...Dh(this.schema),...n}})}get isEmpty(){return wi(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 BS(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Bn(t){return new Mi({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(m=>m===t.type&&m!==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 FS(t){return new Mi({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 ca(t){return new Mi({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 dr(t){return new Mi({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&&Ra(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,m=d||u.$to.parentOffset&&u.$from.marks();if(m){const g=m.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&&mn(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var Ge=class Jh extends Za{constructor(...e){super(...e),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Jh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function pn(t){return new Kh({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(m=>m.mark.type.excluded.find(g=>g===t.type&&g!==m.mark.type)).filter(m=>m.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 Gh=new WeakSet,Xh=new WeakSet;function kn(t){const e=t;return Gh.add(e),e}function ua(t){return Array.isArray(t)&&Gh.has(t)}function Zh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Xh.has(e)&&!ua(e)?Zh(e):[e])}function HS(t,e){if(t==="slot")return 0;if(t instanceof Function){const i=t(e);return Array.isArray(i)&&!ua(i)&&!Xh.has(i)?kn(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(ua(n))return kn([t,r,n]);if(n.length===0)return kn([t,r]);const i=Zh(n);return i.length===0?kn([t,r]):kn([t,r,...i])}return n!=null?kn([t,r,n]):kn([t,r])}const xo=(t,e)=>HS(t,e),jS=(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 m=o.parent.content,g=new _(m,0,0);return d.replace(u,o.after(),g),d.setSelection(U.create(d.doc,u+m.size)),d.scrollIntoView(),p(d),!0})},VS=/^\s*>\s$/,qS=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
143
|
`).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
|
|
144
144
|
`))}),r.join(`
|
|
145
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:()=>
|
|
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:()=>jS(this.editor,this.type)}},addInputRules(){return[dr({find:VS,type:this.type})]}}),US=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,WS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,KS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,YS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,JS=yn.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[Bn({find:US,type:this.type}),Bn({find:KS,type:this.type})]},addPasteRules(){return[pn({find:WS,type:this.type}),pn({find:YS,type:this.type})]}}),GS=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},XS=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 ZS(t){const e=new Set((t.match(/`+/g)||[]).map(r=>r.length));let n=1;for(;e.has(n);)n+=1;return n}const QS=yn.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(ZS(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[Bn({find:GS,type:this.type})]},addPasteRules(){return[pn({find:XS,type:this.type})]}}),Cl=4,ew=/^```([a-z]+)?[\s\n]$/,tw=/^~~~([a-z]+)?[\s\n]$/,nw=Ge.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Cl,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
147
|
`):r=`\`\`\`${i}
|
|
148
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:
|
|
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:Cl,{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
150
|
`,`
|
|
151
151
|
`).split(`
|
|
152
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:
|
|
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:Cl,{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
154
|
`,`
|
|
155
155
|
`).split(`
|
|
156
|
-
`);let m=0,g=0;const b=c-u;for(let R=0;R<p.length;R+=1){if(g+p[R].length>=b){m=R;break}g+=p[R].length+1}const x=((a=p[m].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<m;R+=1)T+=p[R].length+1;return l.delete(T,T+w),c-T<=w&&l.setSelection(
|
|
156
|
+
`);let m=0,g=0;const b=c-u;for(let R=0;R<p.length;R+=1){if(g+p[R].length>=b){m=R;break}g+=p[R].length+1}const x=((a=p[m].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<m;R+=1)T+=p[R].length+1;return l.delete(T,T+w),c-T<=w&&l.setSelection(U.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=i,u=r.doc.textBetween(a,c,`
|
|
157
157
|
`,`
|
|
158
158
|
`).split(`
|
|
159
159
|
`).map(d=>{var p;const m=((p=d.match(/^ */))===null||p===void 0?void 0:p[0])||"",g=Math.min(m.length,n);return d.slice(g)}).join(`
|
|
160
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
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(
|
|
163
|
-
`));return s.replaceSelectionWith(this.type.create({language:o},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(
|
|
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[ca({find:ew,type:this.type,getAttributes:t=>({language:t[1]})}),ca({find:tw,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(U.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),rw=Ge.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
164
164
|
|
|
165
|
-
`):""}),
|
|
165
|
+
`):""}),iw=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
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()}}}),GS=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=>sa({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),XS=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(!nS(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Ih(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[LS({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ZS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,QS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ew=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,tw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,nw=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:ZS,type:this.type}),$n({find:ew,type:this.type})]},addPasteRules(){return[fn({find:QS,type:this.type}),fn({find:tw,type:this.type})]}}),rw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",iw="ελ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",aa="numeric",ca="ascii",ua="alpha",Vr="asciinumeric",$r="alphanumeric",da="domain",Jh="emoji",ow="scheme",sw="slashscheme",Cl="whitespace";function lw(t,e){return t in e||(e[t]=[]),e[t]}function Mn(t,e,n){e[aa]&&(e[Vr]=!0,e[$r]=!0),e[ca]&&(e[Vr]=!0,e[ua]=!0),e[Vr]&&(e[$r]=!0),e[ua]&&(e[$r]=!0),e[$r]&&(e[da]=!0),e[Jh]&&(e[da]=!0);for(const r in e){const i=lw(r,n);i.indexOf(t)<0&&i.push(t)}}function aw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ye(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ye.groups={};Ye.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||Ye.groups;let i;return e&&e.j?i=e:(i=new Ye(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||Ye.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 Ye,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ye,o){if(r)if(s.t&&typeof s.t=="string"){const a=Object.assign(aw(s.t,r),n);Mn(o,a,r)}else n&&Mn(o,n,r);s.t=o}return i.j[t]=s,s}};const Q=(t,e,n,r,i)=>t.ta(e,n,r,i),he=(t,e,n,r,i)=>t.tr(e,n,r,i),kd=(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",fa="UWORD",Gh="ASCIINUMERICAL",Xh="ALPHANUMERICAL",ui="LOCALHOST",pa="TLD",ha="UTLD",no="SCHEME",Zn="SLASH_SCHEME",Ga="NUM",ma="WS",Xa="NL",Ur="OPENBRACE",qr="CLOSEBRACE",xo="OPENBRACKET",So="CLOSEBRACKET",wo="OPENPAREN",Co="CLOSEPAREN",vo="OPENANGLEBRACKET",Mo="CLOSEANGLEBRACKET",To="FULLWIDTHLEFTPAREN",Ao="FULLWIDTHRIGHTPAREN",Eo="LEFTCORNERBRACKET",No="RIGHTCORNERBRACKET",Oo="LEFTWHITECORNERBRACKET",Lo="RIGHTWHITECORNERBRACKET",Io="FULLWIDTHLESSTHAN",Ro="FULLWIDTHGREATERTHAN",Do="AMPERSAND",Po="APOSTROPHE",$o="ASTERISK",Xt="AT",Bo="BACKSLASH",_o="BACKTICK",zo="CARET",Tn="COLON",Za="COMMA",Fo="DOLLAR",yt="DOT",Ho="EQUALS",Qa="EXCLAMATION",ot="HYPHEN",Wr="PERCENT",jo="PIPE",Vo="PLUS",Uo="POUND",Kr="QUERY",ec="QUOTE",Zh="FULLWIDTHMIDDLEDOT",tc="SEMI",bt="SLASH",Yr="TILDE",qo="UNDERSCORE",Qh="EMOJI",Wo="SYM";var em=Object.freeze({__proto__:null,ALPHANUMERICAL:Xh,AMPERSAND:Do,APOSTROPHE:Po,ASCIINUMERICAL:Gh,ASTERISK:$o,AT:Xt,BACKSLASH:Bo,BACKTICK:_o,CARET:zo,CLOSEANGLEBRACKET:Mo,CLOSEBRACE:qr,CLOSEBRACKET:So,CLOSEPAREN:Co,COLON:Tn,COMMA:Za,DOLLAR:Fo,DOT:yt,EMOJI:Qh,EQUALS:Ho,EXCLAMATION:Qa,FULLWIDTHGREATERTHAN:Ro,FULLWIDTHLEFTPAREN:To,FULLWIDTHLESSTHAN:Io,FULLWIDTHMIDDLEDOT:Zh,FULLWIDTHRIGHTPAREN:Ao,HYPHEN:ot,LEFTCORNERBRACKET:Eo,LEFTWHITECORNERBRACKET:Oo,LOCALHOST:ui,NL:Xa,NUM:Ga,OPENANGLEBRACKET:vo,OPENBRACE:Ur,OPENBRACKET:xo,OPENPAREN:wo,PERCENT:Wr,PIPE:jo,PLUS:Vo,POUND:Uo,QUERY:Kr,QUOTE:ec,RIGHTCORNERBRACKET:No,RIGHTWHITECORNERBRACKET:Lo,SCHEME:no,SEMI:tc,SLASH:bt,SLASH_SCHEME:Zn,SYM:Wo,TILDE:Yr,TLD:pa,UNDERSCORE:qo,UTLD:ha,UWORD:fa,WORD:Lt,WS:ma});const Et=/[a-z]/,Ar=new RegExp("\\p{L}","u"),vl=new RegExp("\\p{Emoji}","u"),Nt=/\d/,Ml=/\s/,xd="\r",Tl=`
|
|
168
|
-
`,
|
|
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()}}}),ow=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=>ca({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),sw=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(!dS(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return $h(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(U.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(q.create(s.doc,a.pos)):s.setSelection(U.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(U.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[FS({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),lw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,aw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,uw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dw=yn.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[Bn({find:lw,type:this.type}),Bn({find:cw,type:this.type})]},addPasteRules(){return[pn({find:aw,type:this.type}),pn({find:uw,type:this.type})]}}),fw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",pw="ελ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",da="numeric",fa="ascii",pa="alpha",qr="asciinumeric",Br="alphanumeric",ha="domain",Qh="emoji",hw="scheme",mw="slashscheme",vl="whitespace";function gw(t,e){return t in e||(e[t]=[]),e[t]}function Tn(t,e,n){e[da]&&(e[qr]=!0,e[Br]=!0),e[fa]&&(e[qr]=!0,e[pa]=!0),e[qr]&&(e[Br]=!0),e[pa]&&(e[Br]=!0),e[Br]&&(e[ha]=!0),e[Qh]&&(e[ha]=!0);for(const r in e){const i=gw(r,n);i.indexOf(t)<0&&i.push(t)}}function yw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ye(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ye.groups={};Ye.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||Ye.groups;let i;return e&&e.j?i=e:(i=new Ye(e),n&&r&&Tn(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||Ye.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 Ye,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ye,o){if(r)if(s.t&&typeof s.t=="string"){const a=Object.assign(yw(s.t,r),n);Tn(o,a,r)}else n&&Tn(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),wd=(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",ma="UWORD",em="ASCIINUMERICAL",tm="ALPHANUMERICAL",di="LOCALHOST",ga="TLD",ya="UTLD",ro="SCHEME",Qn="SLASH_SCHEME",Qa="NUM",ba="WS",ec="NL",Ur="OPENBRACE",Wr="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",Zt="AT",_o="BACKSLASH",zo="BACKTICK",Fo="CARET",An="COLON",tc="COMMA",Ho="DOLLAR",yt="DOT",jo="EQUALS",nc="EXCLAMATION",ot="HYPHEN",Kr="PERCENT",Vo="PIPE",qo="PLUS",Uo="POUND",Yr="QUERY",rc="QUOTE",nm="FULLWIDTHMIDDLEDOT",ic="SEMI",bt="SLASH",Jr="TILDE",Wo="UNDERSCORE",rm="EMOJI",Ko="SYM";var im=Object.freeze({__proto__:null,ALPHANUMERICAL:tm,AMPERSAND:Po,APOSTROPHE:$o,ASCIINUMERICAL:em,ASTERISK:Bo,AT:Zt,BACKSLASH:_o,BACKTICK:zo,CARET:Fo,CLOSEANGLEBRACKET:To,CLOSEBRACE:Wr,CLOSEBRACKET:wo,CLOSEPAREN:vo,COLON:An,COMMA:tc,DOLLAR:Ho,DOT:yt,EMOJI:rm,EQUALS:jo,EXCLAMATION:nc,FULLWIDTHGREATERTHAN:Do,FULLWIDTHLEFTPAREN:Ao,FULLWIDTHLESSTHAN:Ro,FULLWIDTHMIDDLEDOT:nm,FULLWIDTHRIGHTPAREN:Eo,HYPHEN:ot,LEFTCORNERBRACKET:No,LEFTWHITECORNERBRACKET:Lo,LOCALHOST:di,NL:ec,NUM:Qa,OPENANGLEBRACKET:Mo,OPENBRACE:Ur,OPENBRACKET:So,OPENPAREN:Co,PERCENT:Kr,PIPE:Vo,PLUS:qo,POUND:Uo,QUERY:Yr,QUOTE:rc,RIGHTCORNERBRACKET:Oo,RIGHTWHITECORNERBRACKET:Io,SCHEME:ro,SEMI:ic,SLASH:bt,SLASH_SCHEME:Qn,SYM:Ko,TILDE:Jr,TLD:ga,UNDERSCORE:Wo,UTLD:ya,UWORD:ma,WORD:Lt,WS:ba});const Et=/[a-z]/,Er=new RegExp("\\p{L}","u"),Ml=new RegExp("\\p{Emoji}","u"),Nt=/\d/,Tl=/\s/,Cd="\r",Al=`
|
|
168
|
+
`,bw="️",kw="",El="";let Ui=null,Wi=null;function xw(t=[]){const e={};Ye.groups=e;const n=new Ye;Ui==null&&(Ui=vd(fw)),Wi==null&&(Wi=vd(pw)),P(n,"'",$o),P(n,"{",Ur),P(n,"}",Wr),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,"@",Zt),P(n,"`",zo),P(n,"^",Fo),P(n,":",An),P(n,",",tc),P(n,"$",Ho),P(n,".",yt),P(n,"=",jo),P(n,"!",nc),P(n,"-",ot),P(n,"%",Kr),P(n,"|",Vo),P(n,"+",qo),P(n,"#",Uo),P(n,"?",Yr),P(n,'"',rc),P(n,"/",bt),P(n,";",ic),P(n,"~",Jr),P(n,"_",Wo),P(n,"\\",_o),P(n,"・",nm);const r=he(n,Nt,Qa,{[da]:!0});he(r,Nt,r);const i=he(r,Et,em,{[qr]:!0}),o=he(r,Er,tm,{[Br]:!0}),s=he(n,Et,Lt,{[fa]:!0});he(s,Nt,i),he(s,Et,s),he(i,Nt,i),he(i,Et,i);const l=he(n,Er,ma,{[pa]:!0});he(l,Et),he(l,Nt,o),he(l,Er,l),he(o,Nt,o),he(o,Et),he(o,Er,o);const a=P(n,Al,ec,{[vl]:!0}),c=P(n,Cd,ba,{[vl]:!0}),u=he(n,Tl,ba,{[vl]:!0});P(n,El,u),P(c,Al,a),P(c,El,u),he(c,Tl,u),P(u,Cd),P(u,Al),he(u,Tl,u),P(u,El,u);const d=he(n,Ml,rm,{[Qh]:!0});P(d,"#"),he(d,Ml,d),P(d,bw,d);const p=P(d,kw);P(p,"#"),he(p,Ml,d);const m=[[Et,s],[Nt,i]],g=[[Et,null],[Er,l],[Nt,o]];for(let b=0;b<Ui.length;b++)Yt(n,Ui[b],ga,Lt,m);for(let b=0;b<Wi.length;b++)Yt(n,Wi[b],ya,ma,g);Tn(ga,{tld:!0,ascii:!0},e),Tn(ya,{utld:!0,alpha:!0},e),Yt(n,"file",ro,Lt,m),Yt(n,"mailto",ro,Lt,m),Yt(n,"http",Qn,Lt,m),Yt(n,"https",Qn,Lt,m),Yt(n,"ftp",Qn,Lt,m),Yt(n,"ftps",Qn,Lt,m),Tn(ro,{scheme:!0,ascii:!0},e),Tn(Qn,{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]?{[hw]:!0}:{[mw]:!0};x.indexOf("-")>=0?T[ha]=!0:Et.test(x)?Nt.test(x)?T[qr]=!0:T[fa]=!0:T[da]=!0,wd(n,x,x,T)}return wd(n,"localhost",di,{ascii:!0}),n.jd=new Ye(Ko),{start:n,tokens:Object.assign({groups:e},im)}}function om(t,e){const n=Sw(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 Sw(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 Yt(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 Ye(r),o.jr=i.slice(),t.j[a]=o),t=o}return o=new Ye(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function vd(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 fi={defaultProtocol:"http",events:null,format:Md,formatHref:Md,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oc(t,e=null){let n=Object.assign({},fi);t&&(n=Object.assign(n,t instanceof oc?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}oc.prototype={o:fi,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]:fi[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 Md(t){return t}function sm(t,e){this.t="token",this.v=t,this.tk=e}sm.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=fi.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 sm{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 ww=ks("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Td=ks("text"),Cw=ks("nl"),Ki=ks("url",{isLink:!0,toHref(t=fi.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==di&&t[1].t===An}}),rt=t=>new Ye(t);function vw({groups:t}){const e=t.domain.concat([Po,Bo,Zt,_o,zo,Fo,Ho,jo,ot,Qa,Kr,Vo,qo,Uo,bt,Ko,Jr,Wo]),n=[$o,An,tc,yt,nc,Kr,Yr,rc,ic,Mo,To,Ur,Wr,wo,So,Co,vo,Ao,Eo,No,Oo,Lo,Io,Ro,Do],r=[Po,$o,Bo,_o,zo,Fo,Ho,jo,ot,Ur,Wr,Kr,Vo,qo,Uo,Yr,bt,Ko,Jr,Wo],i=rt(),o=P(i,Jr);Z(o,r,o),Z(o,t.domain,o);const s=rt(),l=rt(),a=rt();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,Zt);P(o,Zt,c),P(l,Zt,c),P(a,Zt,c);const u=P(o,yt);Z(u,r,o),Z(u,t.domain,o);const d=rt();Z(c,t.domain,d),Z(d,t.domain,d);const p=P(d,yt);Z(p,t.domain,d);const m=rt(ww);Z(p,t.tld,m),Z(p,t.utld,m),P(c,di,m);const g=P(d,ot);P(g,ot,g),Z(g,t.domain,d),Z(m,t.domain,d),P(m,yt,p),P(m,ot,g);const b=P(s,ot),x=P(s,yt);P(b,ot,b),Z(b,t.domain,s),Z(x,r,o),Z(x,t.domain,s);const w=rt(Ki);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,ot,b),P(w,Zt,c);const T=P(w,An),R=rt(Ki);Z(T,t.numeric,R);const $=rt(Ki),Y=rt();Z($,e,$),Z($,n,Y),Z(Y,e,$),Z(Y,n,Y),P(w,bt,$),P(R,bt,$);const te=P(l,An),j=P(a,An),Q=P(j,bt),ee=P(Q,bt);Z(l,t.domain,s),P(l,yt,x),P(l,ot,b),Z(a,t.domain,s),P(a,yt,x),P(a,ot,b),Z(te,t.domain,$),P(te,bt,$),P(te,Yr,$),Z(ee,t.domain,$),Z(ee,e,$),P(ee,bt,$);const ye=[[Ur,Wr],[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=rt(Ki);Z(le,e,De);const z=rt();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,di,w),P(i,ec,Cw),{start:i,tokens:im}}function Mw(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(Nl(Td,e,s)),s=[]),i-=p,u-=p;const m=d.t,g=n.slice(i-u,i);o.push(Nl(m,e,g))}}return s.length>0&&o.push(Nl(Td,e,s)),o}function Nl(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 Tw=typeof console<"u"&&console&&console.warn||(()=>{}),Aw="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 Ew(){return Ye.groups={},de.scanner=null,de.parser=null,de.tokenQueue=[],de.pluginQueue=[],de.customSchemes=[],de.initialized=!1,de}function Ad(t,e=!1){if(de.initialized&&Tw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Aw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
169
169
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
170
170
|
2. Cannot start or end with "-"
|
|
171
|
-
3. "-" cannot repeat`);de.customSchemes.push([t,e])}function xw(){de.scanner=dw(de.customSchemes);for(let t=0;t<de.tokenQueue.length;t++)de.tokenQueue[t][1]({scanner:de.scanner});de.parser=mw(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 rc(t){return de.initialized||xw(),gw(de.parser.start,t,tm(de.scanner.start,t))}rc.scan=tm;function rm(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 nc(n),i=rc(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 ks="[\0- -\u2029 ]",Sw=new RegExp(ks),ww=new RegExp(`${ks}$`),Cw=new RegExp(`${ks}+$`),vw=new RegExp(ks,"g");function Mw(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(Cw))===null||i===void 0?void 0:i[0];if(!s)return;const l=e.to-s.length,a=gs(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 Tw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Aw(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=Th(n.doc,[...e]);if(!e.some(lk)){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),m=d.map(c.from+c.slice.size,-1);p<m&&a.push({from:p,to:m})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Mw(s,c,t.type))}if(ms(l).forEach(({newRange:a})=>{const c=Qk(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(!ww.test(p))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){const p=d.split(Sw).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=u.pos+d.lastIndexOf(m);if(!m)return!1;const b=rc(m).map(x=>x.toObject(t.defaultProtocol));if(!Tw(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=>{gs(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 Ew(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=Lh(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 Nw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Ow=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function im(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Lw(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&im(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 om(t,e,n){var r,i;const[,o,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||im(t,(r=e.index)!==null&&r!==void 0?r:0)||Lw(t,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!o.trim()&&n(s)}function sm(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 Iw(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function lm(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 Rw(t){const e=$n({find:n=>{const r=Nw.exec(n);return!r||!om(n,r,t.isAllowedHref)?null:sm(r)},type:t.type,getAttributes:lm});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 Dw(t){const e=fn({find:n=>{var r,i;const o=[];for(const l of n.matchAll(Ow))om(n,l,t.isAllowedHref)&&o.push(sm(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=>Iw(a,l)));return[...o,...s]},type:t.type,getAttributes:lm});return new Vh({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 Pw(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=rm(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(vw,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const am=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"){vd(t);return}vd(t.scheme,t.optionalSlashes)})},onDestroy(){kw()},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?[Rw({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;rm(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?[Dw({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(Aw({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(Ew({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Pw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var $w=am;const Bw="listItem",Md="textStyle",Td=/^\s*([-+*])\s$/,cm=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(Bw,this.editor.getAttributes(Md)).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:Td,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ur({find:Td,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Md),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 m=i.depth;m>0;m-=1)if(i.node(m).type.name===e){o=m;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(m=>{m.type===c&&m.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(m=>{p.push(m)}),p.length===0?null:{listItemDepth:o,nestedList:d,nestedListPos:i.after(),insertPos:i.after(o),items:p}},zw=(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},Fw=(t,e,n)=>zw(t.state,t.view.dispatch,e,n),um=(t,e)=>ae.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>Fw(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),dm=[[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",fm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function xs(t){let e=t,n="";for(const[r,i]of dm)for(;e>=r;)n+=i,e-=r;return n}function ic(t){return xs(t).toUpperCase()}function pm(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let i=!1;for(const[o,s]of dm)if(e.startsWith(s,n)){r+=o,n+=s.length,i=!0;break}if(!i)return 0}return r}function Hw(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=pm(t);return e<=0?!1:(t===t.toLowerCase()?xs(e):ic(e))===t}function jw(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 Ko(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 Ss(t){if(!(!t||/^\d+$/.test(t))){if(Hw(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 oc(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=Ss(t);if(e==="i"||e==="I")return pm(t);if(e==="a"||e==="A"){const r=jw(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function Vw(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Ko(e);case"A":return Ko(e).toUpperCase();case"i":return xs(e);case"I":return ic(e);default:return String(e)}}function Uw(t){var e;if(t.length===0)return!1;const n=(e=Ss(t[0]))!==null&&e!==void 0?e:"numeric",r=oc(t[0]);if(r<1)return!1;for(let i=0;i<t.length;i++){const o=Vw(n,r+i);if(t[i]!==o)return!1}return!0}function qw(t){return{type:Ss(t),start:oc(t)}}function Ww(t){const{type:e,start:n}=qw(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function Kw(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Ko(r)}${n}`;case"A":return`${Ko(r).toUpperCase()}${n}`;case"i":return`${xs(r)}${n}`;case"I":return`${ic(r)}${n}`;default:return`${r}${n}`}}function Yw(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 Jw(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const hm=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(Yw(t))return{type:"listItem",content:[{type:"paragraph",content:Jw(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)=>Fh(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 Kw((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[um(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)}}}),sc=(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}},mm=(t,e)=>{const n=sc(t,e);if(!n)return!1;const[,r]=ux(e,t,n.$pos.pos+4);return r},Gw=(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))},Ad=(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)&&Gw(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)||!mx(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()},Xw=(t,e)=>{const n=mm(t,e),r=sc(t,e);return!r||!n?!1:n>r.depth},Zw=(t,e)=>{const n=mm(t,e),r=sc(t,e);return!r||!n?!1:n<r.depth},Ed=(t,e)=>{if(!Ft(t.state,e)||!hx(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Xw(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Zw(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Qw=(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=dx(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:m})=>(m&&(p.delete(c,u).insert(d,L.from(a)),p.setSelection(q.create(p.doc,d+1)),p.scrollIntoView()),!0))},gm=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&&Ed(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&&Ed(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&&Ad(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&&Ad(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&&Qw(t,e,n))return!0;return!1}}}}),Yo=new RegExp(`^(\\s*)(${fm})([.)])\\s+(.*)$`),e1=/^\s/,Qn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function t1(t){return Yo.test(t.trimStart())}function n1(t){const e=t.trimStart();return Qn.bulletItem.test(e)||t1(e)||Qn.heading.test(e)||Qn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Qn.codeFence.test(e)||Qn.blockMath.test(e)}function r1(t){return Object.values(Qn).some(e=>e.test(t))}function i1(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&&n1(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function Nd(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],o=i.match(Yo);if(!o)break;const[,s,l,a,c]=o,u=s.length,d=parseInt(l,10),p=isNaN(d)?Ss(l):void 0,m=isNaN(d)?oc(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(Yo))break;if(T.trim()==="")x.push(T),g.push(""),w=!0,b+=1;else if(T.match(e1)){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||r1(T))break;x.push(T),g.push(T),b+=1}}e.push({indent:u,number:m,type:p,content:g.join(`
|
|
171
|
+
3. "-" cannot repeat`);de.customSchemes.push([t,e])}function Nw(){de.scanner=xw(de.customSchemes);for(let t=0;t<de.tokenQueue.length;t++)de.tokenQueue[t][1]({scanner:de.scanner});de.parser=vw(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 sc(t){return de.initialized||Nw(),Mw(de.parser.start,t,om(de.scanner.start,t))}sc.scan=om;function lm(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 oc(n),i=sc(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 ]",Ow=new RegExp(xs),Lw=new RegExp(`${xs}$`),Iw=new RegExp(`${xs}+$`),Rw=new RegExp(xs,"g");function Dw(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(Iw))===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 Pw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function $w(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=Oh(n.doc,[...e]);if(!e.some(gk)){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),m=d.map(c.from+c.slice.size,-1);p<m&&a.push({from:p,to:m})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Dw(s,c,t.type))}if(gs(l).forEach(({newRange:a})=>{const c=ax(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(!Lw.test(p))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){const p=d.split(Ow).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=u.pos+d.lastIndexOf(m);if(!m)return!1;const b=sc(m).map(x=>x.toObject(t.defaultProtocol));if(!Pw(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 Bw(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=Ph(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 _w=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,zw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function am(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Fw(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&am(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 cm(t,e,n){var r,i;const[,o,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||am(t,(r=e.index)!==null&&r!==void 0?r:0)||Fw(t,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!o.trim()&&n(s)}function um(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 Hw(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function dm(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 jw(t){const e=Bn({find:n=>{const r=_w.exec(n);return!r||!cm(n,r,t.isAllowedHref)?null:um(r)},type:t.type,getAttributes:dm});return new Mi({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 Vw(t){const e=pn({find:n=>{var r,i;const o=[];for(const l of n.matchAll(zw))cm(n,l,t.isAllowedHref)&&o.push(um(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=>Hw(a,l)));return[...o,...s]},type:t.type,getAttributes:dm});return new Kh({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 qw(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=lm(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(Rw,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const fm=yn.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"){Ad(t);return}Ad(t.scheme,t.optionalSlashes)})},onDestroy(){Ew()},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?[jw({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;lm(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?[Vw({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})]:[pn({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($w({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(Bw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(qw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Uw=fm;const Ww="listItem",Ed="textStyle",Nd=/^\s*([-+*])\s$/,pm=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(Ww,this.editor.getAttributes(Ed)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=dr({find:Nd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=dr({find:Nd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ed),editor:this.editor})),[t]}}),Kw=(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 m=i.depth;m>0;m-=1)if(i.node(m).type.name===e){o=m;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(m=>{m.type===c&&m.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(m=>{p.push(m)}),p.length===0?null:{listItemDepth:o,nestedList:d,nestedListPos:i.after(),insertPos:i.after(o),items:p}},Yw=(t,e,n,r)=>{const i=Kw(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},Jw=(t,e,n)=>Yw(t.state,t.view.dispatch,e,n),hm=(t,e)=>ae.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>Jw(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),mm=[[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"]],Yi="abcdefghijklmnopqrstuvwxyz",gm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Ss(t){let e=t,n="";for(const[r,i]of mm)for(;e>=r;)n+=i,e-=r;return n}function lc(t){return Ss(t).toUpperCase()}function ym(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let i=!1;for(const[o,s]of mm)if(e.startsWith(s,n)){r+=o,n+=s.length,i=!0;break}if(!i)return 0}return r}function Gw(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=ym(t);return e<=0?!1:(t===t.toLowerCase()?Ss(e):lc(e))===t}function Xw(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 Yi[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Yi[n]:Yi[e]+Yi[n]}function ws(t){if(!(!t||/^\d+$/.test(t))){if(Gw(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 ac(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=ws(t);if(e==="i"||e==="I")return ym(t);if(e==="a"||e==="A"){const r=Xw(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function Zw(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 lc(e);default:return String(e)}}function Qw(t){var e;if(t.length===0)return!1;const n=(e=ws(t[0]))!==null&&e!==void 0?e:"numeric",r=ac(t[0]);if(r<1)return!1;for(let i=0;i<t.length;i++){const o=Zw(n,r+i);if(t[i]!==o)return!1}return!0}function e1(t){return{type:ws(t),start:ac(t)}}function t1(t){const{type:e,start:n}=e1(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function n1(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`${lc(r)}${n}`;default:return`${r}${n}`}}function r1(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 i1(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const bm=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(r1(t))return{type:"listItem",content:[{type:"paragraph",content:i1(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)=>qh(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 n1((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[hm(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)}}}),cc=(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}},km=(t,e)=>{const n=cc(t,e);if(!n)return!1;const[,r]=kx(e,t,n.$pos.pos+4);return r},o1=(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))},Od=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ht(t.state,e)&&o1(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(!Ht(t.state,e)||!vx(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()},s1=(t,e)=>{const n=km(t,e),r=cc(t,e);return!r||!n?!1:n>r.depth},l1=(t,e)=>{const n=km(t,e),r=cc(t,e);return!r||!n?!1:n<r.depth},Ld=(t,e)=>{if(!Ht(t.state,e)||!Cx(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:s1(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():l1(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},a1=(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||Ht(r,e))return!1;const s=xx(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:m})=>(m&&(p.delete(c,u).insert(d,L.from(a)),p.setSelection(U.create(p.doc,d+1)),p.scrollIntoView()),!0))},xm=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&&Ld(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&&Ld(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&&Od(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&&Od(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&&a1(t,e,n))return!0;return!1}}}}),Jo=new RegExp(`^(\\s*)(${gm})([.)])\\s+(.*)$`),c1=/^\s/,er={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function u1(t){return Jo.test(t.trimStart())}function d1(t){const e=t.trimStart();return er.bulletItem.test(e)||u1(e)||er.heading.test(e)||er.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||er.codeFence.test(e)||er.blockMath.test(e)}function f1(t){return Object.values(er).some(e=>e.test(t))}function p1(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&&d1(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function Id(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,m=isNaN(d)?ac(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(c1)){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||f1(T))break;x.push(T),g.push(T),b+=1}}e.push({indent:u,number:m,type:p,content:g.join(`
|
|
173
173
|
`).trim(),contentLines:g,raw:x.join(`
|
|
174
|
-
`)}),r=b,n=b}return[e,r]}const
|
|
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(
|
|
174
|
+
`)}),r=b,n=b}return[e,r]}const h1=new RegExp(`^(${gm})([.)])\\s+(.+)$`);function m1(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(h1);if(!i)return null;n.push({marker:i[1],content:i[3]})}return Qw(n.map(r=>r.marker))?{type:"orderedList",attrs:t1(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function Sm(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}=p1(o.contentLines),a=s.join(`
|
|
176
176
|
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
|
|
177
|
-
`).trim();if(u){const m=n.blockTokens(u);c.push(...m)}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 m=
|
|
178
|
-
`)})}r.push({type:"list_item",raw:o.raw,tokens:c}),i=d}else i+=1}return r}function
|
|
179
|
-
`,r);if(i===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,i)),r=i+1}return n}function
|
|
180
|
-
`),n=e===-1?t:t.slice(0,e);if(!
|
|
181
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,i;const[o,s,l]=
|
|
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(
|
|
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=md(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=md(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(cm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(hm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(gm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(h1.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(m1.configure(this.options.taskList)),t}});const Yi=" ",Nl=" ",g1=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()}}}),y1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,b1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,k1=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:y1,type:this.type})]},addPasteRules(){return[fn({find:b1,type:this.type})]}}),x1=Ge.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),S1=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 w1(t={}){return new fe({view(e){return new C1(e,t)}})}class C1{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 m=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(m){let g=m.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,m=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*m}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=op(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 X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ge.valid(r)?new ge(r):X.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 lc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!v1(e)||!M1(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;X.jsonID("gapcursor",ge);class lc{constructor(e){this.pos=e}map(e){return new lc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ge.valid(n)?new ge(n):X.near(n)}}function km(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function v1(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||km(i.type))return!0;if(i.inlineContent)return!1}}return!0}function M1(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||km(i.type))return!0;if(i.inlineContent)return!1}}return!0}function T1(){return new fe({props:{decorations:O1,createSelectionBetween(t,e,n){return e.pos==n.pos&&ge.valid(n)?new ge(n):null},handleClick:E1,handleKeyDown:A1,handleDOMEvents:{beforeinput:N1}}})}const A1=ch({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 E1(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 N1(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 O1(t){if(!(t.selection instanceof ge))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[Ve.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 L1=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[w1(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(Ve.node(c,c+a.nodeSize,{class:this.options.className}))}),re.create(t,o)}}})]}});const I1=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[T1()]},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}}}),xm="placeholder",Dd=new xe("tiptap__placeholder");function Sm(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),Ve.node(i,i+o.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:o,pos:i,hasAnchor:l}):n})}function wm(t,e){return typeof t=="function"?t(e):t}function Cm({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,m=!u.isLeaf&&Si(u);return u.type.isTextblock&&(p||!e.showOnlyCurrent)&&m&&a.push(Sm({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:wm(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:p})},node:u,pos:d})),e.includeChildren}),a}function vm({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(Sm({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:wm(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...Cm({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 R1(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 D1(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 P1(t,e){const n=R1(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 $1(t,e,n){const r=[];if(t.docChanged){const i=ms(t);for(const o of i)r.push(...P1(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)))),D1(r)}function B1(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}=B1(a.from,a.to,o),d=l.find(c,u).filter(m=>m.from>=c&&m.to<=u);d.length&&(l=l.remove(d));const p=Cm({editor:n,options:r,dataAttribute:i,doc:o,selection:s,from:c,to:u});p.length&&(l=l.add(o,p))}return l}function z1({editor:t,options:e,dataAttribute:n}){return{init(r,i){const o=vm({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:$1(r,o,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function F1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function H1({editor:t,options:e}){const n=e.dataAttribute?`data-${F1(e.dataAttribute)}`:`data-${xm}`,r=e.showOnlyCurrent&&!e.includeChildren;return new fe({key:Dd,...r?{}:{state:z1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:i,selection:o})=>vm({editor:t,options:e,dataAttribute:n,doc:i,selection:o}):i=>{var o;return e.showOnlyWhenEditable&&!t.isEditable?re.empty:(o=Dd.getState(i))!==null&&o!==void 0?o:re.empty}}})}const j1=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:xm,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[H1({editor:this.editor,options:this.options})]}});function ga(t,e){return!t.selection.empty&&!Ih(t.selection)&&e.isEditable}function V1(t,e){return ga(t,e)&&!e.isFocused&&!e.view.dragging}function U1(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function q1(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 V1(n,t)?re.create(n.doc,[Ve.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return ga(n.state,t)&&U1(),!1},focus(n){return ga(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&q1(n)}),!1}}}})]}});function Pd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}const W1=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(m=>m.getMeta("skipTrailingNode"))&&u)return a.insert(d,p.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!Pd({node:s,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!Pd({node:s,types:r})}}})]}}),K1=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ph(t,e),redo:()=>({state:t,dispatch:e})=>hh(t,e)}},addProseMirrorPlugins(){return[sk(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()}}}),Y1=ae.create({name:"starterKit",addExtensions(){const t=[];if(this.options.bold!==!1&&t.push(FS.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(PS.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(cm.configure(this.options.bulletList)),this.options.code!==!1&&t.push(US.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(KS.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(YS.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(L1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(I1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(JS.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(GS.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(K1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(XS.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(nw.configure(this.options.italic)),this.options.listItem!==!1&&t.push(hm.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(gm.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(am.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(bm.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(g1.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(k1.configure(this.options.strike)),this.options.text!==!1&&t.push(x1.configure(this.options.text)),this.options.underline!==!1){var r;t.push(S1.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;t.push(W1.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return t}});var J1=Y1,G1=j1;const X1=20,Mm=(t,e=0)=>{const n=[];return!t.children.length||e>X1||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Mm(r,e+1))}),n},Z1=t=>{if(!t.children.length)return;const e=Mm(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}`)})},Tm=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&&Z1(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}}}}),Q1=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()}}}),Am=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()}}}),eC=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()}}}),tC=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()}}}),nC=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(Q1.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Am.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(eC.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(tC.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(nC.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Tm.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 rC(t,e){if(t.blockBody){const r=e.body||"";return`{% include ${t.include} markdown="1" %}
|
|
177
|
+
`).trim();if(u){const m=n.blockTokens(u);c.push(...m)}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 m=Sm(p,Math.min(...p.map(g=>g.indent)),n);c.push({type:"list",ordered:!0,start:p[0].number,typeMarker:p[0].type,items:m,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 g1(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 y1=64;function Rd(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 b1(t){const e=t.indexOf(`
|
|
180
|
+
`),n=e===-1?t:t.slice(0,e);if(!Jo.test(n))return[[],0,[]];let r=y1,i=Rd(t,r),o=Id(i);for(;o[1]===i.length&&i.length===r;)r*=2,i=Rd(t,r),o=Id(i);return[o[0],o[1],i]}const k1="listItem",Dd="textStyle",Pd=/^(\d+)\.\s$/;function $d(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 wm=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=$d(n);if(i)return i}const r=t.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const o=$d(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?g1(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]=b1(t);if(o.length===0)return;const a=Sm(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(k1,this.editor.getAttributes(Dd)).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=m1(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=dr({find:Pd,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=dr({find:Pd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Dd)}),joinPredicate:t,editor:this.editor})),[e]}}),x1=/^\s*(\[([( |x])?\])\s$/,S1="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",w1=(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"}`},C1=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 qh(t,e,r)},addExtensions(){return this.options.nested?[hm(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=S1;const c=d=>{const p=w1(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:m})=>{const g=n();if(typeof g!="number")return!1;const b=m.doc.nodeAt(g);return m.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,m=ui(d,p),g=new Set(Object.keys(m)),b=this.options.HTMLAttributes;return u.forEach(x=>{g.has(x)||(x in b?i.setAttribute(x,b[x]):i.removeAttribute(x))}),Object.entries(m).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[dr({find:x1,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),v1=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=bd(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=bd(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(pm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(bm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(xm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(wm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(C1.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(v1.configure(this.options.taskList)),t}});const Ji=" ",Ol=" ",M1=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===Ji||n[0].text===Ji||n[0].raw===Ol||n[0].text===Ol)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ji||r[0].text===Ol)?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?Ji:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),T1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,A1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,E1=yn.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[Bn({find:T1,type:this.type})]},addPasteRules(){return[pn({find:A1,type:this.type})]}}),N1=Ge.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),O1=yn.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 L1(t={}){return new fe({view(e){return new I1(e,t)}})}class I1{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 m=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(m){let g=m.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,m=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*m}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=cp(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 uc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!R1(e)||!D1(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&&!q.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 uc{constructor(e){this.pos=e}map(e){return new uc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ge.valid(n)?new ge(n):G.near(n)}}function Cm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function R1(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||Cm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function D1(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||Cm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function P1(){return new fe({props:{decorations:z1,createSelectionBetween(t,e,n){return e.pos==n.pos&&ge.valid(n)?new ge(n):null},handleClick:B1,handleKeyDown:$1,handleDOMEvents:{beforeinput:_1}}})}const $1=ph({ArrowLeft:Gi("horiz",-1),ArrowRight:Gi("horiz",1),ArrowUp:Gi("vert",-1),ArrowDown:Gi("vert",1)});function Gi(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 U){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 B1(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&&q.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ge(r))),!0)}function _1(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(U.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function z1(t){if(!(t.selection instanceof ge))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[Ve.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 F1=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[L1(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(Ve.node(c,c+a.nodeSize,{class:this.options.className}))}),re.create(t,o)}}})]}});const H1=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[P1()]},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}}}),vm="placeholder",Bd=new xe("tiptap__placeholder");function Mm(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),Ve.node(i,i+o.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:o,pos:i,hasAnchor:l}):n})}function Tm(t,e){return typeof t=="function"?t(e):t}function Am({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,m=!u.isLeaf&&wi(u);return u.type.isTextblock&&(p||!e.showOnlyCurrent)&&m&&a.push(Mm({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tm(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:p})},node:u,pos:d})),e.includeChildren}),a}function Em({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&&wi(c)){const d=o>=u&&o<=u+c.nodeSize;s.push(Mm({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tm(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...Am({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return re.create(r,s)}function Gr(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 Xr(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function j1(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 V1(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 q1(t,e){const n=j1(t,e.from,e.to);return n.push(Xr(t,Gr(t,e.from))),e.to>e.from?n.push(Xr(t,Gr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Xr(t,Gr(t,Math.min(e.from+1,t.content.size)))),n}function U1(t,e,n){const r=[];if(t.docChanged){const i=gs(t);for(const o of i)r.push(...q1(n.doc,o.newRange))}return t.selectionSet&&(r.push(Xr(n.doc,Gr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Xr(n.doc,Gr(n.doc,n.selection.anchor)))),V1(r)}function W1(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 K1({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}=W1(a.from,a.to,o),d=l.find(c,u).filter(m=>m.from>=c&&m.to<=u);d.length&&(l=l.remove(d));const p=Am({editor:n,options:r,dataAttribute:i,doc:o,selection:s,from:c,to:u});p.length&&(l=l.add(o,p))}return l}function Y1({editor:t,options:e,dataAttribute:n}){return{init(r,i){const o=Em({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:K1({decorations:i.map(r.mapping,r.doc),ranges:U1(r,o,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function J1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function G1({editor:t,options:e}){const n=e.dataAttribute?`data-${J1(e.dataAttribute)}`:`data-${vm}`,r=e.showOnlyCurrent&&!e.includeChildren;return new fe({key:Bd,...r?{}:{state:Y1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:i,selection:o})=>Em({editor:t,options:e,dataAttribute:n,doc:i,selection:o}):i=>{var o;return e.showOnlyWhenEditable&&!t.isEditable?re.empty:(o=Bd.getState(i))!==null&&o!==void 0?o:re.empty}}})}const X1=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:vm,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[G1({editor:this.editor,options:this.options})]}});function ka(t,e){return!t.selection.empty&&!$h(t.selection)&&e.isEditable}function Z1(t,e){return ka(t,e)&&!e.isFocused&&!e.view.dragging}function Q1(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function eC(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 Z1(n,t)?re.create(n.doc,[Ve.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return ka(n.state,t)&&Q1(),!1},focus(n){return ka(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&eC(n)}),!1}}}})]}});function _d({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}const tC=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(m=>m.getMeta("skipTrailingNode"))&&u)return a.insert(d,p.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!_d({node:s,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!_d({node:s,types:r})}}})]}}),nC=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>yh(t,e),redo:()=>({state:t,dispatch:e})=>bh(t,e)}},addProseMirrorPlugins(){return[mk(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()}}}),rC=ae.create({name:"starterKit",addExtensions(){const t=[];if(this.options.bold!==!1&&t.push(JS.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(qS.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(pm.configure(this.options.bulletList)),this.options.code!==!1&&t.push(QS.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(nw.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(rw.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(F1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(H1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(iw.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(ow.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(nC.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(sw.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(dw.configure(this.options.italic)),this.options.listItem!==!1&&t.push(bm.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(xm.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(fm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(wm.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(M1.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(E1.configure(this.options.strike)),this.options.text!==!1&&t.push(N1.configure(this.options.text)),this.options.underline!==!1){var r;t.push(O1.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;t.push(tC.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return t}});var iC=rC,oC=X1;const sC=20,Nm=(t,e=0)=>{const n=[];return!t.children.length||e>sC||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Nm(r,e+1))}),n},lC=t=>{if(!t.children.length)return;const e=Nm(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}`)})},Om=yn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&lC(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}}}}),aC=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=Ci(t,"background-color"))!==null&&e!==void 0?e:t.style.backgroundColor;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>vi(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()}}}),Lm=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=Ci(t,"color"))!==null&&e!==void 0?e:t.style.color;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>vi(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()}}}),cC=ae.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=Ci(t,"font-family"))!==null&&e!==void 0?e:t.style.fontFamily},renderHTML:t=>vi(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()}}}),uC=ae.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=Ci(t,"font-size"))!==null&&e!==void 0?e:t.style.fontSize},renderHTML:t=>vi(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()}}}),dC=ae.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=Ci(t,"line-height"))!==null&&e!==void 0?e:t.style.lineHeight},renderHTML:t=>vi(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(aC.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Lm.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(cC.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(uC.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(dC.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Om.configure(this.options.textStyle)),t}});const fr=[{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 fC(t,e){if(t.blockBody){const r=e.body||"";return`{% include ${t.include} markdown="1" %}
|
|
184
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,""")}"`);return n.length?`{% include ${t.include} ${n.join(" ")} %}`:`{% include ${t.include} %}`}function
|
|
186
|
-
`)&&n.trim()===n){t.push({type:"heading",attrs:{level:r[1].length},content
|
|
187
|
-
`;const n=
|
|
185
|
+
{% endinclude %}`}const n=t.fields.filter(r=>e[r]!=null&&String(e[r]).length).map(r=>`${r}="${String(e[r]).replace(/"/g,""")}"`);return n.length?`{% include ${t.include} ${n.join(" ")} %}`:`{% include ${t.include} %}`}function Im(t){const e={};return String(t||"").replace(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,(n,r,i,o)=>(e[r]=i??o,"")),e}const Rm=/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g;function Go(t){return fr.find(e=>e.include===t)}function pC(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:dc(i,r[2],r[0])}function dc(t,e,n){return{type:t.name,attrs:{...Im(e),raw:n}}}function hC(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=Im(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 Dm(t,e){return hC(t,e)?e.raw:fC(t,e)}function zd(t){const e=String(t||""),n=[],r=new RegExp(Rm.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(dc(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 Pm(t){return String(t||"").replace(/^\n+|\n+$/g,"")}function Fd(t,e){const n=Pm(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:zd(r[2])});return}t.push({type:"paragraph",content:zd(n)})}function mC(t,e){const n=Pm(e);if(!n)return;const r=pC(n);if(r){t.push(r);return}const i=new RegExp(Rm.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:dc(c,l[2],l[0])}),s=l.index+l[0].length)}if(!a){Fd(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()&&Fd(t,c.text)}function gC(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&&Hd(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&&Hd(t,o.slice(r))}function Hd(t,e){const n=String(e||"").split(/\n{2,}/);for(const r of n)mC(t,r)}function xa(t){const e=[];return gC(e,t),e.length||e.push({type:"paragraph"}),{type:"doc",content:e}}function jd(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=fr.find(o=>o.name===e.type);return n?Dm(n,e.attrs||{}):""}).join("")}function _r(t){return(t||[]).map(e=>{var r,i;const n=fr.find(o=>o.name===e.type);if(n){const o=Dm(n,e.attrs||{});return o.endsWith(`
|
|
188
188
|
`)?`${o}
|
|
189
189
|
`:`${o}
|
|
190
190
|
|
|
191
|
-
`}switch(e.type){case"paragraph":return`${
|
|
191
|
+
`}switch(e.type){case"paragraph":return`${jd(e.content||[])}
|
|
192
192
|
|
|
193
|
-
`;case"heading":{const o=((r=e.attrs)==null?void 0:r.level)||1;return`${"#".repeat(o)} ${
|
|
193
|
+
`;case"heading":{const o=((r=e.attrs)==null?void 0:r.level)||1;return`${"#".repeat(o)} ${jd(e.content||[])}
|
|
194
194
|
|
|
195
|
-
`}case"blockquote":return
|
|
195
|
+
`}case"blockquote":return _r(e.content||[]).split(`
|
|
196
196
|
`).map(o=>o?`> ${o}`:">").join(`
|
|
197
197
|
`)+`
|
|
198
198
|
|
|
199
|
-
`;case"bulletList":return(e.content||[]).map(o=>`- ${
|
|
199
|
+
`;case"bulletList":return(e.content||[]).map(o=>`- ${_r(o.content||[]).trim()}`).join(`
|
|
200
200
|
`)+`
|
|
201
201
|
|
|
202
|
-
`;case"orderedList":return(e.content||[]).map((o,s)=>`${s+1}. ${
|
|
202
|
+
`;case"orderedList":return(e.content||[]).map((o,s)=>`${s+1}. ${_r(o.content||[]).trim()}`).join(`
|
|
203
203
|
`)+`
|
|
204
204
|
|
|
205
205
|
`;case"codeBlock":return"```"+(((i=e.attrs)==null?void 0:i.language)||"")+`
|
|
206
206
|
`+(e.content||[]).map(s=>s.text||"").join("")+"\n```\n\n";case"horizontalRule":return`---
|
|
207
207
|
|
|
208
|
-
`;default:return e.content?
|
|
209
|
-
`}function
|
|
210
|
-
]`).replace("lheading",
|
|
208
|
+
`;default:return e.content?_r(e.content):""}}).join("")}function $m(t){return _r(t).trim()+`
|
|
209
|
+
`}function yC(t){const e=xa(t);return $m(e.content||[])}function bC(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 Vd(t){const e=t.getJSON();return $m(e.content||[])}function kC(t,{content:e="",onUpdate:n}={}){const r=fr.map(bC),i=new zS({element:t,extensions:[iC.configure({heading:{levels:[1,2,3,4]}}),Om,Lm,Uw.configure({autolink:!1,linkOnPaste:!1,openOnClick:!1}),oC.configure({placeholder:"Write… Use Insert for Liquid blocks."}),...r],content:xa(e),onUpdate:({editor:o})=>{n&&n(Vd(o))}});return{editor:i,getMarkdown:()=>Vd(i),setMarkdown:o=>{i.commands.setContent(xa(o))},destroy:()=>i.destroy(),insertInclude:(o,s={})=>{const l=fr.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]||"",m=[...d].slice(1).join("");return p.toLocaleUpperCase()+m.toLocaleLowerCase()});else return;i.chain().focus().insertContentAt({from:s,to:l},u).run()}}}function fc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Hn=fc();function Bm(t){Hn=t}var Zr={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(qe.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var qe={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")},xC=/^(?:[ \t]*(?:\n|$))+/,SC=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,wC=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ti=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,CC=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pc=/(?:[*+-]|\d{1,9}[.)])/,_m=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zm=se(_m).replace(/bull/g,pc).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(),vC=se(_m).replace(/bull/g,pc).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(),hc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,MC=/^[^\n]+/,mc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,TC=se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",mc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),AC=se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,pc).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",gc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,EC=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",gc).replace("tag",Cs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fm=se(hc).replace("hr",Ti).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(),NC=se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Fm).getRegex(),yc={blockquote:NC,code:SC,def:TC,fences:wC,heading:CC,hr:Ti,html:EC,lheading:zm,list:AC,newline:xC,paragraph:Fm,table:Zr,text:MC},qd=se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ti).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(),OC={...yc,lheading:vC,table:qd,paragraph:se(hc).replace("hr",Ti).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qd).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()},LC={...yc,html:se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gc).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:Zr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:se(hc).replace("hr",Ti).replace("heading",` *#{1,6} *[^
|
|
210
|
+
]`).replace("lheading",zm).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},IC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,RC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Hm=/^( {2,}|\\)\n(?!\s*$)/,DC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vs=/[\p{P}\p{S}]/u,bc=/[\s\p{P}\p{S}]/u,jm=/[^\s\p{P}\p{S}]/u,PC=se(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bc).getRegex(),Vm=/(?!~)[\p{P}\p{S}]/u,$C=/(?!~)[\s\p{P}\p{S}]/u,BC=/(?:[^\s\p{P}\p{S}]|~)/u,_C=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,qm=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,zC=se(qm,"u").replace(/punct/g,vs).getRegex(),FC=se(qm,"u").replace(/punct/g,Vm).getRegex(),Um="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",HC=se(Um,"gu").replace(/notPunctSpace/g,jm).replace(/punctSpace/g,bc).replace(/punct/g,vs).getRegex(),jC=se(Um,"gu").replace(/notPunctSpace/g,BC).replace(/punctSpace/g,$C).replace(/punct/g,Vm).getRegex(),VC=se("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,jm).replace(/punctSpace/g,bc).replace(/punct/g,vs).getRegex(),qC=se(/\\(punct)/,"gu").replace(/punct/g,vs).getRegex(),UC=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(),WC=se(gc).replace("(?:-->|$)","-->").getRegex(),KC=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",WC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,YC=se(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wm=se(/^!?\[(label)\]\[(ref)\]/).replace("label",Xo).replace("ref",mc).getRegex(),Km=se(/^!?\[(ref)\](?:\[\])?/).replace("ref",mc).getRegex(),JC=se("reflink|nolink(?!\\()","g").replace("reflink",Wm).replace("nolink",Km).getRegex(),kc={_backpedal:Zr,anyPunctuation:qC,autolink:UC,blockSkip:_C,br:Hm,code:RC,del:Zr,emStrongLDelim:zC,emStrongRDelimAst:HC,emStrongRDelimUnd:VC,escape:IC,link:YC,nolink:Km,punctuation:PC,reflink:Wm,reflinkSearch:JC,tag:KC,text:DC,url:Zr},GC={...kc,link:se(/^!?\[(label)\]\((.*?)\)/).replace("label",Xo).getRegex(),reflink:se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xo).getRegex()},Sa={...kc,emStrongRDelimAst:jC,emStrongLDelim:FC,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},XC={...Sa,br:se(Hm).replace("{2,}","*").getRegex(),text:se(Sa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Xi={normal:yc,gfm:OC,pedantic:LC},Nr={normal:kc,gfm:Sa,breaks:XC,pedantic:GC},ZC={"&":"&","<":"<",">":">",'"':""","'":"'"},Ud=t=>ZC[t];function mt(t,e){if(e){if(qe.escapeTest.test(t))return t.replace(qe.escapeReplace,Ud)}else if(qe.escapeTestNoEncode.test(t))return t.replace(qe.escapeReplaceNoEncode,Ud);return t}function Wd(t){try{t=encodeURI(t).replace(qe.percentDecode,"%")}catch{return null}return t}function Kd(t,e){var o;const n=t.replace(qe.findPipe,(s,l,a)=>{let c=!1,u=l;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(qe.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(qe.slashPipe,"|");return r}function Or(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 QC(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 Yd(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 ev(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
|
|
211
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
|
|
213
|
-
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=
|
|
214
|
-
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
212
|
+
`)}var Zo=class{constructor(t){ce(this,"options");ce(this,"rules");ce(this,"lexer");this.options=t||Hn}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:Or(n,`
|
|
213
|
+
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=ev(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=Or(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:Or(e[0],`
|
|
214
|
+
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Or(e[0],`
|
|
215
215
|
`).split(`
|
|
216
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
217
|
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -225,14 +225,14 @@ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
225
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
226
|
`,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),p=t.split(`
|
|
227
227
|
`,1)[0],m=!d.trim(),g=0;if(this.options.pedantic?(g=2,u=d.trimStart()):m?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),m&&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),
|
|
229
|
-
`,1)[0];let j;if(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 te=t.split(`
|
|
229
|
+
`,1)[0];let j;if(p=te,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
230
|
`+j.slice(g);else{if(m||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(d)||$.test(d)||T.test(d))break;u+=`
|
|
231
|
-
`+p}!m&&!p.trim()&&(m=!0),c+=
|
|
232
|
-
`,t=t.substring(
|
|
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(
|
|
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=
|
|
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(
|
|
231
|
+
`+p}!m&&!p.trim()&&(m=!0),c+=te+`
|
|
232
|
+
`,t=t.substring(te.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=Kd(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(Kd(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=Or(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{const o=QC(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)),Yd(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 Yd(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 m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}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}}}},Bt=class wa{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||Hn,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:qe,block:Xi.normal,inline:Nr.normal};this.options.pedantic?(n.block=Xi.pedantic,n.inline=Nr.pedantic):this.options.gfm&&(n.block=Xi.gfm,this.options.breaks?n.inline=Nr.breaks:n.inline=Nr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Xi,inline:Nr}}static lex(e,n){return new wa(n).lex(e)}static lexInline(e,n){return new wa(n).inlineTokens(e)}lex(e){e=e.replace(qe.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(qe.tabCharGlobal," ").replace(qe.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
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
237
|
`+l.raw,c.text+=`
|
|
238
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+=`
|
|
@@ -241,7 +241,7 @@ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
241
241
|
`+l.raw,c.text+=`
|
|
242
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
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 m=e.slice(1);let g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},m),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}},
|
|
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 m=e.slice(1);let g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},m),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||Hn}space(t){return""}code({text:t,lang:e,escaped:n}){var o;const r=(o=(e||"").match(qe.notSpaceStart))==null?void 0:o[0],i=t.replace(qe.endingNewline,"")+`
|
|
245
245
|
`;return r?'<pre><code class="language-'+mt(r)+'">'+(n?i:mt(i,!0))+`</code></pre>
|
|
246
246
|
`:"<pre><code>"+(n?i:mt(i,!0))+`</code></pre>
|
|
247
247
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
@@ -259,37 +259,37 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
259
259
|
`}tablerow({text:t}){return`<tr>
|
|
260
260
|
${t}</tr>
|
|
261
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=
|
|
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}}
|
|
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}}},
|
|
265
|
-
`)}function
|
|
266
|
-
`).toLowerCase().includes(n)):t.slice()}function
|
|
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=Wd(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=Wd(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)}},xc=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""}},_t=class Ca{constructor(e){ce(this,"options");ce(this,"renderer");ce(this,"textRenderer");this.options=e||Hn,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 xc}static parse(e,n){return new Ca(n).parse(e)}static parseInline(e,n){return new Ca(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}},zl,io=(zl=class{constructor(t){ce(this,"options");ce(this,"block");this.options=t||Hn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Bt.lex:Bt.lexInline}provideParser(){return this.block?_t.parse:_t.parseInline}},ce(zl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),zl),tv=class{constructor(...t){ce(this,"defaults",fc());ce(this,"options",this.setOptions);ce(this,"parse",this.parseMarkdown(!0));ce(this,"parseInline",this.parseMarkdown(!1));ce(this,"Parser",_t);ce(this,"Renderer",Qo);ce(this,"TextRenderer",xc);ce(this,"Lexer",Bt);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 Bt.lex(t,e??this.defaults)}parser(t,e){return _t.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?Bt.lex:Bt.lexInline,a=o.hooks?o.hooks.provideParser():t?_t.parse:_t.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}}},_n=new tv;function oe(t,e){return _n.parse(t,e)}oe.options=oe.setOptions=function(t){return _n.setOptions(t),oe.defaults=_n.defaults,Bm(oe.defaults),oe};oe.getDefaults=fc;oe.defaults=Hn;oe.use=function(...t){return _n.use(...t),oe.defaults=_n.defaults,Bm(oe.defaults),oe};oe.walkTokens=function(t,e){return _n.walkTokens(t,e)};oe.parseInline=_n.parseInline;oe.Parser=_t;oe.parser=_t.parse;oe.Renderer=Qo;oe.TextRenderer=xc;oe.Lexer=Bt;oe.lexer=Bt.lex;oe.Tokenizer=Zo;oe.Hooks=io;oe.parse=oe;oe.options;oe.setOptions;oe.use;oe.walkTokens;oe.parseInline;_t.parse;Bt.lex;function Ie(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Se(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function mr(t){const e=String(t??"").trim();if(!e)return"";const n=e.match(/^\[([^\]]*)\]\(([^)\s]+)\)\s*$/);return n?String(n[2]||"").trim():e}function Ym(t,e="100"){let n=String(t==null||t===""?e:t).trim();return n||(n=e),n=n.replace(/%$/,""),`max-width:${Ie(n)}%;`}function nv(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 rv(t){const e=mr(t.src);if(!e)return"";const n=Ym(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 iv(t){const e=mr(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 Jm(t){const e=mr(t);if(!e)return"";const n=e.split(/[?#]/)[0],r=n.split(/[/\\]/).filter(Boolean);return r[r.length-1]||n}function va(t){const e=mr(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 rr(t,{width:e,height:n,aspect:r,caption:i}={}){const o=String(t||"").trim()||"Embed",s=[Ym(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 ov(t){const e=va(t.id||t.src);return e?rr(`YouTube video: ${e}`,{width:t.width,aspect:"16 / 9",caption:t.caption}):""}function sv(t){const e=va(t.src||t.id);if(!e)return"";const n=va(t.src2||t.id2);return n?[rr(`YouTube short: ${e}`,{width:"45",aspect:"9 / 16"}),rr(`YouTube short: ${n}`,{width:"45",aspect:"9 / 16"})].join(""):rr(`YouTube short: ${e}`,{width:t.width||"45",aspect:"9 / 16"})}function lv(t){const e=mr(t.src);if(!e)return"";const n=Jm(e)||e;return rr(`Video: ${n}`,{width:t.width,aspect:"16 / 9",caption:t.caption})}function av(t){const e=mr(t.src);if(!e)return"";const n=Jm(e)||e;return rr(`Plotly: ${n}`,{width:t.width,height:t.height||"480",caption:t.caption})}function Gm(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 Sc(t,e){const n=String(e||"").trim();return Gm(n||"?",{kind:t,key:n})}function cv(t){return Sc("xcite",t.key)}function uv(t){return Sc("cite",t.key)}function dv(t){return Se(String(t||"").trim()).replace(/\r\n|\r|\n/g,"<br>")}function fv(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">${dv(t.def)}</div>`),o&&d.push(`<p class="sov-card__note">${o}</p>`),s){let p=`${Se(s)}, s.v. “${Se(e)},”`;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 pv(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 hv(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 Jd(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 mv(t,e){return Gm(String(t||"").trim(),{variant:"latex",display:!!e})}function Gd(t){return String(t||"").replace(/\\\s/g,"\\\\ ")}function gv(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,Gd(o))),n=n.replace(/\\\[([\s\S]+?)\\\]/g,(i,o)=>r(!0,Gd(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 yv(t,e){return String(t||"").replace(/\uE000MATH(\d+)\uE001/g,(n,r)=>{const i=e[Number(r)];return i?mv(i.math,i.display):""})}const bv={"figure.html":rv,"cut-in.html":iv,"youtube.html":ov,"youtube-short.html":sv,"video.html":lv,"plotly.html":av,"xcite.html":cv,"cite.html":uv,"dict-card.html":fv,"tweet.html":hv};function kv(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)=>Jd(r)),e=e.replace(/<div\s+([^>]*\barticle-note\b[^>]*)>([\s\S]*?)<\/div>/gi,(n,r,i)=>Jd(i)),e=e.replace(/\{%-?\s*cite\s+([^\s%]+)[\s\S]*?-?%\}/g,(n,r)=>Sc("cite",r)),e=e.replace(/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g,(n,r,i)=>{const o=bv[r];return o?o(nv(i)):`<div class="studio-unknown-include" data-include="${Ie(r)}"></div>`}),e}function xv(t){const e=gv(String(t||"")),n=kv(e.text);let r;try{r=oe.parse(n,{gfm:!0,breaks:!1})}catch{r=`<p>${Se(n)}</p>`}return pv(yv(r,e.store))}function xn(t,e,n=1){return String(t||"").localeCompare(String(e||""),void 0,{sensitivity:"base",numeric:!0})*n}function Xd(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)=>Xd(t.date,e.date,-1)||xn(t.title||t.name,e.title||e.name)},{id:"date-asc",label:"Date | oldest first",compare:(t,e)=>Xd(t.date,e.date,1)||xn(t.title||t.name,e.title||e.name)},{id:"title-asc",label:"Title | A–Z",compare:(t,e)=>xn(t.title||t.name,e.title||e.name,1)},{id:"title-desc",label:"Title | Z–A",compare:(t,e)=>xn(t.title||t.name,e.title||e.name,-1)},{id:"path-asc",label:"Path | A–Z",compare:(t,e)=>xn(t.path||t.name,e.path||e.name,1)},{id:"path-desc",label:"Path | Z–A",compare:(t,e)=>xn(t.path||t.name,e.path||e.name,-1)},{id:"key-asc",label:"Key | A–Z",compare:(t,e)=>xn(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",Xm="studio-list-sort:",Zm="studio-list-page-size:";function Sv(t){return es.find(e=>e.id===t)||es[0]}function wv(t){return ns.find(e=>e.id===t)||ns[0]}function Qm(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 Cv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>[r.title,r.name,r.key,r.path,r.date,Qm(r).join(" ")].filter(Boolean).join(`
|
|
266
|
+
`).toLowerCase().includes(n)):t.slice()}function vv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>Qm(r).some(i=>i.toLowerCase()===n)):t.slice()}function Mv(t,{query:e="",sortId:n=ts,tag:r=""}={}){const i=vv(Cv(t,e),r),o=Sv(n);return i.sort((s,l)=>o.compare(s,l))}function Tv(t,{pageSizeId:e=rs,page:n=1}={}){const r=wv(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 Av(t,e=ts){try{const n=localStorage.getItem(Xm+t);if(n&&es.some(r=>r.id===n))return n}catch{}return e}function Ev(t,e){try{localStorage.setItem(Xm+t,e)}catch{}}function Nv(t,e=rs){try{const n=localStorage.getItem(Zm+t);if(n&&ns.some(r=>r.id===n))return n}catch{}return e}function Ov(t,e){try{localStorage.setItem(Zm+t,e)}catch{}}const Zd={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"]},Lv=new Set(["name","filename"]);function Iv(t){const e=String(t||"").split("/").filter(Boolean);return e.length?e[e.length-1]:""}function Rv(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 Dv(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&&Zd[e]?Zd[e].slice():[]}function Pv(t,e){const n=Array.isArray(e)?e.map(String):Dv(e),r=[];for(const o of n){if(Lv.has(o))continue;const s=Rv(o,t);s&&r.push(s)}const i=String((t==null?void 0:t.name)||"").trim()||Iv(t==null?void 0:t.path);return i&&r[r.length-1]!==i&&r.push(i),r.join(" | ")}const $v={lineWidth:100,noRefs:!0,sortKeys:!1};function gr(t){return!t||t.format!=="yaml"?null:t.list?"list":t.root_key||(t.fields||[]).length?"map":"source"}function St(t){const e=dn.dump(t??null,$v);return e.endsWith(`
|
|
267
267
|
`)?e:e+`
|
|
268
|
-
`}function
|
|
268
|
+
`}function Qr(t){try{return dn.load(t)}catch(e){const n=new Error((e==null?void 0:e.message)||"Invalid YAML");throw n.cause=e,n}}function wc(t){const e={};for(const n of t||[])!(n!=null&&n.name)||n.hidden||(Object.prototype.hasOwnProperty.call(n,"default")?e[n.name]=Bv(n.default):n.list?e[n.name]=[]:n.type==="boolean"?e[n.name]=!1:e[n.name]="");return e}function Bv(t){if(t==null||typeof t!="object")return t;try{return structuredClone(t)}catch{return JSON.parse(JSON.stringify(t))}}function zn(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 eg(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}):[]}function ir(t){return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}const xt="content/media",Qd=25*1024*1024,_v=/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i,zv=/\.(mp4|webm|mov|m4v)$/i,Fv=/\.html?$/i,tg=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Hv(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 ng(t){return _v.test(String(t||""))}function rg(t){return zv.test(String(t||""))}function ig(t){return Fv.test(String(t||""))}function og(t){return ng(t)?"image":rg(t)?"video":ig(t)?"html":null}function sg(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 jv(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 tg.test(n)?n:null}function Vv(t){const e=String(t||"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"");return!tg.test(e)||e===".gitkeep"?null:e}function qv(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 Uv(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 Wv(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=Uv(u),m=r("nav",{className:"media-breadcrumb","aria-label":"Media path"});p.forEach((w,T)=>{T>0&&m.append(r("span",{className:"media-breadcrumb-sep",text:"/"})),T===p.length-1?m.append(r("span",{className:"media-breadcrumb-current",text:w.label})):m.append(r("button",{className:"media-breadcrumb-link",type:"button",text:w.label,onClick:()=>void yr(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 Qv(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 Zv(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=>Kv(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"}),m]),b,x])}function Kv(t,e){const{el:n,materialIcon:r,resolveMediaUrl:i,state:o}=e,s=t.type==="dir",l=s?null:og(t.name),a=t.public_path||(s?null:Ms(t.path)),c=!s&&ng(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 rg(t.name)?u=n("span",{className:"media-thumb media-thumb--file"},[r("movie","media-thumb-icon")]):ig(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(sg(t.size)),a&&d.push(a);const p=s?()=>void yr(t.path,e):l?b=>Gv(t,b.currentTarget,e):()=>void cg(a,e),m=s?`Open ${t.name}`:l?`Preview ${t.name}`:`Copy ${a}`,g=!s&&a?Yv(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:m,"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 Yv(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(),cg(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(),Xv(t,n)}},[i("delete")]);return r("div",{className:"media-ops",role:"group","aria-label":"Operations"},[l,a])}let kt=null,Ma=null;function Jv(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(),Ll()}},[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:()=>Ll()}),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(),Ll())}),kt={root:l,img:n,video:r,frame:i,caption:o,closeBtn:s},kt}function lg(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 ag(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 Ll(){if(!kt||kt.root.hidden)return;lg(kt),ag(kt,!1);const t=Ma;if(Ma=null,t&&typeof t.focus=="function")try{t.focus()}catch{}}function Gv(t,e,n){const{el:r,materialIcon:i,resolveMediaUrl:o}=n,s=og(t.name),l=t.public_path||Ms(t.path),a=l?o(l):"";if(!s||!a)return;const c=Jv(r,i);Ma=e||null,lg(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,ag(c,!0),c.closeBtn.focus()}async function cg(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 Xv(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
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);const u=await n.deleteFile({path:l,sha:c,message:`studio: delete ${l}`});r.mediaBusy=!1,r.status=`Deleted ${l}`,typeof e.onCommitted=="function"&&e.onCommitted(u==null?void 0:u.commit),await
|
|
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);const u=await n.deleteFile({path:l,sha:c,message:`studio: delete ${l}`});r.mediaBusy=!1,r.status=`Deleted ${l}`,typeof e.onCommitted=="function"&&e.onCommitted(u==null?void 0:u.commit),await yr(r.mediaPath,e)}catch(c){r.mediaBusy=!1,o(c),i()}}}async function yr(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 Zv(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=Vv(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{const c=await e.createMediaFolder({path:a,message:`studio: mkdir ${a}`});n.mediaBusy=!1,n.status=`Created ${Ms(a)||a}`,typeof t.onCommitted=="function"&&t.onCommitted(c==null?void 0:c.commit),await yr(n.mediaPath,t)}catch(c){n.mediaBusy=!1,i(c),r()}}async function Qv(t,e){const{api:n,state:r,render:i,captureError:o,clearError:s}=e;s();const l=r.mediaPath||xt;let a=0,c=null;r.mediaBusy=!0;for(const u of t){const d=jv(u.name);if(!d){r.error=`Skipped invalid name: ${u.name}`;continue}if(u.size>Qd){r.error=`${d} exceeds ${sg(Qd)} (GitHub Contents API soft limit in Studio)`;continue}r.status=`Uploading ${d}…`,i();try{const p=await qv(u),m=`${l}/${d}`,g=await n.uploadMedia({path:m,content_base64:p,message:`studio: upload ${m}`});a+=1,r.status=`Uploaded ${g.public_path||Ms(m)}`,c=(g==null?void 0:g.commit)||c}catch(p){o(p),r.mediaBusy=!1,i();return}}r.mediaBusy=!1,a&&(r.status=a===1?r.status:`Uploaded ${a} files`),a&&c&&typeof e.onCommitted=="function"&&e.onCommitted(c),await yr(l,e)}const eM="pk_test_c291bmQtc3F1aXJyZWwtNDgzMC5jbGVyay5hY2NvdW50cy5kZXYk",Qt="/studio/",ef="",ug={forceRedirectUrl:Qt,fallbackRedirectUrl:Qt,signInForceRedirectUrl:Qt,signInFallbackRedirectUrl:Qt,signUpForceRedirectUrl:Qt,signUpFallbackRedirectUrl:Qt};function tM(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 tf(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 nM(t){if(window.Clerk&&typeof window.Clerk.load=="function"&&window.__internal_ClerkUICtor)return window.Clerk;const e="".replace(/^https?:\/\//,"").replace(/\/$/,"")||tM(t);if(!e)throw new Error("Cannot resolve Clerk Frontend API host from publishable key");const n=`https://${e}/npm`;await tf(`${n}/@clerk/ui@1/dist/ui.browser.js`),await tf(`${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 rM(){const t=await nM(eM);return await t.load({clerkUICtor:window.__internal_ClerkUICtor,...ug}),Gg(async()=>t.session?t.session.getToken():null),t}const at=document.getElementById("app"),h={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,pipeline:{state:"idle",sha:"",runUrl:"",message:"",pollGen:0},reexporting:!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},iM={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"},Ta={Writing:"edit_note",References:"menu_book",Portfolio:"work",Media:"photo_library",Pages:"description","CV Summary":"badge",Presentation:"campaign",Profile:"person"},oM=[{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)"}],sM={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 Ai(t){return String(t||"").split("/").filter(Boolean).join(" | ")}function dg(t){return sM[t]||`Browse ${t} collections`}function Cc(t){return"nav-group-"+String(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function fg(t){var i;const e=!h.navOpenGroups.has(t);e?h.navOpenGroups.add(t):h.navOpenGroups.delete(t);const n=document.getElementById(Cc(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 pg(t){const e=hg(t.description);if(e)return e;const n=Ai(t.path)||t.name;return t.type==="file"?`Open ${t.label} | ${n}`:`List entries in ${t.label} | ${n}`}function hg(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 nf(t){return hg(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
271
|
`).slice(0,6).join(`
|
|
272
272
|
`));h.error=e,h.errorCode=String((t==null?void 0:t.code)||((o=t==null?void 0:t.data)==null?void 0:o.error)||""),h.errorDetail=n.join(`
|
|
273
|
-
`).trim(),h.status=""}function ct(){h.error="",h.errorCode="",h.errorDetail=""}function Ll(){var t;return h.mediaOpen?"Media":(t=h.collection)!=null&&t.label?h.collection.label:"Home"}function Sc(){h.navMenuOpen=!1}function wc(){var t,e;vt(),h.collection=null,h.file=null,h.baseline=null,h.items=[],h.yamlDoc=null,h.yamlList=null,h.listLoading=!1,h.fileLoading=!1,h.dirty=!1,h.insertMenuOpen=!1,h.mediaOpen=!1,h.mediaItems=[],h.mediaLoading=!1,h.mediaBusy=!1,Sc(),ct(),h.status=((t=h.session)==null?void 0:t.email)||((e=h.session)==null?void 0:e.userId)||"",Y(),mg()}function dg(){return{api:ze,state:h,el:k,materialIcon:_e,resolveMediaUrl:gg,render:()=>Y(),captureError:Ct,clearError:ct,goHome:wc,onCommitted:t=>Ts(t)}}async function fg(t){vt(),h.collection=null,h.file=null,h.baseline=null,h.items=[],h.insertMenuOpen=!1,h.dirty=!1,h.mediaOpen=!0,h.navOpenGroups.add("Media"),Sc();const e=Iv(h.schema);await gr(e,dg())}function _e(t,e=""){return k("span",{className:"material-symbols-outlined"+(e?` ${e}`:""),text:t,"aria-hidden":"true"})}function Ms({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 ef(t){const e=t.title||t.name||"Entry",n=Ti(t.path);return n?`Open ${e} | ${n}`:`Open ${e}`}function Zv(){var e;const t=(e=h.collection)==null?void 0:e.name;return t&&h.listQueryByCollection[t]||""}function Qv(){var n;const t=(n=h.collection)==null?void 0:n.name;if(!t)return es;if(h.listSortByCollection[t])return h.listSortByCollection[t];const e=bv(t,es);return h.listSortByCollection[t]=e,e}function eM(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listSortByCollection[e]=t,kv(e,t),Cc())}function tM(){var n;const t=(n=h.collection)==null?void 0:n.name;if(!t)return ns;if(h.listPageSizeByCollection[t])return h.listPageSizeByCollection[t];const e=xv(t,ns);return h.listPageSizeByCollection[t]=e,e}function nM(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listPageSizeByCollection[e]=t,Sv(e,t),Cc())}function tf(){var e;const t=(e=h.collection)==null?void 0:e.name;return t?Math.max(1,Number(h.listPageByCollection[t])||1):1}function Il(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listPageByCollection[e]=Math.max(1,Number(t)||1))}function Cc(){var e;const t=(e=h.collection)==null?void 0:e.name;t&&(h.listPageByCollection[t]=1)}function pg(t,e){t!=null&&t.name&&(h.navCountByCollection[t.name]=Math.max(0,Number(e)||0))}function hg(t,e){if(!(t!=null&&t.name))return;const n=Array.isArray(e)?e:[];h.treeCacheByCollection[t.name]={items:n},pg(t,n.length)}function rM(t){if(!(t!=null&&t.name))return null;const e=h.treeCacheByCollection[t.name];return e?e.items:null}function vc(t){if(!t){h.treeCacheByCollection=Object.create(null);return}delete h.treeCacheByCollection[t]}function iM(t=h.schema){return((t==null?void 0:t.collections)||[]).filter(e=>e&&e.type!=="file"&&e.path)}function oM(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 mg(){const t=++h.treePrefetchGen,e=()=>{sM(t)};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:2500}):setTimeout(e,400)}async function sM(t){const e=oM(iM()).filter(n=>!h.treeCacheByCollection[n.name]);for(const n of e){if(t!==h.treePrefetchGen)return;try{const r=await ze.tree(n.path);if(t!==h.treePrefetchGen)return;h.treeCacheByCollection[n.name]||(hg(n,r.items||[]),h.file||Y())}catch{}await new Promise(r=>setTimeout(r,60))}}function gg(t){const e=String(t||"").trim();return e?/^https?:\/\//i.test(e)?e:e.startsWith("/media/")?`${Xd.replace(/\/$/,"")}${e}`:e.startsWith("media/")?`${Xd.replace(/\/$/,"")}/${e}`:(e.startsWith("/"),e):""}function nf(){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 rf(t){const e=gg(t.thumbnail);if(!e)return nf();const n=k("img",{className:"ledger-thumb",src:e,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});return n.addEventListener("error",()=>{n.replaceWith(nf())}),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 yg="studio-theme",rs={light:"light_mode",dark:"dark_mode",system:"routine"};function fi(){const t=localStorage.getItem(yg);return t==="light"||t==="dark"||t==="system"?t:"system"}function lM(){const t=fi();return t==="dark"?"dark":t==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function aM(t){localStorage.setItem(yg,t),va(),pi()}function va(){document.documentElement.setAttribute("data-theme",lM())}function cM(){va();const t=window.matchMedia("(prefers-color-scheme: dark)");typeof t.addEventListener=="function"&&t.addEventListener("change",()=>{fi()==="system"&&va()})}function pi(){const t=fi(),e=document.querySelector("[data-studio-theme-icon]");e&&(e.textContent=rs[t]||rs.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",h.themeMenuOpen?"true":"false"),r.hidden=!h.themeMenuOpen)}function uM(){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:!h.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(),aM(r.id),h.themeMenuOpen=!1,pi();const o=ve("#preview-frame");o&&Mg(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":h.themeMenuOpen?"true":"false","aria-controls":"studio-theme-menu",onClick:r=>{r.stopPropagation(),h.themeMenuOpen=!h.themeMenuOpen,pi()}},[k("span",{className:"material-symbols-outlined","data-studio-theme-icon":"true",text:rs[fi()]||rs.system,"aria-hidden":"true"}),k("span",{className:"btn-label",text:"Theme"})]);return k("div",{className:"studio-theme-menu"},[n,e])}function Mc(){const t=String(window.location.hostname||"");return t==="localhost"||t==="127.0.0.1"||t==="[::1]"}function dM(t){return new Promise(e=>setTimeout(e,t))}function fM(t){switch(t){case"syncing":case"running":return{label:"Exporting…",icon:"progress_activity",className:"pipeline-chip pipeline-running",spinning:!0,title:"Content export is running"};case"awaiting_run":return{label:"Waiting…",icon:"schedule",className:"pipeline-chip pipeline-awaiting",spinning:!1,title:"Waiting for the content pipeline run"};case"ok":return{label:"Live",icon:"check_circle",className:"pipeline-chip pipeline-ok",spinning:!1,title:"Content pipeline succeeded for this commit"};case"error":return{label:"Failed",icon:"error",className:"pipeline-chip pipeline-error",spinning:!1,title:h.pipeline.message||"Content pipeline failed"};case"stalled":return{label:"No run",icon:"hourglass_disabled",className:"pipeline-chip pipeline-stalled",spinning:!1,title:"No pipeline run appeared for this commit yet"};case"unconfigured":return{label:"Pipeline",icon:"cloud_off",className:"pipeline-chip pipeline-idle",spinning:!1,title:h.pipeline.message||"Set pandorga.content.workflow in _config.yml (e.g. content-pipeline.yml)"};default:return{label:"Pipeline",icon:"cloud",className:"pipeline-chip pipeline-idle",spinning:!1,title:"Content pipeline status"}}}function pM(){const t=fM(h.pipeline.state),e=h.pipeline.runUrl,n=[k("span",{className:"material-symbols-outlined"+(t.spinning?" studio-icon-spin":""),text:t.icon,"aria-hidden":"true"}),k("span",{className:"btn-label",text:t.label})];return k("button",{className:`btn btn-tool ${t.className}`,type:"button",title:t.title,"aria-label":t.label,role:"status","data-studio-action":"pipeline-status",disabled:!e,onClick:()=>{if(e)try{window.open(e,"_blank","noopener,noreferrer")}catch{}}},n)}function bg(t){var e;if(h.pipeline.runUrl=((e=t.run)==null?void 0:e.html_url)||h.pipeline.runUrl||"",t.sha&&(h.pipeline.sha=String(t.sha).toLowerCase()),h.pipeline.message="",t.state==="unconfigured"){h.pipeline.state="unconfigured",h.pipeline.message=t.message||"Set pandorga.content.workflow in _config.yml (e.g. content-pipeline.yml)";return}h.pipeline.state=t.state||"idle",t.state==="error"&&(h.pipeline.message=t.message||"Content pipeline failed for this commit.")}async function hM(t=null){if(!Mc())try{const e=await ze.pipelineStatus(t||null);bg(e),Y()}catch(e){h.pipeline.state="error",h.pipeline.message=String(e.message||e),Y()}}function Ts(t){const e=String(t||"").trim().toLowerCase();if(!e||Mc())return;const n=++h.pipeline.pollGen;h.pipeline.state="awaiting_run",h.pipeline.sha=e,h.pipeline.runUrl="",h.pipeline.message="",Y(),mM(n,e)}async function mM(t,e){const n=Date.now(),r=600*1e3,i=1800*1e3;let o=0;for(;t===h.pipeline.pollGen;){const s=Date.now()-n;if(s>i){(h.pipeline.state==="running"||h.pipeline.state==="awaiting_run")&&(h.pipeline.state="stalled",h.pipeline.message="Timed out waiting for the content pipeline.",Y());return}try{const l=await ze.pipelineStatus(e);if(t!==h.pipeline.pollGen)return;if(o=0,bg(l),l.state==="unconfigured"||l.state==="ok"||l.state==="error"){Y();return}if(l.state==="awaiting_run"&&s>r){h.pipeline.state="stalled",Y();return}Y()}catch(l){if(t!==h.pipeline.pollGen)return;o+=1;const a=(l==null?void 0:l.code)||"";if(a==="actions_forbidden"||a==="github_unconfigured"){h.pipeline.state="error",h.pipeline.message=String(l.message||l),Y();return}if(o>=5){h.pipeline.state="error",h.pipeline.message=String(l.message||l),Y();return}}await dM(s<6e4?2500:7e3)}}function kg(t=h.collection){var e;return!t||t.type!=="collection"?!1:((e=t.operations)==null?void 0:e.create)!==!1}function xg(t=h.collection){var e;return t?((e=t.operations)==null?void 0:e.delete)===!0:!1}function gM(t){return String(t||"").trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function yM(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 bM(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Rl({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 kM({brand:t=null,menuToggle:e=null}={}){const n=h.saving?"Saving…":h.dirty?"Save":"Saved",r=h.saving?"progress_activity":h.dirty?"save":"check",i=h.error?"Error":h.status||"",o=k("div",{className:"studio-toolbar-brand"},[t,i?k("span",{className:"status-pill studio-toolbar-status"+(h.error?" error":""),text:i,title:h.error||h.errorDetail||h.status||""}):null]),s=[uM()];if(Mc()){const a=h.reexporting||h.pipeline.state==="syncing";s.push(Rl({className:"btn btn-tool btn-reexport"+(a?" pipeline-running":"")+(h.pipeline.state==="ok"&&!a?" pipeline-ok":"")+(h.pipeline.state==="error"&&!a?" pipeline-error":""),title:a?"Exporting content JSON locally":"Export content JSON locally and reload",ariaLabel:a?"Exporting locally":"Export locally",action:"reexport",disabled:a,onClick:()=>dT(),icon:a?"progress_activity":"sync",label:a?"Exporting…":"Export",spinning:a}))}else s.push(pM());s.push(Rl({className:"btn btn-tool",title:"Revert all edits to the last loaded or saved version",ariaLabel:"Discard edits",action:"discard",disabled:!h.file||!h.dirty||!h.baseline,onClick:()=>uT(),icon:"undo",label:"Revert"}),Rl({className:"btn btn-tool btn-primary",title:h.saving?"Saving this draft":h.dirty?"Commit this draft":"No edits to commit yet",ariaLabel:n,action:"save",disabled:h.saving||!h.file||!h.dirty,onClick:()=>hT(),icon:r,label:n,spinning:h.saving}));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 Sg(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){xM(t,h.error||"Studio API session failed while you are signed in.");return}at.innerHTML="";const e=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Ms({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"})]);at.append(e),t&&!t.dev?t.mountSignIn(ve("#clerk-sign-in"),{...sg}):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:()=>oo(t)}))}function xM(t,e){at.innerHTML="";const n=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Ms({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)}})]);at.append(n)}function SM(t,e){const n=e||Sg(t)||"the address you used to register";at.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"},[Ms({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)}})]);at.append(o)}const wM=["Writing","Portfolio","References","Pages","CV Summary","Presentation","Profile"];function wg(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 wM)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 CM(){const t="Media",e=h.navOpenGroups.has(t),n=k("div",{className:"studio-nav-group-items",id:xc(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":h.mediaOpen?"page":null,onClick:()=>fg()}));const r=k("button",{className:"studio-nav-group-toggle",type:"button",title:lg(t),"aria-expanded":e?"true":"false","aria-controls":n.id,onClick:()=>{ag(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 vM(){if(!h.error||!h.file&&!h.mediaOpen)return null;const t=[];if(h.errorCode==="conflict"&&h.file){const e=h.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:()=>{ct(),Y()}})),k("div",{className:"studio-error-banner",role:"alert"},[k("p",{className:"studio-error-message",text:h.error}),k("div",{className:"studio-error-actions"},t)])}function Y(){var a;at.innerHTML="";const t=wg(h.schema),e=!!h.navMenuOpen,n=k("button",{className:"studio-brand studio-brand-home studio-brand-toolbar",type:"button",title:"Studio home","aria-current":!h.collection&&!h.mediaOpen?"page":null,onClick:()=>wc()},[Ms({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:()=>{h.navMenuOpen=!h.navMenuOpen,Y()}},[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(CM());for(const[c,u]of t){const d=h.navOpenGroups.has(c),p=k("div",{className:"studio-nav-group-items",id:xc(c),role:"region","aria-label":c});d||(p.hidden=!0);for(const g of u){const b=h.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:cg(g),"aria-current":((a=h.collection)==null?void 0:a.name)===g.name?"page":null,onClick:()=>Ns(g)},x))}const m=k("button",{className:"studio-nav-group-toggle",type:"button",title:lg(c),"aria-expanded":d?"true":"false","aria-controls":p.id,onClick:()=>{ag(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"},[m,p]))}const o=k("nav",{className:"studio-nav"+(e?" is-open":""),"aria-label":"Collections"},[i]),s=kM({brand:n,menuToggle:r}),l=k("div",{className:"studio-main"},[vM(),MM(),k("div",{className:"studio-body"+(h.file?"":" list-only"),id:"studio-body"})]);at.append(k("div",{className:"studio-shell"},[s,o,l])),Sn(),pi(),window.__studioMenuDismissBound||(window.__studioMenuDismissBound=!0,document.addEventListener("click",()=>{h.themeMenuOpen&&(h.themeMenuOpen=!1,pi())}))}function MM(){var e,n;const t=[k("span",{className:"studio-crumb",text:"Studio"})];if(h.mediaOpen&&!h.collection)t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Media"}));else if(h.collection){const r=h.collection.group||"Content",i=h.collection.label||h.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"+(h.file?"":" is-current"),text:i})),h.file){const o=((e=h.fields)==null?void 0:e.title)||((n=h.fields)==null?void 0:n.key)||String(h.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 je(){h.dirty=!0,Ta(),YM()}function Tc(){var t;return!h.file||fr()||h.aiProofBusy?!1:!!String(((t=h.fields)==null?void 0:t.language)||"").trim()}function Ma(){const t=h.aiProofBusy,e=Tc()&&!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(){h.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 io(t){h.aiProofHint=t;const e=ve("#ai-proof-hint");e&&(e.textContent=t,e.hidden=!t),clearTimeout(h._aiProofHintTimer),t&&(h._aiProofHintTimer=setTimeout(()=>{h.aiProofHint="";const n=ve("#ai-proof-hint");n&&(n.textContent="",n.hidden=!0)},3200))}function Cg(){var t;if(h.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=h.body||"";return{kind:"source",start:n,end:r,text:i.slice(n,r)}}if(h.bodyMode==="visual"&&((t=h.bodyEditor)!=null&&t.editor)){const e=h.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,`
|
|
273
|
+
`).trim(),h.status=""}function ct(){h.error="",h.errorCode="",h.errorDetail=""}function Il(){var t;return h.mediaOpen?"Media":(t=h.collection)!=null&&t.label?h.collection.label:"Home"}function vc(){h.navMenuOpen=!1}function Mc(){var t,e;vt(),h.collection=null,h.file=null,h.baseline=null,h.items=[],h.yamlDoc=null,h.yamlList=null,h.listLoading=!1,h.fileLoading=!1,h.dirty=!1,h.insertMenuOpen=!1,h.mediaOpen=!1,h.mediaItems=[],h.mediaLoading=!1,h.mediaBusy=!1,vc(),ct(),h.status=((t=h.session)==null?void 0:t.email)||((e=h.session)==null?void 0:e.userId)||"",ne(),kg()}function mg(){return{api:ze,state:h,el:k,materialIcon:_e,resolveMediaUrl:xg,render:()=>ne(),captureError:Ct,clearError:ct,goHome:Mc,onCommitted:t=>As(t)}}async function gg(t){vt(),h.collection=null,h.file=null,h.baseline=null,h.items=[],h.insertMenuOpen=!1,h.dirty=!1,h.mediaOpen=!0,h.navOpenGroups.add("Media"),vc();const e=Hv(h.schema);await yr(e,mg())}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 rf(t){const e=t.title||t.name||"Entry",n=Ai(t.path);return n?`Open ${e} | ${n}`:`Open ${e}`}function lM(){var e;const t=(e=h.collection)==null?void 0:e.name;return t&&h.listQueryByCollection[t]||""}function aM(){var n;const t=(n=h.collection)==null?void 0:n.name;if(!t)return ts;if(h.listSortByCollection[t])return h.listSortByCollection[t];const e=Av(t,ts);return h.listSortByCollection[t]=e,e}function cM(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listSortByCollection[e]=t,Ev(e,t),Tc())}function uM(){var n;const t=(n=h.collection)==null?void 0:n.name;if(!t)return rs;if(h.listPageSizeByCollection[t])return h.listPageSizeByCollection[t];const e=Nv(t,rs);return h.listPageSizeByCollection[t]=e,e}function dM(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listPageSizeByCollection[e]=t,Ov(e,t),Tc())}function of(){var e;const t=(e=h.collection)==null?void 0:e.name;return t?Math.max(1,Number(h.listPageByCollection[t])||1):1}function Rl(t){var n;const e=(n=h.collection)==null?void 0:n.name;e&&(h.listPageByCollection[e]=Math.max(1,Number(t)||1))}function Tc(){var e;const t=(e=h.collection)==null?void 0:e.name;t&&(h.listPageByCollection[t]=1)}function yg(t,e){t!=null&&t.name&&(h.navCountByCollection[t.name]=Math.max(0,Number(e)||0))}function bg(t,e){if(!(t!=null&&t.name))return;const n=Array.isArray(e)?e:[];h.treeCacheByCollection[t.name]={items:n},yg(t,n.length)}function fM(t){if(!(t!=null&&t.name))return null;const e=h.treeCacheByCollection[t.name];return e?e.items:null}function Ac(t){if(!t){h.treeCacheByCollection=Object.create(null);return}delete h.treeCacheByCollection[t]}function pM(t=h.schema){return((t==null?void 0:t.collections)||[]).filter(e=>e&&e.type!=="file"&&e.path)}function hM(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 kg(){const t=++h.treePrefetchGen,e=()=>{mM(t)};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:2500}):setTimeout(e,400)}async function mM(t){const e=hM(pM()).filter(n=>!h.treeCacheByCollection[n.name]);for(const n of e){if(t!==h.treePrefetchGen)return;try{const r=await ze.tree(n.path);if(t!==h.treePrefetchGen)return;h.treeCacheByCollection[n.name]||(bg(n,r.items||[]),h.file||ne())}catch{}await new Promise(r=>setTimeout(r,60))}}function xg(t){const e=String(t||"").trim();return e?/^https?:\/\//i.test(e)?e:e.startsWith("/media/")?`${ef.replace(/\/$/,"")}${e}`:e.startsWith("media/")?`${ef.replace(/\/$/,"")}/${e}`:(e.startsWith("/"),e):""}function sf(){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 lf(t){const e=xg(t.thumbnail);if(!e)return sf();const n=k("img",{className:"ledger-thumb",src:e,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});return n.addEventListener("error",()=>{n.replaceWith(sf())}),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 Sg="studio-theme",is={light:"light_mode",dark:"dark_mode",system:"routine"};function pi(){const t=localStorage.getItem(Sg);return t==="light"||t==="dark"||t==="system"?t:"system"}function gM(){const t=pi();return t==="dark"?"dark":t==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yM(t){localStorage.setItem(Sg,t),Aa(),hi()}function Aa(){document.documentElement.setAttribute("data-theme",gM())}function bM(){Aa();const t=window.matchMedia("(prefers-color-scheme: dark)");typeof t.addEventListener=="function"&&t.addEventListener("change",()=>{pi()==="system"&&Aa()})}function hi(){const t=pi(),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",h.themeMenuOpen?"true":"false"),r.hidden=!h.themeMenuOpen)}function kM(){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:!h.themeMenuOpen},t.map(r=>k("button",{className:"studio-theme-choice",type:"button",role:"menuitemradio","data-theme-choice":r.id,"aria-checked":pi()===r.id?"true":"false",onClick:i=>{i.stopPropagation(),yM(r.id),h.themeMenuOpen=!1,hi();const o=ve("#preview-frame");o&&Dg(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":h.themeMenuOpen?"true":"false","aria-controls":"studio-theme-menu",onClick:r=>{r.stopPropagation(),h.themeMenuOpen=!h.themeMenuOpen,hi()}},[k("span",{className:"material-symbols-outlined","data-studio-theme-icon":"true",text:is[pi()]||is.system,"aria-hidden":"true"}),k("span",{className:"btn-label",text:"Theme"})]);return k("div",{className:"studio-theme-menu"},[n,e])}function Ec(){const t=String(window.location.hostname||"");return t==="localhost"||t==="127.0.0.1"||t==="[::1]"}function xM(t){return new Promise(e=>setTimeout(e,t))}function wg(t){switch(t){case"syncing":case"running":return{label:"Exporting…",icon:"progress_activity",className:"pipeline-chip pipeline-running",spinning:!0,title:"Content export is running"};case"awaiting_run":return{label:"Waiting…",icon:"schedule",className:"pipeline-chip pipeline-awaiting",spinning:!1,title:"Waiting for the content pipeline run"};case"ok":return{label:"Live",icon:"check_circle",className:"pipeline-chip pipeline-ok",spinning:!1,title:"Content pipeline succeeded for this commit"};case"error":return{label:"Failed",icon:"error",className:"pipeline-chip pipeline-error",spinning:!1,title:h.pipeline.message||"Content pipeline failed"};case"stalled":return{label:"No run",icon:"hourglass_disabled",className:"pipeline-chip pipeline-stalled",spinning:!1,title:"No pipeline run appeared for this commit yet"};case"unconfigured":return{label:"Pipeline",icon:"cloud_off",className:"pipeline-chip pipeline-idle",spinning:!1,title:h.pipeline.message||"Set pandorga.content.workflow in _config.yml (e.g. content-pipeline.yml)"};default:return{label:"Pipeline",icon:"cloud",className:"pipeline-chip pipeline-idle",spinning:!1,title:"Content pipeline status"}}}function Cg(){const t=wg(h.pipeline.state);return JSON.stringify([t.className,t.spinning,t.icon,t.label,t.title,h.pipeline.runUrl||""])}function vg(){const t=wg(h.pipeline.state),e=[k("span",{className:"material-symbols-outlined"+(t.spinning?" studio-icon-spin":""),text:t.icon,"aria-hidden":"true"}),k("span",{className:"btn-label",text:t.label})];return k("button",{className:`btn btn-tool ${t.className}`,type:"button",title:t.title,"aria-label":t.label,role:"status","data-studio-action":"pipeline-status","data-pipeline-key":Cg(),disabled:!h.pipeline.runUrl,onClick:()=>{const n=h.pipeline.runUrl;if(n)try{window.open(n,"_blank","noopener,noreferrer")}catch{}}},e)}function Rt(){const t=document.querySelector("[data-studio-action='pipeline-status']");if(!t)return;const e=Cg();t.getAttribute("data-pipeline-key")!==e&&t.replaceWith(vg())}function Mg(t){var e;if(h.pipeline.runUrl=((e=t.run)==null?void 0:e.html_url)||h.pipeline.runUrl||"",t.sha&&(h.pipeline.sha=String(t.sha).toLowerCase()),h.pipeline.message="",t.state==="unconfigured"){h.pipeline.state="unconfigured",h.pipeline.message=t.message||"Set pandorga.content.workflow in _config.yml (e.g. content-pipeline.yml)";return}h.pipeline.state=t.state||"idle",t.state==="error"&&(h.pipeline.message=t.message||"Content pipeline failed for this commit.")}async function SM(t=null){if(!Ec())try{const e=await ze.pipelineStatus(t||null);Mg(e),Rt()}catch(e){h.pipeline.state="error",h.pipeline.message=String(e.message||e),Rt()}}function As(t){const e=String(t||"").trim().toLowerCase();if(!e||Ec())return;const n=++h.pipeline.pollGen;h.pipeline.state="awaiting_run",h.pipeline.sha=e,h.pipeline.runUrl="",h.pipeline.message="",Rt(),wM(n,e)}async function wM(t,e){const n=Date.now(),r=600*1e3,i=1800*1e3;let o=0;for(;t===h.pipeline.pollGen;){const s=Date.now()-n;if(s>i){(h.pipeline.state==="running"||h.pipeline.state==="awaiting_run")&&(h.pipeline.state="stalled",h.pipeline.message="Timed out waiting for the content pipeline.",Rt());return}try{const l=await ze.pipelineStatus(e);if(t!==h.pipeline.pollGen)return;if(o=0,Mg(l),l.state==="unconfigured"||l.state==="ok"||l.state==="error"){Rt();return}if(l.state==="awaiting_run"&&s>r){h.pipeline.state="stalled",Rt();return}Rt()}catch(l){if(t!==h.pipeline.pollGen)return;o+=1;const a=(l==null?void 0:l.code)||"";if(a==="actions_forbidden"||a==="github_unconfigured"){h.pipeline.state="error",h.pipeline.message=String(l.message||l),Rt();return}if(o>=5){h.pipeline.state="error",h.pipeline.message=String(l.message||l),Rt();return}}await xM(s<6e4?2500:7e3)}}function Tg(t=h.collection){var e;return!t||t.type!=="collection"?!1:((e=t.operations)==null?void 0:e.create)!==!1}function Ag(t=h.collection){var e;return t?((e=t.operations)==null?void 0:e.delete)===!0:!1}function CM(t){return String(t||"").trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function vM(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 MM(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Dl({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 Eg(){const t=h.reexporting||h.pipeline.state==="syncing";return{exportBusy:t,className:"btn btn-tool btn-reexport"+(t?" pipeline-running":"")+(h.pipeline.state==="ok"&&!t?" pipeline-ok":"")+(h.pipeline.state==="error"&&!t?" pipeline-error":""),title:t?"Exporting content JSON locally":"Export content JSON locally and reload",ariaLabel:t?"Exporting locally":"Export locally",icon:t?"progress_activity":"sync",label:t?"Exporting…":"Export"}}function Pl(){const t=document.querySelector("[data-studio-action='reexport']");if(!t)return;const e=Eg();t.className=e.className,t.title=e.title,t.setAttribute("aria-label",e.ariaLabel),t.disabled=e.exportBusy;const n=t.querySelector(".material-symbols-outlined");n&&(n.textContent=e.icon,n.classList.toggle("studio-icon-spin",e.exportBusy));const r=t.querySelector(".btn-label");r&&(r.textContent=e.label)}function $l(){const t=document.querySelector(".studio-toolbar-brand");if(!t)return;const e=h.error?"Error":h.status||"";let n=t.querySelector(".studio-toolbar-status");if(!e){n&&n.remove();return}n||(n=k("span",{className:"status-pill studio-toolbar-status"}),t.append(n)),n.className="status-pill studio-toolbar-status"+(h.error?" error":""),n.textContent=e,n.title=h.error||h.errorDetail||h.status||""}function TM({brand:t=null,menuToggle:e=null}={}){const n=h.saving?"Saving…":h.dirty?"Save":"Saved",r=h.saving?"progress_activity":h.dirty?"save":"check",i=h.error?"Error":h.status||"",o=k("div",{className:"studio-toolbar-brand"},[t,i?k("span",{className:"status-pill studio-toolbar-status"+(h.error?" error":""),text:i,title:h.error||h.errorDetail||h.status||""}):null]),s=[kM()];if(Ec()){const a=Eg();s.push(Dl({className:a.className,title:a.title,ariaLabel:a.ariaLabel,action:"reexport",disabled:a.exportBusy,onClick:()=>yT(),icon:a.icon,label:a.label,spinning:a.exportBusy}))}else s.push(vg());s.push(Dl({className:"btn btn-tool",title:"Revert all edits to the last loaded or saved version",ariaLabel:"Discard edits",action:"discard",disabled:!h.file||!h.dirty||!h.baseline,onClick:()=>gT(),icon:"undo",label:"Revert"}),Dl({className:"btn btn-tool btn-primary",title:h.saving?"Saving this draft":h.dirty?"Commit this draft":"No edits to commit yet",ariaLabel:n,action:"save",disabled:h.saving||!h.file||!h.dirty,onClick:()=>xT(),icon:r,label:n,spinning:h.saving}));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 Ng(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 mi(t){if(t&&!t.dev&&t.user){AM(t,h.error||"Studio API session failed while you are signed in.");return}at.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"})]);at.append(e),t&&!t.dev?t.mountSignIn(ve("#clerk-sign-in"),{...ug}):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 AM(t,e){at.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:Qt});return}mi(t)}})]);at.append(n)}function EM(t,e){const n=e||Ng(t)||"the address you used to register";at.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:Qt});return}mi(t)}})]);at.append(o)}const NM=["Writing","Portfolio","References","Pages","CV Summary","Presentation","Profile"];function Og(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 NM)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 OM(){const t="Media",e=h.navOpenGroups.has(t),n=k("div",{className:"studio-nav-group-items",id:Cc(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":h.mediaOpen?"page":null,onClick:()=>gg()}));const r=k("button",{className:"studio-nav-group-toggle",type:"button",title:dg(t),"aria-expanded":e?"true":"false","aria-controls":n.id,onClick:()=>{fg(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 Lg(){if(!h.error||!h.file&&!h.mediaOpen)return null;const t=[];if(h.errorCode==="conflict"&&h.file){const e=h.file;t.push(k("button",{className:"btn",type:"button",text:"Reload from GitHub",title:"Replace this screen with the file currently on GitHub",onClick:()=>Ls(e)}))}return t.push(k("button",{className:"btn",type:"button",text:"Dismiss",onClick:()=>{ct(),ne()}})),k("div",{className:"studio-error-banner",role:"alert"},[k("p",{className:"studio-error-message",text:h.error}),k("div",{className:"studio-error-actions"},t)])}function af(){const t=document.querySelector(".studio-main");if(!t)return;const e=t.querySelector(":scope > .studio-error-banner"),n=Lg();if(e&&n)e.replaceWith(n);else if(e&&!n)e.remove();else if(!e&&n){const r=t.querySelector(".studio-breadcrumb");r?r.before(n):t.prepend(n)}}function ne(){var a;at.innerHTML="";const t=Og(h.schema),e=!!h.navMenuOpen,n=k("button",{className:"studio-brand studio-brand-home studio-brand-toolbar",type:"button",title:"Studio home","aria-current":!h.collection&&!h.mediaOpen?"page":null,onClick:()=>Mc()},[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 (${Il()})`:`Open menu (${Il()})`,"aria-expanded":e?"true":"false","aria-controls":"studio-nav-panel",onClick:()=>{h.navMenuOpen=!h.navMenuOpen,ne()}},[k("span",{className:"studio-nav-menu-label sr-only",text:Il()}),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(OM());for(const[c,u]of t){const d=h.navOpenGroups.has(c),p=k("div",{className:"studio-nav-group-items",id:Cc(c),role:"region","aria-label":c});d||(p.hidden=!0);for(const g of u){const b=h.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:pg(g),"aria-current":((a=h.collection)==null?void 0:a.name)===g.name?"page":null,onClick:()=>Os(g)},x))}const m=k("button",{className:"studio-nav-group-toggle",type:"button",title:dg(c),"aria-expanded":d?"true":"false","aria-controls":p.id,onClick:()=>{fg(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"},[m,p]))}const o=k("nav",{className:"studio-nav"+(e?" is-open":""),"aria-label":"Collections"},[i]),s=TM({brand:n,menuToggle:r}),l=k("div",{className:"studio-main"},[Lg(),LM(),k("div",{className:"studio-body"+(h.file?"":" list-only"),id:"studio-body"})]);at.append(k("div",{className:"studio-shell"},[s,o,l])),wn(),hi(),window.__studioMenuDismissBound||(window.__studioMenuDismissBound=!0,document.addEventListener("click",()=>{h.themeMenuOpen&&(h.themeMenuOpen=!1,hi())}))}function LM(){var e,n;const t=[k("span",{className:"studio-crumb",text:"Studio"})];if(h.mediaOpen&&!h.collection)t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Media"}));else if(h.collection){const r=h.collection.group||"Content",i=h.collection.label||h.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"+(h.file?"":" is-current"),text:i})),h.file){const o=((e=h.fields)==null?void 0:e.title)||((n=h.fields)==null?void 0:n.key)||String(h.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 je(){h.dirty=!0,Na(),eT()}function Nc(){var t;return!h.file||pr()||h.aiProofBusy?!1:!!String(((t=h.fields)==null?void 0:t.language)||"").trim()}function Ea(){const t=h.aiProofBusy,e=Nc()&&!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 ei(){h.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){h.aiProofHint=t;const e=ve("#ai-proof-hint");e&&(e.textContent=t,e.hidden=!t),clearTimeout(h._aiProofHintTimer),t&&(h._aiProofHintTimer=setTimeout(()=>{h.aiProofHint="";const n=ve("#ai-proof-hint");n&&(n.textContent="",n.hidden=!0)},3200))}function Ig(){var t;if(h.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;un();const i=h.body||"";return{kind:"source",start:n,end:r,text:i.slice(n,r)}}if(h.bodyMode==="visual"&&((t=h.bodyEditor)!=null&&t.editor)){const e=h.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
274
|
|
|
275
|
-
`);return String(o).trim()?{kind:"visual",from:n,to:r,text:o}:null}return null}function of(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 TM(t,e){var n;if(t.kind==="source"){const r=h.body||"";h.body=r.slice(0,t.start)+e+r.slice(t.end);const i=ve("#body-source");if(i){i.value=h.body;const o=t.start+e.length;i.focus(),i.setSelectionRange(o,o)}je(),pn();return}t.kind==="visual"&&((n=h.bodyEditor)!=null&&n.editor)&&(h.bodyEditor.editor.chain().focus().insertContentAt({from:t.from,to:t.to},e).run(),cn(),je(),pn())}function AM(){var n;const t=h.aiProofSelection||Cg();if(h.aiProofSelection=null,t)return t;cn();const e=h.body||"";if(!String(e).trim())return null;if(h.bodyMode==="source")return{kind:"source",start:0,end:e.length,text:e,wholeBody:!0};if(h.bodyMode==="visual"&&((n=h.bodyEditor)!=null&&n.editor)){const r=h.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 EM(t){var l,a;if(Qr(),io(""),!Tc()){io("Set language in front matter before AI Proof."),Ta();return}const e=AM();if(!e){io("Body is empty.");return}cn();const n=String(h.fields.language||"").trim(),r=h.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";h.aiProofBusy=!0,h.status=t==="refine"?`Refining ${s}…`:`Correcting ${s}…`,Ma();try{const c=await ze.rewrite({mode:t,path:h.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?h.status=`No safe changes to apply (${d.proposed} proposed, all dropped).`:h.status=`No changes proposed for the ${s}.`;return}let p;if(e.kind==="visual"&&e.wholeBody){if(p=of(r,u),p===r){h.status=`No changes proposed for the ${s}.`;return}h.body=p,(a=(l=h.bodyEditor)==null?void 0:l.setMarkdown)==null||a.call(l,p),je(),pn()}else{if(p=of(e.text,u),p===e.text){h.status=`No changes proposed for the ${s}.`;return}TM(e,p)}const m=Number(d.dropped)>0?`, ${d.dropped} dropped`:"";h.status=t==="refine"?`Refined ${s} (${u.length}${m}).`:`Corrected ${s} (${u.length}${m}).`}catch(c){Ct(c);const u=h.error;h.error=u?`AI Proof failed. ${u}`:"AI Proof failed."}finally{h.aiProofBusy=!1,Ma(),Ta()}}function Ta(){const t=document.querySelector("[data-studio-action='save']"),e=document.querySelector("[data-studio-action='discard']");if(t){const n=h.saving?"Saving…":h.dirty?"Save":"Saved";t.disabled=h.saving||!h.file||!h.dirty,t.title=h.saving?"Saving this draft":h.dirty?"Commit this draft":"No edits to commit yet",t.setAttribute("aria-label",n);const r=t.querySelector(".material-symbols-outlined");r&&(r.textContent=h.saving?"progress_activity":h.dirty?"save":"check",r.classList.toggle("studio-icon-spin",h.saving));const i=t.querySelector(".btn-label");i&&(i.textContent=n)}e&&(e.disabled=!h.file||!h.dirty||!h.baseline),Ma()}function Sn(){const t=ve("#studio-body");if(!t)return;t.innerHTML="";const e=h.file&&!fr()?` view-${h.bodyMode}`:"";if(t.className="studio-body"+(h.file?"":" list-only")+e,h.fileLoading){t.append(k("div",{className:"pane"},[k("p",{className:"loading-msg",text:"Loading content…"})]));return}if(!h.collection){if(h.mediaOpen){t.append(Bv(dg()));return}t.append($M());return}if(!h.file){t.append(_M());return}if(fr()){t.append(PM(),af()),pn();return}t.append(WM(),af()),nT(),pn()}function fr(t=h.collection){return(t==null?void 0:t.format)==="yaml"}function NM(){const t=h.collection,e=mr(t);try{if(e==="list")h.body=St(h.yamlList||[]);else if(e==="map")if(t.root_key){const n=h.yamlDoc&&typeof h.yamlDoc=="object"?{...h.yamlDoc}:{};n[t.root_key]=_n({...h.fields},t.fields),h.body=St(n)}else h.body=St(_n({...h.fields},t.fields))}catch(n){Ct(n)}}function OM(){const t=h.collection,e=mr(t);ct();try{const n=Zr(h.body);if(e==="list")h.yamlList=Gm(n),h.fields={};else if(e==="map"){if(t.root_key){const r=rr(n);h.yamlDoc=r,h.fields=rr(r[t.root_key])}else h.yamlDoc=null,h.fields=rr(n);h.yamlList=null}return!0}catch(n){return Ct(n),h.status="Invalid YAML — fix source before switching",!1}}function sf(t){if(t===h.yamlUiMode)return;if(t==="source"){NM(),h.yamlUiMode="source",Y();return}const e=ve("#yaml-source");if(e&&(h.body=e.value),!OM()){Y();return}h.yamlUiMode="structured",Y()}function LM(t){const e=h.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:()=>sf("structured")}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"YAML",title:"Raw YAML source","aria-selected":e?"false":"true",onClick:()=>sf("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 IM(){const t=h.collection,e=As(t),n=Array.isArray(h.yamlList)?h.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]],h.yamlList=d,je(),Y()}}),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]],h.yamlList=d,je(),Y()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{h.yamlList=n.filter((d,p)=>p!==o),je(),Y()}})])]));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:()=>{je()}}));l.append(u),r.append(l)}),r.append(k("button",{className:"btn btn-primary",type:"button",text:"Add item",onClick:()=>{h.yamlList=[...h.yamlList||[],kc(e)],je(),Y()}})),n.length||r.prepend(k("p",{className:"yaml-empty",text:"No items yet. Add one to start this list."})),r}function RM(){const t=k("div",{className:"form-grid",id:"yaml-form"});for(const e of As(h.collection))t.append(Es(e));return t}function DM(){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:h.body,"aria-label":"YAML source",spellcheck:"false",onInput:t=>{h.body=t.target.value,je(),pn()}})])}function PM(){const t=h.collection,e=mr(t)||"source",n=h.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(IM()):n&&e==="map"?i.append(RM()):i.append(DM()),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"){wc();return}h.file=null,h.baseline=null,h.dirty=!1,h.insertMenuOpen=!1,Y()}},[_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(h.file||t.path)})]),LM(e),i])}function $M(){const t=wg(h.schema),e=[BM()];for(const[n,r]of t){const i=r.map(o=>k("button",{className:"studio-map-card",type:"button",title:cg(o),onClick:()=>{h.navOpenGroups.add(n),Ns(o)}},[_e(o.type==="file"?"draft":Ca[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(Ca[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 BM(){return k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[_e(Ca.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:()=>fg()},[_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 _M(){const t=Zv(),e=Qv(),n=tM(),r=aT(),i=gv(h.items,{query:t,sortId:e}),o=yv(i,{pageSizeId:n,page:tf()});o.page!==tf()&&Il(o.page);const s=o.items,l=qM(h.collection,{entryCount:h.listLoading?null:h.items.length});if(h.listLoading)return k("div",{className:"pane"},[l,k("p",{className:"loading-msg",text:"Loading content…"})]);if(h.error&&!h.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:h.error}),h.errorDetail?k("pre",{className:"list-error-detail",text:h.errorDetail}):null])]);const a=s.map(T=>HM(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 J;const R=(J=h.collection)==null?void 0:J.name;if(!R)return;h.listQueryByCollection[R]=T.target.value,Cc(),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=>{eM(T.target.value),Sn()}});for(const T of Qo)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=>{nM(T.target.value),Sn()}});for(const T of ts)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 m=null;i.length||(h.error?m=k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:h.error}),h.errorDetail?k("pre",{className:"list-error-detail",text:h.errorDetail}):null]):h.items.length===0?m=k("p",{className:"list-empty",text:"No entries in this collection."}):m=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(h.items.length>0){const T=t;if(!i.length)x=T?`0 of ${h.items.length}`:"";else if(o.pageSize==null)x=T?`${i.length} of ${h.items.length}`:"";else{const R=`${o.from}–${o.to} of ${i.length}`;x=T?`${R} (filtered from ${h.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:[m]),b])}function zM(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 FM(t,{open:e}){const n=xg(),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(),pT(t.path,t.sha)}},[_e("delete")]):null;return k("div",{className:"ledger-ops",role:"group","aria-label":"Operations"},[i,o])}function HM(t,e){const n=Tv(t,h.collection),r=()=>Os(t.path),i=FM(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:ef(t),onClick:r,onKeydown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r())}},[rf(t),l,i])}const o=k("div",{className:"ledger-title-row"},[Tg(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:ef(t),onClick:r,onKeydown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),r())}},[rf(t),s,i])}function As(t){return(t.fields||[]).filter(e=>!e.hidden&&!Af(e)&&e.name!=="layout")}function jM(t){const e=(t.fields||[]).filter(n=>Af(n));return e.length?e:t.format==="raw"&&!t.root_key?[{name:"body",label:"Content",component:"markdown_body"}]:[]}function lf(t,e){return((t==null?void 0:t.fields)||[]).some(n=>n.name===e)}function VM(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="boolean"?!0:String(t).trim()!==""}function UM(){var t;if(h.frontMatterOpen!=null)return!!h.frontMatterOpen;if(h.dirty)return!0;for(const e of As(h.collection))if(e.required&&!VM((t=h.fields)==null?void 0:t[e.name]))return!0;return!1}function qM(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`})),kg(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:()=>fT()},[_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 WM(){const t=As(h.collection),e=jM(h.collection),n=k("div",{className:"form-grid",id:"meta-form"});for(const a of t)n.append(Es(a));const r=UM(),i=t.length>0?k("details",{className:"front-matter",open:r,onToggle:a=>{h.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=h.bodyMode,d=c==="visual"||c==="preview",p=c==="source",m=k("div",{id:"tiptap-host",className:"tiptap editor-surface"});d||(m.hidden=!0);const g=k("textarea",{id:"body-source",className:"body-source editor-surface",text:h.body,"aria-label":"Markdown source",onInput:b=>{h.body=b.target.value,je(),pn()}});if(p||(g.hidden=!0),o.append(k("label",{text:a.label||"Body"}),JM(c),k("div",{className:"editor-pane-fill"},[m,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:h.fields[b.name]||"",onInput:x=>{h.fields[b.name]=x.target.value,je()}}))}const s=e.length>0?KM(h.body):null,l=[];if(lf(h.collection,"published")&&l.push(Tg(h.fields)),!lf(h.collection,"language")){const a=zM(h.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(),h.file=null,h.baseline=null,h.dirty=!1,h.insertMenuOpen=!1,h.frontMatterOpen=null,Y()}},[_e("chevron_left","btn-nav-icon")]),l.length?k("div",{className:"editor-mast-pills"},l):null])]),i,o,s])}function vg(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 KM(t){const{chars:e,words:n,paras:r}=vg(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 YM(){const t=ve("#editor-body-stats");if(!t)return;const{chars:e,words:n,paras:r}=vg(h.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 JM(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(),h.bodyMode="visual",h.lastEditorMode="visual",Qr(),Y())}}),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(),h.bodyMode="source",h.lastEditorMode="source",Qr(),Y())}}),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(),(h.bodyMode==="visual"||h.bodyMode==="source")&&(h.lastEditorMode=h.bodyMode),h.bodyMode="preview",Qr(),Y())}})]),o=k("div",{className:"editor-chrome-row"},[i,k("div",{className:"editor-chrome-actions"},[e||n?ZM():null,e?XM():null])]);return k("div",{className:"editor-chrome"},[o,k("p",{id:"ai-proof-hint",className:"ai-proof-hint",text:h.aiProofHint||"",hidden:!h.aiProofHint,"aria-live":"polite"}),e?QM():null])}function GM(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 XM(){const t=k("div",{className:"editor-insert-menu",id:"insert-menu",role:"menu"});h.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=GM(e);Qr(),h.bodyEditor?h.bodyEditor.insertInclude(e.name,n):Sn()}},[_e(Jv[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":h.insertMenuOpen?"true":"false",title:"Insert a Liquid include block",onClick:e=>{e.stopPropagation();const n=!h.insertMenuOpen;h.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 ZM(){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:!Tc()||h.aiProofBusy,onMouseDown:n=>{n.preventDefault(),h.aiProofSelection=Cg()},onClick:()=>{io(""),EM(e.action)}},[_e(e.icon),k("span",{className:"editor-ai-proof-label",text:h.aiProofBusy?"Working…":e.label})])))}function ht(){var t,e;return(e=(t=h.bodyEditor)==null?void 0:t.editor)==null?void 0:e.chain().focus()}function it(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 Dl(){return k("span",{className:"editor-toolbar-sep","aria-hidden":"true"})}function QM(){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 Gv)t.append(k("option",{value:e.value,text:e.label}));return k("div",{className:"editor-format-toolbar",role:"toolbar","aria-label":"Formatting"},[it({title:"Paragraph",icon:"notes",onClick:()=>{var e;return(e=ht())==null?void 0:e.setParagraph().run()}}),it({title:"Heading 1",text:"H1",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:1}).run()}}),it({title:"Heading 2",text:"H2",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:2}).run()}}),it({title:"Heading 3",text:"H3",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:3}).run()}}),it({title:"Heading 4",text:"H4",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:4}).run()}}),it({title:"Blockquote",icon:"format_quote",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBlockquote().run()}}),Dl(),it({title:"Bold",icon:"format_bold",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBold().run()}}),it({title:"Italic",icon:"format_italic",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleItalic().run()}}),it({title:"Strikethrough",icon:"format_strikethrough",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleStrike().run()}}),Dl(),t,Dl(),it({title:"Lowercase",text:"aa",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("lower")}}),it({title:"Uppercase",text:"AA",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("upper")}}),it({title:"Title case",text:"Aa",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("title")}})])}function eT(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||h.fields,i=e.onChange||(()=>{je()}),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=eT(c,t.default),d=k("input",{id:l,type:"checkbox",className:"field-checkbox",checked:u,onChange:m=>{r[n]=!!m.target.checked,i()}}),p=Qd(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,m=c?String(o).includes(p)||Array.isArray(o)&&o.includes(p):String(o)===String(p);u.append(k("option",{value:p,text:p,selected:m}))}s.append(u)}else if(t.type==="object"&&t.list)Array.isArray(r[n])||(r[n]=Array.isArray(o)?o:[]),s.append(tT(t,r[n],{onChange:c=>{r[n]=c,je(),Y()},idPrefix:`${e.idPrefix||""}${n}-`}));else if(t.list&&(t.type==="string"||!t.type)){const c=Array.isArray(o)?o.join(`
|
|
275
|
+
`);return String(o).trim()?{kind:"visual",from:n,to:r,text:o}:null}return null}function cf(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 IM(t,e){var n;if(t.kind==="source"){const r=h.body||"";h.body=r.slice(0,t.start)+e+r.slice(t.end);const i=ve("#body-source");if(i){i.value=h.body;const o=t.start+e.length;i.focus(),i.setSelectionRange(o,o)}je(),hn();return}t.kind==="visual"&&((n=h.bodyEditor)!=null&&n.editor)&&(h.bodyEditor.editor.chain().focus().insertContentAt({from:t.from,to:t.to},e).run(),un(),je(),hn())}function RM(){var n;const t=h.aiProofSelection||Ig();if(h.aiProofSelection=null,t)return t;un();const e=h.body||"";if(!String(e).trim())return null;if(h.bodyMode==="source")return{kind:"source",start:0,end:e.length,text:e,wholeBody:!0};if(h.bodyMode==="visual"&&((n=h.bodyEditor)!=null&&n.editor)){const r=h.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 DM(t){var l,a;if(ei(),oo(""),!Nc()){oo("Set language in front matter before AI Proof."),Na();return}const e=RM();if(!e){oo("Body is empty.");return}un();const n=String(h.fields.language||"").trim(),r=h.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";h.aiProofBusy=!0,h.status=t==="refine"?`Refining ${s}…`:`Correcting ${s}…`,Ea();try{const c=await ze.rewrite({mode:t,path:h.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?h.status=`No safe changes to apply (${d.proposed} proposed, all dropped).`:h.status=`No changes proposed for the ${s}.`;return}let p;if(e.kind==="visual"&&e.wholeBody){if(p=cf(r,u),p===r){h.status=`No changes proposed for the ${s}.`;return}h.body=p,(a=(l=h.bodyEditor)==null?void 0:l.setMarkdown)==null||a.call(l,p),je(),hn()}else{if(p=cf(e.text,u),p===e.text){h.status=`No changes proposed for the ${s}.`;return}IM(e,p)}const m=Number(d.dropped)>0?`, ${d.dropped} dropped`:"";h.status=t==="refine"?`Refined ${s} (${u.length}${m}).`:`Corrected ${s} (${u.length}${m}).`}catch(c){Ct(c);const u=h.error;h.error=u?`AI Proof failed. ${u}`:"AI Proof failed."}finally{h.aiProofBusy=!1,Ea(),Na()}}function Na(){const t=document.querySelector("[data-studio-action='save']"),e=document.querySelector("[data-studio-action='discard']");if(t){const n=h.saving?"Saving…":h.dirty?"Save":"Saved";t.disabled=h.saving||!h.file||!h.dirty,t.title=h.saving?"Saving this draft":h.dirty?"Commit this draft":"No edits to commit yet",t.setAttribute("aria-label",n);const r=t.querySelector(".material-symbols-outlined");r&&(r.textContent=h.saving?"progress_activity":h.dirty?"save":"check",r.classList.toggle("studio-icon-spin",h.saving));const i=t.querySelector(".btn-label");i&&(i.textContent=n)}e&&(e.disabled=!h.file||!h.dirty||!h.baseline),Ea()}function wn(){const t=ve("#studio-body");if(!t)return;t.innerHTML="";const e=h.file&&!pr()?` view-${h.bodyMode}`:"";if(t.className="studio-body"+(h.file?"":" list-only")+e,h.fileLoading){t.append(k("div",{className:"pane"},[k("p",{className:"loading-msg",text:"Loading content…"})]));return}if(!h.collection){if(h.mediaOpen){t.append(Wv(mg()));return}t.append(jM());return}if(!h.file){t.append(qM());return}if(pr()){t.append(HM(),ff()),hn();return}t.append(ZM(),ff()),aT(),hn()}function pr(t=h.collection){return(t==null?void 0:t.format)==="yaml"}function PM(){const t=h.collection,e=gr(t);try{if(e==="list")h.body=St(h.yamlList||[]);else if(e==="map")if(t.root_key){const n=h.yamlDoc&&typeof h.yamlDoc=="object"?{...h.yamlDoc}:{};n[t.root_key]=zn({...h.fields},t.fields),h.body=St(n)}else h.body=St(zn({...h.fields},t.fields))}catch(n){Ct(n)}}function $M(){const t=h.collection,e=gr(t);ct();try{const n=Qr(h.body);if(e==="list")h.yamlList=eg(n),h.fields={};else if(e==="map"){if(t.root_key){const r=ir(n);h.yamlDoc=r,h.fields=ir(r[t.root_key])}else h.yamlDoc=null,h.fields=ir(n);h.yamlList=null}return!0}catch(n){return Ct(n),h.status="Invalid YAML — fix source before switching",!1}}function uf(t){if(t===h.yamlUiMode)return;if(t==="source"){PM(),h.yamlUiMode="source",ne();return}const e=ve("#yaml-source");if(e&&(h.body=e.value),!$M()){ne();return}h.yamlUiMode="structured",ne()}function BM(t){const e=h.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:()=>uf("structured")}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"YAML",title:"Raw YAML source","aria-selected":e?"false":"true",onClick:()=>uf("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 _M(){const t=h.collection,e=Es(t),n=Array.isArray(h.yamlList)?h.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]],h.yamlList=d,je(),ne()}}),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]],h.yamlList=d,je(),ne()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{h.yamlList=n.filter((d,p)=>p!==o),je(),ne()}})])]));const u=k("div",{className:"form-grid yaml-list-item-fields"});for(const d of e)u.append(Ns(d,{target:s,idPrefix:`yml-${o}-`,onChange:()=>{je()}}));l.append(u),r.append(l)}),r.append(k("button",{className:"btn btn-primary",type:"button",text:"Add item",onClick:()=>{h.yamlList=[...h.yamlList||[],wc(e)],je(),ne()}})),n.length||r.prepend(k("p",{className:"yaml-empty",text:"No items yet. Add one to start this list."})),r}function zM(){const t=k("div",{className:"form-grid",id:"yaml-form"});for(const e of Es(h.collection))t.append(Ns(e));return t}function FM(){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:h.body,"aria-label":"YAML source",spellcheck:"false",onInput:t=>{h.body=t.target.value,je(),hn()}})])}function HM(){const t=h.collection,e=gr(t)||"source",n=h.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(_M()):n&&e==="map"?i.append(zM()):i.append(FM()),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"){Mc();return}h.file=null,h.baseline=null,h.dirty=!1,h.insertMenuOpen=!1,ne()}},[_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:Ai(h.file||t.path)})]),BM(e),i])}function jM(){const t=Og(h.schema),e=[VM()];for(const[n,r]of t){const i=r.map(o=>k("button",{className:"studio-map-card",type:"button",title:pg(o),onClick:()=>{h.navOpenGroups.add(n),Os(o)}},[_e(o.type==="file"?"draft":Ta[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:Ai(o.path)||o.name})])]));e.push(k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[_e(Ta[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 VM(){return k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[_e(Ta.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:()=>gg()},[_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:Ai("content/media")})])])])])}function qM(){const t=lM(),e=aM(),n=uM(),r=hT(),i=Mv(h.items,{query:t,sortId:e}),o=Tv(i,{pageSizeId:n,page:of()});o.page!==of()&&Rl(o.page);const s=o.items,l=XM(h.collection,{entryCount:h.listLoading?null:h.items.length});if(h.listLoading)return k("div",{className:"pane"},[l,k("p",{className:"loading-msg",text:"Loading content…"})]);if(h.error&&!h.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:h.error}),h.errorDetail?k("pre",{className:"list-error-detail",text:h.errorDetail}):null])]);const a=s.map(T=>KM(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=h.collection)==null?void 0:Y.name;if(!R)return;h.listQueryByCollection[R]=T.target.value,Tc(),wn();const $=ve("#list-search-input");if($){$.focus();const te=$.value.length;$.setSelectionRange(te,te)}}});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=>{cM(T.target.value),wn()}});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=>{dM(T.target.value),wn()}});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 m=null;i.length||(h.error?m=k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:h.error}),h.errorDetail?k("pre",{className:"list-error-detail",text:h.errorDetail}):null]):h.items.length===0?m=k("p",{className:"list-empty",text:"No entries in this collection."}):m=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||(Rl(o.page-1),wn())}}),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||(Rl(o.page+1),wn())}})]):null;let x="";if(h.items.length>0){const T=t;if(!i.length)x=T?`0 of ${h.items.length}`:"";else if(o.pageSize==null)x=T?`${i.length} of ${h.items.length}`:"";else{const R=`${o.from}–${o.to} of ${i.length}`;x=T?`${R} (filtered from ${h.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:[m]),b])}function UM(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 WM(t,{open:e}){const n=Ag(),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(),kT(t.path,t.sha)}},[_e("delete")]):null;return k("div",{className:"ledger-ops",role:"group","aria-label":"Operations"},[i,o])}function KM(t,e){const n=Pv(t,h.collection),r=()=>Ls(t.path),i=WM(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:rf(t),onClick:r,onKeydown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r())}},[lf(t),l,i])}const o=k("div",{className:"ledger-title-row"},[Pg(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:rf(t),onClick:r,onKeydown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),r())}},[lf(t),s,i])}function Es(t){return(t.fields||[]).filter(e=>!e.hidden&&!Lf(e)&&e.name!=="layout")}function YM(t){const e=(t.fields||[]).filter(n=>Lf(n));return e.length?e:t.format==="raw"&&!t.root_key?[{name:"body",label:"Content",component:"markdown_body"}]:[]}function df(t,e){return((t==null?void 0:t.fields)||[]).some(n=>n.name===e)}function JM(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="boolean"?!0:String(t).trim()!==""}function GM(){var t;if(h.frontMatterOpen!=null)return!!h.frontMatterOpen;if(h.dirty)return!0;for(const e of Es(h.collection))if(e.required&&!JM((t=h.fields)==null?void 0:t[e.name]))return!0;return!1}function XM(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`})),Tg(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:()=>bT()},[_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 ZM(){const t=Es(h.collection),e=YM(h.collection),n=k("div",{className:"form-grid",id:"meta-form"});for(const a of t)n.append(Ns(a));const r=GM(),i=t.length>0?k("details",{className:"front-matter",open:r,onToggle:a=>{h.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=h.bodyMode,d=c==="visual"||c==="preview",p=c==="source",m=k("div",{id:"tiptap-host",className:"tiptap editor-surface"});d||(m.hidden=!0);const g=k("textarea",{id:"body-source",className:"body-source editor-surface",text:h.body,"aria-label":"Markdown source",onInput:b=>{h.body=b.target.value,je(),hn()}});if(p||(g.hidden=!0),o.append(k("label",{text:a.label||"Body"}),tT(c),k("div",{className:"editor-pane-fill"},[m,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:h.fields[b.name]||"",onInput:x=>{h.fields[b.name]=x.target.value,je()}}))}const s=e.length>0?QM(h.body):null,l=[];if(df(h.collection,"published")&&l.push(Pg(h.fields)),!df(h.collection,"language")){const a=UM(h.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(),h.file=null,h.baseline=null,h.dirty=!1,h.insertMenuOpen=!1,h.frontMatterOpen=null,ne()}},[_e("chevron_left","btn-nav-icon")]),l.length?k("div",{className:"editor-mast-pills"},l):null])]),i,o,s])}function Rg(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 QM(t){const{chars:e,words:n,paras:r}=Rg(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 eT(){const t=ve("#editor-body-stats");if(!t)return;const{chars:e,words:n,paras:r}=Rg(h.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 tT(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||(un(),h.bodyMode="visual",h.lastEditorMode="visual",ei(),ne())}}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Source",title:"Edit raw Markdown source","aria-selected":n?"true":"false",onClick:()=>{n||(un(),h.bodyMode="source",h.lastEditorMode="source",ei(),ne())}}),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||(un(),(h.bodyMode==="visual"||h.bodyMode==="source")&&(h.lastEditorMode=h.bodyMode),h.bodyMode="preview",ei(),ne())}})]),o=k("div",{className:"editor-chrome-row"},[i,k("div",{className:"editor-chrome-actions"},[e||n?iT():null,e?rT():null])]);return k("div",{className:"editor-chrome"},[o,k("p",{id:"ai-proof-hint",className:"ai-proof-hint",text:h.aiProofHint||"",hidden:!h.aiProofHint,"aria-live":"polite"}),e?oT():null])}function nT(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 rT(){const t=k("div",{className:"editor-insert-menu",id:"insert-menu",role:"menu"});h.insertMenuOpen||(t.hidden=!0);for(const e of fr.filter(n=>!n.blockBody))t.append(k("button",{className:"editor-insert-item",type:"button",role:"menuitem",title:e.label,onClick:()=>{const n=nT(e);ei(),h.bodyEditor?h.bodyEditor.insertInclude(e.name,n):wn()}},[_e(iM[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":h.insertMenuOpen?"true":"false",title:"Insert a Liquid include block",onClick:e=>{e.stopPropagation();const n=!h.insertMenuOpen;h.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 iT(){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:!Nc()||h.aiProofBusy,onMouseDown:n=>{n.preventDefault(),h.aiProofSelection=Ig()},onClick:()=>{oo(""),DM(e.action)}},[_e(e.icon),k("span",{className:"editor-ai-proof-label",text:h.aiProofBusy?"Working…":e.label})])))}function ht(){var t,e;return(e=(t=h.bodyEditor)==null?void 0:t.editor)==null?void 0:e.chain().focus()}function it(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 Bl(){return k("span",{className:"editor-toolbar-sep","aria-hidden":"true"})}function oT(){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 oM)t.append(k("option",{value:e.value,text:e.label}));return k("div",{className:"editor-format-toolbar",role:"toolbar","aria-label":"Formatting"},[it({title:"Paragraph",icon:"notes",onClick:()=>{var e;return(e=ht())==null?void 0:e.setParagraph().run()}}),it({title:"Heading 1",text:"H1",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:1}).run()}}),it({title:"Heading 2",text:"H2",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:2}).run()}}),it({title:"Heading 3",text:"H3",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:3}).run()}}),it({title:"Heading 4",text:"H4",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleHeading({level:4}).run()}}),it({title:"Blockquote",icon:"format_quote",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBlockquote().run()}}),Bl(),it({title:"Bold",icon:"format_bold",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleBold().run()}}),it({title:"Italic",icon:"format_italic",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleItalic().run()}}),it({title:"Strikethrough",icon:"format_strikethrough",onClick:()=>{var e;return(e=ht())==null?void 0:e.toggleStrike().run()}}),Bl(),t,Bl(),it({title:"Lowercase",text:"aa",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("lower")}}),it({title:"Uppercase",text:"AA",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("upper")}}),it({title:"Title case",text:"Aa",onClick:()=>{var e;return(e=h.bodyEditor)==null?void 0:e.transformSelectionCase("title")}})])}function sT(t,e){return t===!0||t==="true"?!0:t===!1||t==="false"?!1:e===!0||e==="true"}function Ns(t,e={}){var a;const n=t.name,r=e.target||h.fields,i=e.onChange||(()=>{je()}),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=sT(c,t.default),d=k("input",{id:l,type:"checkbox",className:"field-checkbox",checked:u,onChange:m=>{r[n]=!!m.target.checked,i()}}),p=nf(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,m=c?String(o).includes(p)||Array.isArray(o)&&o.includes(p):String(o)===String(p);u.append(k("option",{value:p,text:p,selected:m}))}s.append(u)}else if(t.type==="object"&&t.list)Array.isArray(r[n])||(r[n]=Array.isArray(o)?o:[]),s.append(lT(t,r[n],{onChange:c=>{r[n]=c,je(),ne()},idPrefix:`${e.idPrefix||""}${n}-`}));else if(t.list&&(t.type==="string"||!t.type)){const c=Array.isArray(o)?o.join(`
|
|
276
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=
|
|
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=nf(t);c&&s.append(k("p",{className:"hint",text:c}))}return s}function lT(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,m)=>m!==a))}})])]));const d=k("div",{className:"form-grid yaml-list-item-fields"});for(const p of t.fields||[])p.hidden||d.append(Ns(p,{target:c,idPrefix:`${r}${a}-`,onChange:()=>{je()}}));u.append(d),o.append(u)}),o.append(k("button",{className:"btn",type:"button",text:`Add ${t.label||"item"}`,onClick:()=>{s([...i,wc(t.fields||[])])}})),o}function ff(){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:h.previewHtml})])])}function aT(){const t=ve("#tiptap-host");if(!t)return;if(vt(),h.bodyMode==="source"){t.hidden=!0;return}t.hidden=!1;const e=(h.bodyMode==="preview"&&h.lastEditorMode==="source",h.body);h.bodyEditor=kC(t,{content:e,onUpdate:n=>{h.body=n,je(),hn()}})}function un(){var r;let t=null;h.bodyEditor&&h.bodyMode!=="source"&&(t=h.bodyEditor.getMarkdown());const e=ve("#body-source");if(e&&h.bodyMode==="source"&&(t=e.value),t==null)return;const n=(r=h.baseline)==null?void 0:r.body;if(typeof n=="string"&&t===yC(n)){h.body=n;return}h.body=t}function vt(){h.bodyEditor&&(h.bodyEditor.destroy(),h.bodyEditor=null)}const Lr=new Map,Jn=new Map,cT=1e3;async function uT(t,e){const n=String(e||"").trim();if(!n)return!1;try{const r=t==="xcite"?await ze.searchXcite(n):await ze.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 dT(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=Jn.get(s);l==="ok"||l==="missing"?Zi(r,l):Zi(r,null)}for(const r of[...Jn.keys()])if(!e.has(r)){Jn.delete(r);const i=Lr.get(r);i&&clearTimeout(i),Lr.delete(r)}for(const[r,i]of n){const o=r.slice(r.indexOf(":")+1),s=r.startsWith("xcite:")?"xcite":"cite";o&&(Jn.get(r)==="ok"||Jn.get(r)==="missing"||Lr.has(r)||Lr.set(r,setTimeout(async()=>{Lr.delete(r);const a=await uT(s,o)?"ok":"missing";Jn.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)},cT)))}}function hn(){const t=ve("#preview-frame");if(pr()?h.previewHtml=fT():h.previewHtml=xv(h.body||""),t){const e=t.scrollTop,n=t.scrollLeft;t.innerHTML=h.previewHtml,t.scrollTop=e,t.scrollLeft=n,pr()||(dT(t),Promise.resolve(Dg(t)).then(()=>{ve("#preview-frame")===t&&(t.scrollTop=e,t.scrollLeft=n)}))}}function pf(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function fT(){const t=h.collection,e=gr(t);let n="";try{if(h.yamlUiMode==="source"||e==="source")n=h.body||"";else if(e==="list")n=St(h.yamlList||[]);else if(e==="map"&&t.root_key){const r=h.yamlDoc&&typeof h.yamlDoc=="object"?{...h.yamlDoc}:{};r[t.root_key]=zn({...h.fields},t.fields),n=St(r)}else e==="map"?n=St(zn({...h.fields},t.fields)):n=h.body||""}catch(r){return`<p class="yaml-preview-error">${pf(r.message||r)}</p>`}return`<pre class="yaml-preview-pre">${pf(n)}</pre>`}let Ir=null;function pT(){return window.mermaid?Promise.resolve(window.mermaid):Ir||(Ir=Hg(()=>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 Ir=null,t}),Ir)}function _l(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
278
|
|
|
279
279
|
`:`Mermaid (unrendered)
|
|
280
280
|
|
|
281
|
-
`;t.innerHTML="";const i=document.createElement("pre");i.className="studio-mermaid-fallback__pre",i.textContent=r+n,t.append(i)}async function
|
|
281
|
+
`;t.innerHTML="";const i=document.createElement("pre");i.className="studio-mermaid-fallback__pre",i.textContent=r+n,t.append(i)}async function Dg(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 pT()}catch(r){for(const i of e)_l(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")||_l(i,(r==null?void 0:r.message)||"render failed")}for(const r of e)r.classList.contains("studio-mermaid-fallback")||r.querySelector("svg")||_l(r,"render produced no diagram")}function hT(t=h.collection){const e=t==null?void 0:t.name;return e==="articles"||e==="posts"}function mT(t){const e=t==null?void 0:t.published;return!(e===!1||e==="false")}function Pg(t){const e=mT(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 Os(t){vt(),h.mediaOpen=!1,h.mediaItems=[],h.collection=t,h.file=null,h.baseline=null,h.frontMatterOpen=null,h.items=[],h.insertMenuOpen=!1,vc(),ct(),h.listLoading=t.type!=="file",h.fileLoading=t.type==="file",h.status=`Loading ${t.label}…`,ne();try{if(t.type==="file"){await Ls(t.path);return}const e=fM(t);if(e){h.items=e,yg(t,e.length),h.listLoading=!1,h.status="",ne();return}const n=await ze.tree(t.path);h.items=n.items||[],bg(t,h.items),h.listLoading=!1,h.status=""}catch(e){h.items=[],h.listLoading=!1,Ct(e)}ne()}async function Ls(t){vt(),h.insertMenuOpen=!1,h.fileLoading=!0,h.file=null,h.baseline=null,h.frontMatterOpen=null,h.status=`Opening ${t}…`,ct(),h.yamlDoc=null,h.yamlList=null,ne();try{const e=await ze.getFile(t);h.file=t,h.sha=e.sha;const n=Rf(e.content),r=h.collection;if(r.format==="yaml"){h.body=e.content;const i=gr(r);if(i==="list"){const o=Qr(e.content);h.yamlList=eg(o),h.fields={},h.yamlDoc=null,h.yamlUiMode="structured"}else if(i==="map"){if(r.root_key){const o=ir(Qr(e.content));h.yamlDoc=o,h.fields=ir(o[r.root_key])}else h.yamlDoc=null,h.fields=ir(Qr(e.content));h.yamlList=null,h.yamlUiMode="structured"}else h.fields={},h.yamlList=null,h.yamlUiMode="source"}else r.format==="raw"?(h.body=e.content,h.fields={}):(h.fields={...n.fm},h.body=n.body);h.dirty=!1,h.fileLoading=!1,h.listLoading=!1,h.status=t,$g()}catch(e){h.fileLoading=!1,h.listLoading=!1,h.baseline=null,Ct(e)}ne()}function $g(){h.baseline={fields:structuredClone(h.fields||{}),body:h.body,yamlDoc:h.yamlDoc?structuredClone(h.yamlDoc):null,yamlList:h.yamlList?structuredClone(h.yamlList):null,yamlUiMode:h.yamlUiMode,sha:h.sha}}function gT(){if(!h.file||!h.baseline)return;const t=h.baseline;vt(),h.fields=structuredClone(t.fields||{}),h.body=t.body,h.yamlDoc=t.yamlDoc?structuredClone(t.yamlDoc):null,h.yamlList=t.yamlList?structuredClone(t.yamlList):null,h.yamlUiMode=t.yamlUiMode||"structured",h.sha=t.sha,h.dirty=!1,h.insertMenuOpen=!1,h.bodyMode==="preview"||h.bodyMode!=="visual"&&h.bodyMode!=="source"&&(h.bodyMode=h.lastEditorMode||"visual"),ct(),h.status=`Reverted ${h.file}`,ne()}async function yT(){if(!h.reexporting){h.reexporting=!0,h.pipeline.state="syncing",h.pipeline.message="",h.status="Reexporting…",ct(),$l(),af(),Pl();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}`);h.reexporting=!1,h.pipeline.state="ok",h.status="Reexported — reloading…",$l(),Pl(),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){h.reexporting=!1,h.pipeline.state="error",h.pipeline.message=String(t.message||t),Ct(t),$l(),af(),Pl()}}}async function bT(){const t=h.collection;if(!Tg(t))return;const e=window.prompt(`New ${t.label||"entry"} key (slug):`);if(e==null)return;const n=CM(e);if(!n){h.error="Key must use letters, numbers, or hyphens.",h.errorDetail="",ne();return}const r=vM(t.filename,n),i=`${String(t.path||"").replace(/\/$/,"")}/${r}`,o=wc(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=MM());let s;t.format==="yaml"?s=St(zn({...o},t.fields)):s=Pf(`---
|
|
282
282
|
---
|
|
283
283
|
|
|
284
284
|
`,{fields:o,body:`
|
|
285
285
|
`,format:t.format||"yaml-frontmatter"}),s.endsWith(`
|
|
286
286
|
`)||(s+=`
|
|
287
|
-
`),h.status=`Creating ${i}…`,ct(),
|
|
287
|
+
`),h.status=`Creating ${i}…`,ct(),ne();try{let l=!1;try{await ze.getFile(i),l=!0}catch(c){if(c.status!==404&&c.code!=="not_found")throw c}if(l)throw new Error(`${i} already exists`);const a=await ze.putFile({path:i,content:s,sha:null,message:`studio: create ${i}`});Ac(t.name),h.status=`Created ${i}`,As(a==null?void 0:a.commit),await Os(t),await Ls(i)}catch(l){Ct(l),ne()}}async function kT(t,e=null){const n=h.collection;if(!Ag(n)||!t)return;const r=String(t).split("/").pop()||t;if(window.confirm(`Delete ${r}?
|
|
288
288
|
|
|
289
|
-
This commits a deletion to main and cannot be undone from Studio.`)){h.status=`Deleting ${t}…`,ct(),
|
|
289
|
+
This commits a deletion to main and cannot be undone from Studio.`)){h.status=`Deleting ${t}…`,ct(),ne();try{let i=e;i||(i=(await ze.getFile(t)).sha);const o=await ze.deleteFile({path:t,sha:i,message:`studio: delete ${t}`});Ac(n==null?void 0:n.name),h.file===t&&(vt(),h.file=null,h.baseline=null,h.sha=null,h.dirty=!1,h.fields={},h.body=""),h.status=`Deleted ${t}`,As(o==null?void 0:o.commit),n?await Os(n):ne()}catch(i){Ct(i),ne()}}}async function xT(){var t;if(!(!h.file||h.saving)){if(un(),pr()){const e=ve("#yaml-source");e&&(h.body=e.value)}h.saving=!0,h.status="Saving…",ct(),ne();try{let e;const n=h.collection;if(n.format==="raw")e=h.body;else if(n.format==="yaml"){const i=gr(n);if(h.yamlUiMode==="source"||i==="source")Qr(h.body),e=h.body.endsWith(`
|
|
290
290
|
`)?h.body:h.body+`
|
|
291
|
-
`;else if(i==="list")e=St(h.yamlList||[]);else if(i==="map"&&n.root_key){const s=h.yamlDoc&&typeof h.yamlDoc=="object"?{...h.yamlDoc}:{};s[n.root_key]=
|
|
291
|
+
`;else if(i==="list")e=St(h.yamlList||[]);else if(i==="map"&&n.root_key){const s=h.yamlDoc&&typeof h.yamlDoc=="object"?{...h.yamlDoc}:{};s[n.root_key]=zn({...h.fields},n.fields),e=St(s)}else i==="map"?e=St(zn({...h.fields},n.fields)):e=h.body.endsWith(`
|
|
292
292
|
`)?h.body:h.body+`
|
|
293
|
-
`}else{const i=(await ze.getFile(h.file)).content,o={...h.fields};e=
|
|
293
|
+
`}else{const i=(await ze.getFile(h.file)).content,o={...h.fields};e=Pf(i,{fields:o,body:h.body,format:n.format})}e.endsWith(`
|
|
294
294
|
`)||(e+=`
|
|
295
|
-
`);const r=await ze.putFile({path:h.file,content:e,sha:h.sha,message:`studio: update ${h.file}`});h.sha=((t=r.content)==null?void 0:t.sha)||h.sha,h.dirty=!1,ct(),h.status=`Saved ${h.file}
|
|
295
|
+
`);const r=await ze.putFile({path:h.file,content:e,sha:h.sha,message:`studio: update ${h.file}`});h.sha=((t=r.content)==null?void 0:t.sha)||h.sha,h.dirty=!1,ct(),h.status=`Saved ${h.file}`,$g(),n!=null&&n.name&&Ac(n.name),As(r==null?void 0:r.commit)}catch(e){Ct(e)}finally{h.saving=!1,ne()}}}async function so(t){var e,n;try{h.session=await ze.session()}catch(r){if((((e=r==null?void 0:r.data)==null?void 0:e.error)||"")==="not_allowlisted"){EM(t,((n=r==null?void 0:r.data)==null?void 0:n.email)||Ng(t));return}h.error=`Session failed: ${r.message}`,mi(t),h.error&&at.append(k("p",{className:"status-pill error",text:h.error}));return}try{h.schema=await Yg()}catch(r){h.error=String(r.message||r),at.innerHTML="",at.append(k("p",{className:"auth-gate status-pill error",text:h.error}));return}ne(),SM(),kg(),t&&!t.dev&&t.addListener&&t.addListener(({user:r})=>{r||(vt(),mi(t))})}async function ST(){bM();const t=await rM();if(t.dev){await so(t);return}t.user?await so(t):(mi(t),t.addListener(async({user:e})=>{e&&await so(t)}))}ST().catch(t=>{at.textContent=String(t.stack||t)});
|