showai-reader 0.10.0-reader.lp7ix6so → 0.10.0-reader.no2caghj
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/chunks/{CardGrid-CXO2U3K5.js → CardGrid-ZD7JY7UV.js} +1 -1
- package/chunks/{CommandReference-E5Y6VMXC.js → CommandReference-YJNIRPTL.js} +1 -1
- package/chunks/{ComparisonMatrix-TXTUZF55.js → ComparisonMatrix-4DRFSPLO.js} +1 -1
- package/chunks/{EventTimeline-JOTYNIMI.js → EventTimeline-IQ2H46VE.js} +1 -1
- package/chunks/{ExperimentTracker-CWZCU2QO.js → ExperimentTracker-U5ITYX3T.js} +1 -1
- package/chunks/{ExternalDiagram-WFWITA4Q.js → ExternalDiagram-EWPIP7Z3.js} +1 -1
- package/chunks/{Flowchart-DJGFXDXU.js → Flowchart-KG5XEGTX.js} +1 -1
- package/chunks/{G2Chart-YVTXVVRZ.js → G2Chart-VK5272YL.js} +2 -2
- package/chunks/{LayerDiagram-KDSBIPHG.js → LayerDiagram-HCGSQAKS.js} +1 -1
- package/chunks/{Mindmap-SB34H5SG.js → Mindmap-NYV6EHDM.js} +1 -1
- package/chunks/{RichTextEditor-SMQMXUUN.js → RichTextEditor-XZ2B5GGL.js} +46 -46
- package/chunks/{Roadmap-BSPT5PBK.js → Roadmap-4XOIMZZP.js} +1 -1
- package/chunks/{Scene3D-VILMVRHH.js → Scene3D-MGIPMJO3.js} +2 -2
- package/chunks/{SequenceDiagram-W2YQCHNV.js → SequenceDiagram-6UO5Q4AG.js} +1 -1
- package/chunks/{StatusTree-57AOX2U2.js → StatusTree-DRHWD54I.js} +1 -1
- package/chunks/StepGuide-D7YXYHX7.js +1 -0
- package/chunks/{StructureBrowser-PVPAFYTN.js → StructureBrowser-GRRBMR5E.js} +1 -1
- package/chunks/{Waterfall-FIQDQSMD.js → Waterfall-MFZSSWA6.js} +1 -1
- package/chunks/{chunk-55FJSXTX.js → chunk-2URYNZTR.js} +1 -1
- package/chunks/{chunk-X6OHYKIW.js → chunk-7OXIV2BW.js} +1 -1
- package/chunks/{chunk-VUDDBRCY.js → chunk-GMWEGDGS.js} +2 -2
- package/chunks/chunk-JTQMPH6V.js +23 -0
- package/chunks/{chunk-6WTBCWHP.js.LEGAL.txt → chunk-JTQMPH6V.js.LEGAL.txt} +1 -0
- package/chunks/{chunk-5HKZMSJF.js → chunk-NLCSXEUT.js} +1 -1
- package/chunks/{chunk-TFZIEWR5.js → chunk-ODQFSR7R.js} +1 -1
- package/chunks/{chunk-ISEW5ABW.js → chunk-OZ5T5PI3.js} +1 -1
- package/chunks/{chunk-5SAGHDIJ.js → chunk-PPIHNPX6.js} +1 -1
- package/chunks/{chunk-7FHZWI2R.js → chunk-RR2EZ72L.js} +1 -1
- package/chunks/{chunk-7TNODUAV.js → chunk-T4CIPZPJ.js} +1 -1
- package/chunks/{chunk-DTW4F4AN.js → chunk-TJVHVAQF.js} +1 -1
- package/chunks/chunk-VKJZ5EGG.js +330 -0
- package/chunks/{chunk-UWAAPX6Y.js → chunk-YQ6N2DJR.js} +1 -1
- package/index.js +1 -1
- package/manifest.json +4 -4
- package/package.json +1 -1
- package/{reader-LP7IX6SO.js → reader-NO2CAGHJ.js} +31 -31
- package/chunks/StepGuide-VQRICGFO.js +0 -1
- package/chunks/chunk-6WTBCWHP.js +0 -23
- package/chunks/chunk-GREB3PFJ.js +0 -329
- /package/chunks/{G2Chart-YVTXVVRZ.js.LEGAL.txt → G2Chart-VK5272YL.js.LEGAL.txt} +0 -0
- /package/chunks/{Scene3D-VILMVRHH.js.LEGAL.txt → Scene3D-MGIPMJO3.js.LEGAL.txt} +0 -0
- /package/chunks/{chunk-VUDDBRCY.js.LEGAL.txt → chunk-GMWEGDGS.js.LEGAL.txt} +0 -0
- /package/{reader-LP7IX6SO.js.LEGAL.txt → reader-NO2CAGHJ.js.LEGAL.txt} +0 -0
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{a as Ds,c as Ls,i as Qc,m as Nn,n as Is,o as Zc,q as su,r as $e,s as Do,t as lu}from"./chunk-GREB3PFJ.js";import{A as W,B as ne,C as ru,E as ou,I as Bs,b as z,c as tu,d as ae,e as Ao,f as Ps,g as Rn,h as On,i as To,j as nu,k as Dn,l as Ct,m as $t,n as nr,o as dt,p as bt,q as rr,r as No,s as Ro,t as Oo,u as J,v as $s,w as L,x as H,y as rn,z as Br}from"./chunk-5HKZMSJF.js";import"./chunk-SNEZ3O5V.js";import{a as zs,b as Lo,c as au,e as cu}from"./chunk-7G6RMB6W.js";import{a as xg,b as Sg}from"./chunk-VUDDBRCY.js";import{a as iu}from"./chunk-5AW2WUSZ.js";import{a as uu}from"./chunk-X6OHYKIW.js";import{$ as Pc,$a as Tn,A as Co,Aa as nn,Da as Es,Ea as jc,F as Ac,G as Tc,I as Nc,L as Rc,La as Ms,Ma as As,N as Oc,Na as Fc,O as Dc,Qa as Wc,Sa as Ts,Ta as Kc,Ua as Ns,Va as Uc,Wa as qc,Xa as Rs,Y as Lc,Ya as Mn,Za as An,_ as Ic,_a as Gc,a as Cc,aa as $c,ab as Eo,ba as Bc,bb as Mo,c as tn,ca as xo,cb as Jc,db as Xc,ea as zc,fb as Yc,ia as So,ib as $r,ja as xs,jb as Xe,kb as Os,la as Ss,m as xc,mb as Fe,p as Sc,q as Cs,qa as Hc,r as Ec,ra as _c,wa as Vc,y as Mc,z as Pr}from"./chunk-6WTBCWHP.js";import{a as eu,f as tr}from"./chunk-J6IRWTF7.js";import{a as Cg,c as be}from"./chunk-DCANE7XH.js";var Pm=Cg((ST,Im)=>{function Cm(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&Cm(n)}),e}var hs=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function xm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function bn(e,...t){let n=Object.create(null);for(let r in e)n[r]=e[r];return t.forEach(function(r){for(let o in r)n[o]=r[o]}),n}var Ax="</span>",gm=e=>!!e.scope,Tx=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((r,o)=>`${r}${"_".repeat(o+1)}`)].join(" ")}return`${t}${e}`},sc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=xm(t)}openNode(t){if(!gm(t))return;let n=Tx(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){gm(t)&&(this.buffer+=Ax)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},bm=(e={})=>{let t={children:[]};return Object.assign(t,e),t},lc=class e{constructor(){this.rootNode=bm(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){let n=bm({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(r=>this._walk(t,r)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{e._collapse(n)}))}},ac=class extends lc{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){let r=t.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new sc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function yo(e){return e?typeof e=="string"?e:e.source:null}function Sm(e){return er("(?=",e,")")}function Nx(e){return er("(?:",e,")*")}function Rx(e){return er("(?:",e,")?")}function er(...e){return e.map(n=>yo(n)).join("")}function Ox(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function gs(...e){return"("+(Ox(e).capture?"":"?:")+e.map(r=>yo(r)).join("|")+")"}function Em(e){return new RegExp(e.toString()+"|").exec("").length-1}function Dx(e,t){let n=e&&e.exec(t);return n&&n.index===0}var Lx=new RegExp(gs(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function uc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=yo(r),s="";for(;i.length>0;){let l=Lx.exec(i);if(!l){s+=i;break}s+=i.substring(0,l.index),i=i.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?s+="\\"+String(Number(l[1])+o):(s+=l[0],(l[0]==="("||/^\(\?[<']/.test(l[0]))&&n++)}return s}).map(r=>`(${r})`).join(t)}var Ix=/\b\B/,Mm="[a-zA-Z]\\w*",dc="[a-zA-Z_]\\w*",Am="\\b\\d+(\\.\\d+)?",Tm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Nm="\\b(0b[01]+)",Px="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",$x=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=er(t,/.*\b/,e.binary,/\b.*/)),bn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},wo={begin:"\\\\[\\s\\S]",relevance:0},Bx={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[wo]},zx={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[wo]},Hx={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},bs=function(e,t,n={}){let r=bn({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let o=gs("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:er(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},_x=bs("//","$"),Vx=bs("/\\*","\\*/"),jx=bs("#","$"),Fx={scope:"number",begin:Am,relevance:0},Wx={scope:"number",begin:Tm,relevance:0},Kx={scope:"number",begin:Nm,relevance:0},Ux={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[wo,{begin:/\[/,end:/\]/,relevance:0,contains:[wo]}]},qx={scope:"title",begin:Mm,relevance:0},Gx={scope:"title",begin:dc,relevance:0},Jx={begin:"\\.\\s*"+dc,relevance:0},Xx=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})},ps=Object.freeze({__proto__:null,APOS_STRING_MODE:Bx,BACKSLASH_ESCAPE:wo,BINARY_NUMBER_MODE:Kx,BINARY_NUMBER_RE:Nm,COMMENT:bs,C_BLOCK_COMMENT_MODE:Vx,C_LINE_COMMENT_MODE:_x,C_NUMBER_MODE:Wx,C_NUMBER_RE:Tm,END_SAME_AS_BEGIN:Xx,HASH_COMMENT_MODE:jx,IDENT_RE:Mm,MATCH_NOTHING_RE:Ix,METHOD_GUARD:Jx,NUMBER_MODE:Fx,NUMBER_RE:Am,PHRASAL_WORDS_MODE:Hx,QUOTE_STRING_MODE:zx,REGEXP_MODE:Ux,RE_STARTERS_RE:Px,SHEBANG:$x,TITLE_MODE:qx,UNDERSCORE_IDENT_RE:dc,UNDERSCORE_TITLE_MODE:Gx});function Yx(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function Qx(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function Zx(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=Yx,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function eS(e,t){Array.isArray(e.illegal)&&(e.illegal=gs(...e.illegal))}function tS(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function nS(e,t){e.relevance===void 0&&(e.relevance=1)}var rS=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(r=>{delete e[r]}),e.keywords=n.keywords,e.begin=er(n.beforeMatch,Sm(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},oS=["of","and","for","in","not","or","if","then","parent","list","value"],iS="keyword";function Rm(e,t,n=iS){let r=Object.create(null);return typeof e=="string"?o(n,e.split(" ")):Array.isArray(e)?o(n,e):Object.keys(e).forEach(function(i){Object.assign(r,Rm(e[i],t,i))}),r;function o(i,s){t&&(s=s.map(l=>l.toLowerCase())),s.forEach(function(l){let a=l.split("|");r[a[0]]=[i,sS(a[0],a[1])]})}}function sS(e,t){return t?Number(t):lS(e)?0:1}function lS(e){return oS.includes(e.toLowerCase())}var ym={},Zn=e=>{console.error(e)},wm=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Or=(e,t)=>{ym[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ym[`${e}/${t}`]=!0)},ms=new Error;function Om(e,t,{key:n}){let r=0,o=e[n],i={},s={};for(let l=1;l<=t.length;l++)s[l+r]=o[l],i[l+r]=!0,r+=Em(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function aS(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Zn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ms;if(typeof e.beginScope!="object"||e.beginScope===null)throw Zn("beginScope must be object"),ms;Om(e,e.begin,{key:"beginScope"}),e.begin=uc(e.begin,{joinWith:""})}}function cS(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Zn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ms;if(typeof e.endScope!="object"||e.endScope===null)throw Zn("endScope must be object"),ms;Om(e,e.end,{key:"endScope"}),e.end=uc(e.end,{joinWith:""})}}function uS(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function dS(e){uS(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),aS(e),cS(e)}function fS(e){function t(s,l){return new RegExp(yo(s),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(l?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,l]),this.matchAt+=Em(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(uc(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;let a=this.matcherRe.exec(l);if(!a)return null;let u=a.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return a.splice(0,u),Object.assign(a,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];let a=new n;return this.rules.slice(l).forEach(([u,c])=>a.addRule(u,c)),a.compile(),this.multiRegexes[l]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,a){this.rules.push([l,a]),a.type==="begin"&&this.count++}exec(l){let a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let u=a.exec(l);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){let c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(l)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function o(s){let l=new r;return s.contains.forEach(a=>l.addRule(a.begin,{rule:a,type:"begin"})),s.terminatorEnd&&l.addRule(s.terminatorEnd,{type:"end"}),s.illegal&&l.addRule(s.illegal,{type:"illegal"}),l}function i(s,l){let a=s;if(s.isCompiled)return a;[Qx,tS,dS,rS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[Zx,eS,nS].forEach(c=>c(s,l)),s.isCompiled=!0;let u=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),u=s.keywords.$pattern,delete s.keywords.$pattern),u=u||/\w+/,s.keywords&&(s.keywords=Rm(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(u,!0),l&&(s.begin||(s.begin=/\B|\b/),a.beginRe=t(a.begin),!s.end&&!s.endsWithParent&&(s.end=/\B|\b/),s.end&&(a.endRe=t(a.end)),a.terminatorEnd=yo(a.end)||"",s.endsWithParent&&l.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+l.terminatorEnd)),s.illegal&&(a.illegalRe=t(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map(function(c){return pS(c==="self"?s:c)})),s.contains.forEach(function(c){i(c,a)}),s.starts&&i(s.starts,l),a.matcher=o(a),a}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=bn(e.classNameAliases||{}),i(e)}function Dm(e){return e?e.endsWithParent||Dm(e.starts):!1}function pS(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return bn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Dm(e)?bn(e,{starts:e.starts?bn(e.starts):null}):Object.isFrozen(e)?bn(e):e}var hS="11.12.0",cc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},ic=xm,km=bn,vm=Symbol("nomatch"),mS=7,Lm=function(e){let t=Object.create(null),n=Object.create(null),r=[],o=!0,i="Could not find the language '{}', did you forget to load/include a language module?",s={disableAutodetect:!0,name:"Plain text",contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ac};function a(A){return l.noHighlightRe.test(A)}function u(A){let R=A.className+" ";R+=A.parentNode?A.parentNode.className:"";let q=l.languageDetectRe.exec(R);if(q){let ie=B(q[1]);return ie||(wm(i.replace("{}",q[1])),wm("Falling back to no-highlight mode for this block.",A)),ie?q[1]:"no-highlight"}return R.split(/\s+/).find(ie=>a(ie)||B(ie))}function c(A,R,q){let ie="",le="";typeof R=="object"?(ie=A,q=R.ignoreIllegals,le=R.language):(Or("10.7.0","highlight(lang, code, ...args) has been deprecated."),Or("10.7.0",`Please use highlight(code, options) instead.
|
|
2
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),
|
|
3
|
-
`),1;if(w>1e5&&w>I.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ge+=G,G.length}let Je=B(A);if(!Je)throw Zn(i.replace("{}",A)),new Error('Unknown language: "'+A+'"');let Zt=fS(Je),kt="",V=ie||Zt,It={},ke=new l.__emitter(l);tt();let ge="",vt=0,Pt=0,w=0,vn=!1;try{if(Je.__emitTokens)Je.__emitTokens(R,ke);else{for(V.matcher.considerAll();;){w++,vn?vn=!1:V.matcher.considerAll(),V.matcher.lastIndex=Pt;let O=V.matcher.exec(R);if(!O)break;let I=R.substring(Pt,O.index),G=kn(I,O);Pt=O.index+G}kn(R.substring(Pt))}return ke.finalize(),kt=ke.toHTML(),{language:A,value:kt,relevance:vt,illegal:!1,_emitter:ke,_top:V}}catch(O){if(O.message&&O.message.includes("Illegal"))return{language:A,value:ic(R),illegal:!0,relevance:0,_illegalBy:{message:O.message,index:Pt,context:R.slice(Pt-100,Pt+100),mode:O.mode,resultSoFar:kt},_emitter:ke};if(o)return{language:A,value:ic(R),illegal:!1,relevance:0,errorRaised:O,_emitter:ke,_top:V};throw O}}function f(A){let R={value:ic(A),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return R._emitter.addText(A),R}function p(A,R){R=R||l.languages||Object.keys(t);let q=f(A),ie=R.filter(B).filter(Q).map(je=>d(je,A,!1));ie.unshift(q);let le=ie.sort((je,Oe)=>{if(je.relevance!==Oe.relevance)return Oe.relevance-je.relevance;if(je.language&&Oe.language){if(B(je.language).supersetOf===Oe.language)return 1;if(B(Oe.language).supersetOf===je.language)return-1}return 0}),[Ie,gt]=le,Dt=Ie;return Dt.secondBest=gt,Dt}function h(A,R,q){let ie=R&&n[R]||q;A.classList.add("hljs"),A.classList.add(`language-${ie}`)}function g(A){let R=null,q=u(A);if(a(q))return;if(Re("before:highlightElement",{el:A,language:q}),A.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",A);return}if(A.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(A)),l.throwUnescapedHTML))throw new cc("One of your code blocks includes unescaped HTML.",A.innerHTML);R=A;let ie=R.textContent,le=q?c(ie,{language:q,ignoreIllegals:!0}):p(ie);A.innerHTML=le.value,A.dataset.highlighted="yes",h(A,q,le.language),A.result={language:le.language,re:le.relevance,relevance:le.relevance},le.secondBest&&(A.secondBest={language:le.secondBest.language,relevance:le.secondBest.relevance}),Re("after:highlightElement",{el:A,result:le,text:ie})}function m(A){l=km(l,A)}let b=()=>{C(),Or("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function v(){C(),Or("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let S=!1;function C(){function A(){C()}if(document.readyState==="loading"){S||window.addEventListener("DOMContentLoaded",A,!1),S=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function M(A,R){let q=null;try{q=R(e)}catch(ie){if(Zn("Language definition for '{}' could not be registered.".replace("{}",A)),o)Zn(ie);else throw ie;q=s}q.name||(q.name=A),t[A]=q,q.rawDefinition=R.bind(null,e),q.aliases&&oe(q.aliases,{languageName:A})}function T(A){delete t[A];for(let R of Object.keys(n))n[R]===A&&delete n[R]}function E(){return Object.keys(t)}function B(A){return A=(A||"").toLowerCase(),t[A]||t[n[A]]}function oe(A,{languageName:R}){typeof A=="string"&&(A=[A]),A.forEach(q=>{n[q.toLowerCase()]=R})}function Q(A){let R=B(A);return R&&!R.disableAutodetect}function me(A){A["before:highlightBlock"]&&!A["before:highlightElement"]&&(A["before:highlightElement"]=R=>{A["before:highlightBlock"](Object.assign({block:R.el},R))}),A["after:highlightBlock"]&&!A["after:highlightElement"]&&(A["after:highlightElement"]=R=>{A["after:highlightBlock"](Object.assign({block:R.el},R))})}function it(A){me(A),r.push(A)}function Ve(A){let R=r.indexOf(A);R!==-1&&r.splice(R,1)}function Re(A,R){let q=A;r.forEach(function(ie){ie[q]&&ie[q](R)})}function Me(A){return Or("10.7.0","highlightBlock will be removed entirely in v12.0"),Or("10.7.0","Please use highlightElement now."),g(A)}Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:C,highlightElement:g,highlightBlock:Me,configure:m,initHighlighting:b,initHighlightingOnLoad:v,registerLanguage:M,unregisterLanguage:T,listLanguages:E,getLanguage:B,registerAliases:oe,autoDetection:Q,inherit:km,addPlugin:it,removePlugin:Ve}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=hS,e.regex={concat:er,lookahead:Sm,either:gs,optional:Rx,anyNumberOfTimes:Nx};for(let A in ps)typeof ps[A]=="object"&&Cm(ps[A]);return Object.assign(e,ps),e},Dr=Lm({});Dr.newInstance=()=>Lm({});Im.exports=Dr;Dr.HighlightJS=Dr;Dr.default=Dr});var fu=be(tn(),1);var du=eu("primitives",{"zh-CN":{imageFrame:"\u56FE\u7247",appearance:"\u5916\u89C2",color:"\u6587\u5B57\u989C\u8272",backgroundColor:"\u80CC\u666F\u989C\u8272",fontSize:"\u5B57\u53F7",padding:"\u5185\u8FB9\u8DDD",radius:"\u5706\u89D2",title:"\u6807\u9898",language:"\u8BED\u8A00",plainText:"\u7EAF\u6587\u672C",copy:"\u590D\u5236\u4EE3\u7801",copied:"\u5DF2\u590D\u5236",width:"\u5BBD\u5EA6",height:"\u9AD8\u5EA6",fit:"\u56FE\u7247\u9002\u914D",contain:"\u5B8C\u6574\u663E\u793A",cover:"\u88C1\u5207\u586B\u5145",addImage:"\u6DFB\u52A0\u56FE\u7247",editImage:"\u7F16\u8F91\u56FE\u7247",imageSrc:"\u56FE\u7247\u5730\u5740",imageAlt:"\u66FF\u4EE3\u6587\u5B57",imageCaption:"\u56FE\u6CE8",table:"\u57FA\u7840\u8868\u683C",scrollTable:"{title}\uFF1A\u5DE6\u53F3\u6EDA\u52A8\u67E5\u770B\u5168\u90E8\u5217",comparisonTable:"\u5BF9\u7167\u8868",columnName:"\u5217 {column} \u540D\u79F0",cell:"\u7B2C {row} \u884C\u7B2C {column} \u5217",addRow:"\u6DFB\u52A0\u884C",removeLastRow:"\u79FB\u9664\u672B\u884C",callout:"\u63D0\u793A\u6846",toggleSummary:"\u5C55\u5F00\u5185\u5BB9",code:"\u4EE3\u7801\u5757",codeContent:"\u4EE3\u7801\u5185\u5BB9"},en:{imageFrame:"Image",appearance:"Appearance",color:"Text color",backgroundColor:"Background",fontSize:"Font size",padding:"Padding",radius:"Corner radius",title:"Title",language:"Language",plainText:"Plain text",copy:"Copy code",copied:"Copied",width:"Width",height:"Height",fit:"Image fit",contain:"Contain",cover:"Cover",addImage:"Add image",editImage:"Edit image",imageSrc:"Image URL",imageAlt:"Alt text",imageCaption:"Caption",table:"Basic table",scrollTable:"{title}: scroll sideways to see all columns",comparisonTable:"Comparison table",columnName:"Column {column} name",cell:"Row {row}, column {column}",addRow:"Add row",removeLastRow:"Remove last row",callout:"Callout",toggleSummary:"Show content",code:"Code block",codeContent:"Code"}});var ye=be(Xe(),1);function pu({editor:e,position:t}){let n=Fe(du),[r,o]=(0,fu.useState)(""),i=e.state.doc.nodeAt(t);if(!i||!e.isEditable)return null;let s=i.type.name,l=(f,p)=>{e.view.dispatch(e.state.tr.setNodeAttribute(t,f,p))},a=(f,p)=>(0,ye.jsxs)("label",{children:[p,(0,ye.jsx)("input",{value:i.attrs[f]??"",onChange:h=>l(f,h.target.value)})]},f),u=["image","table","codeBlock","callout","toggle","horizontalRule"].includes(s),c=i.attrs.componentStyle??{},d=(f,p)=>{let h={...c};p===void 0?delete h[f]:h[f]=p,l("componentStyle",h)};return(0,ye.jsxs)("div",{className:"content-node-fields",children:[s==="image"&&(0,ye.jsxs)(ye.Fragment,{children:[a("src",n("imageSrc")),a("alt",n("imageAlt")),a("caption",n("imageCaption")),["width","height"].map(f=>(0,ye.jsxs)("label",{children:[n(f),(0,ye.jsx)("input",{inputMode:"decimal",value:i.attrs[f]??"",onChange:p=>{let h=p.target.value;(!h||/^\d+(?:px|%)?$/.test(h)&&parseInt(h)>0&&parseInt(h)<=1e4)&&l(f,h?/^\d+$/.test(h)?Number(h):h:null)}})]},f)),(0,ye.jsxs)("label",{children:[n("fit"),(0,ye.jsxs)("select",{value:i.attrs.fit??"contain",onChange:f=>l("fit",f.target.value),children:[(0,ye.jsx)("option",{value:"contain",children:n("contain")}),(0,ye.jsx)("option",{value:"cover",children:n("cover")})]})]})]}),["table","callout","toggle"].includes(s)&&a("title",n("title")),s==="codeBlock"&&(0,ye.jsxs)(ye.Fragment,{children:[(0,ye.jsxs)("label",{children:[n("language"),(0,ye.jsxs)("select",{value:Lo(i.attrs.language),onChange:f=>l("language",f.target.value),children:[(0,ye.jsx)("option",{value:"plaintext",children:n("plainText")}),!zs.includes(Lo(i.attrs.language))&&(0,ye.jsxs)("option",{value:Lo(i.attrs.language),children:[i.attrs.language,au(i.attrs.language)?"":` (${n("plainText")})`]}),zs.filter(f=>f!=="plaintext").map(f=>(0,ye.jsx)("option",{value:f,children:f},f))]})]}),(0,ye.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(i.textContent).then(()=>o(n("copied"))).catch(f=>o(f.message))},children:n("copy")}),r&&(0,ye.jsx)("span",{role:"status",children:r})]}),u&&(0,ye.jsxs)("details",{children:[(0,ye.jsx)("summary",{children:n("appearance")}),["color","backgroundColor"].map(f=>(0,ye.jsxs)("label",{children:[n(f),(0,ye.jsx)("input",{value:c[f]??"",onChange:p=>d(f,p.target.value||void 0)})]},f)),["fontSize","padding","radius"].map(f=>(0,ye.jsxs)("label",{children:[n(f),(0,ye.jsx)("input",{type:"number",min:f==="fontSize"?8:0,max:"200",value:c[f]??"",onChange:p=>{let h=p.target.value;(!h||Number(h)>=(f==="fontSize"?8:0)&&Number(h)<=200)&&d(f,h?Number(h):void 0)}})]},f))]})]})}function hu(e,t){let n=e.cut(0,t).toJSON().content??[],r=e.cut(t).toJSON().content??[],o=l=>l?.type==="paragraph"&&!l.content?.length||l?.type==="richText"&&!Object.keys(l.attrs?.data??{}).length&&(l.content??[]).every(o);o(n.at(-1))&&n.pop(),o(r[0])&&r.shift();let i=new Set,s=l=>{let a=l.attrs?.id;a&&(i.has(a)&&(l.attrs={...l.attrs,id:crypto.randomUUID()}),i.add(l.attrs.id)),l.content?.forEach(s)};return n.forEach(s),r.forEach(s),{before:n,after:r}}var $=be(tn(),1),yc=be(Os(),1);var ee=be(tn(),1);var ui=be(Os(),1),cp=be(xg(),1);var mu=Object.defineProperty,gu=(e,t)=>{let n={};for(var r in e)mu(n,r,{get:e[r],enumerable:!0});return t||mu(n,Symbol.toStringTag,{value:"Module"}),n};var yu=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function wu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var _s=(e,t,n)=>{let r=wu(e,n);if(!r)return!1;let o=js(r);if(!o){let s=r.blockRange(),l=s&&$t(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Tu(e,o,t,-1))return!0;if(r.parent.content.size==0&&(or(i,"end")||H.isSelectable(i)))for(let s=r.depth;;s--){let l=Ro(e.doc,r.before(s),r.after(s),ae.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(or(i,"end")?J.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):H.create(a.doc,o.pos-i.nodeSize)),t(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},ku=(e,t,n)=>{let r=wu(e,n);if(!r)return!1;let o=js(r);return o?Cu(e,o,t):!1},vu=(e,t,n)=>{let r=xu(e,n);if(!r)return!1;let o=Ks(r);return o?Cu(e,o,t):!1};function Cu(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let c=o.lastChild;if(!c)return!1;o=c}let s=t.nodeAfter,l=s,a=t.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let u=Ro(e.doc,i,a,ae.empty);if(!u||u.from!=i||u instanceof Dn&&u.slice.size>=a-i)return!1;if(n){let c=e.tr.step(u);c.setSelection(L.create(c.doc,i)),n(c.scrollIntoView())}return!0}function or(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Vs=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=js(r)}let s=i&&i.nodeBefore;return!s||!H.isSelectable(s)?!1:(t&&t(e.tr.setSelection(H.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function js(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function xu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Fs=(e,t,n)=>{let r=xu(e,n);if(!r)return!1;let o=Ks(r);if(!o)return!1;let i=o.nodeAfter;if(Tu(e,o,t,1))return!0;if(r.parent.content.size==0&&(or(i,"start")||H.isSelectable(i))){let s=Ro(e.doc,r.before(),r.after(),ae.empty);if(s&&s.slice.size<s.to-s.from){if(t){let l=e.tr.step(s);l.setSelection(or(i,"start")?J.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):H.create(l.doc,l.mapping.map(o.pos))),t(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Ws=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=Ks(r)}let s=i&&i.nodeAfter;return!s||!H.isSelectable(s)?!1:(t&&t(e.tr.setSelection(H.create(e.doc,i.pos)).scrollIntoView()),!0)};function Ks(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Su=(e,t)=>{let n=e.selection,r=n instanceof H,o;if(r){if(n.node.isTextblock||!bt(e.doc,n.from))return!1;o=n.from}else if(o=rr(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(H.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},Eu=(e,t)=>{let n=e.selection,r;if(n instanceof H){if(n.node.isTextblock||!bt(e.doc,n.to))return!1;r=n.to}else if(r=rr(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Mu=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&$t(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},Us=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
4
|
-
`).scrollIntoView()),!0)};function qs(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Gs=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=qs(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let l=n.after(),a=e.tr.replaceWith(l,l,s.createAndFill());a.setSelection(J.near(a.doc.resolve(l),1)),t(a.scrollIntoView())}return!0},Js=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof rn||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=qs(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(s,i.createAndFill());l.setSelection(L.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},Xs=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(dt(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&$t(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function Eg(e){return(t,n)=>{if(t.selection instanceof H&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!dt(t.doc,p.pos)?!1:(n&&n(t.tr.split(p.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof L||t.selection instanceof rn)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,u=!1,c=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){u=o.end(p)==o.pos+(o.depth-p),c=o.start(p)==o.pos-(o.depth-p),a=qs(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let g=e&&e(o.parent,u,o);s.unshift(g||(u&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=o.pos,f=dt(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=dt(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!u&&c&&o.node(l).type!=a){let p=r.mapping.slice(i),h=p.map(o.before(l)),g=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&r.setNodeMarkup(p.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Mg=Eg();var Au=(e,t)=>{let{$from:n,to:r}=e.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),t&&t(e.tr.setSelection(H.create(e.doc,o))),!0)},Ag=(e,t)=>(t&&t(e.tr.setSelection(new rn(e.doc))),!0);function Tg(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(i,i+1)||!(o.isTextblock||bt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Tu(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Tg(e,t,n))return!0;let u=!a&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let p=t.pos+i.nodeSize,h=z.empty;for(let b=s.length-1;b>=0;b--)h=z.from(s[b].create(null,h));h=z.from(o.copy(h));let g=e.tr.step(new Ct(t.pos-1,p,t.pos,p,new ae(h,1,0),s.length,!0)),m=g.doc.resolve(p+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&bt(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&a?null:J.findFrom(t,1),d=c&&c.$from.blockRange(c.$to),f=d&&$t(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(u&&or(i,"start",!0)&&or(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(n){let b=z.empty;for(let S=h.length-1;S>=0;S--)b=z.from(h[S].copy(b));let v=e.tr.step(new Ct(t.pos-h.length,t.pos+i.nodeSize,t.pos+m,t.pos+i.nodeSize-m,new ae(b,h.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function Nu(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(t.tr.setSelection(L.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var Ys=Nu(-1),Qs=Nu(1);function Ru(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&nr(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Zs(e,t=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,u)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)o=!0;else{let c=n.doc.resolve(u),d=c.index();o=c.parent.canReplaceWith(d,d+1,e)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,e,t)}r(i.scrollIntoView())}return!0}}function el(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}var Hs=el(yu,_s,Vs),bu=el(yu,Fs,Ws),on={Enter:el(Us,Js,Xs,Mg),"Mod-Enter":Gs,Backspace:Hs,"Mod-Backspace":Hs,"Shift-Backspace":Hs,Delete:bu,"Mod-Delete":bu,"Mod-a":Ag},Ng={"Ctrl-h":on.Backspace,"Alt-Backspace":on["Mod-Backspace"],"Ctrl-d":on.Delete,"Ctrl-Alt-Backspace":on["Mod-Delete"],"Alt-Delete":on["Mod-Delete"],"Alt-d":on["Mod-Delete"],"Ctrl-a":Ys,"Ctrl-e":Qs};for(let e in on)Ng[e]=on[e];var m1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Ou(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Rg(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Rg(e,t,n,r=null){let o=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let a=s.resolve(t.start-2);i=new Ao(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new Ao(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=nr(i,n,r,t);return l?(e&&Og(e,t,l,o,n),!0):!1}function Og(e,t,n,r,o){let i=z.empty;for(let c=n.length-1;c>=0;c--)i=z.from(n[c].type.create(n[c].attrs,i));e.step(new Ct(t.start-(r?2:0),t.end,t.start,t.end,new ae(i,0,0),n.length,!0));let s=0;for(let c=0;c<n.length;c++)n[c].type==o&&(s=c+1);let l=n.length-s,a=t.start+n.length-(r?2:0),u=t.parent;for(let c=t.startIndex,d=t.endIndex,f=!0;c<d;c++,f=!1)!f&&dt(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=u.child(c).nodeSize;return e}function Du(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==e);return i?n?r.node(i.depth-1).type==e?Dg(t,n,e,i):Lg(t,n,i):!0:!1}}function Dg(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Ct(i-1,s,i,s,new ae(z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ao(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=$t(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return bt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}function Lg(e,t,n){let r=e.tr,o=n.parent;for(let p=n.end,h=n.endIndex-1,g=n.startIndex;h>g;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,u=i.node(-1),c=i.index(-1);if(!u.canReplace(c+(l?0:1),c+1,s.content.append(a?z.empty:z.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new Ct(d-(l?1:0),f+(a?1:0),d+1,f-1,new ae((l?z.empty:z.from(o.copy(z.empty))).append(a?z.empty:z.from(o.copy(z.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function Lu(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,u=>u.childCount>0&&u.firstChild.type==e);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=e)return!1;if(n){let u=a.lastChild&&a.lastChild.type==l.type,c=z.from(u?e.create():null),d=new ae(z.from(e.create(null,z.from(l.type.create(null,c)))),u?3:1,0),f=i.start,p=i.end;n(t.tr.step(new Ct(f-(u?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var Be=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ar=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},il=null,zt=function(e,t,n){let r=il||(il=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ig=function(){il=null},_n=function(e,t,n,r){return n&&(Iu(e,t,n,r,-1)||Iu(e,t,n,r,1))},Pg=/^(img|br|input|textarea|hr)$/i;function Iu(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ke(e))){let s=e.parentNode;if(!s||!j(s)||Ur(e)||Pg.test(e.nodeName)||e.contentEditable=="false")return!1;t=Be(e)+(o<0?0:1),e=s}else if(j(e)){let s=e.childNodes[t+(o<0?-1:0)];if(j(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=o;else return!1;else e=s,t=o<0?Ke(e):0}else return!1}}function Ke(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function j(e){return e.nodeType==1}function De(e){return e.nodeType==3}function Vn(e,t){return t?e.contains(j(t)?t:t.parentNode):!1}function $g(e,t){for(;;){if(De(e)&&t)return e;if(j(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Ke(e)}else if(e.parentNode&&!Ur(e))t=Be(e),e=e.parentNode;else return null}}function Bg(e,t){for(;;){if(De(e)&&t<e.nodeValue.length)return e;if(j(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Ur(e))t=Be(e)+1,e=e.parentNode;else return null}}function zg(e,t,n){for(let r=t==0,o=t==Ke(e);r||o;){if(e==n)return!0;let i=Be(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==Ke(e)}}function Ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Wo=function(e){return e.focusNode&&_n(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ln(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Hg(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function _g(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}var xt=typeof navigator<"u"?navigator:null,Pu=typeof document<"u"?document:null,un=xt&&xt.userAgent||"",sl=/Edge\/(\d+)/.exec(un),ud=/MSIE \d/.exec(un),ll=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(un),nt=!!(ud||ll||sl),an=ud?document.documentMode:ll?+ll[1]:sl?+sl[1]:0,st=!nt&&/gecko\/(\d+)/i.test(un);st&&+(/Firefox\/(\d+)/.exec(un)||[0,0])[1];var al=!nt&&/Chrome\/(\d+)/.exec(un),ze=!!al,dd=al?+al[1]:0,Ue=!nt&&!!xt&&/Apple Computer/.test(xt.vendor),cr=Ue&&(/Mobile\/\w+/.test(un)||!!xt&&xt.maxTouchPoints>2),ft=cr||(xt?/Mac/.test(xt.platform):!1),fd=xt?/Win/.test(xt.platform):!1,Ht=/Android \d/.test(un),Ko=!!Pu&&"webkitFontSmoothing"in Pu.documentElement.style,Vg=Ko?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jg(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Bt(e,t){return typeof e=="number"?e:e[t]}function Fg(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function $u(e,t,n){if(!cl(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!j(s)){s=ar(s);continue}let l=s==i.body,a=l?jg(i):Fg(s),u=0,c=0;if(t.top<a.top+Bt(r,"top")?c=-(a.top-t.top+Bt(o,"top")):t.bottom>a.bottom-Bt(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+Bt(o,"top")-a.top:t.bottom-a.bottom+Bt(o,"bottom")),t.left<a.left+Bt(r,"left")?u=-(a.left-t.left+Bt(o,"left")):t.right>a.right-Bt(r,"right")&&(u=t.right-a.right+Bt(o,"right")),u||c)if(l)i.defaultView.scrollBy(u,c);else{let f=s.scrollLeft,p=s.scrollTop;c&&(s.scrollTop+=c),u&&(s.scrollLeft+=u);let h=s.scrollLeft-f,g=s.scrollTop-p;t={left:t.left-h,top:t.top-g,right:t.right-h,bottom:t.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:ar(s)}}function Wg(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,o;for(let i=(t.left+t.right)/2,s=n+1;s<Math.min(innerHeight,t.bottom);s+=5){let l=e.root.elementFromPoint(i,s);if(!l||l==e.dom||!e.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:pd(e.dom)}}function pd(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=ar(r));return t}function Kg({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;hd(n,r==0?0:r-t)}function hd(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}var ir=null;function Ug(e){if(e.setActive)return e.setActive();if(ir)return e.focus(ir);let t=pd(e);e.focus(ir==null?{get preventScroll(){return ir={preventScroll:!0},!0}}:void 0),ir||(ir=!1,hd(t,0))}function md(e,t){let n,r=2e8,o,i=0,s=t.top,l=t.top,a,u;for(let c=e.firstChild,d=0;c;c=c.nextSibling,d++){let f;if(j(c))f=c.getClientRects();else if(De(c))f=zt(c).getClientRects();else continue;for(let p=0;p<f.length;p++){let h=f[p];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(g<r){n=c,r=g,o=g&&De(n)?{left:h.right<t.left?h.right:h.left,top:t.top}:t,j(c)&&g&&(i=d+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!a&&h.left<=t.left&&h.right>=t.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&De(n)?qg(n,o):!n||r?{node:e,offset:i}:md(n,o)}function qg(e,t){let n=e.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let s=sn(r,1);if(s.top!=s.bottom&&El(t,s)){o={node:e,offset:i+(t.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:e,offset:0}}function El(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Gg(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Jg(e,t,n){let{node:r,offset:o}=md(t,n),i=-1;if(j(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}function Xg(e,t,n,r){let o=-1;for(let i=t,s=!1;i!=e.dom;){let l=e.docView.nearestDesc(i,!0),a;if(!l)return null;if(j(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?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<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;i=l.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}function gd(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=e.childNodes[i];if(j(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let u=l[a];if(El(t,u))return gd(s,t,u)}}if((i=(i+1)%r)==o)break}return e}function Yg(e,t){let n=e.dom.ownerDocument,r,o=0,i=_g(n,t.left,t.top);i&&({node:r,offset:o}=i);let s=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!s||!e.dom.contains(s)){let u=e.dom.getBoundingClientRect();if(!El(t,u)||(s=gd(e.dom,t,u),!s))return null}if(Ue)for(let u=s;r&&u;u=ar(u))u.draggable&&(r=void 0);if(s=Gg(s,t),r){if(st&&j(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let c=r.childNodes[o],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&o++}let u;Ko&&o&&j(r)&&j(u=r.childNodes[o-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=t.top&&o--,r==e.dom&&o==r.childNodes.length-1&&j(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(o==0||!j(r)||r.childNodes[o-1].nodeName!="BR")&&(l=Xg(e,r,o,t))}l==null&&(l=Jg(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function cl(e){return e.top<e.bottom||e.left<e.right}function sn(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(cl(r))return r}return Array.prototype.find.call(n,cl)||e.getBoundingClientRect()}var Qg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function bd(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=Ko||st;if(De(r))if(s&&(Qg.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=sn(zt(r,o,o),n);if(st&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let u=sn(zt(r,o-1,o-1),-1);if(u.top==a.top){let c=sn(zt(r,o,o+1),-1);if(c.top!=a.top)return zr(c,c.left<u.left)}}return a}else{let a=o,u=o,c=n<0?1:-1;return n<0&&!o?(u++,c=-1):n>=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,zr(sn(zt(r,a,u),c),c<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Ke(r))){let a=r.childNodes[o-1];if(j(a))return tl(a.getBoundingClientRect(),!1)}if(i==null&&o<Ke(r)){let a=r.childNodes[o];if(j(a))return tl(a.getBoundingClientRect(),!0)}return tl(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Ke(r))){let a=r.childNodes[o-1],u=De(a)?zt(a,Ke(a)-(s?0:1)):j(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return zr(sn(u,1),!1)}if(i==null&&o<Ke(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?De(a)?zt(a,0,s?0:1):j(a)?a:null:null;if(u)return zr(sn(u,-1),!0)}return zr(sn(De(r)?zt(r):r,-n),n>=0)}function zr(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function tl(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function yd(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}function Zg(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return yd(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=bd(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(j(l))a=l.getClientRects();else if(De(l))a=zt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}var eb=/[\u0590-\u08ac]/;function tb(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?!eb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:yd(e,t,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=e.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:g}=e.domSelectionRange(),m=h&&!Vn(p,h)||a==h&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return f!=null&&(l.caretBidiLevel=f),m}):r.pos==r.start()||r.pos==r.end()}var Bu=null,zu=null,Hu=!1;function nb(e,t,n){return Bu==t&&zu==n?Hu:(Bu=t,zu=n,Hu=n=="up"||n=="down"?Zg(e,t,n):tb(e,t,n))}var pt=0,_u=1,In=2,yt=3,jn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=pt,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==t)return r;r+=o.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(t,n,r){if(this.contentDOM&&Vn(this.contentDOM,t))if(r<0){let i,s;if(t==this.contentDOM)i=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM)i=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=n>Be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(t.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(j(s)?Vn(s,t):s==t))r=!1;else return i}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==t&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(t<i)return o.descAt(t-r-o.border);r=i}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>t){o=t-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof $o||i instanceof Io&&i.side>=0))break}if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Be(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Be(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],u=s+a.size;if(o==-1&&t<=u){let c=s+a.border;if(t>=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,n,c);t=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=Be(f.dom)+1;break}t-=f.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;c<this.children.length;c++){let d=this.children[c];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Be(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=u}return{node:this.contentDOM,from:t,to:n,fromOffset:o,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(!j(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,o=!1){let i=Math.min(t,n),s=Math.max(t,n);for(let p=0,h=0;p<this.children.length;p++){let g=this.children[p],m=h+g.size;if(i>h&&s<m)return g.setSelection(t-h-g.border,n-h-g.border,r,o);h=m}let l=this.domFromPos(t,t?-1:1),a=n==t?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),c=r.domSelectionRange(),d=!1;if((st||Ue)&&t==n){let{node:p,offset:h}=l;if(De(p)){if(d=!!(h&&p.nodeValue[h-1]==`
|
|
5
|
-
`),d&&h==p.nodeValue.length)for(let g=p,m;g;g=g.parentNode){if(m=g.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:Be(m)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=p.childNodes[h-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(st&&c.focusNode&&c.focusNode!=a.node&&j(c.focusNode)){let p=c.focusNode.childNodes[c.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||d&&Ue)&&_n(l.node,l.offset,c.anchorNode,c.anchorOffset)&&_n(a.node,a.offset,c.focusNode,c.focusOffset))return;let f=!1;if((u.extend||t==n)&&!(d&&st)){u.collapse(l.node,l.offset);try{t!=n&&u.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(t>n){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?t<=s&&n>=r:t<s&&n>r){let l=r+i.border,a=s-i.border;if(t>=l&&n<=a){this.dirty=t==r||n==s?In:_u,t==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=yt:i.markDirty(t-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?In:yt}r=s}this.dirty=In}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?In:_u;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},Io=class extends jn{constructor(t,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=j(s)?s:document.createElement("span");l!=s&&l.appendChild(s),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(t){return this.dirty==pt&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.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}},ul=class extends jn{constructor(t,n,r,o){super(t,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},$n=class e extends jn{constructor(t,n,r,o,i){super(t,[],r,o),this.mark=n,this.spec=i}static create(t,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=On.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&yt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=yt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=pt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=pt}}slice(t,n,r){let o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=hl(i,n,s,r)),t>0&&(i=hl(i,0,t,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},cn=class e extends jn{constructor(t,n,r,o,i,s,l){super(t,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(t,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,u=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(!De(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=On.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let f=c;return c=vd(c,r,n),u?a=new dl(t,n,r,o,c,d||null,f,u):n.isText?new Po(t,n,r,o,c,f):new e(t,n,r,o,c,d||null,f)}parseRule(t){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 o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=t&&t.find(o=>j(o)&&t.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>z.empty}}return n}matchesNode(t,n,r){return this.dirty==pt&&t.eq(this.node)&&Bo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,o=n,i=t.composing?this.localCompositionInfo(t,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new pl(this,s&&s.node,t),u=this.node.inlineContent,c=u&&this.node.isBlock;sb(this.node,this.innerDeco,(d,f,p)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,t,f):d.type.side>=0&&!p&&a.syncToMarks(f==this.node.childCount?tu.none:this.node.child(f).marks,r,t,f),a.placeWidget(d,t,o)},(d,f,p,h)=>{a.syncToMarks(d.marks,r,t,h),c&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(d,f,p,h)||l&&t.state.selection.from>o&&t.state.selection.to<o+d.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,p,g,t)||a.updateNextNode(d,f,p,t,h,o)||a.addNode(d,f,p,t,o),o+=d.nodeSize,u&&(c=d.isAtom&&!d.isText)}),a.syncToMarks([],r,t,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==In)&&(s&&this.protectLocalComposition(t,s),wd(this.contentDOM,this.children,t),cr&&lb(this.dom))}localCompositionInfo(t,n){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof L)||r<n||o>n+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=ab(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new ul(this,i,n,o);t.input.compositionNodes.push(s),this.children=hl(this.children,r,r+o.length,t,s)}update(t,n,r,o){return this.dirty==yt||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,o),!0)}updateInner(t,n,r,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=pt}updateOuterDeco(t){if(Bo(t,this.outerDeco))return;let n=!j(this.nodeDOM),r=this.dom;this.dom=kd(this.dom,this.nodeDOM,fl(this.outerDeco,this.node,n),fl(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){j(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){j(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 Vu(e,t,n,r,o){vd(r,t,e);let i=new cn(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Po=class e extends cn{constructor(t,n,r,o,i,s){super(t,n,r,o,i,null,s)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,o){return this.dirty==yt||this.dirty!=pt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=pt||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=pt,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=yt)}get domAtom(){return!1}isText(t){return this.node.text==t}},$o=class extends jn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==pt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},dl=class extends cn{constructor(t,n,r,o,i,s,l,a){super(t,n,r,o,i,s,l),this.spec=a}update(t,n,r,o){if(this.dirty==yt)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r.root):super.setSelection(t,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function wd(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=ju(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof $n){let a=r?r.previousSibling:e.lastChild;wd(s.contentDOM,s.children,n),r=a?a.nextSibling:e.firstChild}}for(;r;)r=ju(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var _r=function(e){e&&(this.nodeName=e)};_r.prototype=Object.create(null);var Pn=[new _r];function fl(e,t,n){if(e.length==0)return Pn;let r=n?Pn[0]:new _r,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new _r(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new _r(t.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 o}function kd(e,t,n,r){if(n==Pn&&r==Pn)return t;let o=t;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=e&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Pn[0]),o=a}rb(o,l||Pn[0],s)}return o}function rb(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&e.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&e.classList.add(o[i]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(t.style);)e.style.removeProperty(o[1])}n.style&&(e.style.cssText+=n.style)}}function vd(e,t,n){return kd(e,e,Pn,fl(t,n,!j(e)))}function Bo(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ju(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var pl=class{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=ob(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let r=t;r<n;r++)this.top.children[r].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,t.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=pt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let a=-1,u=this.top.children.length;o<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let c=this.index;c<u;c++){let d=this.top.children[c];if(d.matchesMark(t[s])&&!this.isLocked(d.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof $n&&c.dirty!=yt&&c.mark.type==t[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(t[s])&&(c.mark=t[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 c=$n.create(this.top,t[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(t,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,n,r))i=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 u=this.top.children[l];if(u.matchesNode(t,n,r)&&!this.preMatch.matched.has(u)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,n,r,o,i){let s=this.top.children[o];return s.dirty==yt&&s.dom==s.contentDOM&&(s.dirty=In),s.update(t,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}t=n}}updateNextNode(t,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof cn){let u=this.preMatch.matched.get(a);if(u!=null&&u!=i)return!1;let c=a.dom,d,f=this.isLocked(c)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&a.dirty!=yt&&Bo(n,a.outerDeco));if(!f&&a.update(t,n,r,o))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,t,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=In,d.updateChildren(o,s+1),d.dirty=pt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,r,o,i,s){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!Bo(r,t.outerDeco)||!o.eq(t.innerDeco))return null;let l=cn.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=t.children,t.children=[];for(let a of l.children)a.parent=l}return t.destroy(),l}addNode(t,n,r,o,i){let s=cn.create(this.top,t,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Io(this.top,t,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof $n;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof Po)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ue||ze)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new $o(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||j(t)&&t.contains(this.lock.parentNode))}};function ob(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof $n)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function ib(e,t){return e.type.side-t.type.side}function sb(e,t,n,r){let o=t.locals(e),i=0;if(o.length==0){for(let u=0;u<e.childCount;u++){let c=e.child(u);r(c,o,t.forChild(i,c),u),i+=c.nodeSize}return}let s=0,l=[],a=null;for(let u=0;;){let c,d;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(c?(d||(d=[c])).push(m):c=m)}if(c)if(d){d.sort(ib);for(let m=0;m<d.length;m++)n(d[m],u,!!a)}else n(c,u,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(u<e.childCount)p=u,f=e.child(u++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+f.nodeSize;if(f.isText){let m=h;s<o.length&&o[s].from<m&&(m=o[s].from);for(let b=0;b<l.length;b++)l[b].to<m&&(m=l[b].to);m<h&&(a=f.cut(m-i),f=f.cut(0,m-i),h=m,p=-1)}else for(;s<o.length&&o[s].to<h;)s++;let g=f.isInline&&!f.isLeaf?l.filter(m=>!m.inline):l.slice();r(f,g,t.forChild(i,f),p),i=h}}function lb(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function ab(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let u=e.child(o++);if(i+=u.nodeSize,!u.isText)break;a+=u.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let u=l<r?a.lastIndexOf(t,r-l-1):-1;if(u>=0&&u+t.length+l>=n)return l+u;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}function hl(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],u=l,c=l+=a.size;u>=n||c<=t?i.push(a):(u<t&&i.push(a.slice(0,t-u,r)),o&&(i.push(o),o=void 0),c>n&&i.push(a.slice(n-u,a.size,r)))}return i}function Ml(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Wo(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&H.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&zg(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new H(s==d?l:r.resolve(d))}else if(st&&t=="key"&&s>e.state.selection.to&&j(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){u=J.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!j(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let p=0;p<n.rangeCount;p++){let h=n.getRangeAt(p);d=Math.min(d,e.docView.posFromDOM(h.startContainer,h.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=f==e.state.selection.anchor?[f,d]:[d,f],l=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!u){let d=t=="pointer"||e.state.selection.head<l.pos&&!i?1:-1;u=Al(e,c,l,d)}return u}function Cd(e){return e.editable?e.hasFocus():Sd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Vt(e,t=!1){let n=e.state.selection;if(xd(e,n),!Cd(e))return;let r=e.input.mouseDown;if(!t&&ze&&r){let o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&_n(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)ub(e);else{let{anchor:o,head:i}=n,s,l;Fu&&!(n instanceof L)&&(n.$from.parent.inlineContent||(s=Wu(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Wu(e,n.to))),e.docView.setSelection(o,i,e,t),Fu&&(s&&Ku(s),l&&Ku(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&cb(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var Fu=Ue||ze&&dd<63;function Wu(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Ue&&o&&o.contentEditable=="false")return nl(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return nl(o);if(i)return nl(i)}}function nl(e){return e.contentEditable="true",Ue&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ku(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function cb(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Cd(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function ub(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Be(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&nt&&an<=11&&(n.disabled=!0,n.disabled=!1)}function xd(e,t){if(t instanceof H){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Uu(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Uu(e)}function Uu(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Al(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||L.between(t,n,r)}function qu(e){return e.editable&&!e.hasFocus()?!1:Sd(e)}function Sd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Vn(e.dom,t.anchorNode)&&(e.editable||Vn(e.dom,t.focusNode))}catch{return!1}}function db(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return _n(t.node,t.offset,n.anchorNode,n.anchorOffset)}function ml(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&J.findFrom(i,t)}function ln(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Gu(e,t,n){let r=e.state.selection;if(r instanceof L)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return ln(e,new L(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=ml(e.state,t);return o&&o instanceof H?ln(e,o):!1}else if(!(ft&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(l))&&!s.contentDOM?H.isSelectable(i)?ln(e,new H(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):ln(e,new L(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof H&&r.node.isInline)return ln(e,new L(t>0?r.$to:r.$from));{let o=ml(e.state,t);return o?ln(e,o):!1}}}function Vr(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):j(e)&&e.contentEditable=="false"}function sr(e,t){return t<0?fb(e):pb(e)}function fb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(st&&j(n)&&r<Ke(n)&&Vr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!j(n))break;let l=n.childNodes[r-1];if(Vr(l,-1))o=n,i=--r;else if(De(l))n=l,r=n.nodeValue.length;else break}else{if(Ed(n))break;{let l=n.previousSibling;for(;l&&Vr(l,-1);)o=n.parentNode,i=Be(l),l=l.previousSibling;if(l)n=l,r=Ke(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?gl(e,n,r):o&&gl(e,o,i)}function pb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=Ke(n),i,s;for(;;)if(r<o){if(!j(n))break;let l=n.childNodes[r];if(Vr(l,1))i=n,s=++r;else break}else{if(Ed(n))break;{let l=n.nextSibling;for(;l&&Vr(l,1);)i=l.parentNode,s=Be(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=Ke(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&gl(e,i,s)}function Ed(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function hb(e,t){for(;e&&t==e.childNodes.length&&!Ur(e);)t=Be(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(De(n))return n;if(j(n)&&n.contentEditable=="false")break;e=n,t=0}}function mb(e,t){for(;e&&!t&&!Ur(e);)t=Be(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(De(n))return n;if(j(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function gl(e,t,n){if(!De(t)){let i,s;(s=hb(t,n))?(t=s,n=0):(i=mb(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Wo(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Vt(e)},50)}function Ju(e,t){let n=e.state.doc.resolve(t);if(!(ze||fd)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Xu(e,t,n){let r=e.state.selection;if(r instanceof L&&!r.empty||n.indexOf("s")>-1||ft&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=ml(e.state,t);if(s&&s instanceof H)return ln(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,l=r instanceof rn?J.near(s,t):J.findFrom(s,t);return l?ln(e,l):!1}return!1}function Yu(e,t){if(!(e.state.selection instanceof L))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),e.dispatch(s),!0}return!1}function Qu(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function gb(e){if(!Ue||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&j(t)&&n==0&&t.firstChild&&j(t.firstChild)&&t.firstChild.contentEditable=="false"){let r=t.firstChild;Qu(e,r,"true"),setTimeout(()=>Qu(e,r,"false"),20)}return!1}function bb(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function yb(e,t){let n=t.keyCode,r=bb(t);if(n==8||ft&&n==72&&r=="c")return Yu(e,-1)||sr(e,-1);if(n==46&&!t.shiftKey||ft&&n==68&&r=="c")return Yu(e,1)||sr(e,1);if(n==13||n==27)return!0;if(n==37||ft&&n==66&&r=="c"){let o=n==37?Ju(e,e.state.selection.from)=="ltr"?-1:1:-1;return Gu(e,o,r)||sr(e,o)}else if(n==39||ft&&n==70&&r=="c"){let o=n==39?Ju(e,e.state.selection.from)=="ltr"?1:-1:1;return Gu(e,o,r)||sr(e,o)}else{if(n==38||ft&&n==80&&r=="c")return Xu(e,-1,r)||sr(e,-1);if(n==40||ft&&n==78&&r=="c")return gb(e)||Xu(e,1,r)||sr(e,1);if(r==(ft?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Tl(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=e.someProp("clipboardSerializer")||On.fromSchema(e.state.schema),l=Od(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&j(u)&&(c=Rd[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}u=a.firstChild}u&&j(u)&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
1
|
+
import{A as tu,C as au,D as $e,E as Lo,F as cu,G as fu,H as pu,k as Ls,m as Is,s as Zc,w as rn,x as Ps,y as eu}from"./chunk-VKJZ5EGG.js";import{A as K,B as ne,C as iu,E as su,I as zs,b as z,c as ru,d as ce,e as To,f as $s,g as On,h as Dn,i as No,j as ou,k as Ln,l as Ct,m as $t,n as ir,o as dt,p as bt,q as sr,r as Ro,s as Oo,t as Do,u as X,v as Bs,w as L,x as _,y as on,z as Br}from"./chunk-NLCSXEUT.js";import"./chunk-SNEZ3O5V.js";import{a as Hs,b as Io,c as uu,e as du}from"./chunk-7G6RMB6W.js";import{a as Tg,b as Ng}from"./chunk-GMWEGDGS.js";import{a as lu}from"./chunk-5AW2WUSZ.js";import{a as hu}from"./chunk-7OXIV2BW.js";import{$ as Pc,$a as Jc,A as Pr,B as xo,Ba as nn,Ea as Ms,Fa as Fc,G as Tc,H as Nc,J as Rc,M as Oc,Ma as As,Na as Ts,O as Dc,Oa as Wc,P as Lc,Ra as Kc,Ta as Ns,Ua as Uc,Va as Rs,Wa as qc,Xa as Gc,Ya as Os,Z as Ic,Za as Tn,_a as Nn,a as Cc,aa as $c,ab as Rn,ba as Bc,bb as Mo,c as tn,ca as zc,cb as Ao,da as So,db as Xc,eb as Yc,fa as Hc,gb as Qc,ja as Eo,jb as $r,ka as Ss,kb as Xe,lb as Ds,m as xc,ma as Es,nb as Be,o as Sc,q as Ec,r as xs,ra as _c,s as Mc,sa as Vc,xa as jc,z as Ac}from"./chunk-JTQMPH6V.js";import{a as nu,f as or}from"./chunk-J6IRWTF7.js";import{a as Ag,c as ye}from"./chunk-DCANE7XH.js";var Hm=Ag((OT,zm)=>{function Mm(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&Mm(n)}),e}var ms=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function Am(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function yn(e,...t){let n=Object.create(null);for(let r in e)n[r]=e[r];return t.forEach(function(r){for(let o in r)n[o]=r[o]}),n}var Dx="</span>",km=e=>!!e.scope,Lx=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((r,o)=>`${r}${"_".repeat(o+1)}`)].join(" ")}return`${t}${e}`},sc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=Am(t)}openNode(t){if(!km(t))return;let n=Lx(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){km(t)&&(this.buffer+=Dx)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},vm=(e={})=>{let t={children:[]};return Object.assign(t,e),t},lc=class e{constructor(){this.rootNode=vm(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){let n=vm({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(r=>this._walk(t,r)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{e._collapse(n)}))}},ac=class extends lc{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){let r=t.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new sc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function wo(e){return e?typeof e=="string"?e:e.source:null}function Tm(e){return rr("(?=",e,")")}function Ix(e){return rr("(?:",e,")*")}function Px(e){return rr("(?:",e,")?")}function rr(...e){return e.map(n=>wo(n)).join("")}function $x(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function bs(...e){return"("+($x(e).capture?"":"?:")+e.map(r=>wo(r)).join("|")+")"}function Nm(e){return new RegExp(e.toString()+"|").exec("").length-1}function Bx(e,t){let n=e&&e.exec(t);return n&&n.index===0}var zx=new RegExp(bs(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function uc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=wo(r),s="";for(;i.length>0;){let l=zx.exec(i);if(!l){s+=i;break}s+=i.substring(0,l.index),i=i.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?s+="\\"+String(Number(l[1])+o):(s+=l[0],(l[0]==="("||/^\(\?[<']/.test(l[0]))&&n++)}return s}).map(r=>`(${r})`).join(t)}var Hx=/\b\B/,Rm="[a-zA-Z]\\w*",dc="[a-zA-Z_]\\w*",Om="\\b\\d+(\\.\\d+)?",Dm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Lm="\\b(0b[01]+)",_x="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Vx=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=rr(t,/.*\b/,e.binary,/\b.*/)),yn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},ko={begin:"\\\\[\\s\\S]",relevance:0},jx={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ko]},Fx={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ko]},Wx={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},ys=function(e,t,n={}){let r=yn({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let o=bs("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:rr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},Kx=ys("//","$"),Ux=ys("/\\*","\\*/"),qx=ys("#","$"),Gx={scope:"number",begin:Om,relevance:0},Jx={scope:"number",begin:Dm,relevance:0},Xx={scope:"number",begin:Lm,relevance:0},Yx={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ko,{begin:/\[/,end:/\]/,relevance:0,contains:[ko]}]},Qx={scope:"title",begin:Rm,relevance:0},Zx={scope:"title",begin:dc,relevance:0},eS={begin:"\\.\\s*"+dc,relevance:0},tS=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})},hs=Object.freeze({__proto__:null,APOS_STRING_MODE:jx,BACKSLASH_ESCAPE:ko,BINARY_NUMBER_MODE:Xx,BINARY_NUMBER_RE:Lm,COMMENT:ys,C_BLOCK_COMMENT_MODE:Ux,C_LINE_COMMENT_MODE:Kx,C_NUMBER_MODE:Jx,C_NUMBER_RE:Dm,END_SAME_AS_BEGIN:tS,HASH_COMMENT_MODE:qx,IDENT_RE:Rm,MATCH_NOTHING_RE:Hx,METHOD_GUARD:eS,NUMBER_MODE:Gx,NUMBER_RE:Om,PHRASAL_WORDS_MODE:Wx,QUOTE_STRING_MODE:Fx,REGEXP_MODE:Yx,RE_STARTERS_RE:_x,SHEBANG:Vx,TITLE_MODE:Qx,UNDERSCORE_IDENT_RE:dc,UNDERSCORE_TITLE_MODE:Zx});function nS(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function rS(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function oS(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=nS,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function iS(e,t){Array.isArray(e.illegal)&&(e.illegal=bs(...e.illegal))}function sS(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function lS(e,t){e.relevance===void 0&&(e.relevance=1)}var aS=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(r=>{delete e[r]}),e.keywords=n.keywords,e.begin=rr(n.beforeMatch,Tm(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},cS=["of","and","for","in","not","or","if","then","parent","list","value"],uS="keyword";function Im(e,t,n=uS){let r=Object.create(null);return typeof e=="string"?o(n,e.split(" ")):Array.isArray(e)?o(n,e):Object.keys(e).forEach(function(i){Object.assign(r,Im(e[i],t,i))}),r;function o(i,s){t&&(s=s.map(l=>l.toLowerCase())),s.forEach(function(l){let a=l.split("|");r[a[0]]=[i,dS(a[0],a[1])]})}}function dS(e,t){return t?Number(t):fS(e)?0:1}function fS(e){return cS.includes(e.toLowerCase())}var Cm={},nr=e=>{console.error(e)},xm=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Dr=(e,t)=>{Cm[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Cm[`${e}/${t}`]=!0)},gs=new Error;function Pm(e,t,{key:n}){let r=0,o=e[n],i={},s={};for(let l=1;l<=t.length;l++)s[l+r]=o[l],i[l+r]=!0,r+=Nm(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function pS(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw nr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),gs;if(typeof e.beginScope!="object"||e.beginScope===null)throw nr("beginScope must be object"),gs;Pm(e,e.begin,{key:"beginScope"}),e.begin=uc(e.begin,{joinWith:""})}}function hS(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw nr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),gs;if(typeof e.endScope!="object"||e.endScope===null)throw nr("endScope must be object"),gs;Pm(e,e.end,{key:"endScope"}),e.end=uc(e.end,{joinWith:""})}}function mS(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function gS(e){mS(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),pS(e),hS(e)}function bS(e){function t(s,l){return new RegExp(wo(s),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(l?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,l]),this.matchAt+=Nm(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(uc(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;let a=this.matcherRe.exec(l);if(!a)return null;let u=a.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return a.splice(0,u),Object.assign(a,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];let a=new n;return this.rules.slice(l).forEach(([u,c])=>a.addRule(u,c)),a.compile(),this.multiRegexes[l]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,a){this.rules.push([l,a]),a.type==="begin"&&this.count++}exec(l){let a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let u=a.exec(l);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){let c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(l)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function o(s){let l=new r;return s.contains.forEach(a=>l.addRule(a.begin,{rule:a,type:"begin"})),s.terminatorEnd&&l.addRule(s.terminatorEnd,{type:"end"}),s.illegal&&l.addRule(s.illegal,{type:"illegal"}),l}function i(s,l){let a=s;if(s.isCompiled)return a;[rS,sS,gS,aS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[oS,iS,lS].forEach(c=>c(s,l)),s.isCompiled=!0;let u=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),u=s.keywords.$pattern,delete s.keywords.$pattern),u=u||/\w+/,s.keywords&&(s.keywords=Im(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(u,!0),l&&(s.begin||(s.begin=/\B|\b/),a.beginRe=t(a.begin),!s.end&&!s.endsWithParent&&(s.end=/\B|\b/),s.end&&(a.endRe=t(a.end)),a.terminatorEnd=wo(a.end)||"",s.endsWithParent&&l.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+l.terminatorEnd)),s.illegal&&(a.illegalRe=t(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map(function(c){return yS(c==="self"?s:c)})),s.contains.forEach(function(c){i(c,a)}),s.starts&&i(s.starts,l),a.matcher=o(a),a}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=yn(e.classNameAliases||{}),i(e)}function $m(e){return e?e.endsWithParent||$m(e.starts):!1}function yS(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return yn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:$m(e)?yn(e,{starts:e.starts?yn(e.starts):null}):Object.isFrozen(e)?yn(e):e}var wS="11.12.0",cc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},ic=Am,Sm=yn,Em=Symbol("nomatch"),kS=7,Bm=function(e){let t=Object.create(null),n=Object.create(null),r=[],o=!0,i="Could not find the language '{}', did you forget to load/include a language module?",s={disableAutodetect:!0,name:"Plain text",contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ac};function a(T){return l.noHighlightRe.test(T)}function u(T){let R=T.className+" ";R+=T.parentNode?T.parentNode.className:"";let q=l.languageDetectRe.exec(R);if(q){let se=B(q[1]);return se||(xm(i.replace("{}",q[1])),xm("Falling back to no-highlight mode for this block.",T)),se?q[1]:"no-highlight"}return R.split(/\s+/).find(se=>a(se)||B(se))}function c(T,R,q){let se="",ae="";typeof R=="object"?(se=T,q=R.ignoreIllegals,ae=R.language):(Dr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Dr("10.7.0",`Please use highlight(code, options) instead.
|
|
2
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),ae=T,se=R),q===void 0&&(q=!0);let Ie={code:se,language:ae};Re("before:highlight",Ie);let gt=Ie.result?Ie.result:d(Ie.language,Ie.code,q);return gt.code=Ie.code,Re("after:highlight",gt),gt}function d(T,R,q,se){let ae=Object.create(null);function Ie(O,I){return O.keywords[I]}function gt(){if(!F.keywords){ve.addText(be);return}let O=0;F.keywordPatternRe.lastIndex=0;let I=F.keywordPatternRe.exec(be),G="";for(;I;){G+=be.substring(O,I.index);let te=Je.case_insensitive?I[0].toLowerCase():I[0],Ae=Ie(F,te);if(Ae){let[ut,Cs]=Ae;if(ve.addText(G),G="",ae[te]=(ae[te]||0)+1,ae[te]<=kS&&(vt+=Cs),ut.startsWith("_"))G+=I[0];else{let Co=Je.classNameAliases[ut]||ut;Oe(I[0],Co)}}else G+=I[0];O=F.keywordPatternRe.lastIndex,I=F.keywordPatternRe.exec(be)}G+=be.substring(O),ve.addText(G)}function Dt(){if(be==="")return;let O=null;if(typeof F.subLanguage=="string"){if(!t[F.subLanguage]){ve.addText(be);return}O=d(F.subLanguage,be,!0,It[F.subLanguage]),It[F.subLanguage]=O._top}else O=p(be,F.subLanguage.length?F.subLanguage:null);F.relevance>0&&(vt+=O.relevance),ve.__addSublanguage(O._emitter,O.language)}function Fe(){F.subLanguage!=null?Dt():gt(),be=""}function Oe(O,I){O!==""&&(ve.startScope(I),ve.addText(O),ve.endScope())}function Ir(O,I){let G=1,te=I.length-1;for(;G<=te;){if(!O._emit[G]){G++;continue}let Ae=Je.classNameAliases[O[G]]||O[G],ut=I[G];Ae?Oe(ut,Ae):(be=ut,gt(),be=""),G++}}function Qt(O,I){return O.scope&&typeof O.scope=="string"&&ve.openNode(Je.classNameAliases[O.scope]||O.scope),O.beginScope&&(O.beginScope._wrap?(Oe(be,Je.classNameAliases[O.beginScope._wrap]||O.beginScope._wrap),be=""):O.beginScope._multi&&(Ir(O.beginScope,I),be="")),F=Object.create(O,{parent:{value:F}}),F}function Lt(O,I,G){let te=Bx(O.endRe,G);if(te){if(O["on:end"]){let Ae=new ms(O);O["on:end"](I,Ae),Ae.isMatchIgnored&&(te=!1)}if(te){for(;O.endsParent&&O.parent;)O=O.parent;return O}}if(O.endsWithParent)return Lt(O.parent,I,G)}function kn(O){return F.matcher.regexIndex===0?(be+=O[0],1):(xn=!0,0)}function ct(O){let I=O[0],G=O.rule,te=new ms(G),Ae=[G.__beforeBegin,G["on:begin"]];for(let ut of Ae)if(ut&&(ut(O,te),te.isMatchIgnored))return kn(I);return G.skip?be+=I:(G.excludeBegin&&(be+=I),Fe(),!G.returnBegin&&!G.excludeBegin&&(be=I)),Qt(G,O),G.returnBegin?0:I.length}function xe(O){let I=O[0],G=R.substring(O.index),te=Lt(F,O,G);if(!te)return Em;let Ae=F;F.endScope&&F.endScope._wrap?(Fe(),Oe(I,F.endScope._wrap)):F.endScope&&F.endScope._multi?(Fe(),Ir(F.endScope,O)):Ae.skip?be+=I:(Ae.returnEnd||Ae.excludeEnd||(be+=I),Fe(),Ae.excludeEnd&&(be=I));do F.scope&&ve.closeNode(),!F.skip&&!F.subLanguage&&(vt+=F.relevance),F=F.parent;while(F!==te.parent);return te.starts&&Qt(te.starts,O),Ae.returnEnd?0:I.length}function tt(){let O=[];for(let I=F;I!==Je;I=I.parent)I.scope&&O.unshift(I.scope);O.forEach(I=>ve.openNode(I))}let vn={};function Cn(O,I){let G=I&&I[0];if(be+=O,G==null)return Fe(),0;if(vn.type==="begin"&&I.type==="end"&&vn.index===I.index&&G===""){if(be+=R.slice(I.index,I.index+1),!o){let te=new Error(`0 width match regex (${T})`);throw te.languageName=T,te.badRule=vn.rule,te}return 1}if(vn=I,I.type==="begin")return ct(I);if(I.type==="illegal"&&!q){let te=new Error('Illegal lexeme "'+G+'" for mode "'+(F.scope||"<unnamed>")+'"');throw te.mode=F,te}else if(I.type==="end"){let te=xe(I);if(te!==Em)return te}if(I.type==="illegal"&&G==="")return I.index===R.length||(be+=`
|
|
3
|
+
`),1;if(w>1e5&&w>I.index*3)throw new Error("potential infinite loop, way more iterations than matches");return be+=G,G.length}let Je=B(T);if(!Je)throw nr(i.replace("{}",T)),new Error('Unknown language: "'+T+'"');let Zt=bS(Je),kt="",F=se||Zt,It={},ve=new l.__emitter(l);tt();let be="",vt=0,Pt=0,w=0,xn=!1;try{if(Je.__emitTokens)Je.__emitTokens(R,ve);else{for(F.matcher.considerAll();;){w++,xn?xn=!1:F.matcher.considerAll(),F.matcher.lastIndex=Pt;let O=F.matcher.exec(R);if(!O)break;let I=R.substring(Pt,O.index),G=Cn(I,O);Pt=O.index+G}Cn(R.substring(Pt))}return ve.finalize(),kt=ve.toHTML(),{language:T,value:kt,relevance:vt,illegal:!1,_emitter:ve,_top:F}}catch(O){if(O.message&&O.message.includes("Illegal"))return{language:T,value:ic(R),illegal:!0,relevance:0,_illegalBy:{message:O.message,index:Pt,context:R.slice(Pt-100,Pt+100),mode:O.mode,resultSoFar:kt},_emitter:ve};if(o)return{language:T,value:ic(R),illegal:!1,relevance:0,errorRaised:O,_emitter:ve,_top:F};throw O}}function f(T){let R={value:ic(T),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return R._emitter.addText(T),R}function p(T,R){R=R||l.languages||Object.keys(t);let q=f(T),se=R.filter(B).filter(Q).map(Fe=>d(Fe,T,!1));se.unshift(q);let ae=se.sort((Fe,Oe)=>{if(Fe.relevance!==Oe.relevance)return Oe.relevance-Fe.relevance;if(Fe.language&&Oe.language){if(B(Fe.language).supersetOf===Oe.language)return 1;if(B(Oe.language).supersetOf===Fe.language)return-1}return 0}),[Ie,gt]=ae,Dt=Ie;return Dt.secondBest=gt,Dt}function h(T,R,q){let se=R&&n[R]||q;T.classList.add("hljs"),T.classList.add(`language-${se}`)}function g(T){let R=null,q=u(T);if(a(q))return;if(Re("before:highlightElement",{el:T,language:q}),T.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",T);return}if(T.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(T)),l.throwUnescapedHTML))throw new cc("One of your code blocks includes unescaped HTML.",T.innerHTML);R=T;let se=R.textContent,ae=q?c(se,{language:q,ignoreIllegals:!0}):p(se);T.innerHTML=ae.value,T.dataset.highlighted="yes",h(T,q,ae.language),T.result={language:ae.language,re:ae.relevance,relevance:ae.relevance},ae.secondBest&&(T.secondBest={language:ae.secondBest.language,relevance:ae.secondBest.relevance}),Re("after:highlightElement",{el:T,result:ae,text:se})}function m(T){l=Sm(l,T)}let b=()=>{x(),Dr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function k(){x(),Dr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function x(){function T(){x()}if(document.readyState==="loading"){C||window.addEventListener("DOMContentLoaded",T,!1),C=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function E(T,R){let q=null;try{q=R(e)}catch(se){if(nr("Language definition for '{}' could not be registered.".replace("{}",T)),o)nr(se);else throw se;q=s}q.name||(q.name=T),t[T]=q,q.rawDefinition=R.bind(null,e),q.aliases&&ie(q.aliases,{languageName:T})}function A(T){delete t[T];for(let R of Object.keys(n))n[R]===T&&delete n[R]}function M(){return Object.keys(t)}function B(T){return T=(T||"").toLowerCase(),t[T]||t[n[T]]}function ie(T,{languageName:R}){typeof T=="string"&&(T=[T]),T.forEach(q=>{n[q.toLowerCase()]=R})}function Q(T){let R=B(T);return R&&!R.disableAutodetect}function ge(T){T["before:highlightBlock"]&&!T["before:highlightElement"]&&(T["before:highlightElement"]=R=>{T["before:highlightBlock"](Object.assign({block:R.el},R))}),T["after:highlightBlock"]&&!T["after:highlightElement"]&&(T["after:highlightElement"]=R=>{T["after:highlightBlock"](Object.assign({block:R.el},R))})}function it(T){ge(T),r.push(T)}function je(T){let R=r.indexOf(T);R!==-1&&r.splice(R,1)}function Re(T,R){let q=T;r.forEach(function(se){se[q]&&se[q](R)})}function Me(T){return Dr("10.7.0","highlightBlock will be removed entirely in v12.0"),Dr("10.7.0","Please use highlightElement now."),g(T)}Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:x,highlightElement:g,highlightBlock:Me,configure:m,initHighlighting:b,initHighlightingOnLoad:k,registerLanguage:E,unregisterLanguage:A,listLanguages:M,getLanguage:B,registerAliases:ie,autoDetection:Q,inherit:Sm,addPlugin:it,removePlugin:je}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=wS,e.regex={concat:rr,lookahead:Tm,either:bs,optional:Px,anyNumberOfTimes:Ix};for(let T in hs)typeof hs[T]=="object"&&Mm(hs[T]);return Object.assign(e,hs),e},Lr=Bm({});Lr.newInstance=()=>Bm({});zm.exports=Lr;Lr.HighlightJS=Lr;Lr.default=Lr});var gu=ye(tn(),1);var mu=nu("primitives",{"zh-CN":{imageFrame:"\u56FE\u7247",appearance:"\u5916\u89C2",color:"\u6587\u5B57\u989C\u8272",backgroundColor:"\u80CC\u666F\u989C\u8272",fontSize:"\u5B57\u53F7",padding:"\u5185\u8FB9\u8DDD",radius:"\u5706\u89D2",title:"\u6807\u9898",language:"\u8BED\u8A00",plainText:"\u7EAF\u6587\u672C",copy:"\u590D\u5236\u4EE3\u7801",copied:"\u5DF2\u590D\u5236",width:"\u5BBD\u5EA6",height:"\u9AD8\u5EA6",fit:"\u56FE\u7247\u9002\u914D",contain:"\u5B8C\u6574\u663E\u793A",cover:"\u88C1\u5207\u586B\u5145",addImage:"\u6DFB\u52A0\u56FE\u7247",editImage:"\u7F16\u8F91\u56FE\u7247",imageSrc:"\u56FE\u7247\u5730\u5740",imageAlt:"\u66FF\u4EE3\u6587\u5B57",imageCaption:"\u56FE\u6CE8",table:"\u57FA\u7840\u8868\u683C",scrollTable:"{title}\uFF1A\u5DE6\u53F3\u6EDA\u52A8\u67E5\u770B\u5168\u90E8\u5217",comparisonTable:"\u5BF9\u7167\u8868",columnName:"\u5217 {column} \u540D\u79F0",cell:"\u7B2C {row} \u884C\u7B2C {column} \u5217",addRow:"\u6DFB\u52A0\u884C",removeLastRow:"\u79FB\u9664\u672B\u884C",callout:"\u63D0\u793A\u6846",toggleSummary:"\u5C55\u5F00\u5185\u5BB9",code:"\u4EE3\u7801\u5757",codeContent:"\u4EE3\u7801\u5185\u5BB9"},en:{imageFrame:"Image",appearance:"Appearance",color:"Text color",backgroundColor:"Background",fontSize:"Font size",padding:"Padding",radius:"Corner radius",title:"Title",language:"Language",plainText:"Plain text",copy:"Copy code",copied:"Copied",width:"Width",height:"Height",fit:"Image fit",contain:"Contain",cover:"Cover",addImage:"Add image",editImage:"Edit image",imageSrc:"Image URL",imageAlt:"Alt text",imageCaption:"Caption",table:"Basic table",scrollTable:"{title}: scroll sideways to see all columns",comparisonTable:"Comparison table",columnName:"Column {column} name",cell:"Row {row}, column {column}",addRow:"Add row",removeLastRow:"Remove last row",callout:"Callout",toggleSummary:"Show content",code:"Code block",codeContent:"Code"}});var we=ye(Xe(),1);function bu({editor:e,position:t}){let n=Be(mu),[r,o]=(0,gu.useState)(""),i=e.state.doc.nodeAt(t);if(!i||!e.isEditable)return null;let s=i.type.name,l=(f,p)=>{e.view.dispatch(e.state.tr.setNodeAttribute(t,f,p))},a=(f,p)=>(0,we.jsxs)("label",{children:[p,(0,we.jsx)("input",{value:i.attrs[f]??"",onChange:h=>l(f,h.target.value)})]},f),u=["image","table","codeBlock","callout","toggle","stepper","horizontalRule"].includes(s),c=i.attrs.componentStyle??{},d=(f,p)=>{let h={...c};p===void 0?delete h[f]:h[f]=p,l("componentStyle",h)};return(0,we.jsxs)("div",{className:"content-node-fields",children:[s==="image"&&(0,we.jsxs)(we.Fragment,{children:[a("src",n("imageSrc")),a("alt",n("imageAlt")),a("caption",n("imageCaption")),["width","height"].map(f=>(0,we.jsxs)("label",{children:[n(f),(0,we.jsx)("input",{inputMode:"decimal",value:i.attrs[f]??"",onChange:p=>{let h=p.target.value;(!h||/^\d+(?:px|%)?$/.test(h)&&parseInt(h)>0&&parseInt(h)<=1e4)&&l(f,h?/^\d+$/.test(h)?Number(h):h:null)}})]},f)),(0,we.jsxs)("label",{children:[n("fit"),(0,we.jsxs)("select",{value:i.attrs.fit??"contain",onChange:f=>l("fit",f.target.value),children:[(0,we.jsx)("option",{value:"contain",children:n("contain")}),(0,we.jsx)("option",{value:"cover",children:n("cover")})]})]})]}),["table","callout","toggle"].includes(s)&&a("title",n("title")),s==="codeBlock"&&(0,we.jsxs)(we.Fragment,{children:[(0,we.jsxs)("label",{children:[n("language"),(0,we.jsxs)("select",{value:Io(i.attrs.language),onChange:f=>l("language",f.target.value),children:[(0,we.jsx)("option",{value:"plaintext",children:n("plainText")}),!Hs.includes(Io(i.attrs.language))&&(0,we.jsxs)("option",{value:Io(i.attrs.language),children:[i.attrs.language,uu(i.attrs.language)?"":` (${n("plainText")})`]}),Hs.filter(f=>f!=="plaintext").map(f=>(0,we.jsx)("option",{value:f,children:f},f))]})]}),(0,we.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(i.textContent).then(()=>o(n("copied"))).catch(f=>o(f.message))},children:n("copy")}),r&&(0,we.jsx)("span",{role:"status",children:r})]}),u&&(0,we.jsxs)("details",{children:[(0,we.jsx)("summary",{children:n("appearance")}),["color","backgroundColor"].map(f=>(0,we.jsxs)("label",{children:[n(f),(0,we.jsx)("input",{value:c[f]??"",onChange:p=>d(f,p.target.value||void 0)})]},f)),["fontSize","padding","radius"].map(f=>(0,we.jsxs)("label",{children:[n(f),(0,we.jsx)("input",{type:"number",min:f==="fontSize"?8:0,max:"200",value:c[f]??"",onChange:p=>{let h=p.target.value;(!h||Number(h)>=(f==="fontSize"?8:0)&&Number(h)<=200)&&d(f,h?Number(h):void 0)}})]},f))]})]})}function yu(e,t){let n=e.cut(0,t).toJSON().content??[],r=e.cut(t).toJSON().content??[],o=l=>l?.type==="paragraph"&&!l.content?.length||l?.type==="richText"&&!Object.keys(l.attrs?.data??{}).length&&(l.content??[]).every(o);o(n.at(-1))&&n.pop(),o(r[0])&&r.shift();let i=new Set,s=l=>{let a=l.attrs?.id;a&&(i.has(a)&&(l.attrs={...l.attrs,id:crypto.randomUUID()}),i.add(l.attrs.id)),l.content?.forEach(s)};return n.forEach(s),r.forEach(s),{before:n,after:r}}var $=ye(tn(),1),yc=ye(Ds(),1);var ee=ye(tn(),1);var di=ye(Ds(),1),pp=ye(Tg(),1);var wu=Object.defineProperty,ku=(e,t)=>{let n={};for(var r in e)wu(n,r,{get:e[r],enumerable:!0});return t||wu(n,Symbol.toStringTag,{value:"Module"}),n};var Cu=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function xu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var Vs=(e,t,n)=>{let r=xu(e,n);if(!r)return!1;let o=Fs(r);if(!o){let s=r.blockRange(),l=s&&$t(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Du(e,o,t,-1))return!0;if(r.parent.content.size==0&&(lr(i,"end")||_.isSelectable(i)))for(let s=r.depth;;s--){let l=Oo(e.doc,r.before(s),r.after(s),ce.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(lr(i,"end")?X.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):_.create(a.doc,o.pos-i.nodeSize)),t(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},Su=(e,t,n)=>{let r=xu(e,n);if(!r)return!1;let o=Fs(r);return o?Mu(e,o,t):!1},Eu=(e,t,n)=>{let r=Au(e,n);if(!r)return!1;let o=Us(r);return o?Mu(e,o,t):!1};function Mu(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let c=o.lastChild;if(!c)return!1;o=c}let s=t.nodeAfter,l=s,a=t.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let u=Oo(e.doc,i,a,ce.empty);if(!u||u.from!=i||u instanceof Ln&&u.slice.size>=a-i)return!1;if(n){let c=e.tr.step(u);c.setSelection(L.create(c.doc,i)),n(c.scrollIntoView())}return!0}function lr(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var js=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=Fs(r)}let s=i&&i.nodeBefore;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Fs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Au(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Ws=(e,t,n)=>{let r=Au(e,n);if(!r)return!1;let o=Us(r);if(!o)return!1;let i=o.nodeAfter;if(Du(e,o,t,1))return!0;if(r.parent.content.size==0&&(lr(i,"start")||_.isSelectable(i))){let s=Oo(e.doc,r.before(),r.after(),ce.empty);if(s&&s.slice.size<s.to-s.from){if(t){let l=e.tr.step(s);l.setSelection(lr(i,"start")?X.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):_.create(l.doc,l.mapping.map(o.pos))),t(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Ks=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=Us(r)}let s=i&&i.nodeAfter;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,i.pos)).scrollIntoView()),!0)};function Us(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Tu=(e,t)=>{let n=e.selection,r=n instanceof _,o;if(r){if(n.node.isTextblock||!bt(e.doc,n.from))return!1;o=n.from}else if(o=sr(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(_.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},Nu=(e,t)=>{let n=e.selection,r;if(n instanceof _){if(n.node.isTextblock||!bt(e.doc,n.to))return!1;r=n.to}else if(r=sr(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Ru=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&$t(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},qs=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
4
|
+
`).scrollIntoView()),!0)};function Gs(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Js=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Gs(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let l=n.after(),a=e.tr.replaceWith(l,l,s.createAndFill());a.setSelection(X.near(a.doc.resolve(l),1)),t(a.scrollIntoView())}return!0},Xs=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof on||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Gs(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(s,i.createAndFill());l.setSelection(L.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},Ys=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(dt(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&$t(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function Rg(e){return(t,n)=>{if(t.selection instanceof _&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!dt(t.doc,p.pos)?!1:(n&&n(t.tr.split(p.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof L||t.selection instanceof on)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,u=!1,c=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){u=o.end(p)==o.pos+(o.depth-p),c=o.start(p)==o.pos-(o.depth-p),a=Gs(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let g=e&&e(o.parent,u,o);s.unshift(g||(u&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=o.pos,f=dt(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=dt(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!u&&c&&o.node(l).type!=a){let p=r.mapping.slice(i),h=p.map(o.before(l)),g=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&r.setNodeMarkup(p.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Og=Rg();var Ou=(e,t)=>{let{$from:n,to:r}=e.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),t&&t(e.tr.setSelection(_.create(e.doc,o))),!0)},Dg=(e,t)=>(t&&t(e.tr.setSelection(new on(e.doc))),!0);function Lg(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(i,i+1)||!(o.isTextblock||bt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Du(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Lg(e,t,n))return!0;let u=!a&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let p=t.pos+i.nodeSize,h=z.empty;for(let b=s.length-1;b>=0;b--)h=z.from(s[b].create(null,h));h=z.from(o.copy(h));let g=e.tr.step(new Ct(t.pos-1,p,t.pos,p,new ce(h,1,0),s.length,!0)),m=g.doc.resolve(p+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&bt(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&a?null:X.findFrom(t,1),d=c&&c.$from.blockRange(c.$to),f=d&&$t(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(u&&lr(i,"start",!0)&&lr(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(n){let b=z.empty;for(let C=h.length-1;C>=0;C--)b=z.from(h[C].copy(b));let k=e.tr.step(new Ct(t.pos-h.length,t.pos+i.nodeSize,t.pos+m,t.pos+i.nodeSize-m,new ce(b,h.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Lu(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(t.tr.setSelection(L.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var Qs=Lu(-1),Zs=Lu(1);function Iu(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&ir(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function el(e,t=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,u)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)o=!0;else{let c=n.doc.resolve(u),d=c.index();o=c.parent.canReplaceWith(d,d+1,e)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,e,t)}r(i.scrollIntoView())}return!0}}function tl(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}var _s=tl(Cu,Vs,js),vu=tl(Cu,Ws,Ks),sn={Enter:tl(qs,Xs,Ys,Og),"Mod-Enter":Js,Backspace:_s,"Mod-Backspace":_s,"Shift-Backspace":_s,Delete:vu,"Mod-Delete":vu,"Mod-a":Dg},Ig={"Ctrl-h":sn.Backspace,"Alt-Backspace":sn["Mod-Backspace"],"Ctrl-d":sn.Delete,"Ctrl-Alt-Backspace":sn["Mod-Delete"],"Alt-Delete":sn["Mod-Delete"],"Alt-d":sn["Mod-Delete"],"Ctrl-a":Qs,"Ctrl-e":Zs};for(let e in sn)Ig[e]=sn[e];var C1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Pu(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Pg(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Pg(e,t,n,r=null){let o=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let a=s.resolve(t.start-2);i=new To(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new To(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=ir(i,n,r,t);return l?(e&&$g(e,t,l,o,n),!0):!1}function $g(e,t,n,r,o){let i=z.empty;for(let c=n.length-1;c>=0;c--)i=z.from(n[c].type.create(n[c].attrs,i));e.step(new Ct(t.start-(r?2:0),t.end,t.start,t.end,new ce(i,0,0),n.length,!0));let s=0;for(let c=0;c<n.length;c++)n[c].type==o&&(s=c+1);let l=n.length-s,a=t.start+n.length-(r?2:0),u=t.parent;for(let c=t.startIndex,d=t.endIndex,f=!0;c<d;c++,f=!1)!f&&dt(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=u.child(c).nodeSize;return e}function $u(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==e);return i?n?r.node(i.depth-1).type==e?Bg(t,n,e,i):zg(t,n,i):!0:!1}}function Bg(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Ct(i-1,s,i,s,new ce(z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new To(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=$t(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return bt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}function zg(e,t,n){let r=e.tr,o=n.parent;for(let p=n.end,h=n.endIndex-1,g=n.startIndex;h>g;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,u=i.node(-1),c=i.index(-1);if(!u.canReplace(c+(l?0:1),c+1,s.content.append(a?z.empty:z.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new Ct(d-(l?1:0),f+(a?1:0),d+1,f-1,new ce((l?z.empty:z.from(o.copy(z.empty))).append(a?z.empty:z.from(o.copy(z.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function Bu(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,u=>u.childCount>0&&u.firstChild.type==e);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=e)return!1;if(n){let u=a.lastChild&&a.lastChild.type==l.type,c=z.from(u?e.create():null),d=new ce(z.from(e.create(null,z.from(l.type.create(null,c)))),u?3:1,0),f=i.start,p=i.end;n(t.tr.step(new Ct(f-(u?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var ze=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},dr=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},sl=null,zt=function(e,t,n){let r=sl||(sl=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Hg=function(){sl=null},Vn=function(e,t,n,r){return n&&(zu(e,t,n,r,-1)||zu(e,t,n,r,1))},_g=/^(img|br|input|textarea|hr)$/i;function zu(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ke(e))){let s=e.parentNode;if(!s||!W(s)||Ur(e)||_g.test(e.nodeName)||e.contentEditable=="false")return!1;t=ze(e)+(o<0?0:1),e=s}else if(W(e)){let s=e.childNodes[t+(o<0?-1:0)];if(W(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=o;else return!1;else e=s,t=o<0?Ke(e):0}else return!1}}function Ke(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function W(e){return e.nodeType==1}function De(e){return e.nodeType==3}function jn(e,t){return t?e.contains(W(t)?t:t.parentNode):!1}function Vg(e,t){for(;;){if(De(e)&&t)return e;if(W(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Ke(e)}else if(e.parentNode&&!Ur(e))t=ze(e),e=e.parentNode;else return null}}function jg(e,t){for(;;){if(De(e)&&t<e.nodeValue.length)return e;if(W(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Ur(e))t=ze(e)+1,e=e.parentNode;else return null}}function Fg(e,t,n){for(let r=t==0,o=t==Ke(e);r||o;){if(e==n)return!0;let i=ze(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==Ke(e)}}function Ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Ko=function(e){return e.focusNode&&Vn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function In(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Wg(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Kg(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}var xt=typeof navigator<"u"?navigator:null,Hu=typeof document<"u"?document:null,dn=xt&&xt.userAgent||"",ll=/Edge\/(\d+)/.exec(dn),hd=/MSIE \d/.exec(dn),al=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dn),nt=!!(hd||al||ll),cn=hd?document.documentMode:al?+al[1]:ll?+ll[1]:0,st=!nt&&/gecko\/(\d+)/i.test(dn);st&&+(/Firefox\/(\d+)/.exec(dn)||[0,0])[1];var cl=!nt&&/Chrome\/(\d+)/.exec(dn),He=!!cl,md=cl?+cl[1]:0,Ue=!nt&&!!xt&&/Apple Computer/.test(xt.vendor),fr=Ue&&(/Mobile\/\w+/.test(dn)||!!xt&&xt.maxTouchPoints>2),ft=fr||(xt?/Mac/.test(xt.platform):!1),gd=xt?/Win/.test(xt.platform):!1,Ht=/Android \d/.test(dn),Uo=!!Hu&&"webkitFontSmoothing"in Hu.documentElement.style,Ug=Uo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function qg(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Bt(e,t){return typeof e=="number"?e:e[t]}function Gg(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function _u(e,t,n){if(!ul(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!W(s)){s=dr(s);continue}let l=s==i.body,a=l?qg(i):Gg(s),u=0,c=0;if(t.top<a.top+Bt(r,"top")?c=-(a.top-t.top+Bt(o,"top")):t.bottom>a.bottom-Bt(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+Bt(o,"top")-a.top:t.bottom-a.bottom+Bt(o,"bottom")),t.left<a.left+Bt(r,"left")?u=-(a.left-t.left+Bt(o,"left")):t.right>a.right-Bt(r,"right")&&(u=t.right-a.right+Bt(o,"right")),u||c)if(l)i.defaultView.scrollBy(u,c);else{let f=s.scrollLeft,p=s.scrollTop;c&&(s.scrollTop+=c),u&&(s.scrollLeft+=u);let h=s.scrollLeft-f,g=s.scrollTop-p;t={left:t.left-h,top:t.top-g,right:t.right-h,bottom:t.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:dr(s)}}function Jg(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,o;for(let i=(t.left+t.right)/2,s=n+1;s<Math.min(innerHeight,t.bottom);s+=5){let l=e.root.elementFromPoint(i,s);if(!l||l==e.dom||!e.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:bd(e.dom)}}function bd(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=dr(r));return t}function Xg({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;yd(n,r==0?0:r-t)}function yd(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}var ar=null;function Yg(e){if(e.setActive)return e.setActive();if(ar)return e.focus(ar);let t=bd(e);e.focus(ar==null?{get preventScroll(){return ar={preventScroll:!0},!0}}:void 0),ar||(ar=!1,yd(t,0))}function wd(e,t){let n,r=2e8,o,i=0,s=t.top,l=t.top,a,u;for(let c=e.firstChild,d=0;c;c=c.nextSibling,d++){let f;if(W(c))f=c.getClientRects();else if(De(c))f=zt(c).getClientRects();else continue;for(let p=0;p<f.length;p++){let h=f[p];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(g<r){n=c,r=g,o=g&&De(n)?{left:h.right<t.left?h.right:h.left,top:t.top}:t,W(c)&&g&&(i=d+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!a&&h.left<=t.left&&h.right>=t.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&De(n)?Qg(n,o):!n||r?{node:e,offset:i}:wd(n,o)}function Qg(e,t){let n=e.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let s=ln(r,1);if(s.top!=s.bottom&&Ml(t,s)){o={node:e,offset:i+(t.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:e,offset:0}}function Ml(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Zg(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function eb(e,t,n){let{node:r,offset:o}=wd(t,n),i=-1;if(W(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}function tb(e,t,n,r){let o=-1;for(let i=t,s=!1;i!=e.dom;){let l=e.docView.nearestDesc(i,!0),a;if(!l)return null;if(W(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?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<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;i=l.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}function kd(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=e.childNodes[i];if(W(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let u=l[a];if(Ml(t,u))return kd(s,t,u)}}if((i=(i+1)%r)==o)break}return e}function nb(e,t){let n=e.dom.ownerDocument,r,o=0,i=Kg(n,t.left,t.top);i&&({node:r,offset:o}=i);let s=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!s||!e.dom.contains(s)){let u=e.dom.getBoundingClientRect();if(!Ml(t,u)||(s=kd(e.dom,t,u),!s))return null}if(Ue)for(let u=s;r&&u;u=dr(u))u.draggable&&(r=void 0);if(s=Zg(s,t),r){if(st&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let c=r.childNodes[o],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&o++}let u;Uo&&o&&W(r)&&W(u=r.childNodes[o-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=t.top&&o--,r==e.dom&&o==r.childNodes.length-1&&W(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(o==0||!W(r)||r.childNodes[o-1].nodeName!="BR")&&(l=tb(e,r,o,t))}l==null&&(l=eb(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ul(e){return e.top<e.bottom||e.left<e.right}function ln(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(ul(r))return r}return Array.prototype.find.call(n,ul)||e.getBoundingClientRect()}var rb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vd(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=Uo||st;if(De(r))if(s&&(rb.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=ln(zt(r,o,o),n);if(st&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let u=ln(zt(r,o-1,o-1),-1);if(u.top==a.top){let c=ln(zt(r,o,o+1),-1);if(c.top!=a.top)return zr(c,c.left<u.left)}}return a}else{let a=o,u=o,c=n<0?1:-1;return n<0&&!o?(u++,c=-1):n>=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,zr(ln(zt(r,a,u),c),c<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Ke(r))){let a=r.childNodes[o-1];if(W(a))return nl(a.getBoundingClientRect(),!1)}if(i==null&&o<Ke(r)){let a=r.childNodes[o];if(W(a))return nl(a.getBoundingClientRect(),!0)}return nl(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Ke(r))){let a=r.childNodes[o-1],u=De(a)?zt(a,Ke(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return zr(ln(u,1),!1)}if(i==null&&o<Ke(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?De(a)?zt(a,0,s?0:1):W(a)?a:null:null;if(u)return zr(ln(u,-1),!0)}return zr(ln(De(r)?zt(r):r,-n),n>=0)}function zr(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function nl(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Cd(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}function ob(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return Cd(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=vd(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(De(l))a=zt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}var ib=/[\u0590-\u08ac]/;function sb(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?!ib.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Cd(e,t,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=e.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:g}=e.domSelectionRange(),m=h&&!jn(p,h)||a==h&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return f!=null&&(l.caretBidiLevel=f),m}):r.pos==r.start()||r.pos==r.end()}var Vu=null,ju=null,Fu=!1;function lb(e,t,n){return Vu==t&&ju==n?Fu:(Vu=t,ju=n,Fu=n=="up"||n=="down"?ob(e,t,n):sb(e,t,n))}var pt=0,Wu=1,Pn=2,yt=3,Fn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=pt,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==t)return r;r+=o.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(t,n,r){if(this.contentDOM&&jn(this.contentDOM,t))if(r<0){let i,s;if(t==this.contentDOM)i=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM)i=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=n>ze(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(t.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(W(s)?jn(s,t):s==t))r=!1;else return i}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==t&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(t<i)return o.descAt(t-r-o.border);r=i}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>t){o=t-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Bo||i instanceof Po&&i.side>=0))break}if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?ze(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?ze(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],u=s+a.size;if(o==-1&&t<=u){let c=s+a.border;if(t>=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,n,c);t=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=ze(f.dom)+1;break}t-=f.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;c<this.children.length;c++){let d=this.children[c];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=ze(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=u}return{node:this.contentDOM,from:t,to:n,fromOffset:o,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(!W(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,o=!1){let i=Math.min(t,n),s=Math.max(t,n);for(let p=0,h=0;p<this.children.length;p++){let g=this.children[p],m=h+g.size;if(i>h&&s<m)return g.setSelection(t-h-g.border,n-h-g.border,r,o);h=m}let l=this.domFromPos(t,t?-1:1),a=n==t?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),c=r.domSelectionRange(),d=!1;if((st||Ue)&&t==n){let{node:p,offset:h}=l;if(De(p)){if(d=!!(h&&p.nodeValue[h-1]==`
|
|
5
|
+
`),d&&h==p.nodeValue.length)for(let g=p,m;g;g=g.parentNode){if(m=g.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:ze(m)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=p.childNodes[h-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(st&&c.focusNode&&c.focusNode!=a.node&&W(c.focusNode)){let p=c.focusNode.childNodes[c.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||d&&Ue)&&Vn(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Vn(a.node,a.offset,c.focusNode,c.focusOffset))return;let f=!1;if((u.extend||t==n)&&!(d&&st)){u.collapse(l.node,l.offset);try{t!=n&&u.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(t>n){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?t<=s&&n>=r:t<s&&n>r){let l=r+i.border,a=s-i.border;if(t>=l&&n<=a){this.dirty=t==r||n==s?Pn:Wu,t==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=yt:i.markDirty(t-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Pn:yt}r=s}this.dirty=Pn}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?Pn:Wu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},Po=class extends Fn{constructor(t,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=W(s)?s:document.createElement("span");l!=s&&l.appendChild(s),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(t){return this.dirty==pt&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.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}},dl=class extends Fn{constructor(t,n,r,o){super(t,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},Bn=class e extends Fn{constructor(t,n,r,o,i){super(t,[],r,o),this.mark=n,this.spec=i}static create(t,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Dn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&yt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=yt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=pt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=pt}}slice(t,n,r){let o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=ml(i,n,s,r)),t>0&&(i=ml(i,0,t,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},un=class e extends Fn{constructor(t,n,r,o,i,s,l){super(t,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(t,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,u=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(!De(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Dn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let f=c;return c=Ed(c,r,n),u?a=new fl(t,n,r,o,c,d||null,f,u):n.isText?new $o(t,n,r,o,c,f):new e(t,n,r,o,c,d||null,f)}parseRule(t){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 o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=t&&t.find(o=>W(o)&&t.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>z.empty}}return n}matchesNode(t,n,r){return this.dirty==pt&&t.eq(this.node)&&zo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,o=n,i=t.composing?this.localCompositionInfo(t,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new hl(this,s&&s.node,t),u=this.node.inlineContent,c=u&&this.node.isBlock;db(this.node,this.innerDeco,(d,f,p)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,t,f):d.type.side>=0&&!p&&a.syncToMarks(f==this.node.childCount?ru.none:this.node.child(f).marks,r,t,f),a.placeWidget(d,t,o)},(d,f,p,h)=>{a.syncToMarks(d.marks,r,t,h),c&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(d,f,p,h)||l&&t.state.selection.from>o&&t.state.selection.to<o+d.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,p,g,t)||a.updateNextNode(d,f,p,t,h,o)||a.addNode(d,f,p,t,o),o+=d.nodeSize,u&&(c=d.isAtom&&!d.isText)}),a.syncToMarks([],r,t,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Pn)&&(s&&this.protectLocalComposition(t,s),xd(this.contentDOM,this.children,t),fr&&fb(this.dom))}localCompositionInfo(t,n){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof L)||r<n||o>n+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=pb(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new dl(this,i,n,o);t.input.compositionNodes.push(s),this.children=ml(this.children,r,r+o.length,t,s)}update(t,n,r,o){return this.dirty==yt||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,o),!0)}updateInner(t,n,r,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=pt}updateOuterDeco(t){if(zo(t,this.outerDeco))return;let n=!W(this.nodeDOM),r=this.dom;this.dom=Sd(this.dom,this.nodeDOM,pl(this.outerDeco,this.node,n),pl(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){W(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 Ku(e,t,n,r,o){Ed(r,t,e);let i=new un(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var $o=class e extends un{constructor(t,n,r,o,i,s){super(t,n,r,o,i,null,s)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,o){return this.dirty==yt||this.dirty!=pt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=pt||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=pt,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=yt)}get domAtom(){return!1}isText(t){return this.node.text==t}},Bo=class extends Fn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==pt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},fl=class extends un{constructor(t,n,r,o,i,s,l,a){super(t,n,r,o,i,s,l),this.spec=a}update(t,n,r,o){if(this.dirty==yt)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r.root):super.setSelection(t,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function xd(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=Uu(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Bn){let a=r?r.previousSibling:e.lastChild;xd(s.contentDOM,s.children,n),r=a?a.nextSibling:e.firstChild}}for(;r;)r=Uu(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var _r=function(e){e&&(this.nodeName=e)};_r.prototype=Object.create(null);var $n=[new _r];function pl(e,t,n){if(e.length==0)return $n;let r=n?$n[0]:new _r,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new _r(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new _r(t.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 o}function Sd(e,t,n,r){if(n==$n&&r==$n)return t;let o=t;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=e&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$n[0]),o=a}ab(o,l||$n[0],s)}return o}function ab(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&e.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&e.classList.add(o[i]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(t.style);)e.style.removeProperty(o[1])}n.style&&(e.style.cssText+=n.style)}}function Ed(e,t,n){return Sd(e,e,$n,pl(t,n,!W(e)))}function zo(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Uu(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var hl=class{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=cb(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let r=t;r<n;r++)this.top.children[r].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,t.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=pt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let a=-1,u=this.top.children.length;o<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let c=this.index;c<u;c++){let d=this.top.children[c];if(d.matchesMark(t[s])&&!this.isLocked(d.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof Bn&&c.dirty!=yt&&c.mark.type==t[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(t[s])&&(c.mark=t[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 c=Bn.create(this.top,t[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(t,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,n,r))i=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 u=this.top.children[l];if(u.matchesNode(t,n,r)&&!this.preMatch.matched.has(u)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,n,r,o,i){let s=this.top.children[o];return s.dirty==yt&&s.dom==s.contentDOM&&(s.dirty=Pn),s.update(t,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}t=n}}updateNextNode(t,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof un){let u=this.preMatch.matched.get(a);if(u!=null&&u!=i)return!1;let c=a.dom,d,f=this.isLocked(c)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&a.dirty!=yt&&zo(n,a.outerDeco));if(!f&&a.update(t,n,r,o))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,t,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Pn,d.updateChildren(o,s+1),d.dirty=pt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,r,o,i,s){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!zo(r,t.outerDeco)||!o.eq(t.innerDeco))return null;let l=un.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=t.children,t.children=[];for(let a of l.children)a.parent=l}return t.destroy(),l}addNode(t,n,r,o,i){let s=un.create(this.top,t,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Po(this.top,t,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof Bn;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof $o)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ue||He)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Bo(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||W(t)&&t.contains(this.lock.parentNode))}};function cb(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Bn)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function ub(e,t){return e.type.side-t.type.side}function db(e,t,n,r){let o=t.locals(e),i=0;if(o.length==0){for(let u=0;u<e.childCount;u++){let c=e.child(u);r(c,o,t.forChild(i,c),u),i+=c.nodeSize}return}let s=0,l=[],a=null;for(let u=0;;){let c,d;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(c?(d||(d=[c])).push(m):c=m)}if(c)if(d){d.sort(ub);for(let m=0;m<d.length;m++)n(d[m],u,!!a)}else n(c,u,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(u<e.childCount)p=u,f=e.child(u++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+f.nodeSize;if(f.isText){let m=h;s<o.length&&o[s].from<m&&(m=o[s].from);for(let b=0;b<l.length;b++)l[b].to<m&&(m=l[b].to);m<h&&(a=f.cut(m-i),f=f.cut(0,m-i),h=m,p=-1)}else for(;s<o.length&&o[s].to<h;)s++;let g=f.isInline&&!f.isLeaf?l.filter(m=>!m.inline):l.slice();r(f,g,t.forChild(i,f),p),i=h}}function fb(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function pb(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let u=e.child(o++);if(i+=u.nodeSize,!u.isText)break;a+=u.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let u=l<r?a.lastIndexOf(t,r-l-1):-1;if(u>=0&&u+t.length+l>=n)return l+u;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}function ml(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],u=l,c=l+=a.size;u>=n||c<=t?i.push(a):(u<t&&i.push(a.slice(0,t-u,r)),o&&(i.push(o),o=void 0),c>n&&i.push(a.slice(n-u,a.size,r)))}return i}function Al(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Ko(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&_.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&Fg(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new _(s==d?l:r.resolve(d))}else if(st&&t=="key"&&s>e.state.selection.to&&W(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){u=X.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!W(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let p=0;p<n.rangeCount;p++){let h=n.getRangeAt(p);d=Math.min(d,e.docView.posFromDOM(h.startContainer,h.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=f==e.state.selection.anchor?[f,d]:[d,f],l=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!u){let d=t=="pointer"||e.state.selection.head<l.pos&&!i?1:-1;u=Tl(e,c,l,d)}return u}function Md(e){return e.editable?e.hasFocus():Td(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Vt(e,t=!1){let n=e.state.selection;if(Ad(e,n),!Md(e))return;let r=e.input.mouseDown;if(!t&&He&&r){let o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Vn(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)mb(e);else{let{anchor:o,head:i}=n,s,l;qu&&!(n instanceof L)&&(n.$from.parent.inlineContent||(s=Gu(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Gu(e,n.to))),e.docView.setSelection(o,i,e,t),qu&&(s&&Ju(s),l&&Ju(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&hb(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var qu=Ue||He&&md<63;function Gu(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Ue&&o&&o.contentEditable=="false")return rl(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return rl(o);if(i)return rl(i)}}function rl(e){return e.contentEditable="true",Ue&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ju(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function hb(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Md(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function mb(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,ze(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&nt&&cn<=11&&(n.disabled=!0,n.disabled=!1)}function Ad(e,t){if(t instanceof _){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Xu(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Xu(e)}function Xu(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Tl(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||L.between(t,n,r)}function Yu(e){return e.editable&&!e.hasFocus()?!1:Td(e)}function Td(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return jn(e.dom,t.anchorNode)&&(e.editable||jn(e.dom,t.focusNode))}catch{return!1}}function gb(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Vn(t.node,t.offset,n.anchorNode,n.anchorOffset)}function gl(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&X.findFrom(i,t)}function an(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Qu(e,t,n){let r=e.state.selection;if(r instanceof L)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return an(e,new L(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=gl(e.state,t);return o&&o instanceof _?an(e,o):!1}else if(!(ft&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(l))&&!s.contentDOM?_.isSelectable(i)?an(e,new _(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):an(e,new L(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof _&&r.node.isInline)return an(e,new L(t>0?r.$to:r.$from));{let o=gl(e.state,t);return o?an(e,o):!1}}}function Vr(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):W(e)&&e.contentEditable=="false"}function cr(e,t){return t<0?bb(e):yb(e)}function bb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(st&&W(n)&&r<Ke(n)&&Vr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(n))break;let l=n.childNodes[r-1];if(Vr(l,-1))o=n,i=--r;else if(De(l))n=l,r=n.nodeValue.length;else break}else{if(Nd(n))break;{let l=n.previousSibling;for(;l&&Vr(l,-1);)o=n.parentNode,i=ze(l),l=l.previousSibling;if(l)n=l,r=Ke(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?bl(e,n,r):o&&bl(e,o,i)}function yb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=Ke(n),i,s;for(;;)if(r<o){if(!W(n))break;let l=n.childNodes[r];if(Vr(l,1))i=n,s=++r;else break}else{if(Nd(n))break;{let l=n.nextSibling;for(;l&&Vr(l,1);)i=l.parentNode,s=ze(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=Ke(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&bl(e,i,s)}function Nd(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function wb(e,t){for(;e&&t==e.childNodes.length&&!Ur(e);)t=ze(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(De(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=0}}function kb(e,t){for(;e&&!t&&!Ur(e);)t=ze(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(De(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function bl(e,t,n){if(!De(t)){let i,s;(s=wb(t,n))?(t=s,n=0):(i=kb(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Ko(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Vt(e)},50)}function Zu(e,t){let n=e.state.doc.resolve(t);if(!(He||gd)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function ed(e,t,n){let r=e.state.selection;if(r instanceof L&&!r.empty||n.indexOf("s")>-1||ft&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=gl(e.state,t);if(s&&s instanceof _)return an(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,l=r instanceof on?X.near(s,t):X.findFrom(s,t);return l?an(e,l):!1}return!1}function td(e,t){if(!(e.state.selection instanceof L))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),e.dispatch(s),!0}return!1}function nd(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function vb(e){if(!Ue||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&W(t)&&n==0&&t.firstChild&&W(t.firstChild)&&t.firstChild.contentEditable=="false"){let r=t.firstChild;nd(e,r,"true"),setTimeout(()=>nd(e,r,"false"),20)}return!1}function Cb(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function xb(e,t){let n=t.keyCode,r=Cb(t);if(n==8||ft&&n==72&&r=="c")return td(e,-1)||cr(e,-1);if(n==46&&!t.shiftKey||ft&&n==68&&r=="c")return td(e,1)||cr(e,1);if(n==13||n==27)return!0;if(n==37||ft&&n==66&&r=="c"){let o=n==37?Zu(e,e.state.selection.from)=="ltr"?-1:1:-1;return Qu(e,o,r)||cr(e,o)}else if(n==39||ft&&n==70&&r=="c"){let o=n==39?Zu(e,e.state.selection.from)=="ltr"?1:-1:1;return Qu(e,o,r)||cr(e,o)}else{if(n==38||ft&&n==80&&r=="c")return ed(e,-1,r)||cr(e,-1);if(n==40||ft&&n==78&&r=="c")return vb(e)||ed(e,1,r)||cr(e,1);if(r==(ft?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Nl(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=e.someProp("clipboardSerializer")||Dn.fromSchema(e.state.schema),l=Pd(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&W(u)&&(c=Id[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}u=a.firstChild}u&&W(u)&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
6
6
|
|
|
7
|
-
`);return{dom:a,text:f,slice:t}}function
|
|
8
|
-
`))),0,0),e.someProp("transformPasted",f=>{l=f(l,e,!0)}),l;let d=e.someProp("clipboardTextParser",f=>f(t,o,r,e));if(d)l=d;else{let f=o.marks(),{schema:p}=e.state,h=On.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(p.text(g,f)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),s=Cb(n),Ko&&xb(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let f=s.firstChild;for(;f&&!j(f);)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||Rn.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!wb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Sb(Zu(l,+c[1],+c[2]),c[4]);else if(l=ae.maxOpen(kb(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=Zu(l,d,f)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var wb=/^(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 kb(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&i.length&&Td(a,i,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=Nd(s[s.length-1],i.length));let c=Ad(l,a);s.push(c),o=o.matchType(c.type),i=a}}),s)return z.from(s)}return e}function Ad(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,z.from(e));return e}function Td(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Td(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(z.from(Ad(n,e,o+1))))}}function Nd(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Nd(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(z.empty,!0);return e.copy(n.append(r))}function bl(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=bl(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function Zu(e,t,n){return t<e.openStart&&(e=new ae(bl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ae(bl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Rd={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 Od(){return document.implementation.createHTMLDocument("title")}var Hr=null;function vb(e){let t=window.trustedTypes;if(!t)return e;if(!Hr){if(Hr=t.defaultPolicy)try{return Hr.createHTML(e)}catch{}Hr=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Hr.createHTML(e)}function Cb(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Od(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(e),i;if((i=o&&Rd[o[1].toLowerCase()])&&(e=i.map(s=>"<"+s+">").join("")+e+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=vb(e),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[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 u=l.rules[a];if(u instanceof CSSStyleRule){let c=r.querySelectorAll(u.selectorText);for(let d=0;d<c.length;d++)c[d].style.cssText+=u.style.cssText}}}return r}function xb(e){let t=e.querySelectorAll(ze?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Sb(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:o,openStart:i,openEnd:s}=e;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=z.from(a.create(r[l+1],o))}catch{break}i++,s++}return new ae(o,i,s)}var Ye={},Qe={},Eb={touchstart:!0,touchmove:!0},yl=class{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 Mb(e){for(let t in Ye){let n=Ye[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{Tb(e,r)&&!Nl(e,r)&&(e.editable||!(r.type in Qe))&&n(e,r)},Eb[t]?{passive:!0}:void 0)}Ue&&e.dom.addEventListener("input",()=>null),wl(e)}function _t(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ab(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function wl(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>Nl(e,r))})}function Nl(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Tb(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Nb(e,t){!Nl(e,t)&&Ye[t.type]&&(e.editable||!(t.type in Qe))&&Ye[t.type](e,t)}Qe.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Id(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Ht&&ze&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),cr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,Ln(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||yb(e,n)?n.preventDefault():_t(e,"key")};Qe.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Qe.keypress=(e,t)=>{let n=t;if(Id(e)||!n.charCode||n.ctrlKey&&!n.altKey||ft&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof L)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",s=>s(e,r.$from.pos,r.$to.pos,o,i))&&e.dispatch(i()),n.preventDefault()}};function qr(e){return{left:e.clientX,top:e.clientY}}function Rb(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Rl(e,t,n,r,o){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(e.someProp(t,l=>s>i.depth?l(e,n,i.nodeAfter,i.before(s),o,!0):l(e,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Gr(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Ob(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&H.isSelectable(r)?(Gr(e,new H(n)),!0):!1}function Db(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof H&&(r=n.node);let i=e.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(H.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Gr(e,H.create(e.state.doc,o)),!0):!1}function Lb(e,t,n,r,o){return Rl(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(o?Db(e,n):Ob(e,n))}function Ib(e,t,n,r){return Rl(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function Pb(e,t,n,r){return Rl(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||$b(e,n,r)}function $b(e,t,n){if(n.button!=0)return!1;let r=Dd(e,t,!0),o=e.state.doc;return r?(Gr(e,r),r instanceof L&&o.eq(e.state.doc)&&(e.input.mouseDown=new vl(e,r)),!0):!1}function Dd(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?L.create(r,0,r.content.size):null;let o=r.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return L.create(r,l+1,l+1+s.content.size);if(n&&H.isSelectable(s))return H.create(r,l)}return null}function Ol(e){return Ho(e)}var Ld=ft?"metaKey":"ctrlKey";Ye.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ol(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&Rb(n,e.input.lastClick)&&!n[Ld]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(qr(n));s&&(i=="singleClick"?e.input.mouseDown=new kl(e,s,n,!!r):(i=="doubleClick"?Ib:Pb)(e,s.pos,s.inside,n)?n.preventDefault():_t(e,"pointer"))};var zo=class{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.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}},kl=class extends zo{constructor(t,n,r,o){super(t),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!r[Ld],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),s=n.inside;else{let c=t.state.doc.resolve(n.pos);i=c.parent,s=c.depth?c.before():0}let l=o?null:r.target,a=l?t.docView.nearestDesc(l,!0):null;this.target=a&&j(a.nodeDOM)?a.nodeDOM:null;let{selection:u}=t.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof H&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&st&&!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(t,"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||Vt(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(qr(t))),this.updateAllowDefault(t),this.allowDefault||!n?_t(this.view,"pointer"):Lb(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ze&&!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)?(Gr(this.view,J.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):_t(this.view,"pointer")}move(t){this.updateAllowDefault(t),_t(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},vl=class extends zo{constructor(t,n){super(t),this.startSelection=n,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),_t(this.view,"pointer");let n=this.view.posAtCoords(qr(t)),r=n&&Dd(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Gr(this.view,L.create(o,s,l))}};Ye.touchstart=e=>{e.input.lastTouch=Date.now(),Ol(e),_t(e,"pointer")};Ye.touchmove=e=>{e.input.lastTouch=Date.now(),_t(e,"pointer")};Ye.contextmenu=e=>Ol(e);function Id(e,t){return e.composing?!0:Ue&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Bb=Ht?5e3:-1;Qe.compositionstart=Qe.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof L&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ze&&fd&&zb(e)))e.markCursor=e.state.storedMarks||n.marks(),Ho(e,!0),e.markCursor=null;else if(Ho(e,!t.selection.empty),st&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&j(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(De(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}Pd(e,Bb)};function zb(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!j(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return j(r)&&r.contentEditable=="false"}Qe.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Pd(e,20))};function Pd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ho(e),t))}function $d(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Hb(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=$g(t.focusNode,t.focusOffset),r=Bg(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Ho(e,t=!1){if(!(Ht&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),$d(e),t||e.docView&&e.docView.dirty){let n=Ml(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function _b(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var jr=nt&&an<15||cr&&Vg<604;Ye.copy=Qe.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let i=jr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Tl(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):_b(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vb(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function jb(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fr(e,r.value,null,o,t):Fr(e,r.textContent,r.innerHTML,o,t)},50)}function Fr(e,t,n,r,o){let i=Md(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,o,i||ae.empty)))return!0;if(!i)return!1;let s=Vb(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Bd(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Qe.paste=(e,t)=>{let n=t;if(e.composing&&!Ht)return;let r=jr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fr(e,Bd(r),r.getData("text/html"),o,n)?n.preventDefault():jb(e,n)};var _o=class{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}},Fb=ft?"altKey":"ctrlKey";function zd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[Fb]}Ye.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(qr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof H?o.to-1:o.to))){if(r&&r.mightDrag)s=H.create(e.state.doc,r.mightDrag.pos);else if(n.target&&j(n.target)){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(s=H.create(e.state.doc,d.posBefore))}}let l=(s||e.state.selection).content(),{dom:a,text:u,slice:c}=Tl(e,l);(!n.dataTransfer.files.length||!ze||dd>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",jr||n.dataTransfer.setData("text/plain",u),e.dragging=new _o(c,zd(e,n),s)};Ye.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Qe.dragover=Qe.dragenter=(e,t)=>t.preventDefault();Qe.drop=(e,t)=>{try{Wb(e,t,e.dragging)}finally{e.dragging=null}};function Wb(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(qr(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",p=>{i=p(i,e,!1)}):i=Md(e,Bd(t.dataTransfer),jr?null:t.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&zd(e,t));if(e.someProp("handleDrop",p=>p(e,t,i||ae.empty,s))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?No(e.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=e.state.tr;if(s){let{node:p}=n;p?p.replace(a):a.deleteSelection()}let u=a.mapping.map(l),c=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(c?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(d))return;let f=a.doc.resolve(u);if(c&&H.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new H(f));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,m,b)=>p=b),a.setSelection(Al(e,f,a.doc.resolve(p)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}Ye.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Vt(e)},20))};Ye.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};Ye.beforeinput=(e,t)=>{if(Ht&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,Ln(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in Qe)Ye[e]=Qe[e];function Wr(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Vo=class e{constructor(t,n){this.toDOM=t,this.spec=n||zn,this.side=this.spec.side||0}map(t,n,r,o){let{pos:i,deleted:s}=t.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Ee(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Wr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},Bn=class e{constructor(t,n){this.attrs=t,this.spec=n||zn}map(t,n,r,o){let i=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Ee(i,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof e&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Cl=class e{constructor(t,n){this.attrs=t,this.spec=n||zn}map(t,n,r,o){let i=t.mapResult(n.from+o,1);if(i.deleted)return null;let s=t.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Ee(i.pos-r,s.pos-r,this)}valid(t,n){let{index:r,offset:o}=t.content.findIndex(n.from),i;return o==n.from&&!(i=t.child(r)).isText&&o+i.nodeSize==n.to}eq(t){return this==t||t instanceof e&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}destroy(){}},Ee=class e{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new e(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new e(t,t,new Vo(n,r))}static inline(t,n,r,o){return new e(t,n,new Bn(r,o))}static node(t,n,r,o){return new e(t,n,new Cl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Bn}get widget(){return this.type instanceof Vo}},lr=[],zn={},ue=class e{constructor(t,n){this.local=t.length?t:lr,this.children=n.length?n:lr}static create(t,n){return n.length?Fo(n,t,0,zn):We}find(t,n,r){let o=[];return this.findInner(t??0,n??1e9,o,0,r),o}findInner(t,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=t&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,n-l,r,o+l,i)}}map(t,n,r){return this==We||t.maps.length==0?this:this.mapInner(t,n,0,0,r||zn)}mapInner(t,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(t,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Kb(this.children,s||[],t,n,r,o,i):s?new e(s.sort(Hn),lr):We}add(t,n){return n.length?this==We?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let o,i=0;t.forEach((l,a)=>{let u=a+r,c;if(c=_d(n,l,u)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,c,u+1):o.splice(i,0,a,a+l.nodeSize,Fo(c,l,u+1,zn)),i+=3}});let s=Hd(i?Vd(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||s.splice(l--,1);return new e(s.length?this.local.concat(s).sort(Hn):this.local,o||this.children)}remove(t){return t.length==0||this==We?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let c=0,d;c<t.length;c++)(d=t[c])&&d.from>l&&d.to<a&&(t[c]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(s,l+1);u!=We?r[i+2]=u:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<t.length;i++)if(s=t[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new e(o,r):We}forChild(t,n){if(this==We)return this;if(n.isLeaf)return e.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let i=t+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof Bn){let u=Math.max(i,a.from)-i,c=Math.min(s,a.to)-i;u<c&&(o||(o=[])).push(a.copy(u,c))}}if(o){let l=new e(o.sort(Hn),lr);return r?new jo([l,r]):l}return r||We}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Dl(this.localsInner(t))}localsInner(t){if(this==We)return lr;if(t.inlineContent||!this.local.some(Bn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Bn||n.push(this.local[r]);return n}forEachSet(t){t(this)}};ue.empty=new ue([],[]);ue.removeOverlap=Dl;var We=ue.empty,jo=class e{constructor(t){this.members=t}map(t,n){let r=this.members.map(o=>o.map(t,n,zn));return e.from(r)}forChild(t,n){if(n.isLeaf)return ue.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,n);i!=We&&(i instanceof e?r=r.concat(i.members):r.push(i))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?Dl(r?n:n.sort(Hn)):lr}static from(t){switch(t.length){case 0:return We;case 1:return t[0];default:return new e(t.every(n=>n instanceof ue)?t:t.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function Kb(e,t,n,r,o,i,s){let l=e.slice();for(let u=0,c=i;u<n.maps.length;u++){let d=0;n.maps[u].forEach((f,p,h,g)=>{let m=g-h-(p-f);for(let b=0;b<l.length;b+=3){let v=l[b+1];if(v<0||f>v+c-d)continue;let S=l[b]+c-d;p>=S?l[b+1]=f<=S?-2:-1:f>=c&&m&&(l[b]+=m,l[b+1]+=m)}d+=m}),c=n.maps[u].map(c,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let c=n.map(e[u]+i),d=c-o;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(e[u+1]+i,-1),p=f-o,{index:h,offset:g}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&g==d&&g+m.nodeSize==p){let b=l[u+2].mapInner(n,m,c+1,e[u]+i+1,s);b!=We?(l[u]=d,l[u+1]=p,l[u+2]=b):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Ub(l,e,t,n,o,i,s),c=Fo(u,r,0,s);t=c.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<c.children.length;d+=3){let p=c.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,c.children[d],c.children[d+1],c.children[d+2])}}return new ue(t.sort(Hn),l)}function Hd(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ee(o.from+t,o.to+t,o.type))}return n}function Ub(e,t,n,r,o,i,s){function l(a,u){for(let c=0;c<a.local.length;c++){let d=a.local[c].map(r,o,u);d?n.push(d):s.onRemove&&s.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+u+1)}for(let a=0;a<e.length;a+=3)e[a+1]==-1&&l(e[a+2],t[a]+i+1);return n}function _d(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let i=0,s;i<e.length;i++)(s=e[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),e[i]=null);return o}function Vd(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Fo(e,t,n,r){let o=[],i=!1;t.forEach((l,a)=>{let u=_d(e,l,a+n);if(u){i=!0;let c=Fo(u,l,n+a+1,r);c!=We&&o.push(a,a+l.nodeSize,c)}});let s=Hd(i?Vd(e):e,-n).sort(Hn);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new ue(s,o):We}function Hn(e,t){return e.from-t.from||e.to-t.to}function Dl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),ed(t,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),ed(t,o,r.copy(i.from,r.to)));break}}}return t}function ed(e,t,n){for(;t<e.length&&Hn(n,e[t])>0;)t++;e.splice(t,0,n)}function rl(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=We&&t.push(r)}),e.cursorWrapper&&t.push(ue.create(e.state.doc,[e.cursorWrapper.deco])),jo.from(t)}var qb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gb=nt&&an<=11,xl=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},Sl=class{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);nt&&an<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Ue&&t.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Gb&&(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,qb)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[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(qu(this.view)){if(this.suppressingSelectionUpdates)return Vt(this.view);if(nt&&an<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&_n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,r;for(let i=t.focusNode;i;i=ar(i))n.add(i);for(let i=t.anchorNode;i;i=ar(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:De(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&qu(t)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let c=0;c<n.length;c++){let d=this.registerMutation(n[c],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||ze&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let d=c.nextSibling;for(;d&&j(d);){if(d.contentEditable=="false"){c.parentNode.removeChild(c);break}d=d.firstChild}}}else if(st&&a.length){let c=a.filter(d=>d.nodeName=="BR");if(c.length==2){let[d,f]=c;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of c){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||Yb(t,d)!=p)&&f.remove()}}}let u=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Wo(r)&&(u=Ml(t))&&u.eq(J.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Vt(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),Jb(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Qb(t,a)),this.handleDOMChange(i,s,l,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||Vt(t),this.currentSelection.set(r))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let c=0;c<t.addedNodes.length;c++){let d=t.addedNodes[c];n.push(d),De(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let o=t.previousSibling,i=t.nextSibling;if(nt&&an<=11&&t.addedNodes.length)for(let c=0;c<t.addedNodes.length;c++){let{previousSibling:d,nextSibling:f}=t.addedNodes[c];(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(o=d),(!f||Array.prototype.indexOf.call(t.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==t.target?Be(o)+1:0,l=r.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?Be(i):t.target.childNodes.length,u=r.localPosFromDOM(t.target,a,1);return{from:l,to:u}}else return t.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}},td=new WeakMap,nd=!1;function Jb(e){if(!td.has(e)&&(td.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=st,nd)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."),nd=!0}}function rd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return _n(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Xb(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return rd(e,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?rd(e,n):null}function Yb(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Qb(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!j(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function Zb(e,t,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),u=e.domSelectionRange(),c,d=u.anchorNode;if(d&&Vn(e.dom,d)&&(c=[{node:d,offset:u.anchorOffset}],Wo(u)||c.push({node:u.focusNode,offset:u.focusOffset})),ze&&e.input.lastKeyCode===8)for(let b=s;b>i;b--){let v=o.childNodes[b-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){s=b;break}if(!S||S.size)break}let f=e.state.doc,p=e.someProp("domParser")||Rn.fromSchema(e.state.schema),h=f.resolve(l),g=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ey(r),context:h});if(c&&c[0].pos!=null){let b=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=b),g={anchor:b+l,head:v+l}}return{doc:m,sel:g,from:l,to:a}}var ey=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Ue&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Ue&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},ty=/^(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 ny(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let E=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,B=Ml(e,E);if(B&&!e.state.selection.eq(B)){if(ze&&Ht&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",Q=>Q(e,Ln(13,"Enter"))))return;let oe=e.state.tr.setSelection(B);E=="pointer"?oe.setMeta("pointer",!0):E=="key"&&oe.scrollIntoView(),i&&oe.setMeta("composition",i),e.dispatch(oe)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a=e.state.selection,u=Zb(e,t,n,o),c=e.state.doc,d=c.slice(u.from,u.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p="end"):(f=e.state.selection.from,p="start"),e.input.lastKeyCode=null;let h=sy(d.content,u.doc.content,u.from,f,p);if(h&&e.input.domChangeCount++,(cr&&e.input.lastIOSEnter>Date.now()-225||Ht)&&o.some(E=>j(E)&&!ty.test(E.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",E=>E(e,Ln(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let E=od(e,e.state.doc,u.sel);if(E&&!E.eq(e.state.selection)){let B=e.state.tr.setSelection(E);i&&B.setMeta("composition",i),e.dispatch(B)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof L&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),nt&&an<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let g=u.doc.resolveNoCache(h.start-u.from),m=u.doc.resolveNoCache(h.endB-u.from),b=c.resolve(h.start),v=g.sameParent(m)&&g.parent.inlineContent&&b.end()>=h.endA;if((cr&&e.input.lastIOSEnter>Date.now()-225&&(!v||o.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!v&&iy(u.doc,g.pos,m.pos))&&e.someProp("handleKeyDown",E=>E(e,Ln(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&oy(c,h.start,h.endA,g,m)&&e.someProp("handleKeyDown",E=>E(e,Ln(8,"Backspace")))){Ht&&ze&&e.domObserver.suppressSelectionUpdates();return}ze&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),Ht&&!v&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,m=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(E){return E(e,Ln(13,"Enter"))})},20));let S=h.start,C=h.endA,M=E=>{let B=E||e.state.tr.replace(S,C,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let oe=od(e,B.doc,u.sel);oe&&!(ze&&e.composing&&oe.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(oe.head==S||oe.head==B.mapping.map(C)-1)||nt&&oe.empty&&oe.head==S)&&B.setSelection(oe)}return i&&B.setMeta("composition",i),B.scrollIntoView()},T;if(v)if(g.pos==m.pos){nt&&an<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Vt(e),20));let E=M(e.state.tr.delete(S,C)),B=c.resolve(h.start).marksAcross(c.resolve(h.endA));B&&E.ensureMarks(B),e.dispatch(E)}else if(h.endA==h.endB&&(T=ry(g.parent.content.cut(g.parentOffset,m.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start())))){let E=M(e.state.tr);T.type=="add"?E.addMark(S,C,T.mark):E.removeMark(S,C,T.mark),e.dispatch(E)}else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let E=g.parent.textBetween(g.parentOffset,m.parentOffset),B=()=>M(e.state.tr.insertText(E,S,C));e.someProp("handleTextInput",oe=>oe(e,S,C,E,B))||e.dispatch(B())}else e.dispatch(M());else e.dispatch(M())}function od(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Al(e,t.resolve(n.anchor),t.resolve(n.head))}function ry(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,o=n,i=r,s,l,a;for(let c=0;c<r.length;c++)o=r[c].removeFromSet(o);for(let c=0;c<n.length;c++)i=n[c].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=c=>c.mark(l.addToSet(c.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<t.childCount;c++)u.push(a(t.child(c)));if(z.from(u).eq(e))return{mark:l,type:s}}function oy(e,t,n,r,o){if(n-t<=o.pos-r.pos||ol(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==t+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(ol(i,!0,!0));return!s.parent.isTextblock||s.pos>n||ol(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function iy(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(i,s)=>{i.isTextblock&&s>=t&&s<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,t-s),Math.min(i.nodeSize,n-s))):i.isLeaf)&&o++}),o==0&&r==1}function ol(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let i=e.node(r).maybeChild(e.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function sy(e,t,n,r,o){let i=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(i==null)return null;let{a,b:u}=e.findDiffEnd(t,s,l);if(o=="end"){let c=Math.max(0,i-Math.min(a,u));r-=a+c-i}if(a<i&&s<l){let c=r<=i&&r>=a?i-r:0;i-=c,u=i+(u-a),a=i}else if(u<i){let c=r<=i&&r>=u?i-r:0;i-=c,a=i+(a-u),u=i}return{start:i,endA:a,endB:u}}var Kr=class{constructor(t,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 yl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(cd),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=ld(this),sd(this),this.nodeViews=ad(this),this.docView=Vu(this.state.doc,id(this),rl(this),this.dom,this),this.domObserver=new Sl(this,(r,o,i,s)=>ny(this,r,o,i,s)),this.domObserver.start(),Mb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&wl(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(cd),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in t)n[r]=t[r];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var r;let o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&($d(this),s=!0),this.state=t;let l=o.plugins!=t.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=ad(this);ay(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&wl(this),this.editable=ld(this),sd(this);let a=rl(this),u=id(this),c=o.plugins!=t.plugins&&!o.doc.eq(t.doc)?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(t.doc,u,a);(d||!t.selection.eq(o.selection))&&(s=!0);let f=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Wg(this);if(s){this.domObserver.stop();let p=d&&(nt||ze)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&ly(o.selection,t.selection);if(d){let g=ze?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Hb(this)),(i||!this.docView.update(t.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Vu(t.doc,u,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let h=this.input.mouseDown;p||!(h&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&db(this)&&h.delaySelUpdate())?Vt(this,p):(xd(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():f&&Kg(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!Vn(this.dom,t))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof H){let n=this.docView.domAfterPos(this.state.selection.from);j(n)&&$u(this,n.getBoundingClientRect(),t)}else $u(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.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,t)}}updateDraggedNode(t,n){let r=t.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new _o(t.slice,t.move,o<0?void 0:H.create(this.state.doc,o))}someProp(t,n){let r=this._props&&this._props[t],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[t];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[t];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(nt){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Ug(this.dom),Vt(this),this.domObserver.start()}get root(){let t=this._root;if(t==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 t||document}updateRoot(){this._root=null}posAtCoords(t){return Yg(this,t)}coordsAtPos(t,n=1){return bd(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,r=-1){let o=this.docView.posFromDOM(t,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,n){return nb(this,n||this.state,t)}pasteHTML(t,n){return Fr(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return Fr(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return Tl(this,t)}destroy(){this.docView&&(Ab(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ig())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Nb(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?Ue&&this.root.nodeType===11&&Hg(this.dom.ownerDocument)==this.dom&&Xb(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Kr.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function id(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let r in n)r=="class"?t.class+=" "+n[r]:r=="style"?t.style=(t.style?t.style+";":"")+n[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[Ee.node(0,e.state.doc.content.size,t)]}function sd(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Ee.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function ld(e){return!e.someProp("editable",t=>t(e.state)===!1)}function ly(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function ad(e){let t=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=r[o])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function ay(e,t){let n=0,r=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let o in t)r++;return n!=r}function cd(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var jt={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:"'"},qo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cy=typeof navigator<"u"&&/Mac/.test(navigator.platform),uy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Te=0;Te<10;Te++)jt[48+Te]=jt[96+Te]=String(Te);var Te;for(Te=1;Te<=24;Te++)jt[Te+111]="F"+Te;var Te;for(Te=65;Te<=90;Te++)jt[Te]=String.fromCharCode(Te+32),qo[Te]=String.fromCharCode(Te);var Te;for(Uo in jt)qo.hasOwnProperty(Uo)||(qo[Uo]=jt[Uo]);var Uo;function jd(e){var t=cy&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||uy&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?qo:jt)[e.keyCode]||e.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}var dy=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fy=typeof navigator<"u"&&/Win/.test(navigator.platform);function py(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l++){let a=t[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))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))dy?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function hy(e){let t=Object.create(null);for(let n in e)t[py(n)]=e[n];return t}function Ll(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Fd(e){return new W({props:{handleKeyDown:Jr(e)}})}function Jr(e){let t=hy(e);return function(n,r){let o=jd(r),i,s=t[Ll(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=t[Ll(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fy&&r.ctrlKey&&r.altKey)&&(i=jt[r.keyCode])&&i!=o){let l=t[Ll(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Go=200,He=function(){};He.prototype.append=function(t){return t.length?(t=He.from(t),!this.length&&t||t.length<Go&&this.leafAppend(t)||this.length<Go&&t.leafPrepend(this)||this.appendInner(t)):this};He.prototype.prepend=function(t){return t.length?He.from(t).append(this):this};He.prototype.appendInner=function(t){return new my(this,t)};He.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?He.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};He.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};He.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};He.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},n,r),o};He.from=function(t){return t instanceof He?t:t&&t.length?new Wd(t):He.empty};var Wd=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new t(this.values.slice(o,i))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},t.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=Go)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=Go)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(He);He.empty=new Wd([]);var my=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(He),Il=He;var gy=500,Fn=class e{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=t.tr,l,a,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,c.push(d);return}if(o){c.push(new St(d.map));let p=d.step.map(o.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],u.push(new St(h,void 0,void 0,u.length+c.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new e(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(t,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let c=0;c<t.steps.length;c++){let d=t.steps[c].invert(t.docs[c]),f=new St(t.mapping.maps[c],d,n),p;(p=a&&a.merge(f))&&(f=p,c?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let u=s-r.depth;return u>yy&&(l=by(l,u),s-=u),new e(l.append(i),s)}remapping(t,n){let r=new To;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},t,n),r}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(n=>new St(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,i=t.mapping,s=t.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let p=i.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=i.maps[p];if(f.step){let g=t.steps[p].invert(t.docs[p]),m=f.selection&&f.selection.map(i.slice(a+1,p));m&&l++,r.push(new St(h,g,m))}else r.push(new St(h))},o);let u=[];for(let f=n;f<s;f++)u.push(new St(i.maps[f]));let c=this.items.slice(0,o).append(u).append(r),d=new e(c,l);return d.emptyItemCount()>gy&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=t)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let c=s.selection&&s.selection.map(n.slice(r));c&&i++;let d=new St(u.invert(),a,c),f,p=o.length-1;(f=o.length&&o[p].merge(d))?o[p]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new e(Il.from(o.reverse()),i)}};Fn.empty=new Fn(Il.empty,0);function by(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}var St=class e{constructor(t,n,r,o){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Et=class{constructor(t,n,r,o,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},yy=20;function wy(e,t,n,r){let o=n.getMeta(dn),i;if(o)return o.historyState;n.getMeta(qd)&&(e=new Et(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(s&&s.getMeta(dn))return s.getMeta(dn).redo?new Et(e.done.addTransform(n,void 0,r,Jo(t)),e.undone,Kd(n.mapping.maps),e.prevTime,e.prevComposition):new Et(e.done,e.undone.addTransform(n,void 0,r,Jo(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=e.prevTime==0||!s&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ky(n,e.prevRanges)),u=s?Pl(e.prevRanges,n.mapping):Kd(n.mapping.maps);return new Et(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Jo(t)),Fn.empty,u,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Et(e.done.rebased(n,i),e.undone.rebased(n,i),Pl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Et(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Pl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ky(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&o>=t[i]&&(n=!0)}),n}function Kd(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,o,i,s)=>t.push(i,s));return t}function Pl(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function vy(e,t,n){let r=Jo(t),o=dn.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new Et(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(dn,{redo:n,historyState:a})}var $l=!1,Ud=null;function Jo(e){let t=e.plugins;if(Ud!=t){$l=!1,Ud=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){$l=!0;break}}return $l}function ur(e){return e.setMeta(qd,!0)}var dn=new ne("history"),qd=new ne("closeHistory");function Gd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new W({key:dn,state:{init(){return new Et(Fn.empty,Fn.empty,null,0,-1)},apply(t,n,r){return wy(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?Bl:r=="historyRedo"?zl:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function Xo(e,t){return(n,r)=>{let o=dn.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(r){let i=vy(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var Bl=Xo(!1,!0),zl=Xo(!0,!0),_1=Xo(!1,!1),V1=Xo(!0,!1);function Jd(e){return e.getMeta(dn)!=null}function ni(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var mr=class ff{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>{let d=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!t,u=t||i.tr,c=()=>(!a&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(u),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...g)=>{let m=this.buildProps(u,n),b=p(...g)(m);return l.push(b),d}])),run:c};return d}static createFakeChain(){let t=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>t}});return t}createCan(t){let{rawCommands:n,state:r}=this,o=!1,i=t||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...u)=>a(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let t=ff.createFakeChain();return new Proxy({chain:()=>t},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:t,editor:o,view:s,state:ni({state:i,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([a,u])=>[a,(...c)=>u(...c)(l)]))}};return l}},Cy=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),xy=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Sy=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{e.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:u,mapping:c}=t,d=u.resolve(c.map(a)),f=u.resolve(c.map(a+l.nodeSize)),p=d.blockRange(f);if(!p)return;let h=$t(p);if(l.type.isTextblock){let{defaultType:g}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(p.start,g)}(h||h===0)&&t.lift(p,h)})}),!0},Ey=e=>t=>e(t),My=()=>({state:e,dispatch:t})=>Js(e,t),Ay=(e,t)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new L(r.doc.resolve(Math.max(s-1,0)))),!0},Ty=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(t){let s=o.before(i),l=o.after(i);e.delete(s,l).scrollIntoView()}return!0}return!1};function Ne(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Ny=e=>({tr:t,state:n,dispatch:r})=>{let o=Ne(e,n.schema),i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1},Ry=e=>({tr:t,dispatch:n})=>{let{from:r,to:o}=e;return n&&t.delete(r,o),!0},Oy=e=>e.content?/^text(\*|\+)/.test(e.content):!1,Xd=(e,t,n)=>{if(!e.parent.isInline||n==="left"&&e.pos>e.start()||n==="right"&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return Oy(r)?n==="left"?e.start()-1:e.end()+1:e.pos},Dy=(e,t,n)=>({from:Xd(e,n,"left"),to:Xd(t,n,"right")}),Ly=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,o=n.steps.length;r.forEach(i=>{let s=n.mapping.slice(o),l=n.doc.resolve(s.map(i.$from.pos)),a=n.doc.resolve(s.map(i.$to.pos)),{from:u,to:c}=Dy(l,a,e.schema);n.deleteRange(u,c)}),n.selection.empty||n.setSelection(L.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},Iy=()=>({commands:e})=>e.keyboardShortcut("Enter"),Py=()=>({state:e,dispatch:t})=>Gs(e,t);function Ul(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ti(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:Ul(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function pf(e,t,n={}){return e.find(r=>r.type===t&&ti(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Yd(e,t,n={}){return!!pf(e,t,n)}function ql(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===t))return;if(!n){let a=r.node.marks.find(u=>u.type===t);a&&(n=a.attrs)}if(!pf([...r.node.marks],t,n))return;let o=r.index,i=e.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&Yd([...e.parent.child(o-1).marks],t,n);)o-=1,i-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&Yd([...e.parent.child(s).marks],t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function Ft(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var $y=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=Ft(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:u,to:c}=l;if(o){let d=ql(a,i,t);if(d&&d.from<=u&&d.to>=c){let f=L.create(s,d.from,d.to);n.setSelection(f)}}return!0},By=e=>t=>{let n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function ri(e){return e instanceof L}function Wn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function jl(e,t=null){if(!t)return null;let n=J.atStart(e),r=J.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;let o=n.from,i=r.to;return t==="all"?L.create(e,Wn(0,o,i),Wn(e.content.size,o,i)):L.create(e,Wn(t,o,i),Wn(t,o,i))}function Qr(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Kn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function zy(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Hy=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(Kn()||Qr())&&r.dom.focus(),zy()&&!Kn()&&!Qr()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(i&&e===null&&!ri(n.state.selection))return s(),!0;let l=jl(o.doc,e)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},_y=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),Vy=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),hf=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&hf(r)}return e};function Yo(e){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return hf(n)}function mf(e){return typeof e?.nodesBetween=="function"}function gr(e,t,n){if(mf(e))return e;let r=typeof e=="object"&&e!==null;n={slice:!0,parseOptions:{},...n};let o=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return z.fromArray(e.map(s=>t.nodeFromJSON(s)));let i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),gr("",t,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new Ps({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Rn.fromSchema(a).parseSlice(Yo(e),n.parseOptions):Rn.fromSchema(a).parse(Yo(e),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Rn.fromSchema(t);return n.slice?i.parseSlice(Yo(e),n.parseOptions).content:i.parse(Yo(e),n.parseOptions)}return gr("",t,n)}function gf(e){return!("type"in e)}function bf(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Dn||o instanceof Ct))return;let i=e.mapping.maps[r],s=0;i.forEach((l,a,u,c)=>{s===0&&(s=c)}),e.setSelection(J.near(e.doc.resolve(s),n))}var jy=(e,t,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=m=>{i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{gr(t,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(m){a(m)}try{var s;l=gr(t,i.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(m){return a(m),!1}let{from:c,to:d}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},f=!0,p=!0,h=gf(l)?l.content:[l];if(h.forEach(m=>{m.check(),f=f?m.isText&&m.marks.length===0:!1,p=p?m.isBlock:!1}),c===d&&p){let{parent:m}=r.doc.resolve(c);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(c-=1,d+=1)}let g;if(f)Array.isArray(t)?g=t.map(m=>m.text||"").join(""):mf(t)?g=h.map(m=>{var b;return(b=m.text)!==null&&b!==void 0?b:""}).join(""):typeof t=="object"&&t&&t.text?g=t.text:g=t,r.insertText(g,c,d);else{g=z.from(h);let m=r.doc.resolve(c),b=m.node(),v=m.parentOffset===0,S=b.isText||b.isTextblock,C=b.content.size>0;v&&S&&C&&p&&(c=Math.max(0,c-1)),r.replaceWith(c,d,h)}n.updateSelection&&bf(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:g})}return!0};function yf(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Fy=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=e,a;typeof o=="number"?a=t.doc.resolve(o):o?a=o:a=t.selection.$from;let u=yf(a.parent.contentMatchAt(a.index()));if(!u)return!1;let c=Object.keys(u.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([p])=>c.includes(p))):{},f;if(s){let p=gr(s,r.schema);f=u.createAndFill(d,p)}else f=u.createAndFill(d);return f?(n&&(t.insert(a.pos,f),l&&bf(t,t.steps.length-1,-1)),!0):!1},Wy=()=>({state:e,dispatch:t})=>Su(e,t),Ky=()=>({state:e,dispatch:t})=>Eu(e,t),Uy=()=>({state:e,dispatch:t})=>_s(e,t),qy=()=>({state:e,dispatch:t})=>Fs(e,t),wf=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},Gy=()=>({state:e,dispatch:t,tr:n})=>{try{let r=rr(e.doc,e.selection.$from.pos,-1);return r==null||!wf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Jy=()=>({state:e,dispatch:t,tr:n})=>{try{let r=rr(e.doc,e.selection.$from.pos,1);return r==null||!wf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Xy=()=>({state:e,dispatch:t})=>ku(e,t),Yy=()=>({state:e,dispatch:t})=>vu(e,t);function kf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Qy(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l+=1){let a=t[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))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Kn()||kf()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Zy=e=>({editor:t,view:n,tr:r,dispatch:o})=>{let i=Qy(e).split(/-(?!$)/),s=i.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=t.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return a?.steps.forEach(u=>{let c=u.map(r.mapping);c&&o&&r.maybeStep(c)}),!0};function Mt(e,t,n={}){let{from:r,to:o,empty:i}=e.selection,s=t?Ne(t,e.schema):null,l=[];e.doc.nodesBetween(r,o,(c,d)=>{if(c.isText)return;let f=Math.max(r,d),p=Math.min(o,d+c.nodeSize);l.push({node:c,from:f,to:p})});let a=o-r,u=l.filter(c=>s?s.name===c.node.type.name:!0).filter(c=>ti(c.node.attrs,n,{strict:!1}));return i?!!u.length:u.reduce((c,d)=>c+d.to-d.from,0)>=a}var e0=(e,t={})=>({state:n,dispatch:r})=>Mt(n,Ne(e,n.schema),t)?Mu(n,r):!1,t0=()=>({state:e,dispatch:t})=>Xs(e,t),n0=e=>({state:t,dispatch:n})=>{let r=Ne(e,t.schema);return Du(r)(t,n)},r0=()=>({state:e,dispatch:t})=>Us(e,t);function oi(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Qd(e,t){let n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}var o0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=oi(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Ne(e,r.schema)),l==="mark"&&(s=Ft(e,r.schema));let a=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(c,d)=>{i&&i===c.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,Qd(c.attrs,t))),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(d,d+c.nodeSize,s.create(Qd(f.attrs,t))))})})}),a},i0=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),s0=()=>({tr:e,dispatch:t})=>{if(t){let n=new rn(e.doc);e.setSelection(n)}return!0},l0=()=>({state:e,dispatch:t})=>Vs(e,t),a0=()=>({state:e,dispatch:t})=>Ws(e,t),c0=()=>({state:e,dispatch:t})=>Au(e,t),u0=()=>({state:e,dispatch:t})=>Qs(e,t),d0=()=>({state:e,dispatch:t})=>Ys(e,t);function Fl(e,t,n={},r={}){return gr(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var f0=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let u=Fl(e,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});if(s){let c=gf(u)?u.content:[u];i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n)}return!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},e,{parseOptions:r,errorOnInvalidContent:t??o.options.enableContentCheck})};function vf(e,t){let n=Ft(t,e.schema),{from:r,to:o,empty:i}=e.selection,s=[];i?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Gl(e,t){let n=new Oo(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Un(e,t){let n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function Cf(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function yr(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function ii(e){return t=>yr(t.$from,e)}function P(e,t,n){return e.config[t]===void 0&&e.parent?P(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?P(e.parent,t,n):null}):e.config[t]}function Jl(e){return e.map(t=>{let n=P(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return n?[t,...Jl(n())]:t}).flat(10)}function Xl(e,t){let n=On.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Wl(e){return typeof e=="function"}function de(e,t=void 0,...n){return Wl(e)?t?e.bind(t)(...n):e(...n):e}function p0(e={}){return Object.keys(e).length===0&&e.constructor===Object}function br(e){return{baseExtensions:e.filter(t=>t.type==="extension"),nodeExtensions:e.filter(t=>t.type==="node"),markExtensions:e.filter(t=>t.type==="mark")}}function xf(e){let t=[],{nodeExtensions:n,markExtensions:r}=br(e),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(u=>u.name!=="text").map(u=>u.name),l=r.map(u=>u.name),a=[...s,...l];return e.forEach(u=>{let c=P(u,"addGlobalAttributes",{name:u.name,options:u.options,storage:u.storage,extensions:o});c&&c().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=s:d.types==="marks"?f=l:f=[],f.forEach(p=>{Object.entries(d.attributes).forEach(([h,g])=>{t.push({type:p,name:h,attribute:{...i,...g}})})})})}),o.forEach(u=>{let c=P(u,"addAttributes",{name:u.name,options:u.options,storage:u.storage});if(!c)return;let d=c();Object.entries(d).forEach(([f,p])=>{let h={...i,...p};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,t.push({type:u.name,name:f,attribute:h})})}),t}function h0(e){let t=[],n="",r=!1,o=!1,i=0,s=e.length;for(let l=0;l<s;l+=1){let a=e[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){t.push(n),n="";continue}}n+=a}return n&&t.push(n),t}function Zd(e){let t=[],n=h0(e||""),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(":");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&t.push([l,a])}return t}function U(...e){return e.filter(t=>!!t).reduce((t,n)=>{let r={...t};return Object.entries(n).forEach(([o,i])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o==="class"){let s=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],a=s.filter(u=>!l.includes(u));r[o]=[...l,...a].join(" ")}else if(o==="style"){let s=new Map([...Zd(r[o]),...Zd(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function At(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>U(n,r),{})}function m0(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function ef(e,t){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let o=t.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):m0(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function tf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&p0(n)?!1:n!=null))}function nf(e){var t,n;let r={};return!(!(e==null||(t=e.attribute)===null||t===void 0)&&t.isRequired)&&"default"in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function g0(e,t){var n;let r=xf(e),{nodeExtensions:o,markExtensions:i}=br(e),s=(n=o.find(u=>P(u,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(o.map(u=>{let c=r.filter(m=>m.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:t},f=tf({...e.reduce((m,b)=>{let v=P(b,"extendNodeSchema",d);return{...m,...v?v(u):{}}},{}),content:de(P(u,"content",d)),marks:de(P(u,"marks",d)),group:de(P(u,"group",d)),inline:de(P(u,"inline",d)),atom:de(P(u,"atom",d)),selectable:de(P(u,"selectable",d)),draggable:de(P(u,"draggable",d)),code:de(P(u,"code",d)),whitespace:de(P(u,"whitespace",d)),linebreakReplacement:de(P(u,"linebreakReplacement",d)),defining:de(P(u,"defining",d)),isolating:de(P(u,"isolating",d)),attrs:Object.fromEntries(c.map(nf))}),p=de(P(u,"parseHTML",d));p&&(f.parseDOM=p.map(m=>ef(m,c)));let h=P(u,"renderHTML",d);h&&(f.toDOM=m=>h({node:m,HTMLAttributes:At(m,c)}));let g=P(u,"renderText",d);return g&&(f.toText=g),[u.name,f]})),a=Object.fromEntries(i.map(u=>{let c=r.filter(g=>g.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:t},f=tf({...e.reduce((g,m)=>{let b=P(m,"extendMarkSchema",d);return{...g,...b?b(u):{}}},{}),inclusive:de(P(u,"inclusive",d)),excludes:de(P(u,"excludes",d)),group:de(P(u,"group",d)),spanning:de(P(u,"spanning",d)),code:de(P(u,"code",d)),attrs:Object.fromEntries(c.map(nf))}),p=de(P(u,"parseHTML",d));p&&(f.parseDOM=p.map(g=>ef(g,c)));let h=P(u,"renderHTML",d);return h&&(f.toDOM=g=>h({mark:g,HTMLAttributes:At(g,c)})),[u.name,f]}));return new Ps({topNode:s,nodes:l,marks:a})}function b0(e){let t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}function Yr(e){return e.sort((n,r)=>{let o=P(n,"priority")||100,i=P(r,"priority")||100;return o>i?-1:o<i?1:0})}function Sf(e){let t=Yr(Jl(e)),n=b0(t.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.`),t}function Ef(e,t,n){let{from:r,to:o}=t,{blockSeparator:i=`
|
|
7
|
+
`);return{dom:a,text:f,slice:t}}function Rd(e,t,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!t)return null;let a=!!t&&(r||i||!n);if(a){if(e.someProp("transformPastedText",f=>{t=f(t,i||r,e)}),i)return l=new ce(z.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
8
|
+
`))),0,0),e.someProp("transformPasted",f=>{l=f(l,e,!0)}),l;let d=e.someProp("clipboardTextParser",f=>f(t,o,r,e));if(d)l=d;else{let f=o.marks(),{schema:p}=e.state,h=Dn.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(p.text(g,f)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),s=Ab(n),Uo&&Tb(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let f=s.firstChild;for(;f&&!W(f);)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||On.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Sb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Nb(rd(l,+c[1],+c[2]),c[4]);else if(l=ce.maxOpen(Eb(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=rd(l,d,f)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var Sb=/^(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 Eb(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&i.length&&Dd(a,i,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=Ld(s[s.length-1],i.length));let c=Od(l,a);s.push(c),o=o.matchType(c.type),i=a}}),s)return z.from(s)}return e}function Od(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,z.from(e));return e}function Dd(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Dd(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(z.from(Od(n,e,o+1))))}}function Ld(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Ld(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(z.empty,!0);return e.copy(n.append(r))}function yl(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=yl(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function rd(e,t,n){return t<e.openStart&&(e=new ce(yl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ce(yl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Id={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 Pd(){return document.implementation.createHTMLDocument("title")}var Hr=null;function Mb(e){let t=window.trustedTypes;if(!t)return e;if(!Hr){if(Hr=t.defaultPolicy)try{return Hr.createHTML(e)}catch{}Hr=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Hr.createHTML(e)}function Ab(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Pd(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(e),i;if((i=o&&Id[o[1].toLowerCase()])&&(e=i.map(s=>"<"+s+">").join("")+e+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Mb(e),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[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 u=l.rules[a];if(u instanceof CSSStyleRule){let c=r.querySelectorAll(u.selectorText);for(let d=0;d<c.length;d++)c[d].style.cssText+=u.style.cssText}}}return r}function Tb(e){let t=e.querySelectorAll(He?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Nb(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:o,openStart:i,openEnd:s}=e;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=z.from(a.create(r[l+1],o))}catch{break}i++,s++}return new ce(o,i,s)}var Ye={},Qe={},Rb={touchstart:!0,touchmove:!0},wl=class{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 Ob(e){for(let t in Ye){let n=Ye[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{Lb(e,r)&&!Rl(e,r)&&(e.editable||!(r.type in Qe))&&n(e,r)},Rb[t]?{passive:!0}:void 0)}Ue&&e.dom.addEventListener("input",()=>null),kl(e)}function _t(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Db(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function kl(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>Rl(e,r))})}function Rl(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Lb(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Ib(e,t){!Rl(e,t)&&Ye[t.type]&&(e.editable||!(t.type in Qe))&&Ye[t.type](e,t)}Qe.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!zd(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Ht&&He&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),fr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,In(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||xb(e,n)?n.preventDefault():_t(e,"key")};Qe.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Qe.keypress=(e,t)=>{let n=t;if(zd(e)||!n.charCode||n.ctrlKey&&!n.altKey||ft&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof L)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",s=>s(e,r.$from.pos,r.$to.pos,o,i))&&e.dispatch(i()),n.preventDefault()}};function qr(e){return{left:e.clientX,top:e.clientY}}function Pb(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Ol(e,t,n,r,o){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(e.someProp(t,l=>s>i.depth?l(e,n,i.nodeAfter,i.before(s),o,!0):l(e,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Gr(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function $b(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&_.isSelectable(r)?(Gr(e,new _(n)),!0):!1}function Bb(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof _&&(r=n.node);let i=e.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(_.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Gr(e,_.create(e.state.doc,o)),!0):!1}function zb(e,t,n,r,o){return Ol(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(o?Bb(e,n):$b(e,n))}function Hb(e,t,n,r){return Ol(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function _b(e,t,n,r){return Ol(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||Vb(e,n,r)}function Vb(e,t,n){if(n.button!=0)return!1;let r=$d(e,t,!0),o=e.state.doc;return r?(Gr(e,r),r instanceof L&&o.eq(e.state.doc)&&(e.input.mouseDown=new Cl(e,r)),!0):!1}function $d(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?L.create(r,0,r.content.size):null;let o=r.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return L.create(r,l+1,l+1+s.content.size);if(n&&_.isSelectable(s))return _.create(r,l)}return null}function Dl(e){return _o(e)}var Bd=ft?"metaKey":"ctrlKey";Ye.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Dl(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&Pb(n,e.input.lastClick)&&!n[Bd]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(qr(n));s&&(i=="singleClick"?e.input.mouseDown=new vl(e,s,n,!!r):(i=="doubleClick"?Hb:_b)(e,s.pos,s.inside,n)?n.preventDefault():_t(e,"pointer"))};var Ho=class{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.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}},vl=class extends Ho{constructor(t,n,r,o){super(t),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!r[Bd],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),s=n.inside;else{let c=t.state.doc.resolve(n.pos);i=c.parent,s=c.depth?c.before():0}let l=o?null:r.target,a=l?t.docView.nearestDesc(l,!0):null;this.target=a&&W(a.nodeDOM)?a.nodeDOM:null;let{selection:u}=t.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof _&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&st&&!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(t,"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||Vt(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(qr(t))),this.updateAllowDefault(t),this.allowDefault||!n?_t(this.view,"pointer"):zb(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Ue&&this.mightDrag&&!this.mightDrag.node.isAtom||He&&!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)?(Gr(this.view,X.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):_t(this.view,"pointer")}move(t){this.updateAllowDefault(t),_t(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Cl=class extends Ho{constructor(t,n){super(t),this.startSelection=n,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),_t(this.view,"pointer");let n=this.view.posAtCoords(qr(t)),r=n&&$d(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Gr(this.view,L.create(o,s,l))}};Ye.touchstart=e=>{e.input.lastTouch=Date.now(),Dl(e),_t(e,"pointer")};Ye.touchmove=e=>{e.input.lastTouch=Date.now(),_t(e,"pointer")};Ye.contextmenu=e=>Dl(e);function zd(e,t){return e.composing?!0:Ue&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var jb=Ht?5e3:-1;Qe.compositionstart=Qe.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof L&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||He&&gd&&Fb(e)))e.markCursor=e.state.storedMarks||n.marks(),_o(e,!0),e.markCursor=null;else if(_o(e,!t.selection.empty),st&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&W(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(De(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}Hd(e,jb)};function Fb(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!W(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return W(r)&&r.contentEditable=="false"}Qe.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Hd(e,20))};function Hd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>_o(e),t))}function _d(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Wb(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Vg(t.focusNode,t.focusOffset),r=jg(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function _o(e,t=!1){if(!(Ht&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),_d(e),t||e.docView&&e.docView.dirty){let n=Al(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Kb(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var jr=nt&&cn<15||fr&&Ug<604;Ye.copy=Qe.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let i=jr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Nl(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Kb(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ub(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function qb(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fr(e,r.value,null,o,t):Fr(e,r.textContent,r.innerHTML,o,t)},50)}function Fr(e,t,n,r,o){let i=Rd(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,o,i||ce.empty)))return!0;if(!i)return!1;let s=Ub(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Vd(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Qe.paste=(e,t)=>{let n=t;if(e.composing&&!Ht)return;let r=jr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fr(e,Vd(r),r.getData("text/html"),o,n)?n.preventDefault():qb(e,n)};var Vo=class{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}},Gb=ft?"altKey":"ctrlKey";function jd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[Gb]}Ye.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(qr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof _?o.to-1:o.to))){if(r&&r.mightDrag)s=_.create(e.state.doc,r.mightDrag.pos);else if(n.target&&W(n.target)){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(s=_.create(e.state.doc,d.posBefore))}}let l=(s||e.state.selection).content(),{dom:a,text:u,slice:c}=Nl(e,l);(!n.dataTransfer.files.length||!He||md>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",jr||n.dataTransfer.setData("text/plain",u),e.dragging=new Vo(c,jd(e,n),s)};Ye.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Qe.dragover=Qe.dragenter=(e,t)=>t.preventDefault();Qe.drop=(e,t)=>{try{Jb(e,t,e.dragging)}finally{e.dragging=null}};function Jb(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(qr(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",p=>{i=p(i,e,!1)}):i=Rd(e,Vd(t.dataTransfer),jr?null:t.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&jd(e,t));if(e.someProp("handleDrop",p=>p(e,t,i||ce.empty,s))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?Ro(e.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=e.state.tr;if(s){let{node:p}=n;p?p.replace(a):a.deleteSelection()}let u=a.mapping.map(l),c=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(c?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(d))return;let f=a.doc.resolve(u);if(c&&_.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new _(f));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,m,b)=>p=b),a.setSelection(Tl(e,f,a.doc.resolve(p)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}Ye.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Vt(e)},20))};Ye.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};Ye.beforeinput=(e,t)=>{if(Ht&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,In(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in Qe)Ye[e]=Qe[e];function Wr(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var jo=class e{constructor(t,n){this.toDOM=t,this.spec=n||Hn,this.side=this.spec.side||0}map(t,n,r,o){let{pos:i,deleted:s}=t.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Ee(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Wr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},zn=class e{constructor(t,n){this.attrs=t,this.spec=n||Hn}map(t,n,r,o){let i=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Ee(i,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof e&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},xl=class e{constructor(t,n){this.attrs=t,this.spec=n||Hn}map(t,n,r,o){let i=t.mapResult(n.from+o,1);if(i.deleted)return null;let s=t.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Ee(i.pos-r,s.pos-r,this)}valid(t,n){let{index:r,offset:o}=t.content.findIndex(n.from),i;return o==n.from&&!(i=t.child(r)).isText&&o+i.nodeSize==n.to}eq(t){return this==t||t instanceof e&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}destroy(){}},Ee=class e{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new e(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new e(t,t,new jo(n,r))}static inline(t,n,r,o){return new e(t,n,new zn(r,o))}static node(t,n,r,o){return new e(t,n,new xl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof zn}get widget(){return this.type instanceof jo}},ur=[],Hn={},ue=class e{constructor(t,n){this.local=t.length?t:ur,this.children=n.length?n:ur}static create(t,n){return n.length?Wo(n,t,0,Hn):We}find(t,n,r){let o=[];return this.findInner(t??0,n??1e9,o,0,r),o}findInner(t,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=t&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,n-l,r,o+l,i)}}map(t,n,r){return this==We||t.maps.length==0?this:this.mapInner(t,n,0,0,r||Hn)}mapInner(t,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(t,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Xb(this.children,s||[],t,n,r,o,i):s?new e(s.sort(_n),ur):We}add(t,n){return n.length?this==We?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let o,i=0;t.forEach((l,a)=>{let u=a+r,c;if(c=Wd(n,l,u)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,c,u+1):o.splice(i,0,a,a+l.nodeSize,Wo(c,l,u+1,Hn)),i+=3}});let s=Fd(i?Kd(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||s.splice(l--,1);return new e(s.length?this.local.concat(s).sort(_n):this.local,o||this.children)}remove(t){return t.length==0||this==We?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let c=0,d;c<t.length;c++)(d=t[c])&&d.from>l&&d.to<a&&(t[c]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(s,l+1);u!=We?r[i+2]=u:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<t.length;i++)if(s=t[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new e(o,r):We}forChild(t,n){if(this==We)return this;if(n.isLeaf)return e.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let i=t+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof zn){let u=Math.max(i,a.from)-i,c=Math.min(s,a.to)-i;u<c&&(o||(o=[])).push(a.copy(u,c))}}if(o){let l=new e(o.sort(_n),ur);return r?new Fo([l,r]):l}return r||We}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Ll(this.localsInner(t))}localsInner(t){if(this==We)return ur;if(t.inlineContent||!this.local.some(zn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof zn||n.push(this.local[r]);return n}forEachSet(t){t(this)}};ue.empty=new ue([],[]);ue.removeOverlap=Ll;var We=ue.empty,Fo=class e{constructor(t){this.members=t}map(t,n){let r=this.members.map(o=>o.map(t,n,Hn));return e.from(r)}forChild(t,n){if(n.isLeaf)return ue.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,n);i!=We&&(i instanceof e?r=r.concat(i.members):r.push(i))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?Ll(r?n:n.sort(_n)):ur}static from(t){switch(t.length){case 0:return We;case 1:return t[0];default:return new e(t.every(n=>n instanceof ue)?t:t.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function Xb(e,t,n,r,o,i,s){let l=e.slice();for(let u=0,c=i;u<n.maps.length;u++){let d=0;n.maps[u].forEach((f,p,h,g)=>{let m=g-h-(p-f);for(let b=0;b<l.length;b+=3){let k=l[b+1];if(k<0||f>k+c-d)continue;let C=l[b]+c-d;p>=C?l[b+1]=f<=C?-2:-1:f>=c&&m&&(l[b]+=m,l[b+1]+=m)}d+=m}),c=n.maps[u].map(c,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let c=n.map(e[u]+i),d=c-o;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(e[u+1]+i,-1),p=f-o,{index:h,offset:g}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&g==d&&g+m.nodeSize==p){let b=l[u+2].mapInner(n,m,c+1,e[u]+i+1,s);b!=We?(l[u]=d,l[u+1]=p,l[u+2]=b):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Yb(l,e,t,n,o,i,s),c=Wo(u,r,0,s);t=c.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<c.children.length;d+=3){let p=c.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,c.children[d],c.children[d+1],c.children[d+2])}}return new ue(t.sort(_n),l)}function Fd(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ee(o.from+t,o.to+t,o.type))}return n}function Yb(e,t,n,r,o,i,s){function l(a,u){for(let c=0;c<a.local.length;c++){let d=a.local[c].map(r,o,u);d?n.push(d):s.onRemove&&s.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+u+1)}for(let a=0;a<e.length;a+=3)e[a+1]==-1&&l(e[a+2],t[a]+i+1);return n}function Wd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let i=0,s;i<e.length;i++)(s=e[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),e[i]=null);return o}function Kd(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Wo(e,t,n,r){let o=[],i=!1;t.forEach((l,a)=>{let u=Wd(e,l,a+n);if(u){i=!0;let c=Wo(u,l,n+a+1,r);c!=We&&o.push(a,a+l.nodeSize,c)}});let s=Fd(i?Kd(e):e,-n).sort(_n);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new ue(s,o):We}function _n(e,t){return e.from-t.from||e.to-t.to}function Ll(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),od(t,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),od(t,o,r.copy(i.from,r.to)));break}}}return t}function od(e,t,n){for(;t<e.length&&_n(n,e[t])>0;)t++;e.splice(t,0,n)}function ol(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=We&&t.push(r)}),e.cursorWrapper&&t.push(ue.create(e.state.doc,[e.cursorWrapper.deco])),Fo.from(t)}var Qb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Zb=nt&&cn<=11,Sl=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},El=class{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Sl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);nt&&cn<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Ue&&t.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Zb&&(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,Qb)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[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(Yu(this.view)){if(this.suppressingSelectionUpdates)return Vt(this.view);if(nt&&cn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Vn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,r;for(let i=t.focusNode;i;i=dr(i))n.add(i);for(let i=t.anchorNode;i;i=dr(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:De(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Yu(t)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let c=0;c<n.length;c++){let d=this.registerMutation(n[c],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||He&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let d=c.nextSibling;for(;d&&W(d);){if(d.contentEditable=="false"){c.parentNode.removeChild(c);break}d=d.firstChild}}}else if(st&&a.length){let c=a.filter(d=>d.nodeName=="BR");if(c.length==2){let[d,f]=c;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of c){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||ny(t,d)!=p)&&f.remove()}}}let u=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ko(r)&&(u=Al(t))&&u.eq(X.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Vt(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),ey(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,ry(t,a)),this.handleDOMChange(i,s,l,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||Vt(t),this.currentSelection.set(r))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let c=0;c<t.addedNodes.length;c++){let d=t.addedNodes[c];n.push(d),De(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let o=t.previousSibling,i=t.nextSibling;if(nt&&cn<=11&&t.addedNodes.length)for(let c=0;c<t.addedNodes.length;c++){let{previousSibling:d,nextSibling:f}=t.addedNodes[c];(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(o=d),(!f||Array.prototype.indexOf.call(t.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==t.target?ze(o)+1:0,l=r.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?ze(i):t.target.childNodes.length,u=r.localPosFromDOM(t.target,a,1);return{from:l,to:u}}else return t.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}},id=new WeakMap,sd=!1;function ey(e){if(!id.has(e)&&(id.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=st,sd)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."),sd=!0}}function ld(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Vn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function ty(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return ld(e,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?ld(e,n):null}function ny(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function ry(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!W(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function oy(e,t,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),u=e.domSelectionRange(),c,d=u.anchorNode;if(d&&jn(e.dom,d)&&(c=[{node:d,offset:u.anchorOffset}],Ko(u)||c.push({node:u.focusNode,offset:u.focusOffset})),He&&e.input.lastKeyCode===8)for(let b=s;b>i;b--){let k=o.childNodes[b-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){s=b;break}if(!C||C.size)break}let f=e.state.doc,p=e.someProp("domParser")||On.fromSchema(e.state.schema),h=f.resolve(l),g=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:iy(r),context:h});if(c&&c[0].pos!=null){let b=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=b),g={anchor:b+l,head:k+l}}return{doc:m,sel:g,from:l,to:a}}var iy=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Ue&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Ue&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},sy=/^(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 ly(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let M=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,B=Al(e,M);if(B&&!e.state.selection.eq(B)){if(He&&Ht&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",Q=>Q(e,In(13,"Enter"))))return;let ie=e.state.tr.setSelection(B);M=="pointer"?ie.setMeta("pointer",!0):M=="key"&&ie.scrollIntoView(),i&&ie.setMeta("composition",i),e.dispatch(ie)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a=e.state.selection,u=oy(e,t,n,o),c=e.state.doc,d=c.slice(u.from,u.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p="end"):(f=e.state.selection.from,p="start"),e.input.lastKeyCode=null;let h=dy(d.content,u.doc.content,u.from,f,p);if(h&&e.input.domChangeCount++,(fr&&e.input.lastIOSEnter>Date.now()-225||Ht)&&o.some(M=>W(M)&&!sy.test(M.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",M=>M(e,In(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let M=ad(e,e.state.doc,u.sel);if(M&&!M.eq(e.state.selection)){let B=e.state.tr.setSelection(M);i&&B.setMeta("composition",i),e.dispatch(B)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof L&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),nt&&cn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let g=u.doc.resolveNoCache(h.start-u.from),m=u.doc.resolveNoCache(h.endB-u.from),b=c.resolve(h.start),k=g.sameParent(m)&&g.parent.inlineContent&&b.end()>=h.endA;if((fr&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!k&&uy(u.doc,g.pos,m.pos))&&e.someProp("handleKeyDown",M=>M(e,In(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&cy(c,h.start,h.endA,g,m)&&e.someProp("handleKeyDown",M=>M(e,In(8,"Backspace")))){Ht&&He&&e.domObserver.suppressSelectionUpdates();return}He&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),Ht&&!k&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,m=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(M){return M(e,In(13,"Enter"))})},20));let C=h.start,x=h.endA,E=M=>{let B=M||e.state.tr.replace(C,x,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let ie=ad(e,B.doc,u.sel);ie&&!(He&&e.composing&&ie.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(ie.head==C||ie.head==B.mapping.map(x)-1)||nt&&ie.empty&&ie.head==C)&&B.setSelection(ie)}return i&&B.setMeta("composition",i),B.scrollIntoView()},A;if(k)if(g.pos==m.pos){nt&&cn<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Vt(e),20));let M=E(e.state.tr.delete(C,x)),B=c.resolve(h.start).marksAcross(c.resolve(h.endA));B&&M.ensureMarks(B),e.dispatch(M)}else if(h.endA==h.endB&&(A=ay(g.parent.content.cut(g.parentOffset,m.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start())))){let M=E(e.state.tr);A.type=="add"?M.addMark(C,x,A.mark):M.removeMark(C,x,A.mark),e.dispatch(M)}else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let M=g.parent.textBetween(g.parentOffset,m.parentOffset),B=()=>E(e.state.tr.insertText(M,C,x));e.someProp("handleTextInput",ie=>ie(e,C,x,M,B))||e.dispatch(B())}else e.dispatch(E());else e.dispatch(E())}function ad(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Tl(e,t.resolve(n.anchor),t.resolve(n.head))}function ay(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,o=n,i=r,s,l,a;for(let c=0;c<r.length;c++)o=r[c].removeFromSet(o);for(let c=0;c<n.length;c++)i=n[c].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=c=>c.mark(l.addToSet(c.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<t.childCount;c++)u.push(a(t.child(c)));if(z.from(u).eq(e))return{mark:l,type:s}}function cy(e,t,n,r,o){if(n-t<=o.pos-r.pos||il(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==t+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(il(i,!0,!0));return!s.parent.isTextblock||s.pos>n||il(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function uy(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(i,s)=>{i.isTextblock&&s>=t&&s<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,t-s),Math.min(i.nodeSize,n-s))):i.isLeaf)&&o++}),o==0&&r==1}function il(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let i=e.node(r).maybeChild(e.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function dy(e,t,n,r,o){let i=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(i==null)return null;let{a,b:u}=e.findDiffEnd(t,s,l);if(o=="end"){let c=Math.max(0,i-Math.min(a,u));r-=a+c-i}if(a<i&&s<l){let c=r<=i&&r>=a?i-r:0;i-=c,u=i+(u-a),a=i}else if(u<i){let c=r<=i&&r>=u?i-r:0;i-=c,a=i+(a-u),u=i}return{start:i,endA:a,endB:u}}var Kr=class{constructor(t,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 wl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(pd),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=dd(this),ud(this),this.nodeViews=fd(this),this.docView=Ku(this.state.doc,cd(this),ol(this),this.dom,this),this.domObserver=new El(this,(r,o,i,s)=>ly(this,r,o,i,s)),this.domObserver.start(),Ob(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&kl(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(pd),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in t)n[r]=t[r];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var r;let o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(_d(this),s=!0),this.state=t;let l=o.plugins!=t.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=fd(this);py(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&kl(this),this.editable=dd(this),ud(this);let a=ol(this),u=cd(this),c=o.plugins!=t.plugins&&!o.doc.eq(t.doc)?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(t.doc,u,a);(d||!t.selection.eq(o.selection))&&(s=!0);let f=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Jg(this);if(s){this.domObserver.stop();let p=d&&(nt||He)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&fy(o.selection,t.selection);if(d){let g=He?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Wb(this)),(i||!this.docView.update(t.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Ku(t.doc,u,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let h=this.input.mouseDown;p||!(h&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gb(this)&&h.delaySelUpdate())?Vt(this,p):(Ad(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():f&&Xg(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!jn(this.dom,t))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof _){let n=this.docView.domAfterPos(this.state.selection.from);W(n)&&_u(this,n.getBoundingClientRect(),t)}else _u(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.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,t)}}updateDraggedNode(t,n){let r=t.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Vo(t.slice,t.move,o<0?void 0:_.create(this.state.doc,o))}someProp(t,n){let r=this._props&&this._props[t],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[t];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[t];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(nt){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Yg(this.dom),Vt(this),this.domObserver.start()}get root(){let t=this._root;if(t==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 t||document}updateRoot(){this._root=null}posAtCoords(t){return nb(this,t)}coordsAtPos(t,n=1){return vd(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,r=-1){let o=this.docView.posFromDOM(t,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,n){return lb(this,n||this.state,t)}pasteHTML(t,n){return Fr(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return Fr(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return Nl(this,t)}destroy(){this.docView&&(Db(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ol(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Hg())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Ib(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?Ue&&this.root.nodeType===11&&Wg(this.dom.ownerDocument)==this.dom&&ty(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Kr.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function cd(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let r in n)r=="class"?t.class+=" "+n[r]:r=="style"?t.style=(t.style?t.style+";":"")+n[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[Ee.node(0,e.state.doc.content.size,t)]}function ud(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Ee.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function dd(e){return!e.someProp("editable",t=>t(e.state)===!1)}function fy(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function fd(e){let t=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=r[o])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function py(e,t){let n=0,r=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let o in t)r++;return n!=r}function pd(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var jt={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:'"'},hy=typeof navigator<"u"&&/Mac/.test(navigator.platform),my=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Te=0;Te<10;Te++)jt[48+Te]=jt[96+Te]=String(Te);var Te;for(Te=1;Te<=24;Te++)jt[Te+111]="F"+Te;var Te;for(Te=65;Te<=90;Te++)jt[Te]=String.fromCharCode(Te+32),Go[Te]=String.fromCharCode(Te);var Te;for(qo in jt)Go.hasOwnProperty(qo)||(Go[qo]=jt[qo]);var qo;function Ud(e){var t=hy&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||my&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Go:jt)[e.keyCode]||e.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}var gy=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),by=typeof navigator<"u"&&/Win/.test(navigator.platform);function yy(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l++){let a=t[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))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))gy?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function wy(e){let t=Object.create(null);for(let n in e)t[yy(n)]=e[n];return t}function Il(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function qd(e){return new K({props:{handleKeyDown:Jr(e)}})}function Jr(e){let t=wy(e);return function(n,r){let o=Ud(r),i,s=t[Il(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=t[Il(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(by&&r.ctrlKey&&r.altKey)&&(i=jt[r.keyCode])&&i!=o){let l=t[Il(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Jo=200,_e=function(){};_e.prototype.append=function(t){return t.length?(t=_e.from(t),!this.length&&t||t.length<Jo&&this.leafAppend(t)||this.length<Jo&&t.leafPrepend(this)||this.appendInner(t)):this};_e.prototype.prepend=function(t){return t.length?_e.from(t).append(this):this};_e.prototype.appendInner=function(t){return new ky(this,t)};_e.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?_e.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};_e.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};_e.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};_e.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},n,r),o};_e.from=function(t){return t instanceof _e?t:t&&t.length?new Gd(t):_e.empty};var Gd=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new t(this.values.slice(o,i))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},t.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=Jo)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=Jo)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(_e);_e.empty=new Gd([]);var ky=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(_e),Pl=_e;var vy=500,Wn=class e{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=t.tr,l,a,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,c.push(d);return}if(o){c.push(new St(d.map));let p=d.step.map(o.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],u.push(new St(h,void 0,void 0,u.length+c.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new e(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(t,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let c=0;c<t.steps.length;c++){let d=t.steps[c].invert(t.docs[c]),f=new St(t.mapping.maps[c],d,n),p;(p=a&&a.merge(f))&&(f=p,c?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let u=s-r.depth;return u>xy&&(l=Cy(l,u),s-=u),new e(l.append(i),s)}remapping(t,n){let r=new No;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},t,n),r}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(n=>new St(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,i=t.mapping,s=t.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let p=i.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=i.maps[p];if(f.step){let g=t.steps[p].invert(t.docs[p]),m=f.selection&&f.selection.map(i.slice(a+1,p));m&&l++,r.push(new St(h,g,m))}else r.push(new St(h))},o);let u=[];for(let f=n;f<s;f++)u.push(new St(i.maps[f]));let c=this.items.slice(0,o).append(u).append(r),d=new e(c,l);return d.emptyItemCount()>vy&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=t)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let c=s.selection&&s.selection.map(n.slice(r));c&&i++;let d=new St(u.invert(),a,c),f,p=o.length-1;(f=o.length&&o[p].merge(d))?o[p]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new e(Pl.from(o.reverse()),i)}};Wn.empty=new Wn(Pl.empty,0);function Cy(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}var St=class e{constructor(t,n,r,o){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Et=class{constructor(t,n,r,o,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},xy=20;function Sy(e,t,n,r){let o=n.getMeta(fn),i;if(o)return o.historyState;n.getMeta(Yd)&&(e=new Et(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(s&&s.getMeta(fn))return s.getMeta(fn).redo?new Et(e.done.addTransform(n,void 0,r,Xo(t)),e.undone,Jd(n.mapping.maps),e.prevTime,e.prevComposition):new Et(e.done,e.undone.addTransform(n,void 0,r,Xo(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=e.prevTime==0||!s&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Ey(n,e.prevRanges)),u=s?$l(e.prevRanges,n.mapping):Jd(n.mapping.maps);return new Et(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Xo(t)),Wn.empty,u,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Et(e.done.rebased(n,i),e.undone.rebased(n,i),$l(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Et(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),$l(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Ey(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&o>=t[i]&&(n=!0)}),n}function Jd(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,o,i,s)=>t.push(i,s));return t}function $l(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function My(e,t,n){let r=Xo(t),o=fn.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new Et(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(fn,{redo:n,historyState:a})}var Bl=!1,Xd=null;function Xo(e){let t=e.plugins;if(Xd!=t){Bl=!1,Xd=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Bl=!0;break}}return Bl}function pr(e){return e.setMeta(Yd,!0)}var fn=new ne("history"),Yd=new ne("closeHistory");function Qd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new K({key:fn,state:{init(){return new Et(Wn.empty,Wn.empty,null,0,-1)},apply(t,n,r){return Sy(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?zl:r=="historyRedo"?Hl:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function Yo(e,t){return(n,r)=>{let o=fn.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(r){let i=My(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var zl=Yo(!1,!0),Hl=Yo(!0,!0),q1=Yo(!1,!1),G1=Yo(!0,!1);function Zd(e){return e.getMeta(fn)!=null}function ri(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var yr=class gf{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>{let d=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!t,u=t||i.tr,c=()=>(!a&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(u),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...g)=>{let m=this.buildProps(u,n),b=p(...g)(m);return l.push(b),d}])),run:c};return d}static createFakeChain(){let t=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>t}});return t}createCan(t){let{rawCommands:n,state:r}=this,o=!1,i=t||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...u)=>a(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let t=gf.createFakeChain();return new Proxy({chain:()=>t},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(t,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:t,editor:o,view:s,state:ri({state:i,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([a,u])=>[a,(...c)=>u(...c)(l)]))}};return l}},Ay=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Ty=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Ny=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{e.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:u,mapping:c}=t,d=u.resolve(c.map(a)),f=u.resolve(c.map(a+l.nodeSize)),p=d.blockRange(f);if(!p)return;let h=$t(p);if(l.type.isTextblock){let{defaultType:g}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(p.start,g)}(h||h===0)&&t.lift(p,h)})}),!0},Ry=e=>t=>e(t),Oy=()=>({state:e,dispatch:t})=>Xs(e,t),Dy=(e,t)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new L(r.doc.resolve(Math.max(s-1,0)))),!0},Ly=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(t){let s=o.before(i),l=o.after(i);e.delete(s,l).scrollIntoView()}return!0}return!1};function Ne(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Iy=e=>({tr:t,state:n,dispatch:r})=>{let o=Ne(e,n.schema),i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1},Py=e=>({tr:t,dispatch:n})=>{let{from:r,to:o}=e;return n&&t.delete(r,o),!0},$y=e=>e.content?/^text(\*|\+)/.test(e.content):!1,ef=(e,t,n)=>{if(!e.parent.isInline||n==="left"&&e.pos>e.start()||n==="right"&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return $y(r)?n==="left"?e.start()-1:e.end()+1:e.pos},By=(e,t,n)=>({from:ef(e,n,"left"),to:ef(t,n,"right")}),zy=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,o=n.steps.length;r.forEach(i=>{let s=n.mapping.slice(o),l=n.doc.resolve(s.map(i.$from.pos)),a=n.doc.resolve(s.map(i.$to.pos)),{from:u,to:c}=By(l,a,e.schema);n.deleteRange(u,c)}),n.selection.empty||n.setSelection(L.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},Hy=()=>({commands:e})=>e.keyboardShortcut("Enter"),_y=()=>({state:e,dispatch:t})=>Js(e,t);function ql(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ni(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:ql(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function bf(e,t,n={}){return e.find(r=>r.type===t&&ni(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function tf(e,t,n={}){return!!bf(e,t,n)}function Gl(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===t))return;if(!n){let a=r.node.marks.find(u=>u.type===t);a&&(n=a.attrs)}if(!bf([...r.node.marks],t,n))return;let o=r.index,i=e.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&tf([...e.parent.child(o-1).marks],t,n);)o-=1,i-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&tf([...e.parent.child(s).marks],t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function Ft(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var Vy=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=Ft(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:u,to:c}=l;if(o){let d=Gl(a,i,t);if(d&&d.from<=u&&d.to>=c){let f=L.create(s,d.from,d.to);n.setSelection(f)}}return!0},jy=e=>t=>{let n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function oi(e){return e instanceof L}function Kn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Fl(e,t=null){if(!t)return null;let n=X.atStart(e),r=X.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;let o=n.from,i=r.to;return t==="all"?L.create(e,Kn(0,o,i),Kn(e.content.size,o,i)):L.create(e,Kn(t,o,i),Kn(t,o,i))}function Qr(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Un(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Fy(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Wy=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(Un()||Qr())&&r.dom.focus(),Fy()&&!Un()&&!Qr()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(i&&e===null&&!oi(n.state.selection))return s(),!0;let l=Fl(o.doc,e)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Ky=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),Uy=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),yf=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&yf(r)}return e};function Qo(e){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return yf(n)}function wf(e){return typeof e?.nodesBetween=="function"}function wr(e,t,n){if(wf(e))return e;let r=typeof e=="object"&&e!==null;n={slice:!0,parseOptions:{},...n};let o=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return z.fromArray(e.map(s=>t.nodeFromJSON(s)));let i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),wr("",t,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new $s({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?On.fromSchema(a).parseSlice(Qo(e),n.parseOptions):On.fromSchema(a).parse(Qo(e),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=On.fromSchema(t);return n.slice?i.parseSlice(Qo(e),n.parseOptions).content:i.parse(Qo(e),n.parseOptions)}return wr("",t,n)}function kf(e){return!("type"in e)}function vf(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Ln||o instanceof Ct))return;let i=e.mapping.maps[r],s=0;i.forEach((l,a,u,c)=>{s===0&&(s=c)}),e.setSelection(X.near(e.doc.resolve(s),n))}var qy=(e,t,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=m=>{i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{wr(t,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(m){a(m)}try{var s;l=wr(t,i.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(m){return a(m),!1}let{from:c,to:d}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},f=!0,p=!0,h=kf(l)?l.content:[l];if(h.forEach(m=>{m.check(),f=f?m.isText&&m.marks.length===0:!1,p=p?m.isBlock:!1}),c===d&&p){let{parent:m}=r.doc.resolve(c);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(c-=1,d+=1)}let g;if(f)Array.isArray(t)?g=t.map(m=>m.text||"").join(""):wf(t)?g=h.map(m=>{var b;return(b=m.text)!==null&&b!==void 0?b:""}).join(""):typeof t=="object"&&t&&t.text?g=t.text:g=t,r.insertText(g,c,d);else{g=z.from(h);let m=r.doc.resolve(c),b=m.node(),k=m.parentOffset===0,C=b.isText||b.isTextblock,x=b.content.size>0;k&&C&&x&&p&&(c=Math.max(0,c-1)),r.replaceWith(c,d,h)}n.updateSelection&&vf(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:g})}return!0};function Cf(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Gy=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=e,a;typeof o=="number"?a=t.doc.resolve(o):o?a=o:a=t.selection.$from;let u=Cf(a.parent.contentMatchAt(a.index()));if(!u)return!1;let c=Object.keys(u.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([p])=>c.includes(p))):{},f;if(s){let p=wr(s,r.schema);f=u.createAndFill(d,p)}else f=u.createAndFill(d);return f?(n&&(t.insert(a.pos,f),l&&vf(t,t.steps.length-1,-1)),!0):!1},Jy=()=>({state:e,dispatch:t})=>Tu(e,t),Xy=()=>({state:e,dispatch:t})=>Nu(e,t),Yy=()=>({state:e,dispatch:t})=>Vs(e,t),Qy=()=>({state:e,dispatch:t})=>Ws(e,t),xf=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},Zy=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sr(e.doc,e.selection.$from.pos,-1);return r==null||!xf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},e0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sr(e.doc,e.selection.$from.pos,1);return r==null||!xf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},t0=()=>({state:e,dispatch:t})=>Su(e,t),n0=()=>({state:e,dispatch:t})=>Eu(e,t);function Sf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function r0(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<t.length-1;l+=1){let a=t[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))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Un()||Sf()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var o0=e=>({editor:t,view:n,tr:r,dispatch:o})=>{let i=r0(e).split(/-(?!$)/),s=i.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=t.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return a?.steps.forEach(u=>{let c=u.map(r.mapping);c&&o&&r.maybeStep(c)}),!0};function Mt(e,t,n={}){let{from:r,to:o,empty:i}=e.selection,s=t?Ne(t,e.schema):null,l=[];e.doc.nodesBetween(r,o,(c,d)=>{if(c.isText)return;let f=Math.max(r,d),p=Math.min(o,d+c.nodeSize);l.push({node:c,from:f,to:p})});let a=o-r,u=l.filter(c=>s?s.name===c.node.type.name:!0).filter(c=>ni(c.node.attrs,n,{strict:!1}));return i?!!u.length:u.reduce((c,d)=>c+d.to-d.from,0)>=a}var i0=(e,t={})=>({state:n,dispatch:r})=>Mt(n,Ne(e,n.schema),t)?Ru(n,r):!1,s0=()=>({state:e,dispatch:t})=>Ys(e,t),l0=e=>({state:t,dispatch:n})=>{let r=Ne(e,t.schema);return $u(r)(t,n)},a0=()=>({state:e,dispatch:t})=>qs(e,t);function ii(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function nf(e,t){let n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}var c0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ii(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Ne(e,r.schema)),l==="mark"&&(s=Ft(e,r.schema));let a=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(c,d)=>{i&&i===c.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,nf(c.attrs,t))),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(d,d+c.nodeSize,s.create(nf(f.attrs,t))))})})}),a},u0=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),d0=()=>({tr:e,dispatch:t})=>{if(t){let n=new on(e.doc);e.setSelection(n)}return!0},f0=()=>({state:e,dispatch:t})=>js(e,t),p0=()=>({state:e,dispatch:t})=>Ks(e,t),h0=()=>({state:e,dispatch:t})=>Ou(e,t),m0=()=>({state:e,dispatch:t})=>Zs(e,t),g0=()=>({state:e,dispatch:t})=>Qs(e,t);function Wl(e,t,n={},r={}){return wr(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var b0=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let u=Wl(e,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});if(s){let c=kf(u)?u.content:[u];i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n)}return!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},e,{parseOptions:r,errorOnInvalidContent:t??o.options.enableContentCheck})};function Ef(e,t){let n=Ft(t,e.schema),{from:r,to:o,empty:i}=e.selection,s=[];i?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Jl(e,t){let n=new Do(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function qn(e,t){let n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function Mf(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function vr(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function si(e){return t=>vr(t.$from,e)}function P(e,t,n){return e.config[t]===void 0&&e.parent?P(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?P(e.parent,t,n):null}):e.config[t]}function Xl(e){return e.map(t=>{let n=P(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return n?[t,...Xl(n())]:t}).flat(10)}function Yl(e,t){let n=Dn.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Kl(e){return typeof e=="function"}function de(e,t=void 0,...n){return Kl(e)?t?e.bind(t)(...n):e(...n):e}function y0(e={}){return Object.keys(e).length===0&&e.constructor===Object}function kr(e){return{baseExtensions:e.filter(t=>t.type==="extension"),nodeExtensions:e.filter(t=>t.type==="node"),markExtensions:e.filter(t=>t.type==="mark")}}function Af(e){let t=[],{nodeExtensions:n,markExtensions:r}=kr(e),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(u=>u.name!=="text").map(u=>u.name),l=r.map(u=>u.name),a=[...s,...l];return e.forEach(u=>{let c=P(u,"addGlobalAttributes",{name:u.name,options:u.options,storage:u.storage,extensions:o});c&&c().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=s:d.types==="marks"?f=l:f=[],f.forEach(p=>{Object.entries(d.attributes).forEach(([h,g])=>{t.push({type:p,name:h,attribute:{...i,...g}})})})})}),o.forEach(u=>{let c=P(u,"addAttributes",{name:u.name,options:u.options,storage:u.storage});if(!c)return;let d=c();Object.entries(d).forEach(([f,p])=>{let h={...i,...p};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,t.push({type:u.name,name:f,attribute:h})})}),t}function w0(e){let t=[],n="",r=!1,o=!1,i=0,s=e.length;for(let l=0;l<s;l+=1){let a=e[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){t.push(n),n="";continue}}n+=a}return n&&t.push(n),t}function rf(e){let t=[],n=w0(e||""),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(":");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&t.push([l,a])}return t}function U(...e){return e.filter(t=>!!t).reduce((t,n)=>{let r={...t};return Object.entries(n).forEach(([o,i])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o==="class"){let s=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],a=s.filter(u=>!l.includes(u));r[o]=[...l,...a].join(" ")}else if(o==="style"){let s=new Map([...rf(r[o]),...rf(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function At(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>U(n,r),{})}function k0(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function of(e,t){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let o=t.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):k0(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function sf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&y0(n)?!1:n!=null))}function lf(e){var t,n;let r={};return!(!(e==null||(t=e.attribute)===null||t===void 0)&&t.isRequired)&&"default"in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function v0(e,t){var n;let r=Af(e),{nodeExtensions:o,markExtensions:i}=kr(e),s=(n=o.find(u=>P(u,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(o.map(u=>{let c=r.filter(m=>m.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:t},f=sf({...e.reduce((m,b)=>{let k=P(b,"extendNodeSchema",d);return{...m,...k?k(u):{}}},{}),content:de(P(u,"content",d)),marks:de(P(u,"marks",d)),group:de(P(u,"group",d)),inline:de(P(u,"inline",d)),atom:de(P(u,"atom",d)),selectable:de(P(u,"selectable",d)),draggable:de(P(u,"draggable",d)),code:de(P(u,"code",d)),whitespace:de(P(u,"whitespace",d)),linebreakReplacement:de(P(u,"linebreakReplacement",d)),defining:de(P(u,"defining",d)),isolating:de(P(u,"isolating",d)),attrs:Object.fromEntries(c.map(lf))}),p=de(P(u,"parseHTML",d));p&&(f.parseDOM=p.map(m=>of(m,c)));let h=P(u,"renderHTML",d);h&&(f.toDOM=m=>h({node:m,HTMLAttributes:At(m,c)}));let g=P(u,"renderText",d);return g&&(f.toText=g),[u.name,f]})),a=Object.fromEntries(i.map(u=>{let c=r.filter(g=>g.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:t},f=sf({...e.reduce((g,m)=>{let b=P(m,"extendMarkSchema",d);return{...g,...b?b(u):{}}},{}),inclusive:de(P(u,"inclusive",d)),excludes:de(P(u,"excludes",d)),group:de(P(u,"group",d)),spanning:de(P(u,"spanning",d)),code:de(P(u,"code",d)),attrs:Object.fromEntries(c.map(lf))}),p=de(P(u,"parseHTML",d));p&&(f.parseDOM=p.map(g=>of(g,c)));let h=P(u,"renderHTML",d);return h&&(f.toDOM=g=>h({mark:g,HTMLAttributes:At(g,c)})),[u.name,f]}));return new $s({topNode:s,nodes:l,marks:a})}function C0(e){let t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}function Yr(e){return e.sort((n,r)=>{let o=P(n,"priority")||100,i=P(r,"priority")||100;return o>i?-1:o<i?1:0})}function Tf(e){let t=Yr(Xl(e)),n=C0(t.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.`),t}function Nf(e,t,n){let{from:r,to:o}=t,{blockSeparator:i=`
|
|
9
9
|
|
|
10
|
-
`,textSerializers:s={}}=n||{},l="";return e.nodesBetween(r,o,(a,u,c,d)=>{a.isBlock&&u>r&&(l+=i);let f=s?.[a.type.name];if(f)return c&&(l+=f({node:a,pos:u,parent:c,index:d,range:t})),!1;if(a.isText){var p;l+=a==null||(p=a.text)===null||p===void 0?void 0:p.slice(Math.max(r,u)-u,o-u)}}),l}function y0(e,t){return Ef(e,{from:0,to:e.content.size},t)}function Mf(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function w0(e,t){let n=Ne(t,e.schema),{from:r,to:o}=e.selection,i=[];e.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Yl(e,t){let n=oi(typeof t=="string"?t:t.name,e.schema);return n==="node"?w0(e,t):n==="mark"?vf(e,t):{}}function k0(e,t=JSON.stringify){let n={};return e.filter(r=>{let o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function v0(e){let t=k0(e);return t.length===1?t:t.filter((n,r)=>!t.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function wr(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let u=t.slice(i).map(l,-1),c=t.slice(i).map(a),d=t.invert().map(u,-1),f=t.invert().map(c);r.push({oldRange:{from:d,to:f},newRange:{from:u,to:c}})})}),v0(r)}function Zr(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(o=>{let i=ql(n.resolve(e),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Af=(e,t,n,r=20)=>{let o=e.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===t?s=l:i-=1}return[s,i]},Tf=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function dr(e,t){return t.nodes[e]||t.marks[e]||null}function ei(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=e.find(i=>i.type===t&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var C0=(e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,i,s,l)=>{var a,u;let c=((a=(u=o.type.spec).toText)===null||a===void 0?void 0:a.call(u,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?c:c.slice(0,Math.max(0,r-i))}),n};function Kl(e,t,n={}){let{empty:r,ranges:o}=e.selection,i=t?Ft(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(c=>i?i.name===c.type.name:!0).find(c=>ti(c.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:c,$to:d})=>{let f=c.pos,p=d.pos;e.doc.nodesBetween(f,p,(h,g)=>{if(i&&h.inlineContent&&!h.type.allowsMarkType(i))return!1;if(!h.isText&&!h.marks.length)return;let m=Math.max(f,g),b=Math.min(p,g+h.nodeSize),v=b-m;s+=v,l.push(...h.marks.map(S=>({mark:S,from:m,to:b})))})}),s===0)return!1;let a=l.filter(c=>i?i.name===c.mark.type.name:!0).filter(c=>ti(c.mark.attrs,n,{strict:!1})).reduce((c,d)=>c+d.to-d.from,0),u=l.filter(c=>i?c.mark.type!==i&&c.mark.type.excludes(i):!0).reduce((c,d)=>c+d.to-d.from,0);return(a>0?a+u:a)>=s}function x0(e,t,n={}){if(!t)return Mt(e,null,n)||Kl(e,null,n);let r=oi(t,e.schema);return r==="node"?Mt(e,t,n):r==="mark"?Kl(e,t,n):!1}var Nf=(e,t)=>{let{$from:n,$to:r,$anchor:o}=e.selection;if(t){let i=ii(l=>l.type.name===t)(e.selection);if(!i)return!1;let s=e.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Rf=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function rf(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function Hl(e,t){let{nodeExtensions:n}=br(t),r=n.find(i=>i.name===e);if(!r)return!1;let o=de(P(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function kr(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name==="hardBreak")return!0;if(e.isText){var r;return!/\S/.test((r=e.text)!==null&&r!==void 0?r:"")}}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let o=!0;return e.content.forEach(i=>{o!==!1&&(kr(i,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function si(e){return e instanceof H}var Of=class Df{constructor(t){this.position=t}static fromJSON(t){return new Df(t.position)}toJSON(){return{position:this.position}}};function S0(e,t){let n=t.mapping.mapResult(e.position);return{position:new Of(n.pos),mapResult:n}}function E0(e){return new Of(e)}function M0(e,t,n){let{selection:r}=t,o=null;if(ri(r)&&(o=r.$cursor),o){var i;let l=(i=e.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let u=l.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(l.pos,a.pos,(c,d,f)=>{if(u)return!1;if(c.isInline){let p=!f||f.type.allowsMarkType(n),h=!!n.isInSet(c.marks)||!c.marks.some(g=>g.type.excludes(n));u=p&&h}return!u}),u})}var A0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=Ft(e,r.schema);if(o)if(s){let u=vf(r,a);n.addStoredMark(a.create({...u,...t}))}else l.forEach(u=>{let c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(f,p)=>{let h=Math.max(p,c),g=Math.min(p+f.nodeSize,d);f.marks.find(m=>m.type===a)?f.marks.forEach(m=>{a===m.type&&n.addMark(h,g,a.create({...m.attrs,...t}))}):n.addMark(h,g,a.create(t))})});return M0(r,n,a)},T0=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),N0=(e,t={})=>({state:n,dispatch:r,chain:o})=>{let i=Ne(e,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Zs(i,{...s,...t})(n)?!0:l.clearNodes()).command(({state:l})=>Zs(i,{...s,...t})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},R0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,o=Wn(e,0,r.content.size),i=H.create(r,o);t.setSelection(i)}return!0},O0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof t=="number"?(s=t,l=t):t&&"from"in t&&"to"in t?(s=t.from,l=t.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,u)=>{a.isText||n.setNodeMarkup(u,void 0,{...a.attrs,dir:e})}),!0},D0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:o,to:i}=typeof e=="number"?{from:e,to:e}:e,s=L.atStart(r).from,l=L.atEnd(r).to,a=Wn(o,s,l),u=Wn(i,s,l),c=L.create(r,a,u);t.setSelection(c)}return!0},L0=e=>({state:t,dispatch:n})=>{let r=Ne(e,t.schema);return Lu(r)(t,n)};function of(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(o=>t?.includes(o.type.name));e.tr.ensureMarks(r)}}var I0=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=t,{$from:l,$to:a}=i,u=o.extensionManager.attributes,c=ei(u,l.node().type.name,l.node().attrs);if(i instanceof H&&i.node.isBlock)return!l.parentOffset||!dt(s,l.pos)?!1:(r&&(e&&of(n,o.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:yf(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=d&&f?[{type:f,attrs:c}]:void 0,h=i instanceof L&&!i.empty?Br.create({doc:t.doc,selection:i}).tr.deleteSelection():null,g=h?h.doc:t.doc,m=h?h.mapping.map(l.pos):l.pos,b=dt(g,m,1,p);if(!p&&!b&&dt(g,m,1,f?[{type:f}]:void 0)&&(b=!0,p=f?[{type:f,attrs:c}]:void 0),r){if(b){let v=t.steps.length;if(i instanceof L&&t.deleteSelection(),t.split(t.mapping.slice(v).map(l.pos),1,p),f&&!d&&!l.parentOffset&&l.parent.type!==f){let S=t.mapping.slice(v).map(l.before()),C=t.doc.resolve(S);l.node(-1).canReplaceWith(C.index(),C.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(v).map(l.before()),f)}}e&&of(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return b},P0=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Ne(e,r.schema),{$from:l,$to:a}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(a))return!1;let c=l.node(-1);if(c.type!==s)return!1;let d=i.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(o){var f;let C=z.empty,M=l.index(-1)?1:l.index(-2)?2:3;for(let me=l.depth-M;me>=l.depth-3;me-=1)C=z.from(l.node(me).copy(C));let T=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...ei(d,l.node().type.name,l.node().attrs),...t},B=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(E))||void 0;C=C.append(z.from(s.createAndFill(null,B)||void 0));let oe=l.before(l.depth-(M-1));n.replace(oe,l.after(-T),new ae(C,4-M,0));let Q=-1;n.doc.nodesBetween(oe,n.doc.content.size,(me,it)=>{if(Q>-1)return!1;me.isTextblock&&me.content.size===0&&(Q=it+1)}),Q>-1&&n.setSelection(L.near(n.doc.resolve(Q))),n.scrollIntoView()}return!0}let p=a.pos===l.end()?c.contentMatchAt(0).defaultType:null,h={...ei(d,c.type.name,c.attrs),...t},g={...ei(d,l.node().type.name,l.node().attrs),...t},m=l.parentOffset===0&&l.index(-1)===0,b=l.before(-1);n.delete(l.pos,a.pos);let v=m?c.attrs:h,S=p?[{type:s,attrs:v},{type:p,attrs:g}]:[{type:s,attrs:v}];if(!dt(n.doc,l.pos,2))return!1;if(o){let{selection:C,storedMarks:M}=r,{splittableMarks:T}=i.extensionManager,E=M||C.$to.parentOffset&&C.$from.marks();if(n.split(l.pos,2,S).scrollIntoView(),m&&n.setNodeMarkup(b,void 0,h),!E||!o)return!0;let B=E.filter(oe=>T.includes(oe.type.name));n.ensureMarks(B)}return!0};function sf(e){return!e||e==="1"?null:e}function Lf(e,t){return sf(e)===sf(t)}var _l=(e,t)=>{let n=ii(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&bt(e.doc,n.pos))||!Lf(n.node.attrs.type,o?.attrs.type)||e.join(n.pos),!0},Vl=(e,t)=>{let n=ii(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&bt(e.doc,r))||!Lf(n.node.attrs.type,o?.attrs.type)||e.join(r),!0};function $0(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),o=t.resolve(n.nodeSize-1);return L.between(r,o)}var B0=(e,t,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:u,can:c})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,p=Ne(e,s.schema),h=Ne(t,s.schema),{selection:g,storedMarks:m}=s,{$from:b,$to:v}=g,S=b.blockRange(v),C=m||g.$to.parentOffset&&g.$from.marks();if(!S)return!1;let M=ii(Ve=>Hl(Ve.type.name,d))(g),T=g.from===0&&g.to===s.doc.content.size,E=s.doc.content.content,B=E.length===1?E[0]:null,oe=T&&B&&Hl(B.type.name,d)?{node:B,pos:0,depth:0}:null,Q=M??oe,me=!!M&&S.depth>=1&&S.depth-M.depth<=1,it=!!oe;if((me||it)&&Q){if(Q.node.type===p)return T&&it?a().command(({tr:Ve,dispatch:Re})=>{let Me=$0(Ve);return Me?(Ve.setSelection(Me),Re&&Re(Ve),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(Hl(Q.node.type.name,d)&&p.validContent(Q.node.content))return a().command(()=>(i.setNodeMarkup(Q.pos,p),!0)).command(()=>_l(i,p)).command(()=>Vl(i,p)).run()}return!n||!C||!l?a().command(()=>c().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>_l(i,p)).command(()=>Vl(i,p)).run():a().command(()=>{let Ve=c().wrapInList(p,r),Re=C.filter(Me=>f.includes(Me.type.name));return i.ensureMarks(Re),Ve?!0:u.clearNodes()}).wrapInList(p,r).command(()=>_l(i,p)).command(()=>Vl(i,p)).run()},z0=(e,t={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=Ft(e,r.schema);return Kl(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},H0=(e,t,n={})=>({state:r,commands:o})=>{let i=Ne(e,r.schema),s=Ne(t,r.schema),l=Mt(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},_0=(e,t={})=>({state:n,commands:r})=>{let o=Ne(e,n.schema);return Mt(n,o,t)?r.lift(o):r.wrapIn(o,t)},V0=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(e))){if(t){let s=e.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},j0=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=e,{selection:i}=t,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let u=Object.values(r.schema.marks).filter(c=>o||!a.includes(c.name));l.forEach(c=>{for(let d of u)t.removeMark(c.$from.pos,c.$to.pos,d)})}return!0},F0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=t,{selection:s}=n,l=Ft(e,r.schema),{$from:a,empty:u,ranges:c}=s;if(!o)return!0;if(u&&i){var d;let{from:f,to:p}=s,h=ql(a,l,(d=a.marks().find(g=>g.type===l))===null||d===void 0?void 0:d.attrs);h&&(f=h.from,p=h.to),n.removeMark(f,p,l)}else c.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},W0=e=>({tr:t,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof e=="number"?(i=e,s=e):e&&"from"in e&&"to"in e?(i=e.from,s=e.to):(i=o.from,s=o.to),r&&t.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let u={...l.attrs};delete u.dir,t.setNodeMarkup(a,void 0,u)}),!0},K0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=oi(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Ne(e,r.schema)),l==="mark"&&(s=Ft(e,r.schema));let a=!1;return n.selection.ranges.forEach(u=>{let c=u.$from.pos,d=u.$to.pos,f,p,h,g;n.selection.empty?r.doc.nodesBetween(c,d,(m,b)=>{i&&i===m.type&&(a=!0,h=Math.max(b,c),g=Math.min(b+m.nodeSize,d),f=b,p=m)}):r.doc.nodesBetween(c,d,(m,b)=>{b<c&&i&&i===m.type&&(a=!0,h=Math.max(b,c),g=Math.min(b+m.nodeSize,d),f=b,p=m),b>=c&&b<=d&&(i&&i===m.type&&(a=!0,o&&n.setNodeMarkup(b,void 0,{...m.attrs,...t})),s&&m.marks.length&&m.marks.forEach(v=>{if(s===v.type&&(a=!0,o)){let S=Math.max(b,c),C=Math.min(b+m.nodeSize,d);n.addMark(S,C,s.create({...v.attrs,...t}))}}))}),p&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...p.attrs,...t}),s&&p.marks.length&&p.marks.forEach(m=>{s===m.type&&o&&n.addMark(h,g,s.create({...m.attrs,...t}))}))}),a},pr=new ne("__tiptap_decorations__"),U0=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(pr,{type:"force",name:e}),!0),q0=(e,t={})=>({state:n,dispatch:r})=>{let o=Ne(e,n.schema);return Ru(o,t)(n,r)},G0=(e,t={})=>({state:n,dispatch:r})=>{let o=Ne(e,n.schema);return Ou(o,t)(n,r)},J0=gu({blur:()=>Cy,clearContent:()=>xy,clearNodes:()=>Sy,command:()=>Ey,createParagraphNear:()=>My,cut:()=>Ay,deleteCurrentNode:()=>Ty,deleteNode:()=>Ny,deleteRange:()=>Ry,deleteSelection:()=>Ly,enter:()=>Iy,exitCode:()=>Py,extendMarkRange:()=>$y,first:()=>By,focus:()=>Hy,forEach:()=>_y,insertContent:()=>Vy,insertContentAt:()=>jy,insertDefaultBlock:()=>Fy,joinBackward:()=>Uy,joinDown:()=>Ky,joinForward:()=>qy,joinItemBackward:()=>Gy,joinItemForward:()=>Jy,joinTextblockBackward:()=>Xy,joinTextblockForward:()=>Yy,joinUp:()=>Wy,keyboardShortcut:()=>Zy,lift:()=>e0,liftEmptyBlock:()=>t0,liftListItem:()=>n0,newlineInCode:()=>r0,resetAttributes:()=>o0,scrollIntoView:()=>i0,selectAll:()=>s0,selectNodeBackward:()=>l0,selectNodeForward:()=>a0,selectParentNode:()=>c0,selectTextblockEnd:()=>u0,selectTextblockStart:()=>d0,setContent:()=>f0,setMark:()=>A0,setMeta:()=>T0,setNode:()=>N0,setNodeSelection:()=>R0,setTextDirection:()=>O0,setTextSelection:()=>D0,sinkListItem:()=>L0,splitBlock:()=>I0,splitListItem:()=>P0,toggleList:()=>B0,toggleMark:()=>z0,toggleNode:()=>H0,toggleWrap:()=>_0,undoInputRule:()=>V0,unsetAllMarks:()=>j0,unsetMark:()=>F0,unsetTextDirection:()=>W0,updateAttributes:()=>K0,updateDecorations:()=>U0,wrapIn:()=>q0,wrapInList:()=>G0}),hr=new WeakMap;function X0(e,t){var n;hr.set(e,((n=hr.get(e))!==null&&n!==void 0?n:0)+1);try{return t()}finally{var r;let o=((r=hr.get(e))!==null&&r!==void 0?r:1)-1;o>0?hr.set(e,o):hr.delete(e)}}function Y0(e){return hr.has(e)}var Q0=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},If=typeof process<"u"&&!1;function Z0(e){return e.kind==="widget"}function Pf(e,t){let n=[],r=new Set;for(let o of e)o.kind==="widget"&&Z0(o)&&r.add(o.key),n.push(o.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function ew(e,t,n){let{decorations:r,widgetKeys:o}=Pf(t,n);return{set:ue.create(e,r),widgetKeys:o}}function $f({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n?!0:e===n&&n===r}function tw({decorations:e,from:t,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return e.filter(s=>$f({position:s.anchor,from:t,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function Bf(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n=="string"?n:void 0}function nw(e){let t=new Map,n=new Map;for(let s of e.find()){var r,o,i;let l=Bf(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:"unknown",u=(o=t.get(l))!==null&&o!==void 0?o:new Set;u.add(a),t.set(l,u),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(t,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function zf(e){return e.jsonID==="attr"}function rw(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||zf(e))return!0;let n=e;return typeof n.from=="number"&&typeof n.to=="number"}function ow(e,t){let n=null,r=0,o=0;for(let i=0;i<e.childCount&&!(o>t.to);i+=1){let s=o+e.child(i).nodeSize;s>=t.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function iw(e,t){if(e.steps.some(i=>!rw(i)))return{type:"full"};let n=wr(e).map(({newRange:i})=>i);e.steps.forEach((i,s)=>{if(!zf(i))return;let l=e.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=ow(t,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function Hf(e,t,n,r){return e.map(t,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function sw(e,t,n){var r,o;let i=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:ue.empty,s=new Set((o=t.widgetKeysByExtension[e])!==null&&o!==void 0?o:[]);return{set:Hf(i,n.mapping,n.doc,s),widgetKeys:s}}function lf(e,t){let n=Object.values(t).flatMap(r=>r.find());return ue.create(e,n)}function af(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function lw(e,t){var n;switch((n=t.update)!==null&&n!==void 0?n:"document"){case"document":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw new Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function aw(e,t,n){return n?!0:e.update==="manual"?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var cw=new Set;var uw=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:t})=>{let n=pr.getState(t);n&&this.warnDuplicateWidgetKeys(n)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:t,spec:n})=>lw(t,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 e,t;return(e=(t=pr.getState(this.editor.state))===null||t===void 0?void 0:t.widgetKeys)!==null&&e!==void 0?e:cw}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let o=r();o&&t.push({name:n,spec:o})}return t}createPlugin(){let{editor:e,entries:t}=this;return new W({key:pr,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of t){let{set:u,widgetKeys:c}=this.buildFullSet(l,a,r);o[l]=u,i[l]=c}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:af(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(pr),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,u={},c={},d=new Set;return X0(e,()=>{for(let{name:f,spec:p}of t){let h=l||a===f;if(aw(p,{editor:e,tr:n,oldState:o,newState:i},h))if(p.update==="changedRanges"&&n.docChanged&&!h){let g=this.applyChangedRangesRecompute(f,p,r,n,i);u[f]=g.set,c[f]=g.widgetKeys,d.add(f)}else{let{set:g,widgetKeys:m}=this.buildFullSet(f,p,i);u[f]=g,c[f]=m,d.add(f)}else{let g=sw(f,r,n);u[f]=g.set,c[f]=g.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:u,widgetKeysByExtension:c,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:u,recomputedNames:d}),widgetKeys:af(c)}}},props:{decorations(n){var r,o;return(r=(o=pr.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:ue.empty}}})}applyChangedRangesRecompute(e,t,n,r,o){let i=iw(r,o.doc);return i.type==="full"?this.buildFullSet(e,t,o):this.rebuildRanges(e,t,n,r,o,i.ranges)}rebuildRanges(e,t,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[e])!==null&&s!==void 0?s:ue.empty,u=new Set((l=n.widgetKeysByExtension[e])!==null&&l!==void 0?l:[]),c=Hf(a,r.mapping,r.doc,u),d=o.doc.content.size;for(let{from:f,to:p}of i){let h=c.find(f,p).filter(b=>$f({position:b.from,from:f,to:p,docSize:d}));for(let b of h){let v=Bf(b);v&&u.delete(v)}c=c.remove(h);let{decorations:g,widgetKeys:m}=Pf(tw({decorations:this.runCreate(e,"createInRange",()=>t.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:p})),from:f,to:p,docSize:d,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(o.doc,g);for(let b of m)u.add(b)}return{set:c,widgetKeys:u}}buildFullSet(e,t,n){let r=this.runCreate(e,"create",()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return ew(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(e){if(!If)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=nw(e.mergedDecorationSet),n=new Set(t.map(({key:r})=>r));for(let{key:r,extensions:o}of t){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`"${s}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:lf(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return e.length===1?r[e[0].name]:o.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):lf(n.doc,r)}};function _f(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof H){let i=r.index();return r.parent.canReplaceWith(i,i+1,t)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(t))return!0;o-=1}return!1}function dw(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}function Vf(e,t){let n=e.getAttribute("style");if(!n)return null;let r=n.split(";").map(i=>i.trim()).filter(Boolean),o=t.toLowerCase();for(let i=r.length-1;i>=0;i-=1){let s=r[i],l=s.indexOf(":");if(l!==-1&&s.slice(0,l).trim().toLowerCase()===o)return s.slice(l+1).trim()}return null}function fw(e){return typeof e=="number"}function pw(e){return Object.prototype.toString.call(e).slice(8,-1)}function Qo(e){return pw(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function vr(e){return typeof e=="string"&&e.trim().length>0&&!/[;{}]/.test(e)}function Ql(e,t,n){let r=e.split(`
|
|
10
|
+
`,textSerializers:s={}}=n||{},l="";return e.nodesBetween(r,o,(a,u,c,d)=>{a.isBlock&&u>r&&(l+=i);let f=s?.[a.type.name];if(f)return c&&(l+=f({node:a,pos:u,parent:c,index:d,range:t})),!1;if(a.isText){var p;l+=a==null||(p=a.text)===null||p===void 0?void 0:p.slice(Math.max(r,u)-u,o-u)}}),l}function x0(e,t){return Nf(e,{from:0,to:e.content.size},t)}function Rf(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function S0(e,t){let n=Ne(t,e.schema),{from:r,to:o}=e.selection,i=[];e.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Ql(e,t){let n=ii(typeof t=="string"?t:t.name,e.schema);return n==="node"?S0(e,t):n==="mark"?Ef(e,t):{}}function E0(e,t=JSON.stringify){let n={};return e.filter(r=>{let o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function M0(e){let t=E0(e);return t.length===1?t:t.filter((n,r)=>!t.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Cr(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let u=t.slice(i).map(l,-1),c=t.slice(i).map(a),d=t.invert().map(u,-1),f=t.invert().map(c);r.push({oldRange:{from:d,to:f},newRange:{from:u,to:c}})})}),M0(r)}function Zr(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(o=>{let i=Gl(n.resolve(e),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Of=(e,t,n,r=20)=>{let o=e.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===t?s=l:i-=1}return[s,i]},Df=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function hr(e,t){return t.nodes[e]||t.marks[e]||null}function ti(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=e.find(i=>i.type===t&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var A0=(e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,i,s,l)=>{var a,u;let c=((a=(u=o.type.spec).toText)===null||a===void 0?void 0:a.call(u,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?c:c.slice(0,Math.max(0,r-i))}),n};function Ul(e,t,n={}){let{empty:r,ranges:o}=e.selection,i=t?Ft(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(c=>i?i.name===c.type.name:!0).find(c=>ni(c.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:c,$to:d})=>{let f=c.pos,p=d.pos;e.doc.nodesBetween(f,p,(h,g)=>{if(i&&h.inlineContent&&!h.type.allowsMarkType(i))return!1;if(!h.isText&&!h.marks.length)return;let m=Math.max(f,g),b=Math.min(p,g+h.nodeSize),k=b-m;s+=k,l.push(...h.marks.map(C=>({mark:C,from:m,to:b})))})}),s===0)return!1;let a=l.filter(c=>i?i.name===c.mark.type.name:!0).filter(c=>ni(c.mark.attrs,n,{strict:!1})).reduce((c,d)=>c+d.to-d.from,0),u=l.filter(c=>i?c.mark.type!==i&&c.mark.type.excludes(i):!0).reduce((c,d)=>c+d.to-d.from,0);return(a>0?a+u:a)>=s}function T0(e,t,n={}){if(!t)return Mt(e,null,n)||Ul(e,null,n);let r=ii(t,e.schema);return r==="node"?Mt(e,t,n):r==="mark"?Ul(e,t,n):!1}var Lf=(e,t)=>{let{$from:n,$to:r,$anchor:o}=e.selection;if(t){let i=si(l=>l.type.name===t)(e.selection);if(!i)return!1;let s=e.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},If=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function af(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function _l(e,t){let{nodeExtensions:n}=kr(t),r=n.find(i=>i.name===e);if(!r)return!1;let o=de(P(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function xr(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name==="hardBreak")return!0;if(e.isText){var r;return!/\S/.test((r=e.text)!==null&&r!==void 0?r:"")}}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let o=!0;return e.content.forEach(i=>{o!==!1&&(xr(i,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function li(e){return e instanceof _}var Pf=class $f{constructor(t){this.position=t}static fromJSON(t){return new $f(t.position)}toJSON(){return{position:this.position}}};function N0(e,t){let n=t.mapping.mapResult(e.position);return{position:new Pf(n.pos),mapResult:n}}function R0(e){return new Pf(e)}function O0(e,t,n){let{selection:r}=t,o=null;if(oi(r)&&(o=r.$cursor),o){var i;let l=(i=e.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let u=l.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(l.pos,a.pos,(c,d,f)=>{if(u)return!1;if(c.isInline){let p=!f||f.type.allowsMarkType(n),h=!!n.isInSet(c.marks)||!c.marks.some(g=>g.type.excludes(n));u=p&&h}return!u}),u})}var D0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=Ft(e,r.schema);if(o)if(s){let u=Ef(r,a);n.addStoredMark(a.create({...u,...t}))}else l.forEach(u=>{let c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(f,p)=>{let h=Math.max(p,c),g=Math.min(p+f.nodeSize,d);f.marks.find(m=>m.type===a)?f.marks.forEach(m=>{a===m.type&&n.addMark(h,g,a.create({...m.attrs,...t}))}):n.addMark(h,g,a.create(t))})});return O0(r,n,a)},L0=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),I0=(e,t={})=>({state:n,dispatch:r,chain:o})=>{let i=Ne(e,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>el(i,{...s,...t})(n)?!0:l.clearNodes()).command(({state:l})=>el(i,{...s,...t})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},P0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,o=Kn(e,0,r.content.size),i=_.create(r,o);t.setSelection(i)}return!0},$0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof t=="number"?(s=t,l=t):t&&"from"in t&&"to"in t?(s=t.from,l=t.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,u)=>{a.isText||n.setNodeMarkup(u,void 0,{...a.attrs,dir:e})}),!0},B0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:o,to:i}=typeof e=="number"?{from:e,to:e}:e,s=L.atStart(r).from,l=L.atEnd(r).to,a=Kn(o,s,l),u=Kn(i,s,l),c=L.create(r,a,u);t.setSelection(c)}return!0},z0=e=>({state:t,dispatch:n})=>{let r=Ne(e,t.schema);return Bu(r)(t,n)};function cf(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(o=>t?.includes(o.type.name));e.tr.ensureMarks(r)}}var H0=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=t,{$from:l,$to:a}=i,u=o.extensionManager.attributes,c=ti(u,l.node().type.name,l.node().attrs);if(i instanceof _&&i.node.isBlock)return!l.parentOffset||!dt(s,l.pos)?!1:(r&&(e&&cf(n,o.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Cf(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=d&&f?[{type:f,attrs:c}]:void 0,h=i instanceof L&&!i.empty?Br.create({doc:t.doc,selection:i}).tr.deleteSelection():null,g=h?h.doc:t.doc,m=h?h.mapping.map(l.pos):l.pos,b=dt(g,m,1,p);if(!p&&!b&&dt(g,m,1,f?[{type:f}]:void 0)&&(b=!0,p=f?[{type:f,attrs:c}]:void 0),r){if(b){let k=t.steps.length;if(i instanceof L&&t.deleteSelection(),t.split(t.mapping.slice(k).map(l.pos),1,p),f&&!d&&!l.parentOffset&&l.parent.type!==f){let C=t.mapping.slice(k).map(l.before()),x=t.doc.resolve(C);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(k).map(l.before()),f)}}e&&cf(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return b},_0=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Ne(e,r.schema),{$from:l,$to:a}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(a))return!1;let c=l.node(-1);if(c.type!==s)return!1;let d=i.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(o){var f;let x=z.empty,E=l.index(-1)?1:l.index(-2)?2:3;for(let ge=l.depth-E;ge>=l.depth-3;ge-=1)x=z.from(l.node(ge).copy(x));let A=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,M={...ti(d,l.node().type.name,l.node().attrs),...t},B=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(M))||void 0;x=x.append(z.from(s.createAndFill(null,B)||void 0));let ie=l.before(l.depth-(E-1));n.replace(ie,l.after(-A),new ce(x,4-E,0));let Q=-1;n.doc.nodesBetween(ie,n.doc.content.size,(ge,it)=>{if(Q>-1)return!1;ge.isTextblock&&ge.content.size===0&&(Q=it+1)}),Q>-1&&n.setSelection(L.near(n.doc.resolve(Q))),n.scrollIntoView()}return!0}let p=a.pos===l.end()?c.contentMatchAt(0).defaultType:null,h={...ti(d,c.type.name,c.attrs),...t},g={...ti(d,l.node().type.name,l.node().attrs),...t},m=l.parentOffset===0&&l.index(-1)===0,b=l.before(-1);n.delete(l.pos,a.pos);let k=m?c.attrs:h,C=p?[{type:s,attrs:k},{type:p,attrs:g}]:[{type:s,attrs:k}];if(!dt(n.doc,l.pos,2))return!1;if(o){let{selection:x,storedMarks:E}=r,{splittableMarks:A}=i.extensionManager,M=E||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,C).scrollIntoView(),m&&n.setNodeMarkup(b,void 0,h),!M||!o)return!0;let B=M.filter(ie=>A.includes(ie.type.name));n.ensureMarks(B)}return!0};function uf(e){return!e||e==="1"?null:e}function Bf(e,t){return uf(e)===uf(t)}var Vl=(e,t)=>{let n=si(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&bt(e.doc,n.pos))||!Bf(n.node.attrs.type,o?.attrs.type)||e.join(n.pos),!0},jl=(e,t)=>{let n=si(i=>i.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=e.doc.nodeAt(r);return!(n.node.type===o?.type&&bt(e.doc,r))||!Bf(n.node.attrs.type,o?.attrs.type)||e.join(r),!0};function V0(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),o=t.resolve(n.nodeSize-1);return L.between(r,o)}var j0=(e,t,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:u,can:c})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,p=Ne(e,s.schema),h=Ne(t,s.schema),{selection:g,storedMarks:m}=s,{$from:b,$to:k}=g,C=b.blockRange(k),x=m||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;let E=si(je=>_l(je.type.name,d))(g),A=g.from===0&&g.to===s.doc.content.size,M=s.doc.content.content,B=M.length===1?M[0]:null,ie=A&&B&&_l(B.type.name,d)?{node:B,pos:0,depth:0}:null,Q=E??ie,ge=!!E&&C.depth>=1&&C.depth-E.depth<=1,it=!!ie;if((ge||it)&&Q){if(Q.node.type===p)return A&&it?a().command(({tr:je,dispatch:Re})=>{let Me=V0(je);return Me?(je.setSelection(Me),Re&&Re(je),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(_l(Q.node.type.name,d)&&p.validContent(Q.node.content))return a().command(()=>(i.setNodeMarkup(Q.pos,p),!0)).command(()=>Vl(i,p)).command(()=>jl(i,p)).run()}return!n||!x||!l?a().command(()=>c().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Vl(i,p)).command(()=>jl(i,p)).run():a().command(()=>{let je=c().wrapInList(p,r),Re=x.filter(Me=>f.includes(Me.type.name));return i.ensureMarks(Re),je?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Vl(i,p)).command(()=>jl(i,p)).run()},F0=(e,t={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=Ft(e,r.schema);return Ul(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},W0=(e,t,n={})=>({state:r,commands:o})=>{let i=Ne(e,r.schema),s=Ne(t,r.schema),l=Mt(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},K0=(e,t={})=>({state:n,commands:r})=>{let o=Ne(e,n.schema);return Mt(n,o,t)?r.lift(o):r.wrapIn(o,t)},U0=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(e))){if(t){let s=e.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},q0=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=e,{selection:i}=t,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let u=Object.values(r.schema.marks).filter(c=>o||!a.includes(c.name));l.forEach(c=>{for(let d of u)t.removeMark(c.$from.pos,c.$to.pos,d)})}return!0},G0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=t,{selection:s}=n,l=Ft(e,r.schema),{$from:a,empty:u,ranges:c}=s;if(!o)return!0;if(u&&i){var d;let{from:f,to:p}=s,h=Gl(a,l,(d=a.marks().find(g=>g.type===l))===null||d===void 0?void 0:d.attrs);h&&(f=h.from,p=h.to),n.removeMark(f,p,l)}else c.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},J0=e=>({tr:t,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof e=="number"?(i=e,s=e):e&&"from"in e&&"to"in e?(i=e.from,s=e.to):(i=o.from,s=o.to),r&&t.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let u={...l.attrs};delete u.dir,t.setNodeMarkup(a,void 0,u)}),!0},X0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ii(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Ne(e,r.schema)),l==="mark"&&(s=Ft(e,r.schema));let a=!1;return n.selection.ranges.forEach(u=>{let c=u.$from.pos,d=u.$to.pos,f,p,h,g;n.selection.empty?r.doc.nodesBetween(c,d,(m,b)=>{i&&i===m.type&&(a=!0,h=Math.max(b,c),g=Math.min(b+m.nodeSize,d),f=b,p=m)}):r.doc.nodesBetween(c,d,(m,b)=>{b<c&&i&&i===m.type&&(a=!0,h=Math.max(b,c),g=Math.min(b+m.nodeSize,d),f=b,p=m),b>=c&&b<=d&&(i&&i===m.type&&(a=!0,o&&n.setNodeMarkup(b,void 0,{...m.attrs,...t})),s&&m.marks.length&&m.marks.forEach(k=>{if(s===k.type&&(a=!0,o)){let C=Math.max(b,c),x=Math.min(b+m.nodeSize,d);n.addMark(C,x,s.create({...k.attrs,...t}))}}))}),p&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...p.attrs,...t}),s&&p.marks.length&&p.marks.forEach(m=>{s===m.type&&o&&n.addMark(h,g,s.create({...m.attrs,...t}))}))}),a},gr=new ne("__tiptap_decorations__"),Y0=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(gr,{type:"force",name:e}),!0),Q0=(e,t={})=>({state:n,dispatch:r})=>{let o=Ne(e,n.schema);return Iu(o,t)(n,r)},Z0=(e,t={})=>({state:n,dispatch:r})=>{let o=Ne(e,n.schema);return Pu(o,t)(n,r)},ew=ku({blur:()=>Ay,clearContent:()=>Ty,clearNodes:()=>Ny,command:()=>Ry,createParagraphNear:()=>Oy,cut:()=>Dy,deleteCurrentNode:()=>Ly,deleteNode:()=>Iy,deleteRange:()=>Py,deleteSelection:()=>zy,enter:()=>Hy,exitCode:()=>_y,extendMarkRange:()=>Vy,first:()=>jy,focus:()=>Wy,forEach:()=>Ky,insertContent:()=>Uy,insertContentAt:()=>qy,insertDefaultBlock:()=>Gy,joinBackward:()=>Yy,joinDown:()=>Xy,joinForward:()=>Qy,joinItemBackward:()=>Zy,joinItemForward:()=>e0,joinTextblockBackward:()=>t0,joinTextblockForward:()=>n0,joinUp:()=>Jy,keyboardShortcut:()=>o0,lift:()=>i0,liftEmptyBlock:()=>s0,liftListItem:()=>l0,newlineInCode:()=>a0,resetAttributes:()=>c0,scrollIntoView:()=>u0,selectAll:()=>d0,selectNodeBackward:()=>f0,selectNodeForward:()=>p0,selectParentNode:()=>h0,selectTextblockEnd:()=>m0,selectTextblockStart:()=>g0,setContent:()=>b0,setMark:()=>D0,setMeta:()=>L0,setNode:()=>I0,setNodeSelection:()=>P0,setTextDirection:()=>$0,setTextSelection:()=>B0,sinkListItem:()=>z0,splitBlock:()=>H0,splitListItem:()=>_0,toggleList:()=>j0,toggleMark:()=>F0,toggleNode:()=>W0,toggleWrap:()=>K0,undoInputRule:()=>U0,unsetAllMarks:()=>q0,unsetMark:()=>G0,unsetTextDirection:()=>J0,updateAttributes:()=>X0,updateDecorations:()=>Y0,wrapIn:()=>Q0,wrapInList:()=>Z0}),br=new WeakMap;function tw(e,t){var n;br.set(e,((n=br.get(e))!==null&&n!==void 0?n:0)+1);try{return t()}finally{var r;let o=((r=br.get(e))!==null&&r!==void 0?r:1)-1;o>0?br.set(e,o):br.delete(e)}}function nw(e){return br.has(e)}var rw=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},zf=typeof process<"u"&&!1;function ow(e){return e.kind==="widget"}function Hf(e,t){let n=[],r=new Set;for(let o of e)o.kind==="widget"&&ow(o)&&r.add(o.key),n.push(o.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function iw(e,t,n){let{decorations:r,widgetKeys:o}=Hf(t,n);return{set:ue.create(e,r),widgetKeys:o}}function _f({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n?!0:e===n&&n===r}function sw({decorations:e,from:t,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return e.filter(s=>_f({position:s.anchor,from:t,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function Vf(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n=="string"?n:void 0}function lw(e){let t=new Map,n=new Map;for(let s of e.find()){var r,o,i;let l=Vf(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:"unknown",u=(o=t.get(l))!==null&&o!==void 0?o:new Set;u.add(a),t.set(l,u),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(t,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function jf(e){return e.jsonID==="attr"}function aw(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||jf(e))return!0;let n=e;return typeof n.from=="number"&&typeof n.to=="number"}function cw(e,t){let n=null,r=0,o=0;for(let i=0;i<e.childCount&&!(o>t.to);i+=1){let s=o+e.child(i).nodeSize;s>=t.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function uw(e,t){if(e.steps.some(i=>!aw(i)))return{type:"full"};let n=Cr(e).map(({newRange:i})=>i);e.steps.forEach((i,s)=>{if(!jf(i))return;let l=e.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=cw(t,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function Ff(e,t,n,r){return e.map(t,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function dw(e,t,n){var r,o;let i=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:ue.empty,s=new Set((o=t.widgetKeysByExtension[e])!==null&&o!==void 0?o:[]);return{set:Ff(i,n.mapping,n.doc,s),widgetKeys:s}}function df(e,t){let n=Object.values(t).flatMap(r=>r.find());return ue.create(e,n)}function ff(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function fw(e,t){var n;switch((n=t.update)!==null&&n!==void 0?n:"document"){case"document":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(t.createInRange)throw new Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw new Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function pw(e,t,n){return n?!0:e.update==="manual"?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var hw=new Set;var mw=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:t})=>{let n=gr.getState(t);n&&this.warnDuplicateWidgetKeys(n)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:t,spec:n})=>fw(t,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 e,t;return(e=(t=gr.getState(this.editor.state))===null||t===void 0?void 0:t.widgetKeys)!==null&&e!==void 0?e:hw}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let o=r();o&&t.push({name:n,spec:o})}return t}createPlugin(){let{editor:e,entries:t}=this;return new K({key:gr,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of t){let{set:u,widgetKeys:c}=this.buildFullSet(l,a,r);o[l]=u,i[l]=c}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:ff(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(gr),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,u={},c={},d=new Set;return tw(e,()=>{for(let{name:f,spec:p}of t){let h=l||a===f;if(pw(p,{editor:e,tr:n,oldState:o,newState:i},h))if(p.update==="changedRanges"&&n.docChanged&&!h){let g=this.applyChangedRangesRecompute(f,p,r,n,i);u[f]=g.set,c[f]=g.widgetKeys,d.add(f)}else{let{set:g,widgetKeys:m}=this.buildFullSet(f,p,i);u[f]=g,c[f]=m,d.add(f)}else{let g=dw(f,r,n);u[f]=g.set,c[f]=g.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:u,widgetKeysByExtension:c,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:u,recomputedNames:d}),widgetKeys:ff(c)}}},props:{decorations(n){var r,o;return(r=(o=gr.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:ue.empty}}})}applyChangedRangesRecompute(e,t,n,r,o){let i=uw(r,o.doc);return i.type==="full"?this.buildFullSet(e,t,o):this.rebuildRanges(e,t,n,r,o,i.ranges)}rebuildRanges(e,t,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[e])!==null&&s!==void 0?s:ue.empty,u=new Set((l=n.widgetKeysByExtension[e])!==null&&l!==void 0?l:[]),c=Ff(a,r.mapping,r.doc,u),d=o.doc.content.size;for(let{from:f,to:p}of i){let h=c.find(f,p).filter(b=>_f({position:b.from,from:f,to:p,docSize:d}));for(let b of h){let k=Vf(b);k&&u.delete(k)}c=c.remove(h);let{decorations:g,widgetKeys:m}=Hf(sw({decorations:this.runCreate(e,"createInRange",()=>t.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:p})),from:f,to:p,docSize:d,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(o.doc,g);for(let b of m)u.add(b)}return{set:c,widgetKeys:u}}buildFullSet(e,t,n){let r=this.runCreate(e,"create",()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return iw(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(e){if(!zf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=lw(e.mergedDecorationSet),n=new Set(t.map(({key:r})=>r));for(let{key:r,extensions:o}of t){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`"${s}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:df(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return e.length===1?r[e[0].name]:o.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):df(n.doc,r)}};function Wf(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof _){let i=r.index();return r.parent.canReplaceWith(i,i+1,t)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(t))return!0;o-=1}return!1}function gw(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}function Kf(e,t){let n=e.getAttribute("style");if(!n)return null;let r=n.split(";").map(i=>i.trim()).filter(Boolean),o=t.toLowerCase();for(let i=r.length-1;i>=0;i-=1){let s=r[i],l=s.indexOf(":");if(l!==-1&&s.slice(0,l).trim().toLowerCase()===o)return s.slice(l+1).trim()}return null}function bw(e){return typeof e=="number"}function yw(e){return Object.prototype.toString.call(e).slice(8,-1)}function Zo(e){return yw(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Sr(e){return typeof e=="string"&&e.trim().length>0&&!/[;{}]/.test(e)}function Zl(e,t,n){let r=e.split(`
|
|
11
11
|
`),o=[],i="",s=0,l=t.baseIndentSize||2;for(;s<r.length;){let c=r[s],d=c.match(t.itemPattern);if(!d){if(o.length>0)break;if(c.trim()===""){s+=1,i=`${i}${c}
|
|
12
12
|
`;continue}else return}let f=t.extractItemData(d),{indentLevel:p,mainContent:h}=f;i=`${i}${c}
|
|
13
|
-
`;let g=[h];for(s+=1;s<r.length;){var a;let
|
|
14
|
-
`,s+=1;continue}else break}if((((a=
|
|
15
|
-
`,s+=1;else break}let m,b=g.slice(1);if(b.length>0){let
|
|
16
|
-
`);
|
|
13
|
+
`;let g=[h];for(s+=1;s<r.length;){var a;let C=r[s];if(C.trim()===""){var u;let x=r.slice(s+1).findIndex(E=>E.trim()!=="");if(x===-1)break;if((((u=r[s+1+x].match(/^(\s*)/))===null||u===void 0||(u=u[1])===null||u===void 0?void 0:u.length)||0)>p){g.push(C),i=`${i}${C}
|
|
14
|
+
`,s+=1;continue}else break}if((((a=C.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>p)g.push(C),i=`${i}${C}
|
|
15
|
+
`,s+=1;else break}let m,b=g.slice(1);if(b.length>0){let C=b.map(x=>x.slice(p+l)).join(`
|
|
16
|
+
`);C.trim()&&(t.customNestedParser?m=t.customNestedParser(C):m=n.blockTokens(C))}let k=t.createToken(f,m);o.push(k)}if(o.length!==0)return{items:o,raw:i}}var pf=4;function hf(e){let t=0;for(let n of e)t=n===" "?t+pf-t%pf:t+1;return t}function ea(e,t,n,r,o){if(!e||!Array.isArray(e.content))return"";let i=typeof n=="function"?n(r):n,[s,...l]=e.content,a=`${i}${t.renderChildren([s])}`;return l&&l.length>0&&l.forEach((u,c)=>{var d,f;let p=(d=(f=t.renderChild)===null||f===void 0?void 0:f.call(t,u,c+1))!==null&&d!==void 0?d:t.renderChildren([u]);if(p!=null){let h=m=>{if(!o?.alignNestedToPrefix)return t.indent(m);let b=t.indent(""),k=hf(i);return(hf(b)>=k?b:" ".repeat(k))+m},g=p.split(`
|
|
17
17
|
`).map(m=>h(m||"")).join(`
|
|
18
18
|
`);a+=u.type==="paragraph"?`
|
|
19
19
|
|
|
20
20
|
${g}`:`
|
|
21
|
-
${g}`}}),a}function
|
|
22
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var
|
|
21
|
+
${g}`}}),a}function Uf(e,t){let n={...e};return Zo(e)&&Zo(t)&&Object.keys(t).forEach(r=>{Zo(t[r])&&Zo(e[r])?n[r]=Uf(e[r],t[r]):n[r]=t[r]}),n}function ww(e,t,n={}){let{state:r}=t,{doc:o,tr:i}=r,s=e;o.descendants((l,a)=>{let u=i.mapping.map(a),c=i.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(p=>{if(p!==s)return!1;d=p}),!d)return;let f=!1;if(Object.keys(n).forEach(p=>{n[p]!==d.attrs[p]&&(f=!0)}),f){let p=e.type.create({...e.attrs,...n});i.removeMark(u,c,e.type),i.addMark(u,c,p)}}),i.docChanged&&t.view.dispatch(i)}var Er=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=(t=e.undoable)!==null&&t!==void 0?t:!0}},kw=(e,t)=>{if(ql(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,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 vw(e){let{editor:t,from:n,to:r,text:o,insertText:i}=e;if(!i)return{inputTransaction:null,tr:t.view.state.tr};let s=t.view.state.tr.insertText(o,n,r);return{inputTransaction:s,tr:Br.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function Cw(e){let{editor:t,from:n,to:r,text:o,rule:i,match:s,plugin:l,insertText:a}=e,{view:u}=t,{inputTransaction:c,tr:d}=vw({editor:t,from:n,to:r,text:o,insertText:a}),f=c?n+o.length:r,p=ri({state:u.state,transaction:d}),h={from:n-(s[0].length-o.length),to:f},{commands:g,chain:m,can:b}=new yr({editor:t,state:p});return i.handler({state:p,range:h,match:s,commands:g,chain:m,can:b})===null||!d.steps.length?!1:(c&&(u.dispatch(c),!u.state.doc.eq(c.doc))||(pr(d),d.setMeta("inputRule",!0),i.undoable&&d.setMeta(l,{transform:d,from:n,to:f,text:o}),u.dispatch(d)),!0)}function xw(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let o=e.parentOffset-r;return o>=0&&e.parent.textBetween(o,e.parentOffset)===t[0].slice(0,r)}function ei(e){var t;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l,insertText:a}=e,{view:u}=n;if(u.composing)return!1;let c=u.state.doc.resolve(r);if(c.parent.type.spec.code||!((t=c.nodeBefore||c.nodeAfter)===null||t===void 0)&&t.marks.find(f=>f.type.spec.code))return!1;let d=A0(c)+i;for(let f of s){let p=kw(d,f.find);if(!(!p||!xw(c,p,i))&&Cw({editor:n,from:r,to:o,text:i,rule:f,match:p,plugin:l,insertText:a}))return!0}return!1}function Sw(e){let{editor:t,rules:n}=e,r=new K({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Yl(z.from(u),s.schema);let{from:c}=a,d=c+u.length;ei({editor:t,from:c,to:d,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return ei({editor:t,from:i,to:s,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&ei({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?ei({editor:t,from:s.pos,to:s.pos,text:`
|
|
22
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var ta=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...de(P(this,"addOptions",{name:this.name}))}}get storage(){return{...de(P(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Uf(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},Ve=class qf extends ta{constructor(...t){super(...t),this.type="mark"}static create(t={}){let n=typeof t=="function"?t():t;return new qf(n)}static handleExit({editor:t,mark:n}){let{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let s=i.find(l=>l?.type.name===n.name);return s&&r.removeStoredMark(s),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},na=class{constructor(e){this.find=e.find,this.handler=e.handler}},Ew=(e,t,n)=>{if(ql(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=e,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function Mw(e){let{editor:t,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=e,{commands:a,chain:u,can:c}=new yr({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,p)=>{var h,g,m,b;if(!((h=f.type)===null||h===void 0||(h=h.spec)===null||h===void 0)&&h.code||!(f.isText||f.isTextblock||f.isInline))return;let k=(g=(m=(b=f.content)===null||b===void 0?void 0:b.size)!==null&&m!==void 0?m:f.nodeSize)!==null&&g!==void 0?g:0,C=Math.max(r,p),x=Math.min(o,p+k);if(C>=x)return;let E=f.isText?f.text||"":f.textBetween(C-p,x-p,void 0,"\uFFFC");Ew(E,i.find,s).forEach(A=>{if(A.index===void 0)return;let M=C+A.index+1,B=M+A[0].length,ie={from:n.tr.mapping.map(M),to:n.tr.mapping.map(B)},Q=i.handler({state:n,range:ie,match:A,commands:a,chain:u,can:c,pasteEvent:s,dropEvent:l});d.push(Q)})}),d.every(f=>f!==null)}var mr=null,Aw=e=>{var t;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function Tw(e){let{editor:t,rules:n}=e,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:u,from:c,to:d,rule:f,pasteEvt:p})=>{let h=u.tr,g=ri({state:u,transaction:h});if(!(!Mw({editor:t,state:g,from:Math.max(c-1,0),to:d.b-1,rule:f,pasteEvent:p,dropEvent:l})||!h.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,h}};return t.on("destroy",()=>{mr===t&&(mr=null)}),n.map(u=>new K({view(c){let d=p=>{var h;r=!((h=c.dom.parentElement)===null||h===void 0)&&h.contains(p.target)?c.dom.parentElement:null,r&&(mr=t)},f=()=>{mr&&(mr=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(c,d)=>{if(i=r===c.dom.parentElement,l=d,!i){let f=mr;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(c,d)=>{var f;let p=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return s=d,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(c,d,f)=>{let p=c[0],h=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,m=p.getMeta("applyPasteRules"),b=!!m;if(!h&&!g&&!b)return;if(b){let{text:x}=m;typeof x=="string"?x=x:x=Yl(z.from(x),f.schema);let{from:E}=m,A=E+x.length,M=Aw(x);return a({rule:u,state:f,from:E,to:{b:A},pasteEvt:M})}let k=d.doc.content.findDiffStart(f.doc.content),C=d.doc.content.findDiffEnd(f.doc.content);if(!(!bw(k)||!C||k===C.b))return a({rule:u,state:f,from:k,to:C,pasteEvt:s})}}))}var ai=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Tf(e),this.schema=v0(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=P(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:hr(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Yr([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:hr(r.name,this.schema)},i=[],s=P(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&P(r,"exitable",o)&&(l.ArrowRight=()=>Ve.handleExit({editor:e,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([p,h])=>[p,()=>h({editor:e})]));l={...l,...f}}let a=qd(l);i.push(a);let u=P(r,"addInputRules",o);if(af(r,e.options.enableInputRules)&&u){let f=u();if(f&&f.length){let p=Sw({editor:e,rules:f}),h=Array.isArray(p)?p:[p];i.push(...h)}}let c=P(r,"addPasteRules",o);if(af(r,e.options.enablePasteRules)&&c){let f=c();if(f&&f.length){let p=Tw({editor:e,rules:f});i.push(...p)}}let d=P(r,"addProseMirrorPlugins",o);if(d){let f=d();i.push(...f)}return i}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)===null||e===void 0||e.destroy();let n=[];return this.extensions.forEach(r=>{let o=P(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:hr(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new mw({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){return Af(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=kr(this.extensions);return Object.fromEntries(t.filter(n=>!!P(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=P(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Ne(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,u,c,d)=>{let f=At(l,r);return i({node:l,view:a,getPos:u,decorations:c,innerDecorations:d,editor:e,extension:n,HTMLAttributes:f})};return[n.name,s]}))}dispatchTransaction(e){let{editor:t}=this;return Yr([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:hr(r.name,this.schema)},i=P(r,"dispatchTransaction",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},e)}transformPastedHTML(e){let{editor:t}=this;return Yr([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:hr(r.name,this.schema)},i=P(r,"transformPastedHTML",o);return i?(s,l)=>{let a=n(s,l);return i.call(o,a)}:n},e||(n=>n))}get markViews(){let{editor:e}=this,{markExtensions:t}=kr(this.extensions);return Object.fromEntries(t.filter(n=>!!P(n,"addMarkView")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=P(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Ft(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let u=At(s,r);return o()({mark:s,view:l,inline:a,editor:e,extension:n,HTMLAttributes:u,updateAttributes:c=>{ww(s,e,c)}})};return[n.name,i]}))}destroy(){var e;(e=this.decorationManager)===null||e===void 0||e.destroy(),this.extensions.forEach(t=>{let n=t;for(;n.parent;){let 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(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(t=>[t.name,t.storage])),e.forEach(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:hr(t.name,this.schema)};if(t.type==="mark"){var r,o;(!((r=de(P(t,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(t.name),!((o=de(P(t,"clearable",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(t.name)}let i=P(t,"onBeforeCreate",n),s=P(t,"onCreate",n),l=P(t,"onUpdate",n),a=P(t,"onSelectionUpdate",n),u=P(t,"onTransaction",n),c=P(t,"onFocus",n),d=P(t,"onBlur",n),f=P(t,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),u&&this.editor.on("transaction",u),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};ai.resolve=Tf;ai.sort=Yr;ai.flatten=Xl;var le=class Gf extends ta{constructor(...t){super(...t),this.type="extension"}static create(t={}){let n=typeof t=="function"?t():t;return new Gf(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},Nw=le.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new K({key:new ne("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,i=Rf(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,u)=>a.$from.pos-u.$from.pos).map(({$from:a,$to:u})=>Nf(r,{from:a.pos,to:u.pos},l)).join(s??`
|
|
23
23
|
|
|
24
|
-
`)}}})]}}),
|
|
24
|
+
`)}}})]}}),Rw=le.create({name:"commands",addCommands(){return{...ew}}}),Ow=le.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r;let o=()=>{var i,s,l;if((i=(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,e))!==null&&i!==void 0?i:e.getMeta("y-sync$"))return;let a=Jl(e.before,[e,...t]);Cr(a).forEach(c=>{a.mapping.mapResult(c.oldRange.from).deletedAfter&&a.mapping.mapResult(c.oldRange.to).deletedBefore&&a.before.nodesBetween(c.oldRange.from,c.oldRange.to,(d,f)=>{let p=f+d.nodeSize-2,h=c.oldRange.from<=f&&p<=c.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:p,newFrom:a.mapping.map(f),newTo:a.mapping.map(p),deletedRange:c.oldRange,newRange:c.newRange,partial:!h,editor:this.editor,transaction:e,combinedTransform:a})})});let u=a.mapping;a.steps.forEach((c,d)=>{if(c instanceof ou){var f,p;let h=u.slice(d).map(c.from,-1),g=u.slice(d).map(c.to),m=u.invert().map(h,-1),b=u.invert().map(g),k=h>0?(f=a.doc.nodeAt(h-1))===null||f===void 0?void 0:f.marks.some(x=>x.eq(c.mark)):!1,C=(p=a.doc.nodeAt(g))===null||p===void 0?void 0:p.marks.some(x=>x.eq(c.mark));this.editor.emit("delete",{type:"mark",mark:c.mark,from:c.from,to:c.to,deletedRange:{from:m,to:b},newRange:{from:h,to:g},partial:!!(C||k),editor:this.editor,transaction:e,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(o,0):o()}}),Dw=le.create({name:"drop",addProseMirrorPlugins(){return[new K({key:new ne("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Lw=le.create({name:"editable",addProseMirrorPlugins(){return[new K({key:new ne("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Iw=new ne("focusEvents"),Pw=le.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new K({key:Iw,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),$w=le.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:u}=l,{empty:c,$anchor:d}=a,{pos:f,parent:p}=d,h=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=h.parent.type.spec.isolating,m=d.pos-d.parentOffset,b=g&&h.parent.childCount===1?m===d.pos:X.atStart(u).from===f;return!c||!p.type.isTextblock||p.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),t=()=>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:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Un()||Sf()?i:o},addProseMirrorPlugins(){return[new K({key:new ne("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(p=>p.getMeta("composition")))return;let r=e.some(p=>p.docChanged)&&!t.doc.eq(n.doc),o=e.some(p=>p.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=t.selection,a=X.atStart(t.doc).from,u=X.atEnd(t.doc).to;if(i||!(s===a&&l===u)||!xr(n.doc))return;let c=n.tr,d=ri({state:n,transaction:c}),{commands:f}=new yr({editor:this.editor,state:d});if(f.clearNodes(),!!c.steps.length)return c}})]}}),Bw=le.create({name:"paste",addProseMirrorPlugins(){return[new K({key:new ne("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),zw=le.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new K({key:new ne("tabindex"),props:{attributes:()=>{var e;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(e=this.options.value)!==null&&e!==void 0?e:"0"}}}})]}}),Hw=le.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=kr(this.extensions);return[{types:e.filter(t=>t.name!=="text").map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{let n=t.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new K({key:new ne("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}});var mf=!1;function _w(e){if(mf)return;mf=!0;let t;try{t=Ln.fromJSON(e,{from:0,to:0}).slice.content}catch{return}t instanceof z||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 Vw=class Xr{get name(){return this.node.type.name}constructor(t,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t 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},t)}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;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new Xr(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Xr(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Xr(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let u=new Xr(a,this.editor,o,o||s?n:null);o&&(u.actualDepth=this.depth+1),t.push(u)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===t&&i.every(l=>n[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(t,n,r))))}),o}setAttribute(t){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}},jw=`.ProseMirror {
|
|
25
25
|
position: relative;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -91,14 +91,14 @@ img.ProseMirror-separator {
|
|
|
91
91
|
|
|
92
92
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
93
93
|
display: block;
|
|
94
|
-
}`,
|
|
94
|
+
}`,ra=class extends rw{constructor(e={}){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:N0,createMappablePosition:R0},this.setOptions(e),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:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let t=this.createDoc();if(!this.editorState){let n=Fl(t,this.options.autofocus);this.editorState=Br.create({doc:t,schema:this.schema,selection:n||void 0})}_w(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){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(e),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;let e=this.editorView.dom;e?.editor&&delete e.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(e){console.warn("Failed to remove CSS element:",e)}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():yr.createFakeChain()}can(){return this.commandManager?this.commandManager.can():yr.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=gw(jw,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&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:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return zf&&!this.hasWarnedStaleDecorationRead&&nw(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Kl(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[Lw,Nw.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),Rw,Pw,$w,zw.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),Dw,Bw,Ow,Hw.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?.type));this.extensionManager=new ai(n,this)}createCommandManager(){this.commandManager=new yr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Wl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;let n=Wl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Br.create({doc:n,schema:this.schema,selection:Fl(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:t,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 e}getEditorViewAttributes(){var e;let t=(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes;return Kl(t)?n=>({role:"textbox",...t(n)}):{role:"textbox",...t}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=t.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new Kr(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let 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(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var c;return(c=this.capturedTransaction)===null||c===void 0?void 0:c.step(u)});return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),o=n.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!o)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let s=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=s?.getMeta("focus"),a=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}),!(e.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||i.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Ql(this.state,e)}isActive(e,t){let n=typeof e=="string"?e:null,r=typeof e=="string"?t:e;return T0(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Yl(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
95
95
|
|
|
96
|
-
`,textSerializers:n={}}=e||{};return y0(this.state.doc,{blockSeparator:t,textSerializers:{...Mf(this.schema),...n}})}get isEmpty(){return kr(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 e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new $w(t,this,!1,n)}get $doc(){return this.$pos(0)}};function rt(e){return new Cr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=de(e.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=t,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),u=n.from+l.indexOf(s),c=u+s.length;if(Zr(n.from,n.to,t.doc).filter(f=>f.mark.type.excluded.find(p=>p===e.type&&p!==f.mark.type)).filter(f=>f.to>u).length)return null;c<n.to&&i.delete(c,n.to),u>n.from&&i.delete(n.from+a,u);let d=n.from+a+s.length;i.addMark(n.from+a,d,e.type.create(o||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function ai(e){return new Cr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=de(e.getAttributes,void 0,r)||{},{tr:i}=t,s=n.from,l=n.to,a=e.type.create(o);if(r[1]){let u=s+r[0].lastIndexOf(r[1]);u>l?u=l:l=u+r[1].length;let c=r[0][r[0].length-1];i.insertText(c,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){let u=e.type.isInline?s:s-1;i.insert(u,e.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:e.undoable})}function eo(e){return new Cr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=t.doc.resolve(n.from),i=de(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)},undoable:e.undoable})}function fn(e){return new Cr({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{let i=de(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&nr(l,e.type,i);if(!a)return null;if(s.wrap(l,a),e.keepMarks&&e.editor){let{selection:c,storedMarks:d}=t,{splittableMarks:f}=e.editor.extensionManager,p=d||c.$to.parentOffset&&c.$from.marks();if(p){let h=p.filter(g=>f.includes(g.type.name));s.ensureMarks(h)}}if(e.keepAttributes){let c=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(c,i).run()}let u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&bt(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&s.join(n.from-1)},undoable:e.undoable})}var zw=e=>"touches"in e,Kf=class{constructor(e){var t,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(a,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let u=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(u,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,!((t=e.options)===null||t===void 0)&&t.min&&(this.minSize={...this.minSize,...e.options.min}),!((n=e.options)===null||n===void 0)&&n.max&&(this.maxSize=e.options.max),!(e==null||(r=e.options)===null||r===void 0)&&r.directions&&(this.directions=e.options.directions),!((o=e.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),!((i=e.options)===null||i===void 0)&&i.className&&(this.classNames={container:e.options.className.container||"",wrapper:e.options.className.wrapper||"",handle:e.options.className.handle||"",resizing:e.options.className.resizing||""}),!((s=e.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var e;return(e=this.contentElement)!==null&&e!==void 0?e:null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type!==this.node.type?!1:(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes("top"),r=t.includes("bottom"),o=t.includes("left"),i=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),o&&(e.style.left="0"),i&&(e.style.right="0"),(t==="top"||t==="bottom")&&(e.style.left="0",e.style.right="0"),(t==="left"||t==="right")&&(e.style.top="0",e.style.bottom="0")}attachHandles(){this.directions.forEach(e=>{let t;this.createCustomHandle?t=this.createCustomHandle(e):t=this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener("mousedown",n=>this.handleResizeStart(n,e)),t.addEventListener("touchstart",n=>this.handleResizeStart(n,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,zw(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,e,t),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,o=this.startHeight,i=e.includes("right"),s=e.includes("left"),l=e.includes("bottom"),a=e.includes("top");return i?r=this.startWidth+t:s&&(r=this.startWidth-t),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(e==="right"||e==="left")&&(r=this.startWidth+(i?t:-t)),(e==="top"||e==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,e):{width:r,height:o}}applyConstraints(e,t,n){var r,o;if(!n){var i,s;let u=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(u=Math.min(this.maxSize.width,u)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(c=Math.min(this.maxSize.height,c)),{width:u,height:c}}let l=e,a=t;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(e,t,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:e,height:e/this.aspectRatio}:o?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};var ce=class Uf extends ea{constructor(...t){super(...t),this.type="node"}static create(t={}){let n=typeof t=="function"?t():t;return new Uf(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},qf=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=()=>{try{return t.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n;let{view:r}=this.editor,o=e.target,i=o.nodeType===3?(t=o.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,u,c,d;let v=this.dom.getBoundingClientRect(),S=i.getBoundingClientRect(),C=(a=e.offsetX)!==null&&a!==void 0?a:(u=e.nativeEvent)===null||u===void 0?void 0:u.offsetX,M=(c=e.offsetY)!==null&&c!==void 0?c:(d=e.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=S.x-v.x+C,l=S.y-v.y+M}let f=this.dom.cloneNode(!0);try{let v=this.dom.getBoundingClientRect();f.style.width=`${Math.round(v.width)}px`,f.style.height=`${Math.round(v.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{var h;p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(h=e.dataTransfer)===null||h===void 0||h.setDragImage(f,s,l)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=H.create(r.state.doc,g),b=r.state.tr.setSelection(m);r.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(n))))return!1;let r=e.type.startsWith("drag"),o=e.type==="dragover"||e.type==="dragenter",i=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,u=H.isSelectable(this.node),c=e.type==="copy",d=e.type==="paste",f=e.type==="cut",p=e.type==="mousedown";if(!a&&u&&r&&e.target===this.dom&&e.preventDefault(),a&&r&&!l&&e.target===this.dom)return e.preventDefault(),!1;if(a&&s&&!l&&p){let h=n.closest("[data-drag-handle]");h&&(this.dom===h||this.dom.contains(h))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||c||d||f||p&&u)}ignoreMutation(e){return this.dom?this.contentDOM?typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.contentDOM.contains(e.target)&&e.type==="childList"&&(Kn()||Qr())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target):e.type!=="selection":!0}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return typeof n!="number"?!1:(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if(typeof e!="number")return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function Ze(e){return new ta({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{let i=de(e.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=t,l=r[r.length-1],a=r[0],u=n.to;if(l){let c=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Zr(n.from,n.to,t.doc).filter(p=>p.mark.type.excluded.find(h=>h===e.type&&h!==p.mark.type)).filter(p=>p.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+c,d),u=n.from+c+l.length,s.addMark(n.from+c,u,e.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(e.type)}}})}var qe=be(Xe(),1);var{getOwnPropertyNames:Hw,getOwnPropertySymbols:_w}=Object,{hasOwnProperty:Vw}=Object.prototype;function to(e,t){return function(r,o,i){return e(r,o,i)&&t(r,o,i)}}function no(e){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return e(n,r,o);let{cache:i}=o,s=i.get(n),l=i.get(r);if(s&&l)return s===r&&l===n;i.set(n,r),i.set(r,n);let a=e(n,r,o);return i.delete(n),i.delete(r),a}}function jw(e){return e?.[Symbol.toStringTag]}function Gf(e){return Hw(e).concat(_w(e))}var Fw=Object.hasOwn||((e,t)=>Vw.call(e,t));function qn(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Ww="__v",Kw="__o",Uw="_owner",qw=typeof Float16Array<"u",{getOwnPropertyDescriptor:Jf,keys:Xf}=Object;function Gw(e,t){return e.byteLength===t.byteLength&&ci(new Uint8Array(e),new Uint8Array(t))}function Jw(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Xw(e,t){return e.byteLength===t.byteLength&&ci(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Yw(e,t){return qn(e.getTime(),t.getTime())}function Yf(e,t,n){return e.name===t.name&&e.message===t.message&&e.stack===t.stack&&n.equals(e.cause,t.cause,"cause","cause",e,t,n)}function Qw(e,t){return e===t}function Qf(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.entries(),s,l,a=0;for(;(s=i.next())&&!s.done;){let u=t.entries(),c=!1,d=0;for(;(l=u.next())&&!l.done;){if(o[d]){d++;continue}let f=s.value,p=l.value;if(n.equals(f[0],p[0],a,d,e,t,n)&&n.equals(f[1],p[1],f[0],p[0],e,t,n)){c=o[d]=!0;break}d++}if(!c)return!1;a++}return!0}var Zw=qn;function Zf(e,t,n){let r=Xf(e),o=r.length;if(Xf(t).length!==o)return!1;for(;o-- >0;)if(!np(e,t,n,r[o]))return!1;return!0}function xr(e,t,n){let r=Gf(e),o=r.length;if(Gf(t).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!np(e,t,n,i)||(s=Jf(e,i),l=Jf(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function ek(e,t){return qn(e.valueOf(),t.valueOf())}function tk(e,t){return e.source===t.source&&e.flags===t.flags}function ep(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.values(),s,l;for(;(s=i.next())&&!s.done;){let a=t.values(),u=!1,c=0;for(;(l=a.next())&&!l.done;){if(!o[c]&&n.equals(s.value,l.value,s.value,l.value,e,t,n)){u=o[c]=!0;break}c++}if(!u)return!1}return!0}function ci(e,t){let n=e.length;if(t.length!==n||e.byteOffset!==t.byteOffset)return!1;if(e instanceof Float64Array||e instanceof Float32Array||qw&&e instanceof Float16Array){for(;n-- >0;)if(e[n]!==t[n]&&(e[n]===e[n]||t[n]===t[n]))return!1;return!0}for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function nk(e,t){return e.href===t.href?!0:e.protocol===t.protocol&&e.username===t.username&&e.password===t.password&&e.host===t.host&&e.pathname===t.pathname&&e.hash===t.hash&&rk(e.searchParams,t.searchParams)}function rk(e,t){let n=e.toString(),r=t.toString();return n===r||tp(n)===tp(r)}function tp(e){return e.split("&").sort().join("&")}function np(e,t,n,r){return(r===Uw||r===Kw||r===Ww)&&(e.$$typeof||t.$$typeof)?!0:Fw(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var ok="[object ArrayBuffer]",ik="[object Arguments]",sk="[object Boolean]",lk="[object DataView]",ak="[object Date]",ck="[object Error]",uk="[object Map]",dk="[object Number]",fk="[object Object]",pk="[object RegExp]",hk="[object Set]",mk="[object String]",gk={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},bk="[object URL]",yk=Object.prototype.toString;function wk({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:h}){return function(m,b,v){if(m===b)return!0;if(m==null||b==null)return!1;let S=typeof m;if(S!==typeof b)return!1;if(S!=="object")return S==="number"?l(m,b,v):S==="function"?i(m,b,v):!1;let C=m.constructor;if(C!==b.constructor)return!1;if(C===Object)return a(m,b,v);if(Array.isArray(m))return t(m,b,v);if(C===Date)return r(m,b,v);if(C===RegExp)return c(m,b,v);if(C===Map)return s(m,b,v);if(C===Set)return d(m,b,v);if(C==null)return a(m,b,v);let M=yk.call(m);if(M===ak)return r(m,b,v);if(M===pk)return c(m,b,v);if(M===uk)return s(m,b,v);if(M===hk)return d(m,b,v);if(M===fk)return typeof m.then!="function"&&typeof b.then!="function"&&a(m,b,v);if(M===bk)return p(m,b,v);if(M===ck)return o(m,b,v);if(M===ik)return a(m,b,v);if(gk[M])return f(m,b,v);if(M===ok)return e(m,b,v);if(M===lk)return n(m,b,v);if(M===sk||M===dk||M===mk)return u(m,b,v);if(h){let T=h[M];if(!T){let E=jw(m);E&&(T=h[E])}if(T)return T(m,b,v)}return!1}}function kk({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Gw,areArraysEqual:n?xr:Jw,areDataViewsEqual:Xw,areDatesEqual:Yw,areErrorsEqual:n?to(Yf,xr):to(Yf,Zf),areFunctionsEqual:Qw,areMapsEqual:n?to(Qf,xr):Qf,areNumbersEqual:Zw,areObjectsEqual:n?xr:Zf,arePrimitiveWrappersEqual:ek,areRegExpsEqual:tk,areSetsEqual:n?to(ep,xr):ep,areTypedArraysEqual:n?to(ci,xr):ci,areUrlsEqual:nk,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let o=no(r.areArraysEqual),i=no(r.areErrorsEqual),s=no(r.areMapsEqual),l=no(r.areObjectsEqual),a=no(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function vk(e){return function(t,n,r,o,i,s,l){return e(t,n,l)}}function Ck({circular:e,comparator:t,createState:n,equals:r,strict:o}){if(n)return function(l,a){let{cache:u=e?new WeakMap:void 0,meta:c}=n();return t(l,a,{cache:u,equals:r,meta:c,strict:o})};if(e)return function(l,a){return t(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};let i={cache:void 0,equals:r,meta:void 0,strict:o};return function(l,a){return t(l,a,i)}}var rp=pn(),dE=pn({strict:!0}),fE=pn({circular:!0}),pE=pn({circular:!0,strict:!0}),hE=pn({createInternalComparator:()=>qn}),mE=pn({strict:!0,createInternalComparator:()=>qn}),gE=pn({circular:!0,createInternalComparator:()=>qn}),bE=pn({circular:!0,createInternalComparator:()=>qn,strict:!0});function pn(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:o=!1}=e,i=kk(e),s=wk(i),l=n?n(s):vk(s);return Ck({circular:t,comparator:s,createState:r,equals:l,strict:o})}var up=be(Sg(),1);function xk(e,t){var n,r;if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!=="insertParagraph"&&t.inputType!=="insertLineBreak"||!Kn()&&!Qr())return;let o=e.view,i=o.root,s=(n=(r=i.getSelection)===null||r===void 0?void 0:r.call(i))!==null&&n!==void 0?n:o.dom.ownerDocument.getSelection(),l=s?.anchorNode,a=l?.nodeType===1?l:l?.parentElement,u=a?.closest("[data-node-view-content-react]");if(!u||!o.dom.contains(u))return;let c=o.input.lastKeyCode;c===13&&(o.input.lastKeyCode=null),o.domObserver.forceFlush(),o.domObserver.flush();let d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,shiftKey:t.inputType==="insertLineBreak",bubbles:!0,cancelable:!0});o.someProp("handleKeyDown",f=>f(o,d))?(t.preventDefault(),o.input.lastIOSEnter=0,clearTimeout(o.input.lastIOSEnterFallbackTimeout)):c===13&&(o.input.lastKeyCode=c)}var op=new ne("reactMobileEnter"),Sk=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Ek=({contentComponent:e})=>{let t=(0,cp.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,qe.jsx)(qe.Fragment,{children:Object.values(t)})};function Mk(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(o=>o())}))};return{subscribe(o){return e.add(o),()=>{e.delete(o)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(o,i){t={...t,[o]:ui.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...t};delete i[o],t=i,r()}}}var ra=class extends ee.default.Component{constructor(e){super(e),this.editorContentRef=ee.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(!((e=t.view.dom)===null||e===void 0)&&e.parentNode)){if(t.contentComponent)return;let n=this.editorContentRef.current;n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n}),t.contentComponent=Mk(),t.createNodeViews(),t.registerPlugin(new W({key:op,props:{handleDOMEvents:{beforeinput:(r,o)=>xk(t,o)}}})),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(op),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{var t;if(!(!((t=e.view.dom)===null||t===void 0)&&t.parentNode))return;let n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{ref:Sk(t,this.editorContentRef),...n}),e?.contentComponent&&(0,qe.jsx)(Ek,{contentComponent:e.contentComponent})]})}},Ak=(0,ee.forwardRef)((e,t)=>{let n=ee.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return ee.default.createElement(ra,{key:n,innerRef:t,...e})}),Tk=ee.default.memo(Ak),Nk=typeof window<"u"?ee.useLayoutEffect:ee.useEffect,Rk=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let t,n=o=>{o?.transaction!==void 0&&o.transaction===t||(t=o?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function di(e){var t;let[n]=(0,ee.useState)(()=>new Rk(e.editor)),r=(0,up.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:rp);return Nk(()=>n.watch(e.editor),[e.editor,n]),(0,ee.useDebugValue)(r),r}var Ok=typeof window>"u",SE=Ok||!!(typeof window<"u"&&window.next);var dp=(0,ee.createContext)({editor:null}),EE=dp.Consumer;var fp=(0,ee.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var pp=()=>(0,ee.useContext)(fp);function oa({as:e="div",...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=pp();return(0,qe.jsx)(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var Sr=ee.default.forwardRef((e,t)=>{let{onDragStart:n}=pp(),r=e.as||"div";return(0,qe.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function ip(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function sp(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.forward_ref)"||e.$$typeof.description==="react.forward_ref"))}function Dk(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function Lk(e){if(ip(e)||sp(e))return!0;if(Dk(e)){let t=e.type;if(t)return ip(t)||sp(t)}return!1}function Ik(){try{if(ee.version)return parseInt(ee.version.split(".")[0],10)>=19}catch{}return!1}var Pk=class{constructor(e,{editor:t,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?(0,ui.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,o=Ik(),i=Lk(t),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,qe.jsx)(t,{...s}),r==null||(e=r.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let o=n[r];if(e[o]!==this.props[o]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;t==null||(e=t.contentComponent)===null||e===void 0||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}},ME=ee.default.createContext({markViewContentRef:()=>{}});function $k(e){var t;let n=e.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(t=e.ownerDocument)===null||t===void 0||(t=t.defaultView)===null||t===void 0?void 0:t.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=r;return!o||!s||!e.contains(o)||!e.contains(s)?null:()=>{try{r.setBaseAndExtent(o,i,s,l)}catch{}}}function Bk(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function hp(e){if(!ri(e))return[];let{$from:t,$to:n}=e,r=[],o=Math.min(t.depth,n.depth);for(let i=1;i<=o&&Bk(t,n,i);i+=1)r.push(t.before(i));return r}var zk=class{constructor(e){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=e}register(e){this.viewCount===0&&this.editor.on("transaction",this.handleTransaction),this.views.set(e.dom,e),this.viewCount+=1,this.scheduleSync()}unregister(e){this.views.delete(e.dom),this.viewCount-=1,this.insideViews.delete(e),this.viewCount===0&&this.editor.off("transaction",this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let e=this.findInsideViews();this.updateViews(this.insideViews,e,!1),this.updateViews(e,this.insideViews,!0),this.insideViews=e}updateViews(e,t,n){for(let r of e)t.has(r)||r.setSelectionInside(n)}findInsideViews(){let e=new Set;for(let t of hp(this.editor.state.selection)){let n=this.editor.view.nodeDOM(t),r=n?this.views.get(n):void 0;r&&e.add(r)}return e}},lp=new WeakMap;function ap(e){let t=lp.get(e);return t||(t=new zk(e),lp.set(e,t)),t}var Hk=class extends qf{constructor(e,t,n){if(super(e,t,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";let r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,o){if(r==="storage"){var i;return(i=e.storage[t.name])!==null&&i!==void 0?i:{}}return Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:(0,ee.createRef)()};if(!this.component.displayName){let a=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=a(this.extension.name)}let r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{if(a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement){a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper");let u=$k(this.contentDOMElement);a.appendChild(this.contentDOMElement),u?.()}}},o=this.component,i=(0,ee.memo)(a=>(0,qe.jsx)(fp.Provider,{value:r,children:(0,ee.createElement)(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);let{className:l=""}=this.options;this.renderer=new Pk(i,{editor:this.editor,props:e,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),ap(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(e,t,n){let r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){let s=this.node,l=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:s,oldDecorations:l,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let o=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=o;let i={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(e){let t=this.nodeSelected||this.options.selectedOnTextSelection===!0&&e;this.renderer.updateProps({selectionInside:e,selected:t}),this.renderer.element.classList.toggle("ProseMirror-selectednode",t)}updateSelectedState(e){this.renderer.updateProps({selected:e}),this.renderer.element.classList.toggle("ProseMirror-selectednode",e)}isTextSelectionInside(){let e=this.getPos();return typeof e=="number"&&hp(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),ap(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){let t=this.editor.extensionManager.attributes,n=At(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Er(e,t){return n=>n.editor.contentComponent?new Hk(e,n,t):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var ia=(0,ee.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});ia.displayName="TiptapContext";var _k=()=>(0,ee.useContext)(ia);function mp({children:e,...t}){let n="editor"in t?t.editor:t.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,ee.useMemo)(()=>({editor:n}),[n]),o=(0,ee.useMemo)(()=>({editor:n}),[n]);return(0,qe.jsx)(dp.Provider,{value:o,children:(0,qe.jsx)(ia.Provider,{value:r,children:e})})}mp.displayName="Tiptap";function gp({...e}){let{editor:t}=_k();return(0,qe.jsx)(Tk,{editor:t,...e})}gp.displayName="Tiptap.Content";var AE=Object.assign(mp,{Content:gp});var fi=class extends ra{componentWillUnmount(){let t=this.editorContentRef.current;queueMicrotask(()=>{t?.isConnected||super.componentWillUnmount()})}};var et=be(tn(),1);var Vk=new WeakSet,bp=e=>Vk.has(e);var jk=(0,et.createContext)(null);function yp(e){let t=(0,et.useContext)(jk),n=(0,et.useId)(),r=(0,et.useRef)(e.retentionKey??n).current,o=(0,et.useRef)(e);o.current=e;let i=(0,et.useRef)(t?.find(r)??null),[s,l]=(0,et.useState)(i.current),a=(0,et.useRef)(void 0);return(0,et.useLayoutEffect)(()=>{clearTimeout(a.current);let u=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:p,...h}=o.current;return new na({...h,onUpdate:g=>o.current.onUpdate?.(g),editorProps:{...h.editorProps,handleKeyDown:(g,m)=>o.current.editorProps?.handleKeyDown?.(g,m)??!1,handleClick:(g,m,b)=>o.current.editorProps?.handleClick?.(g,m,b)??!1,handlePaste:(g,m,b)=>o.current.editorProps?.handlePaste?.(g,m,b)??!1}})},c=t?t.get(r,u):i.current&&!i.current.isDestroyed?i.current:u();return i.current=c,c.setEditable(o.current.editable!==!1,!1),l(c),()=>{c.isDestroyed||c.setEditable(!1,!1),!t&&(a.current=setTimeout(()=>{i.current===c&&!c.isDestroyed&&c.destroy()},1))}},[t,r]),s}var sa=new WeakMap;function la(e){let t=sa.get(e);if(t)return t;let n={type:e.type.name};return Object.keys(e.attrs).length&&(n.attrs=e.attrs),e.content.size&&(n.content=[],e.content.forEach(r=>n.content.push(la(r)))),e.marks.length&&(n.marks=e.marks.map(r=>r.toJSON())),e.isText&&(n.text=e.text),sa.set(e,n),n}function wp(e,t){let n=sa.get(e);if(n===t)return!0;if(!n||n.type!==t.type||n.text!==t.text||n.attrs!==t.attrs&&JSON.stringify(n.attrs)!==JSON.stringify(t.attrs)||n.marks!==t.marks&&JSON.stringify(n.marks)!==JSON.stringify(t.marks)||e.childCount!==(t.content?.length??0))return!1;for(let r=0;r<e.childCount;r++)if(!wp(e.child(r),t.content[r]))return!1;return!0}function kp(e,t){if(t.type!==e.type.name||e.childCount!==(t.content?.length??0))return!1;for(let n=0;n<e.childCount;n++)if(!wp(e.child(n),t.content[n]))return!1;return!0}function pi(e,t,n){let r=[],o=[];return e.nodesBetween(t,n,(i,s,l)=>{let a=i.attrs?.id;if(!(typeof a!="string"||a.startsWith("page-tail-")))if(i.isTextblock){let u=s+1,c=u+i.content.size;(Math.max(t,u)<Math.min(n,c)||i.content.size===0&&t<=s&&n>=s+i.nodeSize)&&r.push(a)}else l===e&&o.push(a)}),[...new Set(r.length?r:o)].slice(0,100)}var Le=class e extends J{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):J.near(r)}content(){return ae.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))}getBookmark(){return new aa(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!Fk(t)||!Wk(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&e.valid(t))return t;let o=t.pos,i=null;for(let s=t.depth;;s--){let l=t.node(s);if(n>0?t.indexAfter(s)<l.childCount:t.index(s)>0){i=l.child(n>0?t.indexAfter(s):t.index(s)-1);break}else if(s==0)return null;o+=n;let a=t.doc.resolve(o);if(e.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!H.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=t.doc.resolve(o);if(e.valid(l))return l}return null}}};Le.prototype.visible=!1;Le.findFrom=Le.findGapCursorFrom;J.jsonID("gapcursor",Le);var aa=class e{constructor(t){this.pos=t}map(t){return new e(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Le.valid(n)?new Le(n):J.near(n)}};function vp(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Fk(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||vp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Wk(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||vp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Cp(){return new W({props:{decorations:Gk,createSelectionBetween(e,t,n){return t.pos==n.pos&&Le.valid(n)?new Le(n):null},handleClick:Uk,handleKeyDown:Kk,handleDOMEvents:{beforeinput:qk}}})}var Kk=Jr({ArrowLeft:hi("horiz",-1),ArrowRight:hi("horiz",1),ArrowUp:hi("vert",-1),ArrowDown:hi("vert",1)});function hi(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,i){let s=r.selection,l=t>0?s.$to:s.$from,a=s.empty;if(s instanceof L){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(t>0?l.after():l.before())}let u=Le.findGapCursorFrom(l,t,a);return u?(o&&o(r.tr.setSelection(new Le(u))),!0):!1}}function Uk(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Le.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&H.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Le(r))),!0)}function qk(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Le))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=z.empty;for(let s=r.length-1;s>=0;s--)o=z.from(r[s].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new ae(o,0,0));return i.setSelection(L.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function Gk(e){if(!(e.selection instanceof Le))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",ue.create(e.doc,[Ee.widget(e.selection.head,t,{key:"gapcursor"})])}function Mr(e){let t=e.selection;if(!(t instanceof H)||t.node.type.name!=="widget")return null;let n=J.findFrom(t.$to,1,!0)??J.findFrom(t.$from,-1,!0),r=n?null:new Le(e.doc.resolve(e.doc.content.size)).map(e.doc,new To),o=n??(r instanceof Le?r:null);return o?e.tr.setSelection(o).setMeta("addToHistory",!1):null}function xp(e,t){if(kp(e.doc,t))return null;let n=e.schema.nodeFromJSON(t),r=e.doc.content.findDiffStart(n.content);if(r===null)return null;let o=e.doc.content.findDiffEnd(n.content),i=o.a,s=o.b,l=r-Math.min(i,s);return l>0&&(i+=l,s+=l),e.tr.replace(r,i,n.slice(r,s)).setMeta("addToHistory",!1).setMeta("preventUpdate",!0)}var ua,da;if(typeof WeakMap<"u"){let e=new WeakMap;ua=t=>e.get(t),da=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;ua=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},da=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var he=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,o=t/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[t+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[t+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(e);return t=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){let{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:u}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,u)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s)&&t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==e){let s=t+e*this.width,l=(e+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(e){return ua(e)||da(e,Jk(e))}};function Jk(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=Xk(e),n=e.childCount,r=[],o=0,i=null,s=[];for(let u=0,c=t*n;u<c;u++)r[u]=0;for(let u=0,c=0;u<n;u++){let d=e.child(u);c++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==d.childCount)break;let g=d.child(h),{colspan:m,rowspan:b,colwidth:v}=g.attrs;for(let S=0;S<b;S++){if(S+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:b-S});break}let C=o+S*t;for(let M=0;M<m;M++){r[C+M]==0?r[C+M]=c:(i||(i=[])).push({type:"collision",row:u,pos:c,n:m-M});let T=v&&v[M];if(T){let E=(C+M)%t*2,B=s[E];B==null||B!=T&&s[E+1]==1?(s[E]=T,s[E+1]=1):B==T&&s[E+1]++}}}o+=m,c+=g.nodeSize}let f=(u+1)*t,p=0;for(;o<f;)r[o++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:u,n:p}),c++}(t===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new he(t,n,r,i),a=!1;for(let u=0;!a&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(a=!0);return a&&Yk(l,s,e),l}function Xk(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let o=e.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=e.child(s);for(let a=0;a<l.childCount;a++){let u=l.child(a);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}t==-1?t=i:t!=i&&(t=Math.max(t,i))}return t}function Yk(e,t,n){e.problems||(e.problems=[]);let r={};for(let o=0;o<e.map.length;o++){let i=e.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let u=0;u<a.colspan;u++){let c=t[(o+u)%e.width*2];c!=null&&(!a.colwidth||a.colwidth[u]!=c)&&((l||(l=Qk(a)))[u]=c)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Qk(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Ge(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var hn=new ne("selectingCells");function Kt(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function Zk(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function wt(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function ki(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=Kt(t.$head)||ev(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function ev(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function fa(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function tv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ma(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Lp(e,t,n){let r=e.node(-1),o=he.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return s==null?null:e.node(0).resolve(i+s)}function Gn(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Ip(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}function nv(e,t,n){let r=Ge(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var re=class Wt extends J{constructor(t,n=t){let r=t.node(-1),o=he.get(r),i=t.start(-1),s=o.rectBetween(t.pos-i,n.pos-i),l=t.node(0),a=o.cellsInRect(s).filter(c=>c!=n.pos-i);a.unshift(n.pos-i);let u=a.map(c=>{let d=r.nodeAt(c);if(!d)throw new RangeError(`No cell with offset ${c} found`);let f=i+c+1;return new $s(l.resolve(f),l.resolve(f+d.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(fa(r)&&fa(o)&&ma(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wt.rowSelection(r,o):i&&this.isColSelection()?Wt.colSelection(r,o):new Wt(r,o)}return L.between(r,o)}content(){let t=this.$anchorCell.node(-1),n=he.get(t),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let u=[];for(let c=a*n.width+o.left,d=o.left;d<o.right;d++,c++){let f=n.map[c];if(i[f])continue;i[f]=!0;let p=n.findCell(f),h=t.nodeAt(f);if(!h)throw new RangeError(`No cell with offset ${f} found`);let g=o.left-p.left,m=p.right-o.right;if(g>0||m>0){let b=h.attrs;if(g>0&&(b=Gn(b,0,g)),m>0&&(b=Gn(b,b.colspan-m,m)),p.left<o.left){if(h=h.type.createAndFill(b),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else h=h.type.create(b,h.content)}if(p.top<o.top||p.bottom>o.bottom){let b={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(b):h=h.type.create(b,h.content)}u.push(h)}s.push(t.child(a).copy(z.from(u)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new ae(z.from(l),1,1)}replace(t,n=ae.empty){let r=t.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],u=t.mapping.slice(r);t.replace(u.map(l.pos),u.map(a.pos),s?ae.empty:n)}let i=J.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new ae(z.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=he.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)t(n.nodeAt(i[s]),o+i[s])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let r=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),o=he.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wt(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=he.get(t),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(t){return t instanceof Wt&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),o=he.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wt(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Wt(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Wt(t.resolve(n),t.resolve(r))}getBookmark(){return new rv(this.$anchorCell.pos,this.$headCell.pos)}};re.prototype.visible=!1;J.jsonID("cell",re);var rv=class Pp{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Pp(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ma(n,r)?new re(n,r):J.near(r,1)}};function ov(e){if(!(e.selection instanceof re))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push(Ee.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ue.create(e.doc,t)}function iv({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let i=t.depth;i>=0&&!(t.before(i+1)>t.start(i));i--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}function sv({$from:e,$to:t}){let n,r;for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&t.parentOffset===0}function lv(e,t,n){let r=(t||e).selection,o=(t||e).doc,i,s;if(r instanceof H&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=re.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=re.rowSelection(l,l)}else if(!n){let l=he.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];i=re.create(o,a+1,u)}}else r instanceof L&&iv(r)?i=L.create(o,r.from):r instanceof L&&sv(r)&&(i=L.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var av=new ne("fix-tables");function $p(e,t,n,r){let o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){let a=t.child(s);for(let u=l,c=Math.min(o,s+3);u<c;u++)if(e.child(u)==a){l=u+1,n+=a.nodeSize;continue e}r(a,n),l<o&&e.child(l).sameMarkup(a)?$p(e.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ga(e,t){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=cv(e,o,i,n))};return t?t.doc!=e.doc&&$p(t.doc,e.doc,0,r):e.doc.descendants(r),n}function cv(e,t,n,r){let o=he.get(t);if(!o.problems)return r;r||(r=e.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let u=o.problems[a];if(u.type=="collision"){let c=t.nodeAt(u.pos);if(!c)continue;let d=c.attrs;for(let f=0;f<d.rowspan;f++)i[u.row+f]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Gn(d,d.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){let c=t.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){let c=t.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){let c=r.mapping.map(n);r.delete(c,c+t.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,u=n+1;a<o.height;a++){let c=t.child(a),d=u+c.nodeSize,f=i[a];if(f>0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);let h=[];for(let m=0;m<f;m++){let b=Ge(e.schema)[p].createAndFill();b&&h.push(b)}let g=(a==0||s==a-1)&&l==a?u+1:d-1;r.insert(r.mapping.map(g),h)}u=d}return r.setMeta(av,{fixTables:!0})}function Tt(e){let t=e.selection,n=ki(e),r=n.node(-1),o=n.start(-1),i=he.get(r);return{...t instanceof re?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Bp(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;nv(t,r,o+i)&&(i=o==0||o==t.width?null:0);for(let s=0;s<t.height;s++){let l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){let a=t.map[l],u=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Ip(u.attrs,o-t.colCount(a))),s+=u.attrs.rowspan-1}else{let a=i==null?Ge(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,u=t.positionAt(s,o,r);e.insert(e.mapping.map(n+u),a.createAndFill())}}return e}function zp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Bp(e.tr,n,n.left))}return!0}function Hp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Bp(e.tr,n,n.right))}return!0}function uv(e,{map:t,table:n,tableStart:r},o){let i=e.mapping.maps.length;for(let s=0;s<t.height;){let l=s*t.width+o,a=t.map[l],u=n.nodeAt(a),c=u.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,Gn(c,o-t.colCount(a)));else{let d=e.mapping.slice(i).map(r+a);e.delete(d,d+u.nodeSize)}s+=c.rowspan}}function _p(e,t){if(!wt(e))return!1;if(t){let n=Tt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;uv(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=he.get(i)}t(r)}return!0}function dv(e,t,n){var r;let o=Ge(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(((r=t.nodeAt(e.map[i+n*e.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Vp(e,{map:t,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;let s=[],l=o>0?-1:0;dv(t,r,o+l)&&(l=o==0||o==t.height?null:0);for(let u=0,c=t.width*o;u<t.width;u++,c++)if(o>0&&o<t.height&&t.map[c]==t.map[c-t.width]){let d=t.map[c],f=r.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),u+=f.colspan-1}else{var a;let d=l==null?Ge(r.type.schema).cell:(a=r.nodeAt(t.map[c+l*t.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return e.insert(i,Ge(r.type.schema).row.create(null,s)),e}function jp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Vp(e.tr,n,n.top))}return!0}function Fp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Vp(e.tr,n,n.bottom))}return!0}function fv(e,{map:t,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;let s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);let a=new Set;for(let u=0,c=o*t.width;u<t.width;u++,c++){let d=t.map[c];if(!a.has(d)){if(a.add(d),o>0&&d==t.map[c-t.width]){let f=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(o<t.height&&d==t.map[c+t.width]){let f=n.nodeAt(d),p=f.attrs,h=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=t.positionAt(o+1,u,n);e.insert(e.mapping.slice(l).map(r+g),h),u+=p.colspan-1}}}}function Wp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;fv(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=he.get(n.table)}t(r)}return!0}function Sp(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function pv({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}function ba(e,t){let n=e.selection;if(!(n instanceof re)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Tt(e),{map:o}=r;if(pv(o,r))return!1;if(t){let i=e.tr,s={},l=z.empty,a,u;for(let c=r.top;c<r.bottom;c++)for(let d=r.left;d<r.right;d++){let f=o.map[c*o.width+d],p=r.table.nodeAt(f);if(!(s[f]||!p))if(s[f]=!0,a==null)a=f,u=p;else{Sp(p)||(l=l.append(p.content));let h=i.mapping.map(f+r.tableStart);i.delete(h,h+p.nodeSize)}}if(a==null||u==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Ip(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let c=a+1+u.content.size,d=Sp(u)?a+1:c;i.replaceWith(d+r.tableStart,c+r.tableStart,l)}i.setSelection(new re(i.doc.resolve(a+r.tableStart))),t(i)}return!0}function ya(e,t){let n=Ge(e.schema);return hv(({node:r})=>n[r.type.spec.tableRole])(e,t)}function hv(e){return(t,n)=>{let r=t.selection,o,i;if(r instanceof re){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=Zk(r.$from),!o)return!1;i=(s=Kt(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],u=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let c=Tt(t),d=t.tr;for(let p=0;p<c.right-c.left;p++)a.push(u?{...l,colwidth:u&&u[p]?[u[p]]:null}:l);let f;for(let p=c.top;p<c.bottom;p++){let h=c.map.positionAt(p,c.left,c.table);p==c.top&&(h+=o.nodeSize);for(let g=c.left,m=0;g<c.right;g++,m++)g==c.left&&p==c.top||d.insert(f=d.mapping.map(h+c.tableStart,1),e({node:o,row:p,col:g}).createAndFill(a[m]))}d.setNodeMarkup(i,e({node:o,row:c.top,col:c.left}),a[0]),r instanceof re&&d.setSelection(new re(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Kp(e,t){return function(n,r){if(!wt(n))return!1;let o=ki(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){let i=n.tr;n.selection instanceof re?n.selection.forEachCell((s,l)=>{s.attrs[e]!==t&&i.setNodeMarkup(l,null,{...s.attrs,[e]:t})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(i)}return!0}}function mv(e){return function(t,n){if(!wt(t))return!1;if(n){let r=Ge(t.schema),o=Tt(t),i=t.tr,s=o.map.cellsInRect(e=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:e=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Ep(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let o=0;o<r.length;o++){let i=t.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ar(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?mv(e):function(n,r){if(!wt(n))return!1;if(r){let o=Ge(n.schema),i=Tt(n),s=n.tr,l=Ep("row",i,o),a=Ep("column",i,o),u=(e==="column"?l:e==="row"&&a)?1:0,c=e=="column"?{left:0,top:u,right:1,bottom:i.map.height}:e=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,d=e=="column"?a?o.cell:o.header_cell:e=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(c).forEach(f=>{let p=f+i.tableStart,h=s.doc.nodeAt(p);h&&s.setNodeMarkup(p,d,h.attrs)}),r(s)}return!0}}var sM=Ar("row",{useDeprecatedLogic:!0}),lM=Ar("column",{useDeprecatedLogic:!0}),Up=Ar("cell",{useDeprecatedLogic:!0});function gv(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,o=e.before();r>=0;r--){let i=e.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let r=e.indexAfter(-1),o=e.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function wa(e){return function(t,n){if(!wt(t))return!1;let r=gv(ki(t),e);if(r==null)return!1;if(n){let o=t.doc.resolve(r);n(t.tr.setSelection(L.between(o,tv(o))).scrollIntoView())}return!0}}function qp(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function mi(e,t){let n=e.selection;if(!(n instanceof re))return!1;if(t){let r=e.tr,o=Ge(e.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new ae(o,0,0))}),r.docChanged&&t(r)}return!0}function bv(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;let o=t.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<t.childCount;a++){let u=t.child(a).content,c=a?0:Math.max(0,n-1),d=a<t.childCount-1?0:Math.max(0,r-1);(c||d)&&(u=pa(Ge(s).row,new ae(u,c,d)).content),l.push(u)}else if(i=="cell"||i=="header_cell")l.push(n||r?pa(Ge(s).row,new ae(t,n,r)).content:t);else return null;return yv(s,l)}function yv(e,t){let n=[];for(let o=0;o<t.length;o++){let i=t[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let u=o;u<o+l;u++)n[u]=(n[u]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(z.empty),n[o]<r){let i=Ge(e).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);t[o]=t[o].append(z.from(s))}return{height:t.length,width:r,rows:t}}function pa(e,t){let n=e.createAndFill();return new Oo(n).replace(0,n.content.size,t).doc}function wv({width:e,height:t,rows:n},r,o){if(e!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],u=[];for(let c=i[l]||0,d=0;c<r;d++){let f=a.child(d%a.childCount);c+f.attrs.colspan>r&&(f=f.type.createChecked(Gn(f.attrs,f.attrs.colspan,c+f.attrs.colspan-r),f.content)),u.push(f),c+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+f.attrs.colspan}s.push(z.from(u))}n=s,e=r}if(t!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],u=n[l%t];for(let c=0;c<u.childCount;c++){let d=u.child(c);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(z.from(a))}n=i,t=o}return{width:e,height:t,rows:n}}function kv(e,t,n,r,o,i,s){let l=e.doc.type.schema,a=Ge(l),u,c;if(o>t.width)for(let d=0,f=0;d<t.height;d++){let p=n.child(d);f+=p.nodeSize;let h=[],g;p.lastChild==null||p.lastChild.type==a.cell?g=u||(u=a.cell.createAndFill()):g=c||(c=a.header_cell.createAndFill());for(let m=t.width;m<o;m++)h.push(g);e.insert(e.mapping.slice(s).map(f-1+r),h)}if(i>t.height){let d=[];for(let h=0,g=(t.height-1)*t.width;h<Math.max(t.width,o);h++){let m=h>=t.width?!1:n.nodeAt(t.map[g+h]).type==a.header_cell;d.push(m?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}let f=a.row.create(null,z.from(d)),p=[];for(let h=t.height;h<i;h++)p.push(f);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(u||c)}function Mp(e,t,n,r,o,i,s,l){if(s==0||s==t.height)return!1;let a=!1;for(let u=o;u<i;u++){let c=s*t.width+u,d=t.map[c];if(t.map[c-t.width]==d){a=!0;let f=n.nodeAt(d),{top:p,left:h}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-p}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-s})),u+=f.attrs.colspan-1}}return a}function Ap(e,t,n,r,o,i,s,l){if(s==0||s==t.width)return!1;let a=!1;for(let u=o;u<i;u++){let c=u*t.width+s,d=t.map[c];if(t.map[c-1]==d){a=!0;let f=n.nodeAt(d),p=t.colCount(d),h=e.mapping.slice(l).map(d+r);e.setNodeMarkup(h,null,Gn(f.attrs,s-p,f.attrs.colspan-(s-p))),e.insert(h+f.nodeSize,f.type.createAndFill(Gn(f.attrs,0,s-p))),u+=f.attrs.rowspan-1}}return a}function Tp(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let s=he.get(i),{top:l,left:a}=r,u=a+o.width,c=l+o.height,d=e.tr,f=0;function p(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=he.get(i),f=d.mapping.maps.length}kv(d,s,i,n,u,c,f)&&p(),Mp(d,s,i,n,a,u,l,f)&&p(),Mp(d,s,i,n,a,u,c,f)&&p(),Ap(d,s,i,n,l,c,a,f)&&p(),Ap(d,s,i,n,l,c,u,f)&&p();for(let h=l;h<c;h++){let g=s.positionAt(h,a,i),m=s.positionAt(h,u,i);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(m+n),new ae(o.rows[h-l],0,0))}p(),d.setSelection(new re(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(c-1,u-1,i)))),t(d)}var vv=Jr({ArrowLeft:gi("horiz",-1),ArrowRight:gi("horiz",1),ArrowUp:gi("vert",-1),ArrowDown:gi("vert",1),"Shift-ArrowLeft":bi("horiz",-1),"Shift-ArrowRight":bi("horiz",1),"Shift-ArrowUp":bi("vert",-1),"Shift-ArrowDown":bi("vert",1),Backspace:mi,"Mod-Backspace":mi,Delete:mi,"Mod-Delete":mi});function yi(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function gi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof re)return yi(n,r,J.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let s=Gp(o,e,t);if(s==null)return!1;if(e=="horiz")return yi(n,r,J.near(n.doc.resolve(i.head+t),t));{let l=n.doc.resolve(s),a=Lp(l,e,t),u;return a?u=J.near(a,1):t<0?u=J.near(n.doc.resolve(l.before(-1)),-1):u=J.near(n.doc.resolve(l.after(-1)),1),yi(n,r,u)}}}function bi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof re)s=i;else{let a=Gp(o,e,t);if(a==null)return!1;s=new re(n.doc.resolve(a))}let l=Lp(s.$headCell,e,t);return l?yi(n,r,new re(s.$anchorCell,l)):!1}}function Cv(e,t){let n=e.state.doc,r=Kt(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new re(r))),!0):!1}function xv(e,t,n){if(!wt(e.state))return!1;let r=bv(n),o=e.state.selection;if(o instanceof re){r||(r={width:1,height:1,rows:[z.from(pa(Ge(e.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=he.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=wv(r,l.right-l.left,l.bottom-l.top),Tp(e.state,e.dispatch,s,l,r),!0}else if(r){let i=ki(e.state),s=i.start(-1);return Tp(e.state,e.dispatch,s,he.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Sv(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=Np(e,t.target),o;if(t.shiftKey&&e.state.selection instanceof re)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(o=Kt(e.state.selection.$anchor))!=null&&((n=ca(e,t))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(a,u){let c=ca(e,u),d=hn.getState(e.state)==null;if(!c||!ma(a,c))if(d)c=a;else return;let f=new re(a,c);if(d||!e.state.selection.eq(f)){let p=e.state.tr.setSelection(f);d&&p.setMeta(hn,a.pos),e.dispatch(p)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),hn.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(hn,-1))}function l(a){let u=a,c=hn.getState(e.state),d;if(c!=null)d=e.state.doc.resolve(c);else if(Np(e,u.target)!=r&&(d=ca(e,t),!d))return s();d&&i(d,u)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Gp(e,t,n){if(!(e.state.selection instanceof L))return null;let{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function Np(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function ca(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Kt(e.state.doc.resolve(r))||Kt(e.state.doc.resolve(o))}var Ev=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ha(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ha(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ha(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,u=e.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){let{colspan:p,colwidth:h}=u.child(d).attrs;for(let g=0;g<p;g++,f++){let m=o==f?i:h&&h[g],b=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{let v=document.createElement("col");v.style.width=b,t.appendChild(v)}}}for(;a;){var c;let d=a.nextSibling;(c=a.parentNode)===null||c===void 0||c.removeChild(a),a=d}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var lt=new ne("tableColumnResizing");function Jp({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Ev,lastColumnResizable:o=!0}={}){let i=new W({key:lt,state:{init(s,l){var a;let u=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,c=Ge(l.schema).table.name;return r&&u&&(u[c]=(d,f)=>new r(d,n,f)),new Mv(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=lt.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Av(s,l,e,o)},mouseleave:s=>{Tv(s)},mousedown:(s,l)=>{Nv(s,l,t,n)}},decorations:s=>{let l=lt.getState(s);if(l&&l.activeHandle>-1)return Iv(s,l.activeHandle)},nodeViews:{}}});return i}var Mv=class wi{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(lt);if(r&&r.setHandle!=null)return new wi(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new wi(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return fa(t.doc.resolve(o))||(o=-1),new wi(o,n.dragging)}return n}};function Av(e,t,n,r){if(!e.editable)return;let o=lt.getState(e.state);if(o&&!o.dragging){let i=Ov(t.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();t.clientX-l<=n?s=Rp(e,t,"left",n):a-t.clientX<=n&&(s=Rp(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),a=l.node(-1),u=he.get(a),c=l.start(-1);if(u.colCount(l.pos-c)+l.nodeAfter.attrs.colspan-1==u.width-1)return}Xp(e,s)}}}function Tv(e){if(!e.editable)return;let t=lt.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Xp(e,-1)}function Nv(e,t,n,r){var o;if(!e.editable)return!1;let i=(o=e.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=lt.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),a=Rv(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(lt,{setDragging:{startX:t.clientX,startWidth:a}}));function u(d){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",c);let f=lt.getState(e.state);f?.dragging&&(Dv(e,f.activeHandle,Op(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(lt,{setDragging:null})))}function c(d){if(!d.which)return u(d);let f=lt.getState(e.state);if(f&&f.dragging){let p=Op(f.dragging,d,n);Dp(e,f.activeHandle,p,r)}}return Dp(e,s.activeHandle,a,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",c),t.preventDefault(),!0}function Rv(e,t,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=e.domAtPos(t),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function Ov(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Rp(e,t,n,r){let o=n=="right"?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;let{pos:s}=i,l=Kt(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=he.get(l.node(-1)),u=l.start(-1),c=a.map.indexOf(l.pos-u);return c%a.width==0?-1:u+a.map[c-1]}function Op(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Xp(e,t){e.dispatch(e.state.tr.setMeta(lt,{setHandle:t}))}function Dv(e,t,n){let r=e.state.doc.resolve(t),o=r.node(-1),i=he.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let u=0;u<i.height;u++){let c=u*i.width+l;if(u&&i.map[c]==i.map[c-i.width])continue;let d=i.map[c],f=o.nodeAt(d).attrs,p=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[p]==n)continue;let h=f.colwidth?f.colwidth.slice():Lv(f.colspan);h[p]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:h})}a.docChanged&&e.dispatch(a)}function Dp(e,t,n,r){let o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=he.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ha(i,a.firstChild,a,r,l,n)}function Lv(e){return Array(e).fill(0)}function Iv(e,t){let n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return ue.empty;let i=he.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){let c=l+u*i.width;if((l==i.width-1||i.map[c]!=i.map[c+1])&&(u==0||i.map[c]!=i.map[c-i.width])){var a;let d=i.map[c],f=s+d+o.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((a=lt.getState(e))===null||a===void 0)&&a.dragging&&n.push(Ee.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Ee.widget(f,p))}}return ue.create(e.doc,n)}function Yp({allowTableNodeSelection:e=!1}={}){return new W({key:hn,state:{init(){return null},apply(t,n){let r=t.getMeta(hn);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;let{deleted:o,pos:i}=t.mapping.mapResult(n);return o?null:i}},props:{decorations:ov,handleDOMEvents:{mousedown:Sv},createSelectionBetween(t){return hn.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Cv,handleKeyDown:vv,handlePaste:xv},appendTransaction(t,n,r){return lv(r,ga(r,n),e)}})}var Jn="showaiTableAction";function Qp(e,t,n){let r=e.doc.nodeAt(t);if(r?.type.name!=="table")return null;let o=e.selection instanceof re?e.selection.$headCell:Kt(e.selection.$head),i=o&&o.before(-1)===t?o:e.doc.resolve(t+1+he.get(r).map[0]),s=n==="row"?re.rowSelection(i):n==="column"?re.colSelection(i):new re(i);return e.tr.setSelection(s)}function ro(e){let t=e.selection;if(!(t instanceof re))return null;let n=t.$anchorCell.node(-1),r=t.$anchorCell.start(-1),o=he.get(n).rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r);return{tablePosition:r-1,rows:o.bottom-o.top,columns:o.right-o.left}}function Zp(e,t){let n=t.$anchorCell.nodeAfter?.attrs.id,r=t.$headCell.nodeAfter?.attrs.id;if(!n||!r)return null;let o,i;if(e.descendants((a,u)=>{["tableCell","tableHeader"].includes(a.type.name)&&(a.attrs.id===n&&(o=u),a.attrs.id===r&&(i=u))}),o===void 0&&i===void 0||(o??=i,i??=o,o===void 0||i===void 0))return null;let s=e.resolve(o),l=e.resolve(i);return s.node(-1)!==l.node(-1)?null:new re(s,l)}var at=be(Xe(),1);function vi({editor:e,context:t=!1,onAction:n}){let r=Fe($e),o=ro(e.state);if(!o&&!t&&!e.can().splitCell())return null;let i=s=>{e.view.dispatch(ur(e.state.tr)),e.chain().setMeta(Jn,!0).focus()[s]().run(),n?.()};return(0,at.jsxs)(at.Fragment,{children:[!t&&(0,at.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,at.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,at.jsx)("span",{className:"editor-menu-status",role:"status",children:o.rows===1&&o.columns===1?r("table.shiftClickHint"):r("table.selectedCells",{rows:o.rows,columns:o.columns})}),[["mergeCells",r("table.mergeCells"),Kc],["splitCell",r("table.splitCell"),Uc]].map(([s,l,a])=>(0,at.jsxs)("button",{type:"button",className:"editor-tool",role:t?"menuitem":void 0,"aria-label":l,title:l,disabled:!e.can()[s](),onMouseDown:u=>u.preventDefault(),onClick:()=>i(s),children:[(0,at.jsx)(a,{size:16}),t&&(0,at.jsx)("span",{children:l})]},s)),!t&&o&&(0,at.jsx)("button",{type:"button",className:"editor-tool","aria-label":r("table.clearSelection"),title:r("table.clearSelection"),onMouseDown:s=>s.preventDefault(),onClick:()=>{e.view.dispatch(e.state.tr.setSelection(L.near(e.state.selection.$from))),e.view.focus()},children:(0,at.jsx)($r,{size:16})})]})]})}var oo=be(tn(),1),ih=be(Os(),1);var Ci=be(Xe(),1),Pv=[["left","Left",Tn],["center","Center",Mn],["right","Right",An]];function ka({scope:e,value:t,onChange:n}){let r=Fe(iu),o=i=>e==="table"?r(`align.table${i}`):typeof e=="number"?r(`align.column${i}`,{column:e+1}):r(`align.scope${i}`,{scope:e});return(0,Ci.jsx)("div",{className:"table-alignment-buttons",role:"group","aria-label":o("Group"),children:Pv.map(([i,s,l])=>(0,Ci.jsx)("button",{type:"button","aria-label":o(s),title:o(s),"aria-pressed":t===i,onMouseDown:a=>a.preventDefault(),onClick:a=>{a.stopPropagation(),n(i)},children:(0,Ci.jsx)(l,{size:14})},i))})}var eh=tr($e),th=se.create({name:"tableAlignment",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textAlign:{default:null,parseHTML:e=>["left","center","right"].includes(e.style.textAlign)?e.style.textAlign:null,renderHTML:e=>["left","center","right"].includes(String(e.textAlign))?{style:`text-align: ${e.textAlign}`}:{}}}}]},addProseMirrorPlugins(){let e=this.editor;return[new W({appendTransaction(t,n,r){if(!e.isEditable||!t.some(i=>i.docChanged))return null;let o=r.tr;return r.doc.descendants((i,s)=>{if(i.type.name!=="table")return;let l=he.get(i),a=Array.from({length:l.width},(u,c)=>{let d=new Set(Array.from({length:l.height},(f,p)=>i.nodeAt(l.map[p*l.width+c])?.attrs.textAlign).filter(Boolean));return d.size===1?[...d][0]:i.attrs.textAlign});$v(i,s,(u,c)=>{if(u.attrs.textAlign)return;let d=l.findCell(c-s-1),f=new Set(a.slice(d.left,d.right)),p=f.size===1?[...f][0]:i.attrs.textAlign;p&&o.setNodeAttribute(c,"textAlign",p)})}),o.docChanged?o.setMeta("addToHistory",!1):null}})]}});function $v(e,t,n){e.forEach((r,o)=>r.forEach((i,s)=>n(i,t+2+o+s)))}function va(e,t){let r=nh(e,t).map(o=>e.nodeAt(o)?.attrs.textAlign??e.attrs.textAlign??"left");return r.every(o=>o===r[0])?r[0]??"left":null}function nh(e,t){let n=he.get(e);if(t!==null&&(!Number.isInteger(t)||t<0||t>=n.width))throw new Error(eh("table.columnOutOfRange"));return[...new Set(t===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+t]))]}function rh(e,t,n,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="table")throw new Error(eh("table.notATable"));let i=e.tr;n===null&&i.setNodeAttribute(t,"textAlign",r);for(let s of nh(o,n)){let l=t+1+s,a=e.doc.nodeAt(l);i.setNodeAttribute(l,"textAlign",r),a.descendants((u,c)=>{if(u.type.name==="table")return!1;["paragraph","heading"].includes(u.type.name)&&u.attrs.textAlign&&i.setNodeAttribute(l+1+c,"textAlign",null)})}return i}var Ut=be(tn(),1),Bv=()=>!0;function oh(e,t={}){let n=(0,Ut.useId)(),[r,o]=(0,Ut.useState)(null),[,i]=(0,Ut.useState)(0),s=(0,Ut.useRef)({target:r,options:t});s.current={target:r,options:t};let l=t.accept??Bv;return(0,Ut.useEffect)(()=>{if(!e)return;let a,u=()=>{clearTimeout(a),a=void 0},c=T=>T?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")===n,d=()=>{u(),o(null),s.current.options.onDismiss?.()},f=()=>{a||s.current.options.keepOpen||s.current.target?.context||c(document.activeElement)||(a=setTimeout(d,220))},p=T=>{let E=T.closest("table");if(!(E instanceof HTMLTableElement)||!e.contains(E)||!l(E))return null;let B=T.closest("td, th");return{table:E,cell:B?.parentElement===E.rows[0]?B:null,context:null}},h=T=>{u(),o(E=>E?.table===T.table&&E.cell===T.cell&&!E.context?E:T)},g=T=>{let E=T.target;if(c(E)){u();return}if(s.current.options.keepOpen||s.current.target?.context){u();return}let B=s.current.target;if(B?.cell?.isConnected){let Q=B.cell.getBoundingClientRect(),me=Ca(B,0).column;if(T.clientX>=Math.min(Q.left,me.left)&&T.clientX<=Math.max(Q.right,me.left+88)&&T.clientY>=Q.bottom&&T.clientY<=me.top){u();return}}let oe=p(E);if(oe){h(oe);return}if(B?.table.isConnected){let Q=B.table.getBoundingClientRect();if(T.clientX>=Q.left-8&&T.clientX<=Q.right+8&&T.clientY>=Q.top-44&&T.clientY<=Q.bottom+8){u();return}}f()},m=T=>{let E=T.target;if(c(E)){u();return}let B=p(E);B?(s.current.options.onDismiss?.(),h(B)):d()},b=T=>{let E=p(T.target);E&&(T.preventDefault(),T.stopPropagation(),u(),s.current.options.onDismiss?.(),o({...E,cell:null,context:{left:Math.max(8,Math.min(T.clientX,window.innerWidth-140)),top:Math.max(8,Math.min(T.clientY,window.innerHeight-42))}}))},v=T=>{if(c(T.target))u();else{let E=p(T.target);E&&h(E)}},S=T=>{T.key==="Escape"&&d()},C=T=>{T.target instanceof HTMLElement&&T.target.contains(e)&&d()},M=()=>i(T=>T+1);return document.addEventListener("pointermove",g),document.addEventListener("pointerdown",m),document.addEventListener("focusin",v),document.addEventListener("keydown",S),e.addEventListener("contextmenu",b),window.addEventListener("blur",d),window.addEventListener("showai:viewport-change",C),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),()=>{u(),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",m),document.removeEventListener("focusin",v),document.removeEventListener("keydown",S),e.removeEventListener("contextmenu",b),window.removeEventListener("blur",d),window.removeEventListener("showai:viewport-change",C),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[e,l,n]),{target:r,setTarget:o,owner:n}}function Ca(e,t){let n=e.table.getBoundingClientRect(),r=e.table.closest(".tableWrapper, .sb-table-scroll")?.getBoundingClientRect(),o=Math.min(n.right,r?.right??n.right,window.innerWidth-8),i=Math.max(8,o-t),s=Math.max(8,n.top-36),l=e.cell?.getBoundingClientRect(),a=l?(l.left+l.right-88)/2:i;return{global:e.context??{left:Math.max(t+8,o),top:s,transform:"translateX(-100%)"},column:{left:Math.max(8,Math.min(a,o-88)),top:l?l.bottom+4:s}}}var fe=be(Xe(),1),zv=e=>!e.closest(".document-widget");function sh({editor:e}){let t=Fe($e),[,n]=(0,oo.useState)(0),[r,o]=(0,oo.useState)(!1),i=ro(e.state),{target:s,setTarget:l,owner:a}=oh(e.view.dom,{keepOpen:r,accept:zv,onDismiss:()=>o(!1)});if((0,oo.useEffect)(()=>{let M=()=>n(E=>E+1),T=E=>{E.key!=="Escape"||!ro(e.state)||!e.view.hasFocus()&&document.activeElement?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")!==a||(e.view.dispatch(e.state.tr.setSelection(L.near(e.state.selection.$from))),o(!1),e.view.focus())};return e.on("transaction",M),document.addEventListener("keydown",T),()=>{e.off("transaction",M),document.removeEventListener("keydown",T)}},[e,a]),!s||!s.table.isConnected||!e.isEditable||!s.context&&(i||e.isFocused&&e.state.selection instanceof L&&!e.state.selection.empty))return null;let u=e.state.doc.resolve(e.view.posAtDOM(s.table,0)),c=u.depth;for(;c>0&&u.node(c).type.name!=="table";)c--;if(!c)return null;let d=u.node(c),f=u.before(c),p=null;if(s.cell?.isConnected){let M=e.view.posAtDOM(s.cell,0),T=e.state.doc.resolve(M),E=T.depth;for(;E>c&&!["tableCell","tableHeader"].includes(T.node(E).type.name);)E--;E>c&&(p=he.get(d).findCell(T.before(E)-f-1).left)}let h=Ca(s,128),g=h.global.top>window.innerHeight/2,m=()=>{let{$from:M}=e.state.selection;Array.from({length:M.depth},(E,B)=>B+1).some(E=>M.node(E).type.name==="table"&&M.before(E)===f)||e.view.dispatch(e.state.tr.setSelection(L.near(e.state.doc.resolve(f+3))))},b=M=>{m(),e.view.dispatch(ur(e.state.tr)),M(),o(!1)},v=()=>e.chain().setMeta(Jn,!0).focus(),S=M=>b(()=>{let T=Qp(e.state,f,M);T&&e.view.dispatch(T),e.view.focus()}),C=(M,T)=>{e.view.dispatch(rh(e.state,f,M,T).setMeta(Jn,!0)),s.context&&(l(null),e.view.focus())};return(0,ih.createPortal)((0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsxs)("div",{className:"document-table-controls table-global-alignment","data-editor-menu-trigger":s.context?"context":"hover",role:s.context?"dialog":void 0,"aria-label":t("table.alignment"),"data-table-controls-owner":a,style:h.global,children:[(0,fe.jsx)(ka,{scope:"table",value:va(d,null),onChange:M=>C(null,M)}),!s.context&&(0,fe.jsx)("button",{className:"document-table-menu-trigger",type:"button","aria-label":t("table.actions"),title:t("table.actions"),"aria-expanded":r,"aria-haspopup":"menu",onMouseDown:M=>M.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,fe.jsx)(Rc,{size:16})}),(r||s.context)&&(0,fe.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":t("table.actionsMenu"),style:{...g?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,g?h.global.top-12:window.innerHeight-h.global.top-46),overflowY:"auto"},onMouseDown:M=>M.preventDefault(),children:[(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{v().addRowAfter().run()}),children:[(0,fe.jsx)(nn,{size:14}),t("table.addRow")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{v().addColumnAfter().run()}),children:[(0,fe.jsx)(nn,{size:14}),t("table.addColumn")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{v().toggleHeaderRow().run()}),children:[(0,fe.jsx)(qc,{size:14,"aria-hidden":"true"}),t("table.toggleHeader")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>S("cell"),children:[(0,fe.jsx)(Fc,{size:14,"aria-hidden":"true"}),t("table.selectCells")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>S("row"),children:[(0,fe.jsx)(Rs,{size:14,"aria-hidden":"true"}),t("table.selectRow")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>S("column"),children:[(0,fe.jsx)(Ns,{size:14,"aria-hidden":"true"}),t("table.selectColumn")]}),s.context&&(0,fe.jsx)(vi,{editor:e,context:!0,onAction:()=>{l(null),o(!1)}}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{v().deleteRow().run()}),children:[(0,fe.jsx)(Rs,{size:14,"aria-hidden":"true"}),t("table.deleteRow")]}),(0,fe.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{v().deleteColumn().run()}),children:[(0,fe.jsx)(Ns,{size:14,"aria-hidden":"true"}),t("table.deleteColumn")]}),(0,fe.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>b(()=>{v().deleteTable().run(),l(null)}),children:[(0,fe.jsx)(Eo,{size:14}),t("table.deleteTable")]})]})]}),p!==null&&!s.context&&(0,fe.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:h.column,children:(0,fe.jsx)(ka,{scope:p,value:va(d,p),onChange:M=>C(p,M)})})]}),document.body)}var qt=be(tn(),1);Cc(`.rich-format-controls{display:contents}.rich-format-group{display:inline-flex;align-items:center;flex:0 0 auto;gap:1px}.rich-format-divider{width:1px;height:18px;margin:0 5px;flex-shrink:0;background:var(--line, #e8e8eb)}.rich-format-select{position:relative;display:inline-flex;align-items:center;height:32px;border-radius:6px;color:var(--text, #343a35)}.rich-format-select>svg:last-child{position:absolute;right:6px;pointer-events:none;color:var(--muted, #777)}.rich-format-select select{appearance:none;width:100%;height:32px;padding:0 21px 0 8px;border:0;border-radius:inherit;background:transparent;color:inherit;font:12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-format-block{width:70px}.rich-format-font{width:76px}.rich-format-size{width:58px}.rich-format-alignment{width:41px}.rich-format-alignment>svg:first-child{margin-left:6px}.rich-format-alignment select{position:absolute;inset:0;opacity:0}.rich-format-select:hover,.rich-format-colors-toggle:hover{background:var(--hover, #f5f5f7)}.rich-format-select:focus-within{outline:2px solid var(--accent, #6c805f);outline-offset:-2px}.rich-format-select select:focus-visible{outline:none}.rich-format-colors-toggle{display:inline-flex;align-items:center;justify-content:center;gap:5px;width:43px;height:32px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--text, #343a35);cursor:pointer}.rich-format-colors-toggle.is-active{background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f)}.rich-format-color-icon{display:inline-flex;flex-direction:column;align-items:center;gap:2px}.rich-format-color-icon i{width:16px;height:3px;border-radius:2px}.rich-text-selection-toolbar.editor-bubble{--editor-soft: var(--accent-soft, #eeedf9);gap:2px;max-width:min(680px,calc(100vw - 24px));padding:6px;flex-wrap:wrap;overflow:visible;border:1px solid var(--line, #e8e8eb);border-radius:12px;box-shadow:0 4px 12px #25233508,0 12px 36px #25233514}.rich-text-selection-toolbar .editor-tool,.editor-toolbar .rich-format-group .editor-tool{width:30px;height:32px;border-radius:6px;color:var(--text, #343a35);cursor:pointer}.rich-text-selection-toolbar .editor-tool:hover,.rich-text-selection-toolbar .editor-tool.is-active{color:var(--accent, #6c805f);background:var(--editor-soft)}.rich-text-selection-toolbar .toolbar-divider{margin:0 5px;height:18px}.rich-text-selection-toolbar .editor-bubble-assistant{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:30px;padding:0 10px;border:1px solid color-mix(in srgb,var(--accent, #6c805f) 12%,transparent);border-radius:7px;background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f);font:500 12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-text-selection-toolbar .editor-bubble-reference{color:var(--accent, #6c805f)}.rich-text-selection-toolbar .editor-bubble-assistant:hover{background:color-mix(in srgb,var(--accent, #6c805f) 15%,var(--paper, white))}.rich-text-selection-toolbar :is(button,input):focus-visible,.rich-format-color-panel :is(button,input):focus-visible{outline:2px solid var(--accent, #6c805f);outline-offset:2px}.editor-toolbar:has(.rich-format-controls){flex-wrap:wrap}.rich-format-color-panel{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));order:10;flex:1 0 100%;gap:20px;padding:14px 8px 8px;margin-top:5px;border-top:1px solid var(--line, #e8e8eb)}.rich-format-panel-label{display:block;margin-bottom:10px;color:var(--muted, #777);font-size:11px;font-weight:500}.rich-format-swatches{display:flex;flex-wrap:wrap;gap:7px}.rich-format-swatch,.rich-format-custom-color{position:relative;width:20px;height:20px;flex:0 0 20px;padding:0;border:1px solid #0000000a;border-radius:50%;cursor:pointer}.rich-format-swatch:hover{transform:scale(1.12)}.rich-format-swatch.is-active{outline:2px solid var(--accent, #6c805f);outline-offset:2px;box-shadow:inset 0 0 0 2px var(--paper, white)}.rich-format-custom-color{overflow:hidden;border-color:var(--line, #ddd)}.rich-format-custom-color input{width:100%;height:100%;padding:0;border:0;background:none;cursor:pointer}.rich-format-custom-color input::-webkit-color-swatch-wrapper{padding:3px}.rich-format-custom-color input::-webkit-color-swatch{border:0;border-radius:50%}.rich-format-highlight-modes{display:flex;gap:4px;margin-top:12px}.rich-format-highlight-modes button{display:inline-flex;align-items:center;gap:6px;padding:5px 7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--muted, #777);font:11px/1.2 var(--font-ui, system-ui, sans-serif);white-space:nowrap;cursor:pointer}.rich-format-highlight-modes button[aria-pressed=true]{border-color:var(--line, #e8e8eb);background:var(--hover, #f5f5f7);color:var(--text, #343a35)}.rich-format-highlight-preview{color:#343a35;font:600 12px/1.3 Georgia,serif;background:linear-gradient(transparent 52%,var(--highlight-preview) 52%)}.rich-format-highlight-preview.is-full{background:var(--highlight-preview)}@media(max-width:680px){.rich-text-selection-toolbar.editor-bubble{max-width:min(360px,calc(100vw - 24px));row-gap:5px}.rich-text-selection-toolbar .rich-format-divider{display:none}.rich-text-selection-toolbar .rich-format-group{gap:2px;order:2}.rich-text-selection-toolbar .rich-format-controls>.rich-format-group:first-child{flex-grow:1;order:0}.rich-text-selection-toolbar .toolbar-divider{display:none}.rich-text-selection-toolbar .editor-bubble-assistant{order:1;margin-left:auto}.rich-text-selection-toolbar .editor-bubble-reference{order:1}.rich-text-selection-toolbar .rich-format-color-panel{grid-template-columns:1fr;gap:14px}}
|
|
97
|
-
`);var
|
|
96
|
+
`,textSerializers:n={}}=e||{};return x0(this.state.doc,{blockSeparator:t,textSerializers:{...Rf(this.schema),...n}})}get isEmpty(){return xr(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 e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Vw(t,this,!1,n)}get $doc(){return this.$pos(0)}};function rt(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=de(e.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=t,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),u=n.from+l.indexOf(s),c=u+s.length;if(Zr(n.from,n.to,t.doc).filter(f=>f.mark.type.excluded.find(p=>p===e.type&&p!==f.mark.type)).filter(f=>f.to>u).length)return null;c<n.to&&i.delete(c,n.to),u>n.from&&i.delete(n.from+a,u);let d=n.from+a+s.length;i.addMark(n.from+a,d,e.type.create(o||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function ci(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=de(e.getAttributes,void 0,r)||{},{tr:i}=t,s=n.from,l=n.to,a=e.type.create(o);if(r[1]){let u=s+r[0].lastIndexOf(r[1]);u>l?u=l:l=u+r[1].length;let c=r[0][r[0].length-1];i.insertText(c,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){let u=e.type.isInline?s:s-1;i.insert(u,e.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:e.undoable})}function eo(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=t.doc.resolve(n.from),i=de(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)},undoable:e.undoable})}function pn(e){return new Er({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{let i=de(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&ir(l,e.type,i);if(!a)return null;if(s.wrap(l,a),e.keepMarks&&e.editor){let{selection:c,storedMarks:d}=t,{splittableMarks:f}=e.editor.extensionManager,p=d||c.$to.parentOffset&&c.$from.marks();if(p){let h=p.filter(g=>f.includes(g.type.name));s.ensureMarks(h)}}if(e.keepAttributes){let c=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(c,i).run()}let u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&bt(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&s.join(n.from-1)},undoable:e.undoable})}var Fw=e=>"touches"in e,Jf=class{constructor(e){var t,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(a,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let u=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(u,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,!((t=e.options)===null||t===void 0)&&t.min&&(this.minSize={...this.minSize,...e.options.min}),!((n=e.options)===null||n===void 0)&&n.max&&(this.maxSize=e.options.max),!(e==null||(r=e.options)===null||r===void 0)&&r.directions&&(this.directions=e.options.directions),!((o=e.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),!((i=e.options)===null||i===void 0)&&i.className&&(this.classNames={container:e.options.className.container||"",wrapper:e.options.className.wrapper||"",handle:e.options.className.handle||"",resizing:e.options.className.resizing||""}),!((s=e.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var e;return(e=this.contentElement)!==null&&e!==void 0?e:null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type!==this.node.type?!1:(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes("top"),r=t.includes("bottom"),o=t.includes("left"),i=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),o&&(e.style.left="0"),i&&(e.style.right="0"),(t==="top"||t==="bottom")&&(e.style.left="0",e.style.right="0"),(t==="left"||t==="right")&&(e.style.top="0",e.style.bottom="0")}attachHandles(){this.directions.forEach(e=>{let t;this.createCustomHandle?t=this.createCustomHandle(e):t=this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener("mousedown",n=>this.handleResizeStart(n,e)),t.addEventListener("touchstart",n=>this.handleResizeStart(n,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,Fw(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,e,t),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,o=this.startHeight,i=e.includes("right"),s=e.includes("left"),l=e.includes("bottom"),a=e.includes("top");return i?r=this.startWidth+t:s&&(r=this.startWidth-t),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(e==="right"||e==="left")&&(r=this.startWidth+(i?t:-t)),(e==="top"||e==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,e):{width:r,height:o}}applyConstraints(e,t,n){var r,o;if(!n){var i,s;let u=Math.max(this.minSize.width,e),c=Math.max(this.minSize.height,t);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(u=Math.min(this.maxSize.width,u)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(c=Math.min(this.maxSize.height,c)),{width:u,height:c}}let l=e,a=t;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(e,t,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:e,height:e/this.aspectRatio}:o?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};var re=class Xf extends ta{constructor(...t){super(...t),this.type="node"}static create(t={}){let n=typeof t=="function"?t():t;return new Xf(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},Yf=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=()=>{try{return t.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n;let{view:r}=this.editor,o=e.target,i=o.nodeType===3?(t=o.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,u,c,d;let k=this.dom.getBoundingClientRect(),C=i.getBoundingClientRect(),x=(a=e.offsetX)!==null&&a!==void 0?a:(u=e.nativeEvent)===null||u===void 0?void 0:u.offsetX,E=(c=e.offsetY)!==null&&c!==void 0?c:(d=e.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=C.x-k.x+x,l=C.y-k.y+E}let f=this.dom.cloneNode(!0);try{let k=this.dom.getBoundingClientRect();f.style.width=`${Math.round(k.width)}px`,f.style.height=`${Math.round(k.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{var h;p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(h=e.dataTransfer)===null||h===void 0||h.setDragImage(f,s,l)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=_.create(r.state.doc,g),b=r.state.tr.setSelection(m);r.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(n))))return!1;let r=e.type.startsWith("drag"),o=e.type==="dragover"||e.type==="dragenter",i=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,u=_.isSelectable(this.node),c=e.type==="copy",d=e.type==="paste",f=e.type==="cut",p=e.type==="mousedown";if(!a&&u&&r&&e.target===this.dom&&e.preventDefault(),a&&r&&!l&&e.target===this.dom)return e.preventDefault(),!1;if(a&&s&&!l&&p){let h=n.closest("[data-drag-handle]");h&&(this.dom===h||this.dom.contains(h))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||c||d||f||p&&u)}ignoreMutation(e){return this.dom?this.contentDOM?typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.contentDOM.contains(e.target)&&e.type==="childList"&&(Un()||Qr())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target):e.type!=="selection":!0}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return typeof n!="number"?!1:(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if(typeof e!="number")return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function Ze(e){return new na({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{let i=de(e.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=t,l=r[r.length-1],a=r[0],u=n.to;if(l){let c=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Zr(n.from,n.to,t.doc).filter(p=>p.mark.type.excluded.find(h=>h===e.type&&h!==p.mark.type)).filter(p=>p.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+c,d),u=n.from+c+l.length,s.addMark(n.from+c,u,e.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(e.type)}}})}var qe=ye(Xe(),1);var{getOwnPropertyNames:Ww,getOwnPropertySymbols:Kw}=Object,{hasOwnProperty:Uw}=Object.prototype;function to(e,t){return function(r,o,i){return e(r,o,i)&&t(r,o,i)}}function no(e){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return e(n,r,o);let{cache:i}=o,s=i.get(n),l=i.get(r);if(s&&l)return s===r&&l===n;i.set(n,r),i.set(r,n);let a=e(n,r,o);return i.delete(n),i.delete(r),a}}function qw(e){return e?.[Symbol.toStringTag]}function Qf(e){return Ww(e).concat(Kw(e))}var Gw=Object.hasOwn||((e,t)=>Uw.call(e,t));function Gn(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Jw="__v",Xw="__o",Yw="_owner",Qw=typeof Float16Array<"u",{getOwnPropertyDescriptor:Zf,keys:ep}=Object;function Zw(e,t){return e.byteLength===t.byteLength&&ui(new Uint8Array(e),new Uint8Array(t))}function ek(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function tk(e,t){return e.byteLength===t.byteLength&&ui(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function nk(e,t){return Gn(e.getTime(),t.getTime())}function tp(e,t,n){return e.name===t.name&&e.message===t.message&&e.stack===t.stack&&n.equals(e.cause,t.cause,"cause","cause",e,t,n)}function rk(e,t){return e===t}function np(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.entries(),s,l,a=0;for(;(s=i.next())&&!s.done;){let u=t.entries(),c=!1,d=0;for(;(l=u.next())&&!l.done;){if(o[d]){d++;continue}let f=s.value,p=l.value;if(n.equals(f[0],p[0],a,d,e,t,n)&&n.equals(f[1],p[1],f[0],p[0],e,t,n)){c=o[d]=!0;break}d++}if(!c)return!1;a++}return!0}var ok=Gn;function rp(e,t,n){let r=ep(e),o=r.length;if(ep(t).length!==o)return!1;for(;o-- >0;)if(!sp(e,t,n,r[o]))return!1;return!0}function Mr(e,t,n){let r=Qf(e),o=r.length;if(Qf(t).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!sp(e,t,n,i)||(s=Zf(e,i),l=Zf(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function ik(e,t){return Gn(e.valueOf(),t.valueOf())}function sk(e,t){return e.source===t.source&&e.flags===t.flags}function op(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let o=new Array(r),i=e.values(),s,l;for(;(s=i.next())&&!s.done;){let a=t.values(),u=!1,c=0;for(;(l=a.next())&&!l.done;){if(!o[c]&&n.equals(s.value,l.value,s.value,l.value,e,t,n)){u=o[c]=!0;break}c++}if(!u)return!1}return!0}function ui(e,t){let n=e.length;if(t.length!==n||e.byteOffset!==t.byteOffset)return!1;if(e instanceof Float64Array||e instanceof Float32Array||Qw&&e instanceof Float16Array){for(;n-- >0;)if(e[n]!==t[n]&&(e[n]===e[n]||t[n]===t[n]))return!1;return!0}for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function lk(e,t){return e.href===t.href?!0:e.protocol===t.protocol&&e.username===t.username&&e.password===t.password&&e.host===t.host&&e.pathname===t.pathname&&e.hash===t.hash&&ak(e.searchParams,t.searchParams)}function ak(e,t){let n=e.toString(),r=t.toString();return n===r||ip(n)===ip(r)}function ip(e){return e.split("&").sort().join("&")}function sp(e,t,n,r){return(r===Yw||r===Xw||r===Jw)&&(e.$$typeof||t.$$typeof)?!0:Gw(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var ck="[object ArrayBuffer]",uk="[object Arguments]",dk="[object Boolean]",fk="[object DataView]",pk="[object Date]",hk="[object Error]",mk="[object Map]",gk="[object Number]",bk="[object Object]",yk="[object RegExp]",wk="[object Set]",kk="[object String]",vk={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Ck="[object URL]",xk=Object.prototype.toString;function Sk({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:h}){return function(m,b,k){if(m===b)return!0;if(m==null||b==null)return!1;let C=typeof m;if(C!==typeof b)return!1;if(C!=="object")return C==="number"?l(m,b,k):C==="function"?i(m,b,k):!1;let x=m.constructor;if(x!==b.constructor)return!1;if(x===Object)return a(m,b,k);if(Array.isArray(m))return t(m,b,k);if(x===Date)return r(m,b,k);if(x===RegExp)return c(m,b,k);if(x===Map)return s(m,b,k);if(x===Set)return d(m,b,k);if(x==null)return a(m,b,k);let E=xk.call(m);if(E===pk)return r(m,b,k);if(E===yk)return c(m,b,k);if(E===mk)return s(m,b,k);if(E===wk)return d(m,b,k);if(E===bk)return typeof m.then!="function"&&typeof b.then!="function"&&a(m,b,k);if(E===Ck)return p(m,b,k);if(E===hk)return o(m,b,k);if(E===uk)return a(m,b,k);if(vk[E])return f(m,b,k);if(E===ck)return e(m,b,k);if(E===fk)return n(m,b,k);if(E===dk||E===gk||E===kk)return u(m,b,k);if(h){let A=h[E];if(!A){let M=qw(m);M&&(A=h[M])}if(A)return A(m,b,k)}return!1}}function Ek({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Zw,areArraysEqual:n?Mr:ek,areDataViewsEqual:tk,areDatesEqual:nk,areErrorsEqual:n?to(tp,Mr):to(tp,rp),areFunctionsEqual:rk,areMapsEqual:n?to(np,Mr):np,areNumbersEqual:ok,areObjectsEqual:n?Mr:rp,arePrimitiveWrappersEqual:ik,areRegExpsEqual:sk,areSetsEqual:n?to(op,Mr):op,areTypedArraysEqual:n?to(ui,Mr):ui,areUrlsEqual:lk,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let o=no(r.areArraysEqual),i=no(r.areErrorsEqual),s=no(r.areMapsEqual),l=no(r.areObjectsEqual),a=no(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function Mk(e){return function(t,n,r,o,i,s,l){return e(t,n,l)}}function Ak({circular:e,comparator:t,createState:n,equals:r,strict:o}){if(n)return function(l,a){let{cache:u=e?new WeakMap:void 0,meta:c}=n();return t(l,a,{cache:u,equals:r,meta:c,strict:o})};if(e)return function(l,a){return t(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};let i={cache:void 0,equals:r,meta:void 0,strict:o};return function(l,a){return t(l,a,i)}}var lp=hn(),yE=hn({strict:!0}),wE=hn({circular:!0}),kE=hn({circular:!0,strict:!0}),vE=hn({createInternalComparator:()=>Gn}),CE=hn({strict:!0,createInternalComparator:()=>Gn}),xE=hn({circular:!0,createInternalComparator:()=>Gn}),SE=hn({circular:!0,createInternalComparator:()=>Gn,strict:!0});function hn(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:o=!1}=e,i=Ek(e),s=Sk(i),l=n?n(s):Mk(s);return Ak({circular:t,comparator:s,createState:r,equals:l,strict:o})}var hp=ye(Ng(),1);function Tk(e,t){var n,r;if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!=="insertParagraph"&&t.inputType!=="insertLineBreak"||!Un()&&!Qr())return;let o=e.view,i=o.root,s=(n=(r=i.getSelection)===null||r===void 0?void 0:r.call(i))!==null&&n!==void 0?n:o.dom.ownerDocument.getSelection(),l=s?.anchorNode,a=l?.nodeType===1?l:l?.parentElement,u=a?.closest("[data-node-view-content-react]");if(!u||!o.dom.contains(u))return;let c=o.input.lastKeyCode;c===13&&(o.input.lastKeyCode=null),o.domObserver.forceFlush(),o.domObserver.flush();let d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,shiftKey:t.inputType==="insertLineBreak",bubbles:!0,cancelable:!0});o.someProp("handleKeyDown",f=>f(o,d))?(t.preventDefault(),o.input.lastIOSEnter=0,clearTimeout(o.input.lastIOSEnterFallbackTimeout)):c===13&&(o.input.lastKeyCode=c)}var ap=new ne("reactMobileEnter"),Nk=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Rk=({contentComponent:e})=>{let t=(0,pp.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,qe.jsx)(qe.Fragment,{children:Object.values(t)})};function Ok(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(o=>o())}))};return{subscribe(o){return e.add(o),()=>{e.delete(o)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(o,i){t={...t,[o]:di.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...t};delete i[o],t=i,r()}}}var oa=class extends ee.default.Component{constructor(e){super(e),this.editorContentRef=ee.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(!((e=t.view.dom)===null||e===void 0)&&e.parentNode)){if(t.contentComponent)return;let n=this.editorContentRef.current;n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n}),t.contentComponent=Ok(),t.createNodeViews(),t.registerPlugin(new K({key:ap,props:{handleDOMEvents:{beforeinput:(r,o)=>Tk(t,o)}}})),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(ap),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{var t;if(!(!((t=e.view.dom)===null||t===void 0)&&t.parentNode))return;let n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{ref:Nk(t,this.editorContentRef),...n}),e?.contentComponent&&(0,qe.jsx)(Rk,{contentComponent:e.contentComponent})]})}},Dk=(0,ee.forwardRef)((e,t)=>{let n=ee.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return ee.default.createElement(oa,{key:n,innerRef:t,...e})}),Lk=ee.default.memo(Dk),Ik=typeof window<"u"?ee.useLayoutEffect:ee.useEffect,Pk=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let t,n=o=>{o?.transaction!==void 0&&o.transaction===t||(t=o?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function ro(e){var t;let[n]=(0,ee.useState)(()=>new Pk(e.editor)),r=(0,hp.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:lp);return Ik(()=>n.watch(e.editor),[e.editor,n]),(0,ee.useDebugValue)(r),r}var $k=typeof window>"u",OE=$k||!!(typeof window<"u"&&window.next);var mp=(0,ee.createContext)({editor:null}),DE=mp.Consumer;var gp=(0,ee.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var bp=()=>(0,ee.useContext)(gp);function fi({as:e="div",...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=bp();return(0,qe.jsx)(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var Jn=ee.default.forwardRef((e,t)=>{let{onDragStart:n}=bp(),r=e.as||"div";return(0,qe.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function cp(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function up(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.forward_ref)"||e.$$typeof.description==="react.forward_ref"))}function Bk(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function zk(e){if(cp(e)||up(e))return!0;if(Bk(e)){let t=e.type;if(t)return cp(t)||up(t)}return!1}function Hk(){try{if(ee.version)return parseInt(ee.version.split(".")[0],10)>=19}catch{}return!1}var _k=class{constructor(e,{editor:t,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?(0,di.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,o=Hk(),i=zk(t),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,qe.jsx)(t,{...s}),r==null||(e=r.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let o=n[r];if(e[o]!==this.props[o]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;t==null||(e=t.contentComponent)===null||e===void 0||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}},LE=ee.default.createContext({markViewContentRef:()=>{}});function Vk(e){var t;let n=e.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(t=e.ownerDocument)===null||t===void 0||(t=t.defaultView)===null||t===void 0?void 0:t.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=r;return!o||!s||!e.contains(o)||!e.contains(s)?null:()=>{try{r.setBaseAndExtent(o,i,s,l)}catch{}}}function jk(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function yp(e){if(!oi(e))return[];let{$from:t,$to:n}=e,r=[],o=Math.min(t.depth,n.depth);for(let i=1;i<=o&&jk(t,n,i);i+=1)r.push(t.before(i));return r}var Fk=class{constructor(e){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=e}register(e){this.viewCount===0&&this.editor.on("transaction",this.handleTransaction),this.views.set(e.dom,e),this.viewCount+=1,this.scheduleSync()}unregister(e){this.views.delete(e.dom),this.viewCount-=1,this.insideViews.delete(e),this.viewCount===0&&this.editor.off("transaction",this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let e=this.findInsideViews();this.updateViews(this.insideViews,e,!1),this.updateViews(e,this.insideViews,!0),this.insideViews=e}updateViews(e,t,n){for(let r of e)t.has(r)||r.setSelectionInside(n)}findInsideViews(){let e=new Set;for(let t of yp(this.editor.state.selection)){let n=this.editor.view.nodeDOM(t),r=n?this.views.get(n):void 0;r&&e.add(r)}return e}},dp=new WeakMap;function fp(e){let t=dp.get(e);return t||(t=new Fk(e),dp.set(e,t)),t}var Wk=class extends Yf{constructor(e,t,n){if(super(e,t,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";let r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,o){if(r==="storage"){var i;return(i=e.storage[t.name])!==null&&i!==void 0?i:{}}return Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:(0,ee.createRef)()};if(!this.component.displayName){let a=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=a(this.extension.name)}let r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{if(a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement){a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper");let u=Vk(this.contentDOMElement);a.appendChild(this.contentDOMElement),u?.()}}},o=this.component,i=(0,ee.memo)(a=>(0,qe.jsx)(gp.Provider,{value:r,children:(0,ee.createElement)(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);let{className:l=""}=this.options;this.renderer=new _k(i,{editor:this.editor,props:e,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),fp(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(e,t,n){let r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){let s=this.node,l=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:s,oldDecorations:l,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let o=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=o;let i={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(e){let t=this.nodeSelected||this.options.selectedOnTextSelection===!0&&e;this.renderer.updateProps({selectionInside:e,selected:t}),this.renderer.element.classList.toggle("ProseMirror-selectednode",t)}updateSelectedState(e){this.renderer.updateProps({selected:e}),this.renderer.element.classList.toggle("ProseMirror-selectednode",e)}isTextSelectionInside(){let e=this.getPos();return typeof e=="number"&&yp(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),fp(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){let t=this.editor.extensionManager.attributes,n=At(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Xn(e,t){return n=>n.editor.contentComponent?new Wk(e,n,t):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var ia=(0,ee.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});ia.displayName="TiptapContext";var Kk=()=>(0,ee.useContext)(ia);function wp({children:e,...t}){let n="editor"in t?t.editor:t.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,ee.useMemo)(()=>({editor:n}),[n]),o=(0,ee.useMemo)(()=>({editor:n}),[n]);return(0,qe.jsx)(mp.Provider,{value:o,children:(0,qe.jsx)(ia.Provider,{value:r,children:e})})}wp.displayName="Tiptap";function kp({...e}){let{editor:t}=Kk();return(0,qe.jsx)(Lk,{editor:t,...e})}kp.displayName="Tiptap.Content";var IE=Object.assign(wp,{Content:kp});var pi=class extends oa{componentWillUnmount(){let t=this.editorContentRef.current;queueMicrotask(()=>{t?.isConnected||super.componentWillUnmount()})}};var et=ye(tn(),1);var Uk=new WeakSet,vp=e=>Uk.has(e);var qk=(0,et.createContext)(null);function Cp(e){let t=(0,et.useContext)(qk),n=(0,et.useId)(),r=(0,et.useRef)(e.retentionKey??n).current,o=(0,et.useRef)(e);o.current=e;let i=(0,et.useRef)(t?.find(r)??null),[s,l]=(0,et.useState)(i.current),a=(0,et.useRef)(void 0);return(0,et.useLayoutEffect)(()=>{clearTimeout(a.current);let u=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:p,...h}=o.current;return new ra({...h,onUpdate:g=>o.current.onUpdate?.(g),editorProps:{...h.editorProps,handleKeyDown:(g,m)=>o.current.editorProps?.handleKeyDown?.(g,m)??!1,handleClick:(g,m,b)=>o.current.editorProps?.handleClick?.(g,m,b)??!1,handlePaste:(g,m,b)=>o.current.editorProps?.handlePaste?.(g,m,b)??!1}})},c=t?t.get(r,u):i.current&&!i.current.isDestroyed?i.current:u();return i.current=c,c.setEditable(o.current.editable!==!1,!1),l(c),()=>{c.isDestroyed||c.setEditable(!1,!1),!t&&(a.current=setTimeout(()=>{i.current===c&&!c.isDestroyed&&c.destroy()},1))}},[t,r]),s}var sa=new WeakMap;function la(e){let t=sa.get(e);if(t)return t;let n={type:e.type.name};return Object.keys(e.attrs).length&&(n.attrs=e.attrs),e.content.size&&(n.content=[],e.content.forEach(r=>n.content.push(la(r)))),e.marks.length&&(n.marks=e.marks.map(r=>r.toJSON())),e.isText&&(n.text=e.text),sa.set(e,n),n}function xp(e,t){let n=sa.get(e);if(n===t)return!0;if(!n||n.type!==t.type||n.text!==t.text||n.attrs!==t.attrs&&JSON.stringify(n.attrs)!==JSON.stringify(t.attrs)||n.marks!==t.marks&&JSON.stringify(n.marks)!==JSON.stringify(t.marks)||e.childCount!==(t.content?.length??0))return!1;for(let r=0;r<e.childCount;r++)if(!xp(e.child(r),t.content[r]))return!1;return!0}function Sp(e,t){if(t.type!==e.type.name||e.childCount!==(t.content?.length??0))return!1;for(let n=0;n<e.childCount;n++)if(!xp(e.child(n),t.content[n]))return!1;return!0}function hi(e,t,n){let r=[],o=[];return e.nodesBetween(t,n,(i,s,l)=>{let a=i.attrs?.id;if(!(typeof a!="string"||a.startsWith("page-tail-")))if(i.isTextblock){let u=s+1,c=u+i.content.size;(Math.max(t,u)<Math.min(n,c)||i.content.size===0&&t<=s&&n>=s+i.nodeSize)&&r.push(a)}else l===e&&o.push(a)}),[...new Set(r.length?r:o)].slice(0,100)}var Le=class e extends X{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):X.near(r)}content(){return ce.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))}getBookmark(){return new aa(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!Gk(t)||!Jk(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&e.valid(t))return t;let o=t.pos,i=null;for(let s=t.depth;;s--){let l=t.node(s);if(n>0?t.indexAfter(s)<l.childCount:t.index(s)>0){i=l.child(n>0?t.indexAfter(s):t.index(s)-1);break}else if(s==0)return null;o+=n;let a=t.doc.resolve(o);if(e.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!_.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=t.doc.resolve(o);if(e.valid(l))return l}return null}}};Le.prototype.visible=!1;Le.findFrom=Le.findGapCursorFrom;X.jsonID("gapcursor",Le);var aa=class e{constructor(t){this.pos=t}map(t){return new e(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Le.valid(n)?new Le(n):X.near(n)}};function Ep(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Gk(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Ep(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Jk(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Ep(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Mp(){return new K({props:{decorations:Zk,createSelectionBetween(e,t,n){return t.pos==n.pos&&Le.valid(n)?new Le(n):null},handleClick:Yk,handleKeyDown:Xk,handleDOMEvents:{beforeinput:Qk}}})}var Xk=Jr({ArrowLeft:mi("horiz",-1),ArrowRight:mi("horiz",1),ArrowUp:mi("vert",-1),ArrowDown:mi("vert",1)});function mi(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,i){let s=r.selection,l=t>0?s.$to:s.$from,a=s.empty;if(s instanceof L){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(t>0?l.after():l.before())}let u=Le.findGapCursorFrom(l,t,a);return u?(o&&o(r.tr.setSelection(new Le(u))),!0):!1}}function Yk(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Le.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&_.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Le(r))),!0)}function Qk(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Le))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=z.empty;for(let s=r.length-1;s>=0;s--)o=z.from(r[s].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new ce(o,0,0));return i.setSelection(L.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function Zk(e){if(!(e.selection instanceof Le))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",ue.create(e.doc,[Ee.widget(e.selection.head,t,{key:"gapcursor"})])}function Ar(e){let t=e.selection;if(!(t instanceof _)||t.node.type.name!=="widget")return null;let n=X.findFrom(t.$to,1,!0)??X.findFrom(t.$from,-1,!0),r=n?null:new Le(e.doc.resolve(e.doc.content.size)).map(e.doc,new No),o=n??(r instanceof Le?r:null);return o?e.tr.setSelection(o).setMeta("addToHistory",!1):null}function Ap(e,t){if(Sp(e.doc,t))return null;let n=e.schema.nodeFromJSON(t),r=e.doc.content.findDiffStart(n.content);if(r===null)return null;let o=e.doc.content.findDiffEnd(n.content),i=o.a,s=o.b,l=r-Math.min(i,s);return l>0&&(i+=l,s+=l),e.tr.replace(r,i,n.slice(r,s)).setMeta("addToHistory",!1).setMeta("preventUpdate",!0)}var ua,da;if(typeof WeakMap<"u"){let e=new WeakMap;ua=t=>e.get(t),da=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;ua=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},da=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var me=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,o=t/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[t+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[t+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(e);return t=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){let{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:u}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,u)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s)&&t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==e){let s=t+e*this.width,l=(e+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(e){return ua(e)||da(e,ev(e))}};function ev(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=tv(e),n=e.childCount,r=[],o=0,i=null,s=[];for(let u=0,c=t*n;u<c;u++)r[u]=0;for(let u=0,c=0;u<n;u++){let d=e.child(u);c++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==d.childCount)break;let g=d.child(h),{colspan:m,rowspan:b,colwidth:k}=g.attrs;for(let C=0;C<b;C++){if(C+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:b-C});break}let x=o+C*t;for(let E=0;E<m;E++){r[x+E]==0?r[x+E]=c:(i||(i=[])).push({type:"collision",row:u,pos:c,n:m-E});let A=k&&k[E];if(A){let M=(x+E)%t*2,B=s[M];B==null||B!=A&&s[M+1]==1?(s[M]=A,s[M+1]=1):B==A&&s[M+1]++}}}o+=m,c+=g.nodeSize}let f=(u+1)*t,p=0;for(;o<f;)r[o++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:u,n:p}),c++}(t===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new me(t,n,r,i),a=!1;for(let u=0;!a&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(a=!0);return a&&nv(l,s,e),l}function tv(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let o=e.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=e.child(s);for(let a=0;a<l.childCount;a++){let u=l.child(a);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}t==-1?t=i:t!=i&&(t=Math.max(t,i))}return t}function nv(e,t,n){e.problems||(e.problems=[]);let r={};for(let o=0;o<e.map.length;o++){let i=e.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let u=0;u<a.colspan;u++){let c=t[(o+u)%e.width*2];c!=null&&(!a.colwidth||a.colwidth[u]!=c)&&((l||(l=rv(a)))[u]=c)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function rv(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Ge(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var mn=new ne("selectingCells");function Kt(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function ov(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function wt(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function vi(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=Kt(t.$head)||iv(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function iv(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function fa(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function sv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ma(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Bp(e,t,n){let r=e.node(-1),o=me.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return s==null?null:e.node(0).resolve(i+s)}function Yn(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function zp(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}function lv(e,t,n){let r=Ge(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var oe=class Wt extends X{constructor(t,n=t){let r=t.node(-1),o=me.get(r),i=t.start(-1),s=o.rectBetween(t.pos-i,n.pos-i),l=t.node(0),a=o.cellsInRect(s).filter(c=>c!=n.pos-i);a.unshift(n.pos-i);let u=a.map(c=>{let d=r.nodeAt(c);if(!d)throw new RangeError(`No cell with offset ${c} found`);let f=i+c+1;return new Bs(l.resolve(f),l.resolve(f+d.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(fa(r)&&fa(o)&&ma(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wt.rowSelection(r,o):i&&this.isColSelection()?Wt.colSelection(r,o):new Wt(r,o)}return L.between(r,o)}content(){let t=this.$anchorCell.node(-1),n=me.get(t),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let u=[];for(let c=a*n.width+o.left,d=o.left;d<o.right;d++,c++){let f=n.map[c];if(i[f])continue;i[f]=!0;let p=n.findCell(f),h=t.nodeAt(f);if(!h)throw new RangeError(`No cell with offset ${f} found`);let g=o.left-p.left,m=p.right-o.right;if(g>0||m>0){let b=h.attrs;if(g>0&&(b=Yn(b,0,g)),m>0&&(b=Yn(b,b.colspan-m,m)),p.left<o.left){if(h=h.type.createAndFill(b),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else h=h.type.create(b,h.content)}if(p.top<o.top||p.bottom>o.bottom){let b={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(b):h=h.type.create(b,h.content)}u.push(h)}s.push(t.child(a).copy(z.from(u)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new ce(z.from(l),1,1)}replace(t,n=ce.empty){let r=t.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],u=t.mapping.slice(r);t.replace(u.map(l.pos),u.map(a.pos),s?ce.empty:n)}let i=X.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new ce(z.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=me.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)t(n.nodeAt(i[s]),o+i[s])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let r=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),o=me.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wt(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=me.get(t),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(t){return t instanceof Wt&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),o=me.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wt(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Wt(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Wt(t.resolve(n),t.resolve(r))}getBookmark(){return new av(this.$anchorCell.pos,this.$headCell.pos)}};oe.prototype.visible=!1;X.jsonID("cell",oe);var av=class Hp{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Hp(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ma(n,r)?new oe(n,r):X.near(r,1)}};function cv(e){if(!(e.selection instanceof oe))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push(Ee.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ue.create(e.doc,t)}function uv({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let i=t.depth;i>=0&&!(t.before(i+1)>t.start(i));i--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}function dv({$from:e,$to:t}){let n,r;for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&t.parentOffset===0}function fv(e,t,n){let r=(t||e).selection,o=(t||e).doc,i,s;if(r instanceof _&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=oe.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=oe.rowSelection(l,l)}else if(!n){let l=me.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];i=oe.create(o,a+1,u)}}else r instanceof L&&uv(r)?i=L.create(o,r.from):r instanceof L&&dv(r)&&(i=L.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var pv=new ne("fix-tables");function _p(e,t,n,r){let o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){let a=t.child(s);for(let u=l,c=Math.min(o,s+3);u<c;u++)if(e.child(u)==a){l=u+1,n+=a.nodeSize;continue e}r(a,n),l<o&&e.child(l).sameMarkup(a)?_p(e.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ga(e,t){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=hv(e,o,i,n))};return t?t.doc!=e.doc&&_p(t.doc,e.doc,0,r):e.doc.descendants(r),n}function hv(e,t,n,r){let o=me.get(t);if(!o.problems)return r;r||(r=e.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let u=o.problems[a];if(u.type=="collision"){let c=t.nodeAt(u.pos);if(!c)continue;let d=c.attrs;for(let f=0;f<d.rowspan;f++)i[u.row+f]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Yn(d,d.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){let c=t.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){let c=t.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){let c=r.mapping.map(n);r.delete(c,c+t.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,u=n+1;a<o.height;a++){let c=t.child(a),d=u+c.nodeSize,f=i[a];if(f>0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);let h=[];for(let m=0;m<f;m++){let b=Ge(e.schema)[p].createAndFill();b&&h.push(b)}let g=(a==0||s==a-1)&&l==a?u+1:d-1;r.insert(r.mapping.map(g),h)}u=d}return r.setMeta(pv,{fixTables:!0})}function Tt(e){let t=e.selection,n=vi(e),r=n.node(-1),o=n.start(-1),i=me.get(r);return{...t instanceof oe?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Vp(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;lv(t,r,o+i)&&(i=o==0||o==t.width?null:0);for(let s=0;s<t.height;s++){let l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){let a=t.map[l],u=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,zp(u.attrs,o-t.colCount(a))),s+=u.attrs.rowspan-1}else{let a=i==null?Ge(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,u=t.positionAt(s,o,r);e.insert(e.mapping.map(n+u),a.createAndFill())}}return e}function jp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Vp(e.tr,n,n.left))}return!0}function Fp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Vp(e.tr,n,n.right))}return!0}function mv(e,{map:t,table:n,tableStart:r},o){let i=e.mapping.maps.length;for(let s=0;s<t.height;){let l=s*t.width+o,a=t.map[l],u=n.nodeAt(a),c=u.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,Yn(c,o-t.colCount(a)));else{let d=e.mapping.slice(i).map(r+a);e.delete(d,d+u.nodeSize)}s+=c.rowspan}}function Wp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;mv(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=me.get(i)}t(r)}return!0}function gv(e,t,n){var r;let o=Ge(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(((r=t.nodeAt(e.map[i+n*e.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Kp(e,{map:t,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;let s=[],l=o>0?-1:0;gv(t,r,o+l)&&(l=o==0||o==t.height?null:0);for(let u=0,c=t.width*o;u<t.width;u++,c++)if(o>0&&o<t.height&&t.map[c]==t.map[c-t.width]){let d=t.map[c],f=r.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),u+=f.colspan-1}else{var a;let d=l==null?Ge(r.type.schema).cell:(a=r.nodeAt(t.map[c+l*t.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return e.insert(i,Ge(r.type.schema).row.create(null,s)),e}function Up(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Kp(e.tr,n,n.top))}return!0}function qp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e);t(Kp(e.tr,n,n.bottom))}return!0}function bv(e,{map:t,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;let s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);let a=new Set;for(let u=0,c=o*t.width;u<t.width;u++,c++){let d=t.map[c];if(!a.has(d)){if(a.add(d),o>0&&d==t.map[c-t.width]){let f=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(o<t.height&&d==t.map[c+t.width]){let f=n.nodeAt(d),p=f.attrs,h=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=t.positionAt(o+1,u,n);e.insert(e.mapping.slice(l).map(r+g),h),u+=p.colspan-1}}}}function Gp(e,t){if(!wt(e))return!1;if(t){let n=Tt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;bv(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=me.get(n.table)}t(r)}return!0}function Tp(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function yv({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}function ba(e,t){let n=e.selection;if(!(n instanceof oe)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Tt(e),{map:o}=r;if(yv(o,r))return!1;if(t){let i=e.tr,s={},l=z.empty,a,u;for(let c=r.top;c<r.bottom;c++)for(let d=r.left;d<r.right;d++){let f=o.map[c*o.width+d],p=r.table.nodeAt(f);if(!(s[f]||!p))if(s[f]=!0,a==null)a=f,u=p;else{Tp(p)||(l=l.append(p.content));let h=i.mapping.map(f+r.tableStart);i.delete(h,h+p.nodeSize)}}if(a==null||u==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...zp(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let c=a+1+u.content.size,d=Tp(u)?a+1:c;i.replaceWith(d+r.tableStart,c+r.tableStart,l)}i.setSelection(new oe(i.doc.resolve(a+r.tableStart))),t(i)}return!0}function ya(e,t){let n=Ge(e.schema);return wv(({node:r})=>n[r.type.spec.tableRole])(e,t)}function wv(e){return(t,n)=>{let r=t.selection,o,i;if(r instanceof oe){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=ov(r.$from),!o)return!1;i=(s=Kt(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],u=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let c=Tt(t),d=t.tr;for(let p=0;p<c.right-c.left;p++)a.push(u?{...l,colwidth:u&&u[p]?[u[p]]:null}:l);let f;for(let p=c.top;p<c.bottom;p++){let h=c.map.positionAt(p,c.left,c.table);p==c.top&&(h+=o.nodeSize);for(let g=c.left,m=0;g<c.right;g++,m++)g==c.left&&p==c.top||d.insert(f=d.mapping.map(h+c.tableStart,1),e({node:o,row:p,col:g}).createAndFill(a[m]))}d.setNodeMarkup(i,e({node:o,row:c.top,col:c.left}),a[0]),r instanceof oe&&d.setSelection(new oe(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Jp(e,t){return function(n,r){if(!wt(n))return!1;let o=vi(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){let i=n.tr;n.selection instanceof oe?n.selection.forEachCell((s,l)=>{s.attrs[e]!==t&&i.setNodeMarkup(l,null,{...s.attrs,[e]:t})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(i)}return!0}}function kv(e){return function(t,n){if(!wt(t))return!1;if(n){let r=Ge(t.schema),o=Tt(t),i=t.tr,s=o.map.cellsInRect(e=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:e=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Np(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let o=0;o<r.length;o++){let i=t.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Tr(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?kv(e):function(n,r){if(!wt(n))return!1;if(r){let o=Ge(n.schema),i=Tt(n),s=n.tr,l=Np("row",i,o),a=Np("column",i,o),u=(e==="column"?l:e==="row"&&a)?1:0,c=e=="column"?{left:0,top:u,right:1,bottom:i.map.height}:e=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,d=e=="column"?a?o.cell:o.header_cell:e=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(c).forEach(f=>{let p=f+i.tableStart,h=s.doc.nodeAt(p);h&&s.setNodeMarkup(p,d,h.attrs)}),r(s)}return!0}}var pM=Tr("row",{useDeprecatedLogic:!0}),hM=Tr("column",{useDeprecatedLogic:!0}),Xp=Tr("cell",{useDeprecatedLogic:!0});function vv(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,o=e.before();r>=0;r--){let i=e.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let r=e.indexAfter(-1),o=e.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function wa(e){return function(t,n){if(!wt(t))return!1;let r=vv(vi(t),e);if(r==null)return!1;if(n){let o=t.doc.resolve(r);n(t.tr.setSelection(L.between(o,sv(o))).scrollIntoView())}return!0}}function Yp(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function gi(e,t){let n=e.selection;if(!(n instanceof oe))return!1;if(t){let r=e.tr,o=Ge(e.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new ce(o,0,0))}),r.docChanged&&t(r)}return!0}function Cv(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;let o=t.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<t.childCount;a++){let u=t.child(a).content,c=a?0:Math.max(0,n-1),d=a<t.childCount-1?0:Math.max(0,r-1);(c||d)&&(u=pa(Ge(s).row,new ce(u,c,d)).content),l.push(u)}else if(i=="cell"||i=="header_cell")l.push(n||r?pa(Ge(s).row,new ce(t,n,r)).content:t);else return null;return xv(s,l)}function xv(e,t){let n=[];for(let o=0;o<t.length;o++){let i=t[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let u=o;u<o+l;u++)n[u]=(n[u]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(z.empty),n[o]<r){let i=Ge(e).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);t[o]=t[o].append(z.from(s))}return{height:t.length,width:r,rows:t}}function pa(e,t){let n=e.createAndFill();return new Do(n).replace(0,n.content.size,t).doc}function Sv({width:e,height:t,rows:n},r,o){if(e!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],u=[];for(let c=i[l]||0,d=0;c<r;d++){let f=a.child(d%a.childCount);c+f.attrs.colspan>r&&(f=f.type.createChecked(Yn(f.attrs,f.attrs.colspan,c+f.attrs.colspan-r),f.content)),u.push(f),c+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+f.attrs.colspan}s.push(z.from(u))}n=s,e=r}if(t!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],u=n[l%t];for(let c=0;c<u.childCount;c++){let d=u.child(c);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(z.from(a))}n=i,t=o}return{width:e,height:t,rows:n}}function Ev(e,t,n,r,o,i,s){let l=e.doc.type.schema,a=Ge(l),u,c;if(o>t.width)for(let d=0,f=0;d<t.height;d++){let p=n.child(d);f+=p.nodeSize;let h=[],g;p.lastChild==null||p.lastChild.type==a.cell?g=u||(u=a.cell.createAndFill()):g=c||(c=a.header_cell.createAndFill());for(let m=t.width;m<o;m++)h.push(g);e.insert(e.mapping.slice(s).map(f-1+r),h)}if(i>t.height){let d=[];for(let h=0,g=(t.height-1)*t.width;h<Math.max(t.width,o);h++){let m=h>=t.width?!1:n.nodeAt(t.map[g+h]).type==a.header_cell;d.push(m?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}let f=a.row.create(null,z.from(d)),p=[];for(let h=t.height;h<i;h++)p.push(f);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(u||c)}function Rp(e,t,n,r,o,i,s,l){if(s==0||s==t.height)return!1;let a=!1;for(let u=o;u<i;u++){let c=s*t.width+u,d=t.map[c];if(t.map[c-t.width]==d){a=!0;let f=n.nodeAt(d),{top:p,left:h}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-p}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-s})),u+=f.attrs.colspan-1}}return a}function Op(e,t,n,r,o,i,s,l){if(s==0||s==t.width)return!1;let a=!1;for(let u=o;u<i;u++){let c=u*t.width+s,d=t.map[c];if(t.map[c-1]==d){a=!0;let f=n.nodeAt(d),p=t.colCount(d),h=e.mapping.slice(l).map(d+r);e.setNodeMarkup(h,null,Yn(f.attrs,s-p,f.attrs.colspan-(s-p))),e.insert(h+f.nodeSize,f.type.createAndFill(Yn(f.attrs,0,s-p))),u+=f.attrs.rowspan-1}}return a}function Dp(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let s=me.get(i),{top:l,left:a}=r,u=a+o.width,c=l+o.height,d=e.tr,f=0;function p(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=me.get(i),f=d.mapping.maps.length}Ev(d,s,i,n,u,c,f)&&p(),Rp(d,s,i,n,a,u,l,f)&&p(),Rp(d,s,i,n,a,u,c,f)&&p(),Op(d,s,i,n,l,c,a,f)&&p(),Op(d,s,i,n,l,c,u,f)&&p();for(let h=l;h<c;h++){let g=s.positionAt(h,a,i),m=s.positionAt(h,u,i);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(m+n),new ce(o.rows[h-l],0,0))}p(),d.setSelection(new oe(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(c-1,u-1,i)))),t(d)}var Mv=Jr({ArrowLeft:bi("horiz",-1),ArrowRight:bi("horiz",1),ArrowUp:bi("vert",-1),ArrowDown:bi("vert",1),"Shift-ArrowLeft":yi("horiz",-1),"Shift-ArrowRight":yi("horiz",1),"Shift-ArrowUp":yi("vert",-1),"Shift-ArrowDown":yi("vert",1),Backspace:gi,"Mod-Backspace":gi,Delete:gi,"Mod-Delete":gi});function wi(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function bi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof oe)return wi(n,r,X.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let s=Qp(o,e,t);if(s==null)return!1;if(e=="horiz")return wi(n,r,X.near(n.doc.resolve(i.head+t),t));{let l=n.doc.resolve(s),a=Bp(l,e,t),u;return a?u=X.near(a,1):t<0?u=X.near(n.doc.resolve(l.before(-1)),-1):u=X.near(n.doc.resolve(l.after(-1)),1),wi(n,r,u)}}}function yi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof oe)s=i;else{let a=Qp(o,e,t);if(a==null)return!1;s=new oe(n.doc.resolve(a))}let l=Bp(s.$headCell,e,t);return l?wi(n,r,new oe(s.$anchorCell,l)):!1}}function Av(e,t){let n=e.state.doc,r=Kt(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new oe(r))),!0):!1}function Tv(e,t,n){if(!wt(e.state))return!1;let r=Cv(n),o=e.state.selection;if(o instanceof oe){r||(r={width:1,height:1,rows:[z.from(pa(Ge(e.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=me.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=Sv(r,l.right-l.left,l.bottom-l.top),Dp(e.state,e.dispatch,s,l,r),!0}else if(r){let i=vi(e.state),s=i.start(-1);return Dp(e.state,e.dispatch,s,me.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Nv(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=Lp(e,t.target),o;if(t.shiftKey&&e.state.selection instanceof oe)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(o=Kt(e.state.selection.$anchor))!=null&&((n=ca(e,t))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(a,u){let c=ca(e,u),d=mn.getState(e.state)==null;if(!c||!ma(a,c))if(d)c=a;else return;let f=new oe(a,c);if(d||!e.state.selection.eq(f)){let p=e.state.tr.setSelection(f);d&&p.setMeta(mn,a.pos),e.dispatch(p)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),mn.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(mn,-1))}function l(a){let u=a,c=mn.getState(e.state),d;if(c!=null)d=e.state.doc.resolve(c);else if(Lp(e,u.target)!=r&&(d=ca(e,t),!d))return s();d&&i(d,u)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Qp(e,t,n){if(!(e.state.selection instanceof L))return null;let{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function Lp(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function ca(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Kt(e.state.doc.resolve(r))||Kt(e.state.doc.resolve(o))}var Rv=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ha(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ha(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ha(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,u=e.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){let{colspan:p,colwidth:h}=u.child(d).attrs;for(let g=0;g<p;g++,f++){let m=o==f?i:h&&h[g],b=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=b,t.appendChild(k)}}}for(;a;){var c;let d=a.nextSibling;(c=a.parentNode)===null||c===void 0||c.removeChild(a),a=d}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var lt=new ne("tableColumnResizing");function Zp({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Rv,lastColumnResizable:o=!0}={}){let i=new K({key:lt,state:{init(s,l){var a;let u=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,c=Ge(l.schema).table.name;return r&&u&&(u[c]=(d,f)=>new r(d,n,f)),new Ov(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=lt.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Dv(s,l,e,o)},mouseleave:s=>{Lv(s)},mousedown:(s,l)=>{Iv(s,l,t,n)}},decorations:s=>{let l=lt.getState(s);if(l&&l.activeHandle>-1)return Hv(s,l.activeHandle)},nodeViews:{}}});return i}var Ov=class ki{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(lt);if(r&&r.setHandle!=null)return new ki(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ki(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return fa(t.doc.resolve(o))||(o=-1),new ki(o,n.dragging)}return n}};function Dv(e,t,n,r){if(!e.editable)return;let o=lt.getState(e.state);if(o&&!o.dragging){let i=$v(t.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();t.clientX-l<=n?s=Ip(e,t,"left",n):a-t.clientX<=n&&(s=Ip(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),a=l.node(-1),u=me.get(a),c=l.start(-1);if(u.colCount(l.pos-c)+l.nodeAfter.attrs.colspan-1==u.width-1)return}eh(e,s)}}}function Lv(e){if(!e.editable)return;let t=lt.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&eh(e,-1)}function Iv(e,t,n,r){var o;if(!e.editable)return!1;let i=(o=e.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=lt.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),a=Pv(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(lt,{setDragging:{startX:t.clientX,startWidth:a}}));function u(d){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",c);let f=lt.getState(e.state);f?.dragging&&(Bv(e,f.activeHandle,Pp(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(lt,{setDragging:null})))}function c(d){if(!d.which)return u(d);let f=lt.getState(e.state);if(f&&f.dragging){let p=Pp(f.dragging,d,n);$p(e,f.activeHandle,p,r)}}return $p(e,s.activeHandle,a,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",c),t.preventDefault(),!0}function Pv(e,t,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=e.domAtPos(t),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function $v(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Ip(e,t,n,r){let o=n=="right"?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;let{pos:s}=i,l=Kt(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=me.get(l.node(-1)),u=l.start(-1),c=a.map.indexOf(l.pos-u);return c%a.width==0?-1:u+a.map[c-1]}function Pp(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function eh(e,t){e.dispatch(e.state.tr.setMeta(lt,{setHandle:t}))}function Bv(e,t,n){let r=e.state.doc.resolve(t),o=r.node(-1),i=me.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let u=0;u<i.height;u++){let c=u*i.width+l;if(u&&i.map[c]==i.map[c-i.width])continue;let d=i.map[c],f=o.nodeAt(d).attrs,p=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[p]==n)continue;let h=f.colwidth?f.colwidth.slice():zv(f.colspan);h[p]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:h})}a.docChanged&&e.dispatch(a)}function $p(e,t,n,r){let o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=me.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ha(i,a.firstChild,a,r,l,n)}function zv(e){return Array(e).fill(0)}function Hv(e,t){let n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return ue.empty;let i=me.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){let c=l+u*i.width;if((l==i.width-1||i.map[c]!=i.map[c+1])&&(u==0||i.map[c]!=i.map[c-i.width])){var a;let d=i.map[c],f=s+d+o.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((a=lt.getState(e))===null||a===void 0)&&a.dragging&&n.push(Ee.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Ee.widget(f,p))}}return ue.create(e.doc,n)}function th({allowTableNodeSelection:e=!1}={}){return new K({key:mn,state:{init(){return null},apply(t,n){let r=t.getMeta(mn);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;let{deleted:o,pos:i}=t.mapping.mapResult(n);return o?null:i}},props:{decorations:cv,handleDOMEvents:{mousedown:Nv},createSelectionBetween(t){return mn.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Av,handleKeyDown:Mv,handlePaste:Tv},appendTransaction(t,n,r){return fv(r,ga(r,n),e)}})}var Qn="showaiTableAction";function nh(e,t,n){let r=e.doc.nodeAt(t);if(r?.type.name!=="table")return null;let o=e.selection instanceof oe?e.selection.$headCell:Kt(e.selection.$head),i=o&&o.before(-1)===t?o:e.doc.resolve(t+1+me.get(r).map[0]),s=n==="row"?oe.rowSelection(i):n==="column"?oe.colSelection(i):new oe(i);return e.tr.setSelection(s)}function oo(e){let t=e.selection;if(!(t instanceof oe))return null;let n=t.$anchorCell.node(-1),r=t.$anchorCell.start(-1),o=me.get(n).rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r);return{tablePosition:r-1,rows:o.bottom-o.top,columns:o.right-o.left}}function rh(e,t){let n=t.$anchorCell.nodeAfter?.attrs.id,r=t.$headCell.nodeAfter?.attrs.id;if(!n||!r)return null;let o,i;if(e.descendants((a,u)=>{["tableCell","tableHeader"].includes(a.type.name)&&(a.attrs.id===n&&(o=u),a.attrs.id===r&&(i=u))}),o===void 0&&i===void 0||(o??=i,i??=o,o===void 0||i===void 0))return null;let s=e.resolve(o),l=e.resolve(i);return s.node(-1)!==l.node(-1)?null:new oe(s,l)}var at=ye(Xe(),1);function Ci({editor:e,context:t=!1,onAction:n}){let r=Be($e),o=oo(e.state);if(!o&&!t&&!e.can().splitCell())return null;let i=s=>{e.view.dispatch(pr(e.state.tr)),e.chain().setMeta(Qn,!0).focus()[s]().run(),n?.()};return(0,at.jsxs)(at.Fragment,{children:[!t&&(0,at.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,at.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,at.jsx)("span",{className:"editor-menu-status",role:"status",children:o.rows===1&&o.columns===1?r("table.shiftClickHint"):r("table.selectedCells",{rows:o.rows,columns:o.columns})}),[["mergeCells",r("table.mergeCells"),Uc],["splitCell",r("table.splitCell"),qc]].map(([s,l,a])=>(0,at.jsxs)("button",{type:"button",className:"editor-tool",role:t?"menuitem":void 0,"aria-label":l,title:l,disabled:!e.can()[s](),onMouseDown:u=>u.preventDefault(),onClick:()=>i(s),children:[(0,at.jsx)(a,{size:16}),t&&(0,at.jsx)("span",{children:l})]},s)),!t&&o&&(0,at.jsx)("button",{type:"button",className:"editor-tool","aria-label":r("table.clearSelection"),title:r("table.clearSelection"),onMouseDown:s=>s.preventDefault(),onClick:()=>{e.view.dispatch(e.state.tr.setSelection(L.near(e.state.selection.$from))),e.view.focus()},children:(0,at.jsx)($r,{size:16})})]})]})}var io=ye(tn(),1),ch=ye(Ds(),1);var xi=ye(Xe(),1),_v=[["left","Left",Rn],["center","Center",Tn],["right","Right",Nn]];function ka({scope:e,value:t,onChange:n}){let r=Be(lu),o=i=>e==="table"?r(`align.table${i}`):typeof e=="number"?r(`align.column${i}`,{column:e+1}):r(`align.scope${i}`,{scope:e});return(0,xi.jsx)("div",{className:"table-alignment-buttons",role:"group","aria-label":o("Group"),children:_v.map(([i,s,l])=>(0,xi.jsx)("button",{type:"button","aria-label":o(s),title:o(s),"aria-pressed":t===i,onMouseDown:a=>a.preventDefault(),onClick:a=>{a.stopPropagation(),n(i)},children:(0,xi.jsx)(l,{size:14})},i))})}var oh=or($e),ih=le.create({name:"tableAlignment",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textAlign:{default:null,parseHTML:e=>["left","center","right"].includes(e.style.textAlign)?e.style.textAlign:null,renderHTML:e=>["left","center","right"].includes(String(e.textAlign))?{style:`text-align: ${e.textAlign}`}:{}}}}]},addProseMirrorPlugins(){let e=this.editor;return[new K({appendTransaction(t,n,r){if(!e.isEditable||!t.some(i=>i.docChanged))return null;let o=r.tr;return r.doc.descendants((i,s)=>{if(i.type.name!=="table")return;let l=me.get(i),a=Array.from({length:l.width},(u,c)=>{let d=new Set(Array.from({length:l.height},(f,p)=>i.nodeAt(l.map[p*l.width+c])?.attrs.textAlign).filter(Boolean));return d.size===1?[...d][0]:i.attrs.textAlign});Vv(i,s,(u,c)=>{if(u.attrs.textAlign)return;let d=l.findCell(c-s-1),f=new Set(a.slice(d.left,d.right)),p=f.size===1?[...f][0]:i.attrs.textAlign;p&&o.setNodeAttribute(c,"textAlign",p)})}),o.docChanged?o.setMeta("addToHistory",!1):null}})]}});function Vv(e,t,n){e.forEach((r,o)=>r.forEach((i,s)=>n(i,t+2+o+s)))}function va(e,t){let r=sh(e,t).map(o=>e.nodeAt(o)?.attrs.textAlign??e.attrs.textAlign??"left");return r.every(o=>o===r[0])?r[0]??"left":null}function sh(e,t){let n=me.get(e);if(t!==null&&(!Number.isInteger(t)||t<0||t>=n.width))throw new Error(oh("table.columnOutOfRange"));return[...new Set(t===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+t]))]}function lh(e,t,n,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="table")throw new Error(oh("table.notATable"));let i=e.tr;n===null&&i.setNodeAttribute(t,"textAlign",r);for(let s of sh(o,n)){let l=t+1+s,a=e.doc.nodeAt(l);i.setNodeAttribute(l,"textAlign",r),a.descendants((u,c)=>{if(u.type.name==="table")return!1;["paragraph","heading"].includes(u.type.name)&&u.attrs.textAlign&&i.setNodeAttribute(l+1+c,"textAlign",null)})}return i}var Ut=ye(tn(),1),jv=()=>!0;function ah(e,t={}){let n=(0,Ut.useId)(),[r,o]=(0,Ut.useState)(null),[,i]=(0,Ut.useState)(0),s=(0,Ut.useRef)({target:r,options:t});s.current={target:r,options:t};let l=t.accept??jv;return(0,Ut.useEffect)(()=>{if(!e)return;let a,u=()=>{clearTimeout(a),a=void 0},c=A=>A?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")===n,d=()=>{u(),o(null),s.current.options.onDismiss?.()},f=()=>{a||s.current.options.keepOpen||s.current.target?.context||c(document.activeElement)||(a=setTimeout(d,220))},p=A=>{let M=A.closest("table");if(!(M instanceof HTMLTableElement)||!e.contains(M)||!l(M))return null;let B=A.closest("td, th");return{table:M,cell:B?.parentElement===M.rows[0]?B:null,context:null}},h=A=>{u(),o(M=>M?.table===A.table&&M.cell===A.cell&&!M.context?M:A)},g=A=>{let M=A.target;if(c(M)){u();return}if(s.current.options.keepOpen||s.current.target?.context){u();return}let B=s.current.target;if(B?.cell?.isConnected){let Q=B.cell.getBoundingClientRect(),ge=Ca(B,0).column;if(A.clientX>=Math.min(Q.left,ge.left)&&A.clientX<=Math.max(Q.right,ge.left+88)&&A.clientY>=Q.bottom&&A.clientY<=ge.top){u();return}}let ie=p(M);if(ie){h(ie);return}if(B?.table.isConnected){let Q=B.table.getBoundingClientRect();if(A.clientX>=Q.left-8&&A.clientX<=Q.right+8&&A.clientY>=Q.top-44&&A.clientY<=Q.bottom+8){u();return}}f()},m=A=>{let M=A.target;if(c(M)){u();return}let B=p(M);B?(s.current.options.onDismiss?.(),h(B)):d()},b=A=>{let M=p(A.target);M&&(A.preventDefault(),A.stopPropagation(),u(),s.current.options.onDismiss?.(),o({...M,cell:null,context:{left:Math.max(8,Math.min(A.clientX,window.innerWidth-140)),top:Math.max(8,Math.min(A.clientY,window.innerHeight-42))}}))},k=A=>{if(c(A.target))u();else{let M=p(A.target);M&&h(M)}},C=A=>{A.key==="Escape"&&d()},x=A=>{A.target instanceof HTMLElement&&A.target.contains(e)&&d()},E=()=>i(A=>A+1);return document.addEventListener("pointermove",g),document.addEventListener("pointerdown",m),document.addEventListener("focusin",k),document.addEventListener("keydown",C),e.addEventListener("contextmenu",b),window.addEventListener("blur",d),window.addEventListener("showai:viewport-change",x),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{u(),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",m),document.removeEventListener("focusin",k),document.removeEventListener("keydown",C),e.removeEventListener("contextmenu",b),window.removeEventListener("blur",d),window.removeEventListener("showai:viewport-change",x),window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[e,l,n]),{target:r,setTarget:o,owner:n}}function Ca(e,t){let n=e.table.getBoundingClientRect(),r=e.table.closest(".tableWrapper, .sb-table-scroll")?.getBoundingClientRect(),o=Math.min(n.right,r?.right??n.right,window.innerWidth-8),i=Math.max(8,o-t),s=Math.max(8,n.top-36),l=e.cell?.getBoundingClientRect(),a=l?(l.left+l.right-88)/2:i;return{global:e.context??{left:Math.max(t+8,o),top:s,transform:"translateX(-100%)"},column:{left:Math.max(8,Math.min(a,o-88)),top:l?l.bottom+4:s}}}var he=ye(Xe(),1),Fv=e=>!e.closest(".document-widget");function uh({editor:e}){let t=Be($e),[,n]=(0,io.useState)(0),[r,o]=(0,io.useState)(!1),i=oo(e.state),{target:s,setTarget:l,owner:a}=ah(e.view.dom,{keepOpen:r,accept:Fv,onDismiss:()=>o(!1)});if((0,io.useEffect)(()=>{let E=()=>n(M=>M+1),A=M=>{M.key!=="Escape"||!oo(e.state)||!e.view.hasFocus()&&document.activeElement?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")!==a||(e.view.dispatch(e.state.tr.setSelection(L.near(e.state.selection.$from))),o(!1),e.view.focus())};return e.on("transaction",E),document.addEventListener("keydown",A),()=>{e.off("transaction",E),document.removeEventListener("keydown",A)}},[e,a]),!s||!s.table.isConnected||!e.isEditable||!s.context&&(i||e.isFocused&&e.state.selection instanceof L&&!e.state.selection.empty))return null;let u=e.state.doc.resolve(e.view.posAtDOM(s.table,0)),c=u.depth;for(;c>0&&u.node(c).type.name!=="table";)c--;if(!c)return null;let d=u.node(c),f=u.before(c),p=null;if(s.cell?.isConnected){let E=e.view.posAtDOM(s.cell,0),A=e.state.doc.resolve(E),M=A.depth;for(;M>c&&!["tableCell","tableHeader"].includes(A.node(M).type.name);)M--;M>c&&(p=me.get(d).findCell(A.before(M)-f-1).left)}let h=Ca(s,128),g=h.global.top>window.innerHeight/2,m=()=>{let{$from:E}=e.state.selection;Array.from({length:E.depth},(M,B)=>B+1).some(M=>E.node(M).type.name==="table"&&E.before(M)===f)||e.view.dispatch(e.state.tr.setSelection(L.near(e.state.doc.resolve(f+3))))},b=E=>{m(),e.view.dispatch(pr(e.state.tr)),E(),o(!1)},k=()=>e.chain().setMeta(Qn,!0).focus(),C=E=>b(()=>{let A=nh(e.state,f,E);A&&e.view.dispatch(A),e.view.focus()}),x=(E,A)=>{e.view.dispatch(lh(e.state,f,E,A).setMeta(Qn,!0)),s.context&&(l(null),e.view.focus())};return(0,ch.createPortal)((0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)("div",{className:"document-table-controls table-global-alignment","data-editor-menu-trigger":s.context?"context":"hover",role:s.context?"dialog":void 0,"aria-label":t("table.alignment"),"data-table-controls-owner":a,style:h.global,children:[(0,he.jsx)(ka,{scope:"table",value:va(d,null),onChange:E=>x(null,E)}),!s.context&&(0,he.jsx)("button",{className:"document-table-menu-trigger",type:"button","aria-label":t("table.actions"),title:t("table.actions"),"aria-expanded":r,"aria-haspopup":"menu",onMouseDown:E=>E.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,he.jsx)(Oc,{size:16})}),(r||s.context)&&(0,he.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":t("table.actionsMenu"),style:{...g?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,g?h.global.top-12:window.innerHeight-h.global.top-46),overflowY:"auto"},onMouseDown:E=>E.preventDefault(),children:[(0,he.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().addRowAfter().run()}),children:[(0,he.jsx)(nn,{size:14}),t("table.addRow")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().addColumnAfter().run()}),children:[(0,he.jsx)(nn,{size:14}),t("table.addColumn")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().toggleHeaderRow().run()}),children:[(0,he.jsx)(Gc,{size:14,"aria-hidden":"true"}),t("table.toggleHeader")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>C("cell"),children:[(0,he.jsx)(Wc,{size:14,"aria-hidden":"true"}),t("table.selectCells")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>C("row"),children:[(0,he.jsx)(Os,{size:14,"aria-hidden":"true"}),t("table.selectRow")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>C("column"),children:[(0,he.jsx)(Rs,{size:14,"aria-hidden":"true"}),t("table.selectColumn")]}),s.context&&(0,he.jsx)(Ci,{editor:e,context:!0,onAction:()=>{l(null),o(!1)}}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().deleteRow().run()}),children:[(0,he.jsx)(Os,{size:14,"aria-hidden":"true"}),t("table.deleteRow")]}),(0,he.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().deleteColumn().run()}),children:[(0,he.jsx)(Rs,{size:14,"aria-hidden":"true"}),t("table.deleteColumn")]}),(0,he.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>b(()=>{k().deleteTable().run(),l(null)}),children:[(0,he.jsx)(Mo,{size:14}),t("table.deleteTable")]})]})]}),p!==null&&!s.context&&(0,he.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:h.column,children:(0,he.jsx)(ka,{scope:p,value:va(d,p),onChange:E=>x(p,E)})})]}),document.body)}var qt=ye(tn(),1);Cc(`.rich-format-controls{display:contents}.rich-format-group{display:inline-flex;align-items:center;flex:0 0 auto;gap:1px}.rich-format-divider{width:1px;height:18px;margin:0 5px;flex-shrink:0;background:var(--line, #e8e8eb)}.rich-format-select{position:relative;display:inline-flex;align-items:center;height:32px;border-radius:6px;color:var(--text, #343a35)}.rich-format-select>svg:last-child{position:absolute;right:6px;pointer-events:none;color:var(--muted, #777)}.rich-format-select select{appearance:none;width:100%;height:32px;padding:0 21px 0 8px;border:0;border-radius:inherit;background:transparent;color:inherit;font:12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-format-block{width:70px}.rich-format-font{width:76px}.rich-format-size{width:58px}.rich-format-alignment{width:41px}.rich-format-alignment>svg:first-child{margin-left:6px}.rich-format-alignment select{position:absolute;inset:0;opacity:0}.rich-format-select:hover,.rich-format-colors-toggle:hover{background:var(--hover, #f5f5f7)}.rich-format-select:focus-within{outline:2px solid var(--accent, #6c805f);outline-offset:-2px}.rich-format-select select:focus-visible{outline:none}.rich-format-colors-toggle{display:inline-flex;align-items:center;justify-content:center;gap:5px;width:43px;height:32px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--text, #343a35);cursor:pointer}.rich-format-colors-toggle.is-active{background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f)}.rich-format-color-icon{display:inline-flex;flex-direction:column;align-items:center;gap:2px}.rich-format-color-icon i{width:16px;height:3px;border-radius:2px}.rich-text-selection-toolbar.editor-bubble{--editor-soft: var(--accent-soft, #eeedf9);gap:2px;max-width:min(680px,calc(100vw - 24px));padding:6px;flex-wrap:wrap;overflow:visible;border:1px solid var(--line, #e8e8eb);border-radius:12px;box-shadow:0 4px 12px #25233508,0 12px 36px #25233514}.rich-text-selection-toolbar .editor-tool,.editor-toolbar .rich-format-group .editor-tool{width:30px;height:32px;border-radius:6px;color:var(--text, #343a35);cursor:pointer}.rich-text-selection-toolbar .editor-tool:hover,.rich-text-selection-toolbar .editor-tool.is-active{color:var(--accent, #6c805f);background:var(--editor-soft)}.rich-text-selection-toolbar .toolbar-divider{margin:0 5px;height:18px}.rich-text-selection-toolbar .editor-bubble-assistant{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:30px;padding:0 10px;border:1px solid color-mix(in srgb,var(--accent, #6c805f) 12%,transparent);border-radius:7px;background:var(--accent-soft, #eeedf9);color:var(--accent, #6c805f);font:500 12px/1.2 var(--font-ui, system-ui, sans-serif);cursor:pointer}.rich-text-selection-toolbar .editor-bubble-reference{color:var(--accent, #6c805f)}.rich-text-selection-toolbar .editor-bubble-assistant:hover{background:color-mix(in srgb,var(--accent, #6c805f) 15%,var(--paper, white))}.rich-text-selection-toolbar :is(button,input):focus-visible,.rich-format-color-panel :is(button,input):focus-visible{outline:2px solid var(--accent, #6c805f);outline-offset:2px}.editor-toolbar:has(.rich-format-controls){flex-wrap:wrap}.rich-format-color-panel{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));order:10;flex:1 0 100%;gap:20px;padding:14px 8px 8px;margin-top:5px;border-top:1px solid var(--line, #e8e8eb)}.rich-format-panel-label{display:block;margin-bottom:10px;color:var(--muted, #777);font-size:11px;font-weight:500}.rich-format-swatches{display:flex;flex-wrap:wrap;gap:7px}.rich-format-swatch,.rich-format-custom-color{position:relative;width:20px;height:20px;flex:0 0 20px;padding:0;border:1px solid #0000000a;border-radius:50%;cursor:pointer}.rich-format-swatch:hover{transform:scale(1.12)}.rich-format-swatch.is-active{outline:2px solid var(--accent, #6c805f);outline-offset:2px;box-shadow:inset 0 0 0 2px var(--paper, white)}.rich-format-custom-color{overflow:hidden;border-color:var(--line, #ddd)}.rich-format-custom-color input{width:100%;height:100%;padding:0;border:0;background:none;cursor:pointer}.rich-format-custom-color input::-webkit-color-swatch-wrapper{padding:3px}.rich-format-custom-color input::-webkit-color-swatch{border:0;border-radius:50%}.rich-format-highlight-modes{display:flex;gap:4px;margin-top:12px}.rich-format-highlight-modes button{display:inline-flex;align-items:center;gap:6px;padding:5px 7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--muted, #777);font:11px/1.2 var(--font-ui, system-ui, sans-serif);white-space:nowrap;cursor:pointer}.rich-format-highlight-modes button[aria-pressed=true]{border-color:var(--line, #e8e8eb);background:var(--hover, #f5f5f7);color:var(--text, #343a35)}.rich-format-highlight-preview{color:#343a35;font:600 12px/1.3 Georgia,serif;background:linear-gradient(transparent 52%,var(--highlight-preview) 52%)}.rich-format-highlight-preview.is-full{background:var(--highlight-preview)}@media(max-width:680px){.rich-text-selection-toolbar.editor-bubble{max-width:min(360px,calc(100vw - 24px));row-gap:5px}.rich-text-selection-toolbar .rich-format-divider{display:none}.rich-text-selection-toolbar .rich-format-group{gap:2px;order:2}.rich-text-selection-toolbar .rich-format-controls>.rich-format-group:first-child{flex-grow:1;order:0}.rich-text-selection-toolbar .toolbar-divider{display:none}.rich-text-selection-toolbar .editor-bubble-assistant{order:1;margin-left:auto}.rich-text-selection-toolbar .editor-bubble-reference{order:1}.rich-text-selection-toolbar .rich-format-color-panel{grid-template-columns:1fr;gap:14px}}
|
|
97
|
+
`);var V=ye(Xe(),1),Wv=["#292733","#787774","#a85b3c","#c44343","#bd861e","#448361","#3979bf","#8864b4"],Kv=["#e8eed0","#f9e7a0","#f8d8bb","#f4cfd2","#e9d8f1","#d3e5f7","#cde9df","#e5e5e5"];function dh({editor:e,onLink:t}){let n=Be($e),[r,o]=(0,qt.useState)(!1),i=(0,qt.useRef)(null),s=(0,qt.useRef)(null),l=(0,qt.useId)(),a=e.getAttributes("textStyle").color??"#292733",u=e.getAttributes("highlight").color??"#e8eed0",c=e.getAttributes("highlight").mode??"lower",d=e.getAttributes(e.isActive("heading")?"heading":"paragraph").textAlign??"left",f=d==="center"?Tn:d==="right"?Nn:d==="justify"?Jc:Rn;(0,qt.useEffect)(()=>{if(!r)return;let g=()=>o(!1),m=b=>{b.target instanceof Node&&!i.current?.contains(b.target)&&g()};return document.addEventListener("pointerdown",m),e.on("selectionUpdate",g),()=>{document.removeEventListener("pointerdown",m),e.off("selectionUpdate",g)}},[r,e]);let p=(g,m,b,k)=>(0,V.jsx)("button",{type:"button",className:`editor-tool${b?" is-active":""}`,"aria-label":g,title:g,"aria-pressed":b,onMouseDown:C=>C.preventDefault(),onClick:k,children:m}),h=(g,m,b="")=>(0,V.jsxs)("label",{className:`rich-format-select ${b}`,title:g,children:[m,(0,V.jsx)(Pr,{size:11,"aria-hidden":"true"})]});return(0,V.jsxs)("div",{ref:i,className:"rich-format-controls",onKeyDown:g=>{r&&g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),o(!1),s.current?.focus())},onClickCapture:g=>{g.target.closest(".rich-format-colors-toggle, .rich-format-color-panel")||o(!1)},children:[(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":n("format.textStyle"),children:[h(n("format.textStyle"),(0,V.jsxs)("select",{"aria-label":n("format.textStyle"),value:e.isActive("heading")?String(e.getAttributes("heading").level):"paragraph",onChange:g=>g.target.value==="paragraph"?e.chain().focus().setParagraph().run():e.chain().focus().setHeading({level:Number(g.target.value)}).run(),children:[(0,V.jsx)("option",{value:"paragraph",children:n("block.text")}),[1,2,3,4,5,6].map(g=>(0,V.jsx)("option",{value:g,children:n("block.heading",{level:g})},g))]}),"rich-format-block"),h(n("format.font"),(0,V.jsxs)("select",{"aria-label":n("format.font"),value:e.getAttributes("textStyle").fontFamily??"",onChange:g=>e.chain().focus().setMark("textStyle",{fontFamily:g.target.value||null}).run(),children:[(0,V.jsx)("option",{value:"",children:n("format.fontCompact")}),(0,V.jsx)("option",{value:"sans-serif",children:n("format.fontSans")}),(0,V.jsx)("option",{value:"serif",children:n("format.fontSerif")}),(0,V.jsx)("option",{value:"monospace",children:n("format.fontMono")})]}),"rich-format-font"),h(n("format.fontSize"),(0,V.jsxs)("select",{"aria-label":n("format.fontSize"),value:e.getAttributes("textStyle").fontSize??"",onChange:g=>e.chain().focus().setMark("textStyle",{fontSize:g.target.value||null}).run(),children:[(0,V.jsx)("option",{value:"",children:n("format.sizeCompact")}),[12,14,16,18,20,24,28,32,40,48].map(g=>(0,V.jsx)("option",{value:`${g}px`,children:g},g))]}),"rich-format-size")]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":n("format.characterStyle"),children:[p(n("format.bold"),(0,V.jsx)(Mc,{size:16}),e.isActive("bold"),()=>e.chain().focus().toggleBold().run()),p(n("format.italic"),(0,V.jsx)(Hc,{size:16}),e.isActive("italic"),()=>e.chain().focus().toggleItalic().run()),p(n("format.underline"),(0,V.jsx)(Xc,{size:16}),e.isActive("underline"),()=>e.chain().focus().toggleUnderline().run()),p(n("format.strike"),(0,V.jsx)(Kc,{size:16}),e.isActive("strike"),()=>e.chain().focus().toggleStrike().run()),p(n("format.inlineCode"),(0,V.jsx)(Nc,{size:16}),e.isActive("code"),()=>e.chain().focus().toggleCode().run())]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":n("format.colors"),children:[(0,V.jsxs)("button",{ref:s,type:"button",className:`rich-format-colors-toggle${r?" is-active":""}`,"aria-label":n("format.colors"),title:n("format.colors"),"aria-expanded":r,"aria-controls":l,onMouseDown:g=>g.preventDefault(),onClick:()=>o(!r),children:[(0,V.jsxs)("span",{className:"rich-format-color-icon",children:[(0,V.jsx)(Ao,{size:16}),(0,V.jsx)("i",{style:{background:a}})]}),(0,V.jsx)(Pr,{size:11})]}),p(n("format.highlight"),(0,V.jsxs)("span",{className:"rich-format-color-icon",children:[(0,V.jsx)(zc,{size:16}),(0,V.jsx)("i",{style:{background:u}})]}),e.isActive("highlight"),()=>e.chain().focus().toggleMark("highlight",{color:u,mode:c}).run())]}),(0,V.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,V.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":n("format.alignment"),children:[h(n("format.alignment"),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(f,{size:16,"aria-hidden":"true"}),(0,V.jsxs)("select",{"aria-label":n("format.alignment"),value:d,onChange:g=>e.chain().focus().setTextAlign(g.target.value).run(),children:[(0,V.jsx)("option",{value:"left",children:n("format.alignLeft")}),(0,V.jsx)("option",{value:"center",children:n("format.alignCenter")}),(0,V.jsx)("option",{value:"right",children:n("format.alignRight")}),(0,V.jsx)("option",{value:"justify",children:n("format.alignJustify")})]})]}),"rich-format-alignment"),p(n("format.addLink"),(0,V.jsx)(Eo,{size:16}),e.isActive("link"),t)]}),r&&(0,V.jsx)("div",{id:l,className:"rich-format-color-panel",role:"group","aria-label":n("format.colors"),children:["text","highlight"].map(g=>{let m=g==="text",b=m?a:u,k=n(m?"format.textColor":"format.highlightColor"),C=x=>m?e.chain().focus().setMark("textStyle",{color:x}).run():e.chain().focus().setMark("highlight",{color:x,mode:c}).run();return(0,V.jsxs)("div",{className:"rich-format-palette",children:[(0,V.jsx)("span",{className:"rich-format-panel-label",children:k}),(0,V.jsxs)("div",{className:"rich-format-swatches",children:[(m?Wv:Kv).map(x=>(0,V.jsx)("button",{type:"button",className:`rich-format-swatch${b===x?" is-active":""}`,style:{background:x},"aria-label":`${k} ${x}`,title:x,"aria-pressed":b===x,onMouseDown:E=>E.preventDefault(),onClick:()=>C(x)},x)),(0,V.jsx)("label",{className:"rich-format-custom-color",title:n("format.customColor"),children:(0,V.jsx)("input",{type:"color","aria-label":k,value:b,onChange:x=>C(x.target.value)})})]}),!m&&(0,V.jsx)("div",{className:"rich-format-highlight-modes",role:"group","aria-label":n("format.highlightMode"),children:["lower","full"].map(x=>(0,V.jsxs)("button",{type:"button","aria-pressed":c===x,onMouseDown:E=>E.preventDefault(),onClick:()=>e.chain().focus().setMark("highlight",{color:u,mode:x}).run(),children:[(0,V.jsx)("span",{className:`rich-format-highlight-preview is-${x}`,style:{"--highlight-preview":u},children:"Aa"}),n(x==="lower"?"format.highlightLower":"format.highlightFull")]},x))})]},g)})})]})}var fh=new WeakSet,ph=new WeakSet;function Zn(e){let t=e;return fh.add(t),t}function xa(e){return Array.isArray(e)&&fh.has(e)}function hh(e){return e.flatMap(t=>t==null?[]:Array.isArray(t)&&ph.has(t)&&!xa(t)?hh(t):[t])}function Uv(e,t){if(e==="slot")return 0;if(e instanceof Function){let o=e(t);return Array.isArray(o)&&!xa(o)&&!ph.has(o)?Zn(o):o}let{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(xa(n))return Zn([e,r,n]);if(n.length===0)return Zn([e,r]);let o=hh(n);return o.length===0?Zn([e,r]):Zn([e,r,...o])}return n!=null?Zn([e,r,n]):Zn([e,r])}var Nr=(e,t)=>Uv(e,t);var qv=(e,t)=>{var n;let{state:r}=e,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===t)return e.commands.lift(t.name);let u=l.child(a-1);if(u.type!==t||!(!((n=u.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let c=i.before()-1-1;return e.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let p=i.parent.content,h=new ce(p,0,0);return d.replace(c,i.after(),h),d.setSelection(L.create(d.doc,c+p.size)),d.scrollIntoView(),f(d),!0})},Gv=/^\s*>\s$/,mh=re.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return Nr("blockquote",{...U(this.options.HTMLAttributes,e),children:Nr("slot",{})})},parseMarkdown:(e,t)=>{var n;let r=(n=t.parseBlockChildren)!==null&&n!==void 0?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";let n=">",r=[];return e.content.forEach((o,i)=>{var s,l;let a=((s=(l=t.renderChild)===null||l===void 0?void 0:l.call(t,o,i))!==null&&s!==void 0?s:t.renderChildren([o])).split(`
|
|
98
98
|
`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(a.join(`
|
|
99
99
|
`))}),r.join(`
|
|
100
100
|
${n}
|
|
101
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
101
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>qv(this.editor,this.type)}},addInputRules(){return[pn({find:Gv,type:this.type})]}});var Jv=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Xv=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Yv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Qv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gh=Ve.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Nr("strong",{...U(this.options.HTMLAttributes,e),children:Nr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[rt({find:Jv,type:this.type}),rt({find:Yv,type:this.type})]},addPasteRules(){return[Ze({find:Xv,type:this.type}),Ze({find:Qv,type:this.type})]}});var Zv=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},eC=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function tC(e){let t=new Set((e.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;t.has(n);)n+=1;return n}var bh=Ve.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return"";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",i="`".repeat(tC(o)),s=o.startsWith("`")||o.endsWith("`")?" ":"";return`${i}${s}${t.renderChildren(e.content)}${s}${i}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[rt({find:Zv,type:this.type})]},addPasteRules(){return[Ze({find:eC,type:this.type})]}});var Sa=4,nC=/^```([a-z]+)?[\s\n]$/,rC=/^~~~([a-z]+)?[\s\n]$/,Si=re.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Sa,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",U(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return((n=e.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=e.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&e.codeBlockStyle!=="indented"?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r="",o=((n=e.attrs)===null||n===void 0?void 0:n.language)||"";return e.content?r=[`\`\`\`${o}`,t.renderChildren(e.content),"```"].join(`
|
|
102
102
|
`):r=`\`\`\`${o}
|
|
103
103
|
|
|
104
104
|
\`\`\``,r},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=(t=this.options.tabSize)!==null&&t!==void 0?t:Sa,{state:r}=e,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return s?e.commands.insertContent(l):e.commands.command(({tr:a})=>{let{from:u,to:c}=o,d=r.doc.textBetween(u,c,`
|
|
@@ -108,49 +108,49 @@ ${n}
|
|
|
108
108
|
`);return a.replaceWith(u,c,r.schema.text(d)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=(t=this.options.tabSize)!==null&&t!==void 0?t:Sa,{state:r}=e,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?e.commands.command(({tr:l})=>{var a;let{pos:u}=i,c=i.start(),d=i.end(),f=r.doc.textBetween(c,d,`
|
|
109
109
|
`,`
|
|
110
110
|
`).split(`
|
|
111
|
-
`),p=0,h=0,g=u-c;for(let
|
|
111
|
+
`),p=0,h=0,g=u-c;for(let C=0;C<f.length;C+=1){if(h+f[C].length>=g){p=C;break}h+=f[C].length+1}let m=((a=f[p].match(/^ */))===null||a===void 0?void 0:a[0])||"",b=Math.min(m.length,n);if(b===0)return!0;let k=c;for(let C=0;C<p;C+=1)k+=f[C].length+1;return l.delete(k,k+b),u-k<=b&&l.setSelection(L.create(l.doc,k)),!0}):e.commands.command(({tr:l})=>{let{from:a,to:u}=o,c=r.doc.textBetween(a,u,`
|
|
112
112
|
`,`
|
|
113
113
|
`).split(`
|
|
114
114
|
`).map(d=>{var f;let p=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||"",h=Math.min(p.length,n);return d.slice(h)}).join(`
|
|
115
115
|
`);return l.replaceWith(a,u,r.schema.text(c)),!0})},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
|
|
116
116
|
|
|
117
|
-
`);return!i||!s?!1:e.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:e.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?e.commands.command(({tr:l})=>(l.setSelection(
|
|
118
|
-
`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(L.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}});var
|
|
117
|
+
`);return!i||!s?!1:e.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:e.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?e.commands.command(({tr:l})=>(l.setSelection(X.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[eo({find:nC,type:this.type,getAttributes:e=>({language:e[1]})}),eo({find:rC,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new K({key:new ne("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=e.state,a=l.text(n.replace(/\r\n?/g,`
|
|
118
|
+
`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(L.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}});var yh=re.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
119
119
|
|
|
120
|
-
`):""});var
|
|
120
|
+
`):""});var wh=re.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",U(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
121
121
|
`},renderMarkdown:()=>`
|
|
122
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:u,dispatch:c})=>{if(c&&a&&s){let d=a.filter(f=>l.includes(f.type.name));u.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var gh=ce.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,U(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=!((n=e.attrs)===null||n===void 0)&&n.level?parseInt(e.attrs.level,10):1,o="#".repeat(r);return e.content?`${o} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>eo({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var bh=ce.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",U(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!_f(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,o=e();return si(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,u=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(L.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(H.create(s.doc,a.pos)):s.setSelection(L.create(s.doc,a.pos));else{let c=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=c?.create();d&&(s.insert(u,d),s.setSelection(L.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ai({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Zv=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,eC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,tC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,nC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,yh=_e.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",U(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rt({find:Zv,type:this.type}),rt({find:tC,type:this.type})]},addPasteRules(){return[Ze({find:eC,type:this.type}),Ze({find:nC,type:this.type})]}});var rC="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",oC="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Oa="numeric",Da="ascii",La="alpha",lo="asciinumeric",so="alphanumeric",Ia="domain",Sh="emoji",iC="scheme",sC="slashscheme",Ea="whitespace";function lC(e,t){return e in t||(t[e]=[]),t[e]}function Yn(e,t,n){t[Oa]&&(t[lo]=!0,t[so]=!0),t[Da]&&(t[lo]=!0,t[La]=!0),t[lo]&&(t[so]=!0),t[La]&&(t[so]=!0),t[so]&&(t[Ia]=!0),t[Sh]&&(t[Ia]=!0);for(let r in t){let o=lC(r,n);o.indexOf(e)<0&&o.push(e)}}function aC(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function ot(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}ot.groups={};ot.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){let o=t.jr[r][0],i=t.jr[r][1];if(i&&o.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let o=0;o<e.length;o++)this.tt(e[o],t,n,r)},tr(e,t,n,r){r=r||ot.groups;let o;return t&&t.j?o=t:(o=new ot(t),n&&r&&Yn(t,n,r)),this.jr.push([e,o]),o},ts(e,t,n,r){let o=this,i=e.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(e[s]);return o.tt(e[i-1],t,n,r)},tt(e,t,n,r){r=r||ot.groups;let o=this;if(t&&t.j)return o.j[e]=t,t;let i=t,s,l=o.go(e);if(l?(s=new ot,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ot,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(aC(s.t,r),n);Yn(i,a,r)}else n&&Yn(i,n,r);s.t=i}return o.j[e]=s,s}};var Y=(e,t,n,r,o)=>e.ta(t,n,r,o),Se=(e,t,n,r,o)=>e.tr(t,n,r,o),wh=(e,t,n,r,o)=>e.ts(t,n,r,o),N=(e,t,n,r,o)=>e.tt(t,n,r,o),Xt="WORD",Pa="UWORD",Eh="ASCIINUMERICAL",Mh="ALPHANUMERICAL",ho="LOCALHOST",$a="TLD",Ba="UTLD",Ai="SCHEME",Nr="SLASH_SCHEME",Ha="NUM",za="WS",_a="NL",ao="OPENBRACE",co="CLOSEBRACE",Ti="OPENBRACKET",Ni="CLOSEBRACKET",Ri="OPENPAREN",Oi="CLOSEPAREN",Di="OPENANGLEBRACKET",Li="CLOSEANGLEBRACKET",Ii="FULLWIDTHLEFTPAREN",Pi="FULLWIDTHRIGHTPAREN",$i="LEFTCORNERBRACKET",Bi="RIGHTCORNERBRACKET",zi="LEFTWHITECORNERBRACKET",Hi="RIGHTWHITECORNERBRACKET",_i="FULLWIDTHLESSTHAN",Vi="FULLWIDTHGREATERTHAN",ji="AMPERSAND",Fi="APOSTROPHE",Wi="ASTERISK",gn="AT",Ki="BACKSLASH",Ui="BACKTICK",qi="CARET",Qn="COLON",Va="COMMA",Gi="DOLLAR",Nt="DOT",Ji="EQUALS",ja="EXCLAMATION",mt="HYPHEN",uo="PERCENT",Xi="PIPE",Yi="PLUS",Qi="POUND",fo="QUERY",Fa="QUOTE",Ah="FULLWIDTHMIDDLEDOT",Wa="SEMI",Rt="SLASH",po="TILDE",Zi="UNDERSCORE",Th="EMOJI",es="SYM",Nh=Object.freeze({__proto__:null,ALPHANUMERICAL:Mh,AMPERSAND:ji,APOSTROPHE:Fi,ASCIINUMERICAL:Eh,ASTERISK:Wi,AT:gn,BACKSLASH:Ki,BACKTICK:Ui,CARET:qi,CLOSEANGLEBRACKET:Li,CLOSEBRACE:co,CLOSEBRACKET:Ni,CLOSEPAREN:Oi,COLON:Qn,COMMA:Va,DOLLAR:Gi,DOT:Nt,EMOJI:Th,EQUALS:Ji,EXCLAMATION:ja,FULLWIDTHGREATERTHAN:Vi,FULLWIDTHLEFTPAREN:Ii,FULLWIDTHLESSTHAN:_i,FULLWIDTHMIDDLEDOT:Ah,FULLWIDTHRIGHTPAREN:Pi,HYPHEN:mt,LEFTCORNERBRACKET:$i,LEFTWHITECORNERBRACKET:zi,LOCALHOST:ho,NL:_a,NUM:Ha,OPENANGLEBRACKET:Di,OPENBRACE:ao,OPENBRACKET:Ti,OPENPAREN:Ri,PERCENT:uo,PIPE:Xi,PLUS:Yi,POUND:Qi,QUERY:fo,QUOTE:Fa,RIGHTCORNERBRACKET:Bi,RIGHTWHITECORNERBRACKET:Hi,SCHEME:Ai,SEMI:Wa,SLASH:Rt,SLASH_SCHEME:Nr,SYM:es,TILDE:po,TLD:$a,UNDERSCORE:Zi,UTLD:Ba,UWORD:Pa,WORD:Xt,WS:za}),Gt=/[a-z]/,io=/\p{L}/u,Ma=/\p{Emoji}/u;var Jt=/\d/,Aa=/\s/;var kh="\r",Ta=`
|
|
123
|
-
`,
|
|
122
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:u,dispatch:c})=>{if(c&&a&&s){let d=a.filter(f=>l.includes(f.type.name));u.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var kh=re.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,U(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=!((n=e.attrs)===null||n===void 0)&&n.level?parseInt(e.attrs.level,10):1,o="#".repeat(r);return e.content?`${o} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>eo({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var vh=re.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",U(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Wf(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,o=e();return li(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,u=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(L.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(_.create(s.doc,a.pos)):s.setSelection(L.create(s.doc,a.pos));else{let c=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=c?.create();d&&(s.insert(u,d),s.setSelection(L.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ci({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var oC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,iC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,sC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,lC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ch=Ve.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",U(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rt({find:oC,type:this.type}),rt({find:sC,type:this.type})]},addPasteRules(){return[Ze({find:iC,type:this.type}),Ze({find:lC,type:this.type})]}});var aC="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",cC="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Oa="numeric",Da="ascii",La="alpha",ao="asciinumeric",lo="alphanumeric",Ia="domain",Th="emoji",uC="scheme",dC="slashscheme",Ea="whitespace";function fC(e,t){return e in t||(t[e]=[]),t[e]}function er(e,t,n){t[Oa]&&(t[ao]=!0,t[lo]=!0),t[Da]&&(t[ao]=!0,t[La]=!0),t[ao]&&(t[lo]=!0),t[La]&&(t[lo]=!0),t[lo]&&(t[Ia]=!0),t[Th]&&(t[Ia]=!0);for(let r in t){let o=fC(r,n);o.indexOf(e)<0&&o.push(e)}}function pC(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function ot(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}ot.groups={};ot.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){let o=t.jr[r][0],i=t.jr[r][1];if(i&&o.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let o=0;o<e.length;o++)this.tt(e[o],t,n,r)},tr(e,t,n,r){r=r||ot.groups;let o;return t&&t.j?o=t:(o=new ot(t),n&&r&&er(t,n,r)),this.jr.push([e,o]),o},ts(e,t,n,r){let o=this,i=e.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(e[s]);return o.tt(e[i-1],t,n,r)},tt(e,t,n,r){r=r||ot.groups;let o=this;if(t&&t.j)return o.j[e]=t,t;let i=t,s,l=o.go(e);if(l?(s=new ot,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ot,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(pC(s.t,r),n);er(i,a,r)}else n&&er(i,n,r);s.t=i}return o.j[e]=s,s}};var Y=(e,t,n,r,o)=>e.ta(t,n,r,o),Se=(e,t,n,r,o)=>e.tr(t,n,r,o),xh=(e,t,n,r,o)=>e.ts(t,n,r,o),N=(e,t,n,r,o)=>e.tt(t,n,r,o),Xt="WORD",Pa="UWORD",Nh="ASCIINUMERICAL",Rh="ALPHANUMERICAL",mo="LOCALHOST",$a="TLD",Ba="UTLD",Ti="SCHEME",Rr="SLASH_SCHEME",Ha="NUM",za="WS",_a="NL",co="OPENBRACE",uo="CLOSEBRACE",Ni="OPENBRACKET",Ri="CLOSEBRACKET",Oi="OPENPAREN",Di="CLOSEPAREN",Li="OPENANGLEBRACKET",Ii="CLOSEANGLEBRACKET",Pi="FULLWIDTHLEFTPAREN",$i="FULLWIDTHRIGHTPAREN",Bi="LEFTCORNERBRACKET",zi="RIGHTCORNERBRACKET",Hi="LEFTWHITECORNERBRACKET",_i="RIGHTWHITECORNERBRACKET",Vi="FULLWIDTHLESSTHAN",ji="FULLWIDTHGREATERTHAN",Fi="AMPERSAND",Wi="APOSTROPHE",Ki="ASTERISK",bn="AT",Ui="BACKSLASH",qi="BACKTICK",Gi="CARET",tr="COLON",Va="COMMA",Ji="DOLLAR",Nt="DOT",Xi="EQUALS",ja="EXCLAMATION",mt="HYPHEN",fo="PERCENT",Yi="PIPE",Qi="PLUS",Zi="POUND",po="QUERY",Fa="QUOTE",Oh="FULLWIDTHMIDDLEDOT",Wa="SEMI",Rt="SLASH",ho="TILDE",es="UNDERSCORE",Dh="EMOJI",ts="SYM",Lh=Object.freeze({__proto__:null,ALPHANUMERICAL:Rh,AMPERSAND:Fi,APOSTROPHE:Wi,ASCIINUMERICAL:Nh,ASTERISK:Ki,AT:bn,BACKSLASH:Ui,BACKTICK:qi,CARET:Gi,CLOSEANGLEBRACKET:Ii,CLOSEBRACE:uo,CLOSEBRACKET:Ri,CLOSEPAREN:Di,COLON:tr,COMMA:Va,DOLLAR:Ji,DOT:Nt,EMOJI:Dh,EQUALS:Xi,EXCLAMATION:ja,FULLWIDTHGREATERTHAN:ji,FULLWIDTHLEFTPAREN:Pi,FULLWIDTHLESSTHAN:Vi,FULLWIDTHMIDDLEDOT:Oh,FULLWIDTHRIGHTPAREN:$i,HYPHEN:mt,LEFTCORNERBRACKET:Bi,LEFTWHITECORNERBRACKET:Hi,LOCALHOST:mo,NL:_a,NUM:Ha,OPENANGLEBRACKET:Li,OPENBRACE:co,OPENBRACKET:Ni,OPENPAREN:Oi,PERCENT:fo,PIPE:Yi,PLUS:Qi,POUND:Zi,QUERY:po,QUOTE:Fa,RIGHTCORNERBRACKET:zi,RIGHTWHITECORNERBRACKET:_i,SCHEME:Ti,SEMI:Wa,SLASH:Rt,SLASH_SCHEME:Rr,SYM:ts,TILDE:ho,TLD:$a,UNDERSCORE:es,UTLD:Ba,UWORD:Pa,WORD:Xt,WS:za}),Gt=/[a-z]/,so=/\p{L}/u,Ma=/\p{Emoji}/u;var Jt=/\d/,Aa=/\s/;var Sh="\r",Ta=`
|
|
123
|
+
`,hC="\uFE0F",mC="\u200D",Na="\uFFFC",Ei=null,Mi=null;function gC(e=[]){let t={};ot.groups=t;let n=new ot;Ei==null&&(Ei=Eh(aC)),Mi==null&&(Mi=Eh(cC)),N(n,"'",Wi),N(n,"{",co),N(n,"}",uo),N(n,"[",Ni),N(n,"]",Ri),N(n,"(",Oi),N(n,")",Di),N(n,"<",Li),N(n,">",Ii),N(n,"\uFF08",Pi),N(n,"\uFF09",$i),N(n,"\u300C",Bi),N(n,"\u300D",zi),N(n,"\u300E",Hi),N(n,"\u300F",_i),N(n,"\uFF1C",Vi),N(n,"\uFF1E",ji),N(n,"&",Fi),N(n,"*",Ki),N(n,"@",bn),N(n,"`",qi),N(n,"^",Gi),N(n,":",tr),N(n,",",Va),N(n,"$",Ji),N(n,".",Nt),N(n,"=",Xi),N(n,"!",ja),N(n,"-",mt),N(n,"%",fo),N(n,"|",Yi),N(n,"+",Qi),N(n,"#",Zi),N(n,"?",po),N(n,'"',Fa),N(n,"/",Rt),N(n,";",Wa),N(n,"~",ho),N(n,"_",es),N(n,"\\",Ui),N(n,"\u30FB",Oh);let r=Se(n,Jt,Ha,{[Oa]:!0});Se(r,Jt,r);let o=Se(r,Gt,Nh,{[ao]:!0}),i=Se(r,so,Rh,{[lo]:!0}),s=Se(n,Gt,Xt,{[Da]:!0});Se(s,Jt,o),Se(s,Gt,s),Se(o,Jt,o),Se(o,Gt,o);let l=Se(n,so,Pa,{[La]:!0});Se(l,Gt),Se(l,Jt,i),Se(l,so,l),Se(i,Jt,i),Se(i,Gt),Se(i,so,i);let a=N(n,Ta,_a,{[Ea]:!0}),u=N(n,Sh,za,{[Ea]:!0}),c=Se(n,Aa,za,{[Ea]:!0});N(n,Na,c),N(u,Ta,a),N(u,Na,c),Se(u,Aa,c),N(c,Sh),N(c,Ta),Se(c,Aa,c),N(c,Na,c);let d=Se(n,Ma,Dh,{[Th]:!0});N(d,"#"),Se(d,Ma,d),N(d,hC,d);let f=N(d,mC);N(f,"#"),Se(f,Ma,d);let p=[[Gt,s],[Jt,o]],h=[[Gt,null],[so,l],[Jt,i]];for(let g=0;g<Ei.length;g++)gn(n,Ei[g],$a,Xt,p);for(let g=0;g<Mi.length;g++)gn(n,Mi[g],Ba,Pa,h);er($a,{tld:!0,ascii:!0},t),er(Ba,{utld:!0,alpha:!0},t),gn(n,"file",Ti,Xt,p),gn(n,"mailto",Ti,Xt,p),gn(n,"http",Rr,Xt,p),gn(n,"https",Rr,Xt,p),gn(n,"ftp",Rr,Xt,p),gn(n,"ftps",Rr,Xt,p),er(Ti,{scheme:!0,ascii:!0},t),er(Rr,{slashscheme:!0,ascii:!0},t),e=e.sort((g,m)=>g[0]>m[0]?1:-1);for(let g=0;g<e.length;g++){let m=e[g][0],k=e[g][1]?{[uC]:!0}:{[dC]:!0};m.indexOf("-")>=0?k[Ia]=!0:Gt.test(m)?Jt.test(m)?k[ao]=!0:k[Da]=!0:k[Oa]=!0,xh(n,m,m,k)}return xh(n,"localhost",mo,{ascii:!0}),n.jd=new ot(ts),{start:n,tokens:Object.assign({groups:t},Lh)}}function Ih(e,t){let n=bC(t.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=e,a=null,u=0,c=null,d=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,f=0,c=l):d>=0&&(d+=n[s].length,f++),u+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,u-=d,o.push({t:c.t,v:t.slice(i-u,i),s:i-u,e:i})}return o}function bC(e){let t=[],n=e.length,r=0;for(;r<n;){let o=e.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(s),r+=s.length}return t}function gn(e,t,n,r,o){let i,s=t.length;for(let l=0;l<s-1;l++){let a=t[l];e.j[a]?i=e.j[a]:(i=new ot(r),i.jr=o.slice(),e.j[a]=i),e=i}return i=new ot(n),i.jr=o.slice(),e.j[t[s-1]]=i,i}function Eh(e){let t=[],n=[],r=0,o="0123456789";for(;r<e.length;){let i=0;for(;o.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let s=parseInt(e.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(e[r]),r++}return t}var go={defaultProtocol:"http",events:null,format:Mh,formatHref:Mh,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ka(e,t=null){let n=Object.assign({},go);e&&(n=Object.assign(n,e instanceof Ka?e.o:e));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=o}Ka.prototype={o:go,ignoreTags:[],defaultRender(e){return e},check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=t!=null,o=this.o[e];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:go[e],typeof o=="function"&&r&&(o=o(t,n))):typeof o=="function"&&r&&(o=o(t,n.t,n)),o)},getObj(e,t,n){let r=this.o[e];return typeof r=="function"&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}};function Mh(e){return e}function Ph(e,t){this.t="token",this.v=e,this.tk=t}Ph.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=go.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),o=e.get("tagName",n,t),i=this.toFormattedString(e),s={},l=e.get("className",n,t),a=e.get("target",n,t),u=e.get("rel",n,t),c=e.getObj("attributes",n,t),d=e.getObj("events",n,t);return s.href=r,l&&(s.class=l),a&&(s.target=a),u&&(s.rel=u),c&&Object.assign(s,c),{tagName:o,attributes:s,content:i,eventListeners:d}}};function ns(e,t){class n extends Ph{constructor(o,i){super(o,i),this.t=e}}for(let r in t)n.prototype[r]=t[r];return n.t=e,n}var yC=ns("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ah=ns("text"),wC=ns("nl"),Ai=ns("url",{isLink:!0,toHref(e=go.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==mo&&e[1].t===tr}});var ht=e=>new ot(e);function kC({groups:e}){let t=e.domain.concat([Fi,Ki,bn,Ui,qi,Gi,Ji,Xi,mt,Ha,fo,Yi,Qi,Zi,Rt,ts,ho,es]),n=[Wi,tr,Va,Nt,ja,fo,po,Fa,Wa,Li,Ii,co,uo,Ri,Ni,Oi,Di,Pi,$i,Bi,zi,Hi,_i,Vi,ji],r=[Fi,Wi,Ki,Ui,qi,Gi,Ji,Xi,mt,co,uo,fo,Yi,Qi,Zi,po,Rt,ts,ho,es],o=ht(),i=N(o,ho);Y(i,r,i),Y(i,e.domain,i);let s=ht(),l=ht(),a=ht();Y(o,e.domain,s),Y(o,e.scheme,l),Y(o,e.slashscheme,a),Y(s,r,i),Y(s,e.domain,s);let u=N(s,bn);N(i,bn,u),N(l,bn,u),N(a,bn,u);let c=N(i,Nt);Y(c,r,i),Y(c,e.domain,i);let d=ht();Y(u,e.domain,d),Y(d,e.domain,d);let f=N(d,Nt);Y(f,e.domain,d);let p=ht(yC);Y(f,e.tld,p),Y(f,e.utld,p),N(u,mo,p);let h=N(d,mt);N(h,mt,h),Y(h,e.domain,d),Y(p,e.domain,d),N(p,Nt,f),N(p,mt,h);let g=N(s,mt),m=N(s,Nt);N(g,mt,g),Y(g,e.domain,s),Y(m,r,i),Y(m,e.domain,s);let b=ht(Ai);Y(m,e.tld,b),Y(m,e.utld,b),Y(b,e.domain,s),Y(b,r,i),N(b,Nt,m),N(b,mt,g),N(b,bn,u);let k=N(b,tr),C=ht(Ai);Y(k,e.numeric,C);let x=ht(Ai),E=ht();Y(x,t,x),Y(x,n,E),Y(E,t,x),Y(E,n,E),N(b,Rt,x),N(C,Rt,x);let A=N(l,tr),M=N(a,tr),B=N(M,Rt),ie=N(B,Rt);Y(l,e.domain,s),N(l,Nt,m),N(l,mt,g),Y(a,e.domain,s),N(a,Nt,m),N(a,mt,g),Y(A,e.domain,x),N(A,Rt,x),N(A,po,x),Y(ie,e.domain,x),Y(ie,t,x),N(ie,Rt,x);let Q=[[co,uo],[Ni,Ri],[Oi,Di],[Li,Ii],[Pi,$i],[Bi,zi],[Hi,_i],[Vi,ji]];for(let ge=0;ge<Q.length;ge++){let[it,je]=Q[ge],Re=N(x,it);N(E,it,Re);let Me=ht(Ai);Y(Re,t,Me);let T=ht();Y(Re,n,T),N(Re,je,x),Y(Me,t,Me),Y(Me,n,T),Y(T,t,Me),Y(T,n,T),N(Me,je,x),N(T,je,x)}return N(o,mo,b),N(o,_a,wC),{start:o,tokens:Lh}}function vC(e,t,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=e,a=null,u=null,c=0,d=null,f=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(u=a||l.go(n[o].t));)a=null,l=u,l.accepts()?(f=0,d=l):f>=0&&f++,o++,c++;if(f<0)o-=c,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ra(Ah,t,s)),s=[]),o-=f,c-=f;let p=d.t,h=n.slice(o-c,o);i.push(Ra(p,t,h))}}return s.length>0&&i.push(Ra(Ah,t,s)),i}function Ra(e,t,n){let r=n[0].s,o=n[n.length-1].e,i=t.slice(r,o);return new e(i,n)}var CC=typeof console<"u"&&console&&console.warn||(()=>{}),xC="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ce={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function $h(){return ot.groups={},Ce.scanner=null,Ce.parser=null,Ce.tokenQueue=[],Ce.pluginQueue=[],Ce.customSchemes=[],Ce.initialized=!1,Ce}function Ua(e,t=!1){if(Ce.initialized&&CC(`linkifyjs: already initialized - will not register custom scheme "${e}" ${xC}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error(`linkifyjs: incorrect scheme format.
|
|
124
124
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
125
125
|
2. Cannot start or end with "-"
|
|
126
|
-
3. "-" cannot repeat`);ve.customSchemes.push([e,t])}function wC(){ve.scanner=dC(ve.customSchemes);for(let e=0;e<ve.tokenQueue.length;e++)ve.tokenQueue[e][1]({scanner:ve.scanner});ve.parser=mC(ve.scanner.tokens);for(let e=0;e<ve.pluginQueue.length;e++)ve.pluginQueue[e][1]({scanner:ve.scanner,parser:ve.parser});return ve.initialized=!0,ve}function ns(e){return ve.initialized||wC(),gC(ve.parser.start,e,Rh(ve.scanner.start,e))}ns.scan=Rh;function qa(e,t=null,n=null){if(t&&typeof t=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Ka(n),o=ns(e),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!t||l.t===t)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var rs="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",kC=new RegExp(rs),vC=new RegExp(`${rs}$`),CC=new RegExp(`${rs}+$`),xC=new RegExp(rs,"g");function SC(e,t,n){var r,o;let i=e.doc.resolve(t.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=e.doc.textBetween(t.from,t.to,"\uFFFC","\uFFFC").match(CC))===null||o===void 0?void 0:o[0];if(!s)return;let l=t.to-s.length,a=Zr(l,t.to,e.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:u}=i;if(u&&a.some(d=>d.mark.isInSet(u.marks)))return;let c=e.storedMarks;e.removeMark(l,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function EC(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function MC(e){return new W({key:new ne("autolink"),appendTransaction:(t,n,r)=>{let o=t.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=t.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=Gl(n.doc,[...t]);if(!t.some(Jd)){let a=[];l.steps.forEach((u,c)=>{if(!(u instanceof Dn)||!u.slice.size)return;let d=l.mapping.slice(c+1),f=d.map(u.from,1),p=d.map(u.from+u.slice.size,-1);f<p&&a.push({from:f,to:p})}),a.sort((u,c)=>c.to-u.to),a.forEach(u=>SC(s,u,e.type))}if(wr(l).forEach(({newRange:a})=>{let u=Cf(r.doc,a,f=>f.isTextblock),c,d;if(u.length>1)c=u[0],d=r.doc.textBetween(c.pos,c.pos+c.node.nodeSize,void 0," ");else if(u.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!vC.test(f))return;c=u[0],d=r.doc.textBetween(c.pos,a.to,void 0," ")}if(c&&d){let f=d.split(kC).filter(Boolean);if(f.length<=0)return!1;let p=f[f.length-1],h=c.pos+d.lastIndexOf(p);if(!p)return!1;let g=ns(p).map(m=>m.toObject(e.defaultProtocol));if(!EC(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:h+m.start+1,to:h+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>e.validate(m.value)).filter(m=>e.shouldAutoLink(m.value)).forEach(m=>{Zr(m.from,m.to,r.doc).some(b=>b.mark.type===e.type)||s.addMark(m.from,m.to,e.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function AC(e){return new W({key:new ne("handleClickLink"),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let u=e.editor.view.dom;o=a.closest("a"),o&&!u.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(e.enableClickSelection&&(i=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){var s,l;let a=Yl(t.state,e.type.name),u=(s=o.href)!==null&&s!==void 0?s:a.href,c=(l=o.target)!==null&&l!==void 0?l:a.target;u&&(window.open(u,c),i=!0)}return i}}})}var TC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,NC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Lh(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function RC(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Lh(e,r)){r+=1;continue}let o=0;for(;r<t&&e[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function Ih(e,t,n){var r,o;let[,i,s]=t;return(t.index?e[t.index-1]:void 0)==="!"||Lh(e,(r=t.index)!==null&&r!==void 0?r:0)||RC(e,(o=t.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Ph(e){var t,n;let[r,o,i,,s,l,a]=e,u=(t=s??l)!==null&&t!==void 0?t:a;return{index:(n=e.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:u||null,markdown:!0}}}function OC(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function $h(e){var t,n,r;return{href:(t=e.data)===null||t===void 0?void 0:t.href,title:(n=(r=e.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function DC(e){let t=rt({find:n=>{let r=TC.exec(n);return!r||!Ih(n,r,e.isAllowedHref)?null:Ph(r)},type:e.type,getAttributes:$h});return new Cr({find:t.find,handler:n=>{let r=t.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function LC(e){let t=Ze({find:n=>{var r,o;let i=[];for(let l of n.matchAll(NC))Ih(n,l,e.isAllowedHref)&&i.push(Ph(l));let s=((r=(o=e.findPlainUrls)===null||o===void 0?void 0:o.call(e,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>OC(a,l)));return[...i,...s]},type:e.type,getAttributes:$h});return new ta({find:t.find,handler:n=>{var r;let o=t.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function IC(e){return new W({key:new ne("handlePasteLink"),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:o}=e,{state:i}=t,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});let u=qa(a,{defaultProtocol:e.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!u||o!==void 0&&!o(u.value)?!1:e.editor.commands.setMark(e.type,{href:u.href})}}})}function Yt(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!e||e.replace(xC,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Bh=_e.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(e=>{if(typeof e=="string"){Ua(e);return}Ua(e.scheme,e.optionalSlashes)})},onDestroy(){Dh()},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:(e,t)=>!!Yt(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var e,t,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(e=this.options.HTMLAttributes.target)!==null&&e!==void 0?e:null},rel:{default:(t=this.options.HTMLAttributes.rel)!==null&&t!==void 0?t:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!Yt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!Yt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",U(this.options.HTMLAttributes,e),0]:["a",U(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,o,i;let s=(n=(r=e.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=e.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=t.renderChildren(e);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Yt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Yt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[DC({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!Yt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=t=>{let n=[];if(t){let{protocols:r,defaultProtocol:o}=this.options;qa(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Yt(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[LC({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:n=>!!Yt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Ze({find:e,type:this.type,getAttributes:t=>{var n;return{href:(n=t.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(MC({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Yt(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(AC({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(IC({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}});var PC="listItem",zh="textStyle",Hh=/^\s*([-+*])\s$/,Ga=ce.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:e}){return["ul",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>e.type!=="list"||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
127
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(PC,this.editor.getAttributes(zh)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=fn({find:Hh,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=fn({find:Hh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(zh),editor:this.editor})),[e]}}),$C=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let p=o.depth;p>0;p-=1)if(o.node(p).type.name===t){i=p;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let u=e.schema.nodes[t],c=!1;if(a.forEach(p=>{p.type===u&&p.childCount>1&&(c=!0)}),!c)return null;let d=e.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(p=>{f.push(p)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},BC=(e,t,n,r)=>{let o=$C(e,n,r);if(!o)return!1;let{selection:i}=e,{nestedList:s,nestedListPos:l,insertPos:a,items:u}=o,c=e.tr;c.delete(l,l+s.nodeSize);let d=c.mapping.map(a);return c.insert(d,z.from(u)),c.setSelection(i.map(c.doc,c.mapping)),t&&t(c),!0},zC=(e,t,n)=>BC(e.state,e.view.dispatch,t,n),qh=(e,t)=>se.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>zC(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Gh=[[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"]],is="abcdefghijklmnopqrstuvwxyz",Jh=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function as(e){let t=e,n="";for(let[r,o]of Gh)for(;t>=r;)n+=o,t-=r;return n}function Ja(e){return as(e).toUpperCase()}function Xh(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let o=!1;for(let[i,s]of Gh)if(t.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function HC(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=Xh(e);return t<=0?!1:(e===e.toLowerCase()?as(t):Ja(t))===e}function _C(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let n=t.charCodeAt(0)-97,r=t.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function ss(e){if(e<=26)return is[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?is[n]:is[t]+is[n]}function cs(e){if(!(!e||/^\d+$/.test(e))){if(HC(e))return e===e.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(e))return"a";if(/^[A-Z]{1,2}$/.test(e))return"A"}}function Xa(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=cs(e);if(t==="i"||t==="I")return Xh(e);if(t==="a"||t==="A"){let r=_C(e);return r>0?r:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function VC(e,t){if(e==="numeric")return String(t);switch(e){case"a":return ss(t);case"A":return ss(t).toUpperCase();case"i":return as(t);case"I":return Ja(t);default:return String(t)}}function jC(e){var t;if(e.length===0)return!1;let n=(t=cs(e[0]))!==null&&t!==void 0?t:"numeric",r=Xa(e[0]);if(r<1)return!1;for(let o=0;o<e.length;o++){let i=VC(n,r+o);if(e[o]!==i)return!1}return!0}function FC(e){return{type:cs(e),start:Xa(e)}}function WC(e){let{type:t,start:n}=FC(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function KC(e,t,n=". "){let r=t+1;if(!e||e==="1")return`${r}${n}`;switch(e){case"a":return`${ss(r)}${n}`;case"A":return`${ss(r).toUpperCase()}${n}`;case"i":return`${as(r)}${n}`;case"I":return`${Ja(r)}${n}`;default:return`${r}${n}`}}function UC(e){var t,n;let r=(t=e.tokens)===null||t===void 0?void 0:t[0];return!!(e.text&&((n=e.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===e.text)}function qC(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var Ya=ce.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n;if(e.type!=="list_item")return[];let r=(n=t.parseBlockChildren)!==null&&n!==void 0?n:t.parseChildren,o=[];if(e.tokens&&e.tokens.length>0){if(UC(e))return{type:"listItem",content:[{type:"paragraph",content:qC(e.text||"",t)}]};if(e.tokens.some(i=>i.type==="paragraph"))o=r(e.tokens);else{let i=e.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:t.parseInline(i.tokens)}],e.tokens.length>1){let s=r(e.tokens.slice(1));o.push(...s)}}else o=r(e.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(e,t,n)=>Zl(e,t,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return KC((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:n?.parentType==="orderedList"}),addExtensions(){return[qh(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)}}}),Qa=(e,t)=>{let{$from:n}=t.selection,r=Ne(e,t.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:t.doc.resolve(s),depth:l}},Yh=(e,t)=>{let n=Qa(e,t);if(!n)return!1;let[,r]=Af(t,e,n.$pos.pos+4);return r},GC=(e,t,n)=>{let{$anchor:r}=e.selection,o=Math.max(0,r.pos-2),i=e.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},_h=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Mt(e.state,t)&&GC(e.state,t,n)){let{$anchor:i}=e.state.selection,s=e.state.doc.resolve(i.before()-1),l=[];s.node().descendants((c,d)=>{c.type.name===t&&l.push({node:c,pos:d})});let a=l.at(-1);if(!a)return!1;let u=e.state.doc.resolve(s.start()+a.pos+1);return e.chain().cut({from:i.start()-1,to:i.end()+1},u.end()).joinForward().run()}if(!Mt(e.state,t)||!Rf(e.state))return!1;let{$from:r}=e.state.selection,o=r.depth-1;return r.node(o).type!==e.schema.nodes[t]||r.index(o)!==0?!1:e.chain().liftListItem(t).run()},JC=(e,t)=>{let n=Yh(e,t),r=Qa(e,t);return!r||!n?!1:n>r.depth},XC=(e,t)=>{let n=Yh(e,t),r=Qa(e,t);return!r||!n?!1:n<r.depth},Vh=(e,t)=>{if(!Mt(e.state,t)||!Nf(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:JC(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():XC(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},YC=(e,t,n)=>{let{state:r}=e,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||Mt(r,t))return!1;let s=Tf(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==t)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,z.from(a)))return!1;let u=i.before(),c=i.after(),d=u-2;return e.commands.command(({tr:f,dispatch:p})=>(p&&(f.delete(u,c).insert(d,z.from(a)),f.setSelection(L.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Za=se.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Vh(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Vh(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&_h(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&_h(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&YC(e,t,n))return!0;return!1}}}}),ls=new RegExp(`^(\\s*)(${Jh})([.)])\\s+(.*)$`),QC=/^\s/,Rr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function ZC(e){return ls.test(e.trimStart())}function ex(e){let t=e.trimStart();return Rr.bulletItem.test(t)||ZC(t)||Rr.heading.test(t)||Rr.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||Rr.codeFence.test(t)||Rr.blockMath.test(t)}function tx(e){return Object.values(Rr).some(t=>t.test(e))}function nx(e){let t=[],n=[],r=!1;return e.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(t.length>0&&ex(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function jh(e){let t=[],n=0,r=0;for(;n<e.length;){let o=e[n],i=o.match(ls);if(!i)break;let[,s,l,a,u]=i,c=s.length,d=parseInt(l,10),f=isNaN(d)?cs(l):void 0,p=isNaN(d)?Xa(l):d,h=[u],g=n+1,m=[o],b=!1;for(;g<e.length;){let v=e[g];if(v.match(ls))break;if(v.trim()==="")m.push(v),h.push(""),b=!0,g+=1;else if(v.match(QC)){let S=v.length-v.trimStart().length,C=c+l.length+1;m.push(v),h.push(v.slice(Math.min(S,C))),g+=1}else{if(b||tx(v))break;m.push(v),h.push(v),g+=1}}t.push({indent:c,number:p,type:f,content:h.join(`
|
|
126
|
+
3. "-" cannot repeat`);Ce.customSchemes.push([e,t])}function SC(){Ce.scanner=gC(Ce.customSchemes);for(let e=0;e<Ce.tokenQueue.length;e++)Ce.tokenQueue[e][1]({scanner:Ce.scanner});Ce.parser=kC(Ce.scanner.tokens);for(let e=0;e<Ce.pluginQueue.length;e++)Ce.pluginQueue[e][1]({scanner:Ce.scanner,parser:Ce.parser});return Ce.initialized=!0,Ce}function rs(e){return Ce.initialized||SC(),vC(Ce.parser.start,e,Ih(Ce.scanner.start,e))}rs.scan=Ih;function qa(e,t=null,n=null){if(t&&typeof t=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Ka(n),o=rs(e),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!t||l.t===t)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var is="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",EC=new RegExp(is),MC=new RegExp(`${is}$`),AC=new RegExp(`${is}+$`),TC=new RegExp(is,"g");function NC(e,t,n){var r,o;let i=e.doc.resolve(t.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=e.doc.textBetween(t.from,t.to,"\uFFFC","\uFFFC").match(AC))===null||o===void 0?void 0:o[0];if(!s)return;let l=t.to-s.length,a=Zr(l,t.to,e.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:u}=i;if(u&&a.some(d=>d.mark.isInSet(u.marks)))return;let c=e.storedMarks;e.removeMark(l,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function RC(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function OC(e){return new K({key:new ne("autolink"),appendTransaction:(t,n,r)=>{let o=t.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=t.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=Jl(n.doc,[...t]);if(!t.some(Zd)){let a=[];l.steps.forEach((u,c)=>{if(!(u instanceof Ln)||!u.slice.size)return;let d=l.mapping.slice(c+1),f=d.map(u.from,1),p=d.map(u.from+u.slice.size,-1);f<p&&a.push({from:f,to:p})}),a.sort((u,c)=>c.to-u.to),a.forEach(u=>NC(s,u,e.type))}if(Cr(l).forEach(({newRange:a})=>{let u=Mf(r.doc,a,f=>f.isTextblock),c,d;if(u.length>1)c=u[0],d=r.doc.textBetween(c.pos,c.pos+c.node.nodeSize,void 0," ");else if(u.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!MC.test(f))return;c=u[0],d=r.doc.textBetween(c.pos,a.to,void 0," ")}if(c&&d){let f=d.split(EC).filter(Boolean);if(f.length<=0)return!1;let p=f[f.length-1],h=c.pos+d.lastIndexOf(p);if(!p)return!1;let g=rs(p).map(m=>m.toObject(e.defaultProtocol));if(!RC(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:h+m.start+1,to:h+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>e.validate(m.value)).filter(m=>e.shouldAutoLink(m.value)).forEach(m=>{Zr(m.from,m.to,r.doc).some(b=>b.mark.type===e.type)||s.addMark(m.from,m.to,e.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function DC(e){return new K({key:new ne("handleClickLink"),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let u=e.editor.view.dom;o=a.closest("a"),o&&!u.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(e.enableClickSelection&&(i=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){var s,l;let a=Ql(t.state,e.type.name),u=(s=o.href)!==null&&s!==void 0?s:a.href,c=(l=o.target)!==null&&l!==void 0?l:a.target;u&&(window.open(u,c),i=!0)}return i}}})}var LC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,IC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Bh(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function PC(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Bh(e,r)){r+=1;continue}let o=0;for(;r<t&&e[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function zh(e,t,n){var r,o;let[,i,s]=t;return(t.index?e[t.index-1]:void 0)==="!"||Bh(e,(r=t.index)!==null&&r!==void 0?r:0)||PC(e,(o=t.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Hh(e){var t,n;let[r,o,i,,s,l,a]=e,u=(t=s??l)!==null&&t!==void 0?t:a;return{index:(n=e.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:u||null,markdown:!0}}}function $C(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function _h(e){var t,n,r;return{href:(t=e.data)===null||t===void 0?void 0:t.href,title:(n=(r=e.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function BC(e){let t=rt({find:n=>{let r=LC.exec(n);return!r||!zh(n,r,e.isAllowedHref)?null:Hh(r)},type:e.type,getAttributes:_h});return new Er({find:t.find,handler:n=>{let r=t.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function zC(e){let t=Ze({find:n=>{var r,o;let i=[];for(let l of n.matchAll(IC))zh(n,l,e.isAllowedHref)&&i.push(Hh(l));let s=((r=(o=e.findPlainUrls)===null||o===void 0?void 0:o.call(e,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>$C(a,l)));return[...i,...s]},type:e.type,getAttributes:_h});return new na({find:t.find,handler:n=>{var r;let o=t.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function HC(e){return new K({key:new ne("handlePasteLink"),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:o}=e,{state:i}=t,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});let u=qa(a,{defaultProtocol:e.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!u||o!==void 0&&!o(u.value)?!1:e.editor.commands.setMark(e.type,{href:u.href})}}})}function Yt(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!e||e.replace(TC,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Vh=Ve.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(e=>{if(typeof e=="string"){Ua(e);return}Ua(e.scheme,e.optionalSlashes)})},onDestroy(){$h()},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:(e,t)=>!!Yt(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var e,t,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(e=this.options.HTMLAttributes.target)!==null&&e!==void 0?e:null},rel:{default:(t=this.options.HTMLAttributes.rel)!==null&&t!==void 0?t:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!Yt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!Yt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",U(this.options.HTMLAttributes,e),0]:["a",U(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,o,i;let s=(n=(r=e.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=e.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=t.renderChildren(e);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Yt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Yt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[BC({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!Yt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=t=>{let n=[];if(t){let{protocols:r,defaultProtocol:o}=this.options;qa(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Yt(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[zC({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:n=>!!Yt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Ze({find:e,type:this.type,getAttributes:t=>{var n;return{href:(n=t.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(OC({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Yt(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(DC({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(HC({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}});var _C="listItem",jh="textStyle",Fh=/^\s*([-+*])\s$/,Ga=re.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:e}){return["ul",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>e.type!=="list"||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
127
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_C,this.editor.getAttributes(jh)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=pn({find:Fh,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=pn({find:Fh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(jh),editor:this.editor})),[e]}}),VC=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let p=o.depth;p>0;p-=1)if(o.node(p).type.name===t){i=p;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let u=e.schema.nodes[t],c=!1;if(a.forEach(p=>{p.type===u&&p.childCount>1&&(c=!0)}),!c)return null;let d=e.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(p=>{f.push(p)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},jC=(e,t,n,r)=>{let o=VC(e,n,r);if(!o)return!1;let{selection:i}=e,{nestedList:s,nestedListPos:l,insertPos:a,items:u}=o,c=e.tr;c.delete(l,l+s.nodeSize);let d=c.mapping.map(a);return c.insert(d,z.from(u)),c.setSelection(i.map(c.doc,c.mapping)),t&&t(c),!0},FC=(e,t,n)=>jC(e.state,e.view.dispatch,t,n),Yh=(e,t)=>le.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>FC(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Qh=[[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"]],ss="abcdefghijklmnopqrstuvwxyz",Zh=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function cs(e){let t=e,n="";for(let[r,o]of Qh)for(;t>=r;)n+=o,t-=r;return n}function Ja(e){return cs(e).toUpperCase()}function em(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let o=!1;for(let[i,s]of Qh)if(t.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function WC(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=em(e);return t<=0?!1:(e===e.toLowerCase()?cs(t):Ja(t))===e}function KC(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let n=t.charCodeAt(0)-97,r=t.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function ls(e){if(e<=26)return ss[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?ss[n]:ss[t]+ss[n]}function us(e){if(!(!e||/^\d+$/.test(e))){if(WC(e))return e===e.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(e))return"a";if(/^[A-Z]{1,2}$/.test(e))return"A"}}function Xa(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=us(e);if(t==="i"||t==="I")return em(e);if(t==="a"||t==="A"){let r=KC(e);return r>0?r:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function UC(e,t){if(e==="numeric")return String(t);switch(e){case"a":return ls(t);case"A":return ls(t).toUpperCase();case"i":return cs(t);case"I":return Ja(t);default:return String(t)}}function qC(e){var t;if(e.length===0)return!1;let n=(t=us(e[0]))!==null&&t!==void 0?t:"numeric",r=Xa(e[0]);if(r<1)return!1;for(let o=0;o<e.length;o++){let i=UC(n,r+o);if(e[o]!==i)return!1}return!0}function GC(e){return{type:us(e),start:Xa(e)}}function JC(e){let{type:t,start:n}=GC(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function XC(e,t,n=". "){let r=t+1;if(!e||e==="1")return`${r}${n}`;switch(e){case"a":return`${ls(r)}${n}`;case"A":return`${ls(r).toUpperCase()}${n}`;case"i":return`${cs(r)}${n}`;case"I":return`${Ja(r)}${n}`;default:return`${r}${n}`}}function YC(e){var t,n;let r=(t=e.tokens)===null||t===void 0?void 0:t[0];return!!(e.text&&((n=e.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===e.text)}function QC(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var Ya=re.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n;if(e.type!=="list_item")return[];let r=(n=t.parseBlockChildren)!==null&&n!==void 0?n:t.parseChildren,o=[];if(e.tokens&&e.tokens.length>0){if(YC(e))return{type:"listItem",content:[{type:"paragraph",content:QC(e.text||"",t)}]};if(e.tokens.some(i=>i.type==="paragraph"))o=r(e.tokens);else{let i=e.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:t.parseInline(i.tokens)}],e.tokens.length>1){let s=r(e.tokens.slice(1));o.push(...s)}}else o=r(e.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(e,t,n)=>ea(e,t,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return XC((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:n?.parentType==="orderedList"}),addExtensions(){return[Yh(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)}}}),Qa=(e,t)=>{let{$from:n}=t.selection,r=Ne(e,t.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:t.doc.resolve(s),depth:l}},tm=(e,t)=>{let n=Qa(e,t);if(!n)return!1;let[,r]=Of(t,e,n.$pos.pos+4);return r},ZC=(e,t,n)=>{let{$anchor:r}=e.selection,o=Math.max(0,r.pos-2),i=e.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Wh=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Mt(e.state,t)&&ZC(e.state,t,n)){let{$anchor:i}=e.state.selection,s=e.state.doc.resolve(i.before()-1),l=[];s.node().descendants((c,d)=>{c.type.name===t&&l.push({node:c,pos:d})});let a=l.at(-1);if(!a)return!1;let u=e.state.doc.resolve(s.start()+a.pos+1);return e.chain().cut({from:i.start()-1,to:i.end()+1},u.end()).joinForward().run()}if(!Mt(e.state,t)||!If(e.state))return!1;let{$from:r}=e.state.selection,o=r.depth-1;return r.node(o).type!==e.schema.nodes[t]||r.index(o)!==0?!1:e.chain().liftListItem(t).run()},ex=(e,t)=>{let n=tm(e,t),r=Qa(e,t);return!r||!n?!1:n>r.depth},tx=(e,t)=>{let n=tm(e,t),r=Qa(e,t);return!r||!n?!1:n<r.depth},Kh=(e,t)=>{if(!Mt(e.state,t)||!Lf(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:ex(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():tx(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},nx=(e,t,n)=>{let{state:r}=e,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||Mt(r,t))return!1;let s=Df(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==t)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,z.from(a)))return!1;let u=i.before(),c=i.after(),d=u-2;return e.commands.command(({tr:f,dispatch:p})=>(p&&(f.delete(u,c).insert(d,z.from(a)),f.setSelection(L.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Za=le.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Kh(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Kh(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Wh(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Wh(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&nx(e,t,n))return!0;return!1}}}}),as=new RegExp(`^(\\s*)(${Zh})([.)])\\s+(.*)$`),rx=/^\s/,Or={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function ox(e){return as.test(e.trimStart())}function ix(e){let t=e.trimStart();return Or.bulletItem.test(t)||ox(t)||Or.heading.test(t)||Or.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||Or.codeFence.test(t)||Or.blockMath.test(t)}function sx(e){return Object.values(Or).some(t=>t.test(e))}function lx(e){let t=[],n=[],r=!1;return e.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(t.length>0&&ix(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function Uh(e){let t=[],n=0,r=0;for(;n<e.length;){let o=e[n],i=o.match(as);if(!i)break;let[,s,l,a,u]=i,c=s.length,d=parseInt(l,10),f=isNaN(d)?us(l):void 0,p=isNaN(d)?Xa(l):d,h=[u],g=n+1,m=[o],b=!1;for(;g<e.length;){let k=e[g];if(k.match(as))break;if(k.trim()==="")m.push(k),h.push(""),b=!0,g+=1;else if(k.match(rx)){let C=k.length-k.trimStart().length,x=c+l.length+1;m.push(k),h.push(k.slice(Math.min(C,x))),g+=1}else{if(b||sx(k))break;m.push(k),h.push(k),g+=1}}t.push({indent:c,number:p,type:f,content:h.join(`
|
|
128
128
|
`).trim(),contentLines:h,raw:m.join(`
|
|
129
|
-
`)}),r=g,n=g}return[t,r]}var
|
|
130
|
-
`).filter(r=>r.trim().length>0);if(t.length===0)return null;let n=[];for(let r of t){let o=r.trim().match(
|
|
129
|
+
`)}),r=g,n=g}return[t,r]}var ax=new RegExp(`^(${Zh})([.)])\\s+(.+)$`);function cx(e){let t=e.split(`
|
|
130
|
+
`).filter(r=>r.trim().length>0);if(t.length===0)return null;let n=[];for(let r of t){let o=r.trim().match(ax);if(!o)return null;n.push({marker:o[1],content:o[3]})}return qC(n.map(r=>r.marker))?{type:"orderedList",attrs:JC(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function nm(e,t,n){let r=[],o=0;for(;o<e.length;){let i=e[o];if(i.indent===t){let{paragraphLines:s,blockLines:l}=lx(i.contentLines),a=s.join(`
|
|
131
131
|
`).trim(),u=[];a&&u.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let c=l.join(`
|
|
132
|
-
`).trim();if(c){let p=n.blockTokens(c);u.push(...p)}let d=o+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let p=
|
|
133
|
-
`)})}r.push({type:"list_item",raw:i.raw,tokens:u}),o=d}else o+=1}return r}function
|
|
134
|
-
`,r);if(o===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,o)),r=o+1}return n}function
|
|
135
|
-
`),n=t===-1?e:e.slice(0,t);if(!
|
|
136
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(e,t,n)=>{var r,o;let[i,s,l]=
|
|
137
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
138
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||t===void 0?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){let r=i=>{let s=Ql(i,{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){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=Ql(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),PA=se.create({name:"listKit",addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Ga.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Za.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(ec.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(us.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(ds.configure(this.options.taskList)),e}});var fs=" ",tc="\xA0",Zh=ce.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",U(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===fs||n[0].text===fs||n[0].raw===tc||n[0].text===tc)&&r.length===1&&r[0].type==="text"&&(r[0].text===fs||r[0].text===tc)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return"";let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?fs:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var fx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,px=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,em=_e.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rt({find:fx,type:this.type})]},addPasteRules(){return[Ze({find:px,type:this.type})]}});var tm=ce.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""});var nm=_e.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",U(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function rm(e={}){return new W({view(t){return new nc(t,e)}})}var nc=class{constructor(t,n){var r;this.editorView=t,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(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){if(this.cursorPos!=null&&n.doc!=t.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=t.nodeBefore,f=t.nodeAfter;if(d||f){let p=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(p){let h=p.getBoundingClientRect(),g=d?h.bottom:h.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,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 u,c;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,p=d.height/a.offsetHeight;u=d.left-a.scrollLeft*f,c=d.top-a.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-c)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,t):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=No(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let n=this.computeTarget(t);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};var nT=se.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){let n=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(n)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new W({key:new ne("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){e=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,u=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(a,u);return e=!0,c}e=!0},filterTransaction:(t,n)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:t.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!t.getMeta("paste"))return!1;let s=t.selection.$head.pos,l=s-(i-r),a=s;return t.deleteRange(l,a),!(this.storage.characters({node:t.doc})>r)}})]}}),sm=se.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[rm(this.options)]}}),rT=se.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new W({key:new ne("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!n||!r)return ue.create(e,[]);let s=0;this.options.mode==="deepest"&&e.descendants((a,u)=>{if(!a.isText){if(!(o>=u&&o<=u+a.nodeSize-1))return!1;s+=1}});let l=0;return e.descendants((a,u)=>{if(a.isText||!(o>=u&&o<=u+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";i.push(Ee.node(u,u+a.nodeSize,{class:this.options.className}))}),ue.create(e,i)}}})]}}),lm=se.create({name:"gapCursor",addProseMirrorPlugins(){return[Cp()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=de(P(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),am="placeholder",om=new ne("tiptap__placeholder");function cm(e){let{editor:t,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:u}}=e,c=[a];return s&&c.push(u),Ee.node(o,o+i.nodeSize,{class:c.join(" "),[r]:typeof n=="function"?n({editor:t,node:i,pos:o,hasAnchor:l}):n})}function um(e,t){return typeof e=="function"?e(t):e}function dm({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],u=e.isEmpty;return r.nodesBetween(i,s,(c,d)=>{let f=l>=d&&l<=d+c.nodeSize,p=!c.isLeaf&&kr(c);return c.type.isTextblock&&(f||!t.showOnlyCurrent)&&p&&a.push(cm({editor:e,isEmptyDoc:u,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:um(t.emptyNodeClass,{editor:e,node:c,pos:d,hasAnchor:f})},node:c,pos:d})),t.includeChildren}),a}function fm({editor:e,options:t,dataAttribute:n,doc:r,selection:o}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let a=r.resolve(i),u=a.depth>0?a.node(1):a.nodeAfter,c=a.depth>0?a.before(1):i;if(u&&u.type.isTextblock&&kr(u)){let d=i>=c&&i<=c+u.nodeSize;s.push(cm({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:um(t.emptyNodeClass,{editor:e,node:u,pos:c,hasAnchor:d})},node:u,pos:c}))}}else s.push(...dm({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return ue.create(r,s)}function go(e,t){let n=e.resolve(t);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:t,to:t};let s=n.nodeAfter?t:t-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function bo(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function hx(e,t,n){let r=[];return e.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,u=l+1;a<n&&u>t&&r.push({from:s,to:l})}),r}function mx(e){if(e.length===0)return[];let t=[...e].sort((r,o)=>r.from-o.from),n=[{...t[0]}];for(let r=1;r<t.length;r+=1){let o=n[n.length-1],i=t[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function gx(e,t){let n=hx(e,t.from,t.to);return n.push(bo(e,go(e,t.from))),t.to>t.from?n.push(bo(e,go(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(bo(e,go(e,Math.min(t.from+1,e.content.size)))),n}function bx(e,t,n){let r=[];if(e.docChanged){let o=wr(e);for(let i of o)r.push(...gx(n.doc,i.newRange))}return e.selectionSet&&(r.push(bo(n.doc,go(n.doc,e.mapping.map(t.selection.anchor)))),r.push(bo(n.doc,go(n.doc,n.selection.anchor)))),mx(r)}function yx(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function wx({decorations:e,ranges:t,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=e;for(let a of t){let{from:u,to:c}=yx(a.from,a.to,i),d=l.find(u,c).filter(p=>p.from>=u&&p.to<=c);d.length&&(l=l.remove(d));let f=dm({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:u,to:c});f.length&&(l=l.add(i,f))}return l}function kx({editor:e,options:t,dataAttribute:n}){return{init(r,o){let i=fm({editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection});return i??ue.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:wx({decorations:o.map(r.mapping,r.doc),ranges:bx(r,i,s),editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function vx(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Cx({editor:e,options:t}){let n=t.dataAttribute?`data-${vx(t.dataAttribute)}`:`data-${am}`,r=t.showOnlyCurrent&&!t.includeChildren;return new W({key:om,...r?{}:{state:kx({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>fm({editor:e,options:t,dataAttribute:n,doc:o,selection:i}):o=>{var i;return t.showOnlyWhenEditable&&!e.isEditable?ue.empty:(i=om.getState(o))!==null&&i!==void 0?i:ue.empty}}})}var oc=se.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:am,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Cx({editor:this.editor,options:this.options})]}});function rc(e,t){return!e.selection.empty&&!si(e.selection)&&t.isEditable}function xx(e,t){return rc(e,t)&&!t.isFocused&&!t.view.dragging}function Sx(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function Ex(e){e.focus()}var oT=se.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new W({key:new ne("selection"),props:{decorations(n){return xx(n,e)?ue.create(n.doc,[Ee.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(n){return rc(n.state,e)&&Sx(),!1},focus(n){return rc(n.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&n.hasFocus()&&Ex(n)}),!1}}}})]}});function im({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var pm=se.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new ne(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)===null||e===void 0?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new W({key:t,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:u}=s,c=t.getState(s),d=l.content.size,f=u.nodes[n];if(!o.some(p=>p.getMeta("skipTrailingNode"))&&c)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!im({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!im({node:s,types:r})}}})]}}),hm=se.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Bl(e,t),redo:()=>({state:e,dispatch:t})=>zl(e,t)}},addProseMirrorPlugins(){return[Gd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Mx=se.create({name:"starterKit",addExtensions(){let e=[];if(this.options.bold!==!1&&e.push(fh.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(dh.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Ga.configure(this.options.bulletList)),this.options.code!==!1&&e.push(ph.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(xi.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(hh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(sm.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(lm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(mh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(gh.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(hm.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(bh.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(yh.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1){var t;e.push(Za.configure((t=this.options)===null||t===void 0?void 0:t.listKeymap))}if(this.options.link!==!1){var n;e.push(Bh.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&e.push(ec.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Zh.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(em.configure(this.options.strike)),this.options.text!==!1&&e.push(tm.configure(this.options.text)),this.options.underline!==!1){var r;e.push(nm.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;e.push(pm.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return e}}),mm=Mx;var $m=be(Pm(),1);var Bm=$m.default;function _m(e,t=[]){return e.flatMap(n=>{let r=[...t,...n.properties?n.properties.className:[]];return n.children?_m(n.children,r):{text:n.value,classes:r}})}function zm(e){return e.value||e.children||[]}function gS(e){return!!Bm.getLanguage(e)}function Hm({doc:e,name:t,lowlight:n,defaultLanguage:r}){let o=[];return Un(e,i=>i.type.name===t).forEach(i=>{var s;let l=i.pos+1,a=i.node.attrs.language||r,u=n.listLanguages();_m(a&&(u.includes(a)||gS(a)||!((s=n.registered)===null||s===void 0)&&s.call(n,a))?zm(n.highlight(a,i.node.textContent)):zm(n.highlightAuto(i.node.textContent))).forEach(c=>{let d=l+c.text.length;if(c.classes.length){let f=Ee.inline(l,d,{class:c.classes.join(" ")});o.push(f)}l=d})}),ue.create(e,o)}function bS(e){return typeof e=="function"}function yS({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(o=>bS(t[o])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new W({key:new ne("lowlight"),state:{init:(o,{doc:i})=>Hm({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(o,i,s,l)=>{let a=s.selection.$head.parent.type.name,u=l.selection.$head.parent.type.name,c=Un(s.doc,f=>f.type.name===e),d=Un(l.doc,f=>f.type.name===e);return o.docChanged&&([a,u].includes(e)||d.length!==c.length||o.steps.some(f=>f.from!==void 0&&f.to!==void 0&&c.some(p=>p.pos>=f.from&&p.pos+p.node.nodeSize<=f.to)))?Hm({doc:o.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(o.mapping,o.doc)}},props:{decorations(o){return r.getState(o)}}});return r}var wS=xi.extend({addOptions(){var e;return{...(e=this.parent)===null||e===void 0?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...((e=this.parent)===null||e===void 0?void 0:e.call(this))||[],yS({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),Vm=wS;var jm=Vm.extend({addProseMirrorPlugins(){return(this.parent?.()??[]).map(e=>{let t=e.spec.state;if(!t||!e.props.decorations)return e;let n=this.name;return new W({...e.spec,state:{...t,apply(r,o,i,s){if(r.docChanged){let l=Un(i.doc,u=>u.type.name===n),a=Un(s.doc,u=>u.type.name===n);if(l.length!==a.length||a.some((u,c)=>!u.node.eq(l[c].node)))return t.init.call(this,{},s)}return o.map(r.mapping,r.doc)}}})})}}).configure({lowlight:cu,HTMLAttributes:{class:"code-block"}});var Fm=oc;var kS=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,vS=ce.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",U(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,n,r,o,i,s;let l=(t=(n=e.attrs)===null||n===void 0?void 0:n.src)!==null&&t!==void 0?t:"",a=(r=(o=e.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",u=(i=(s=e.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let u=document.createElement("img");u.draggable=!1;let c=U(this.options.HTMLAttributes,l);Object.entries(c).forEach(([b,v])=>{if(v!=null)switch(b){case"src":case"width":case"height":break;default:u.setAttribute(b,v)}}),c.src!==null&&(u.src=c.src);let d={...l},f=b=>{if(typeof b=="string"&&b!==""){u.getAttribute("src")!==b&&(u.src=b);return}u.hasAttribute("src")&&u.removeAttribute("src"),u.src!==""&&(u.src="")};f(l.src);let p=b=>{if(b.type!==i.type)return!1;let v=a.extensionManager.attributes.filter(C=>C.type===b.type.name),S=At(b,v);return Object.keys(d).forEach(C=>{!o.has(C)&&!(C in S)&&u.removeAttribute(C)}),Object.entries(S).forEach(([C,M])=>{o.has(C)||(M!=null?u.setAttribute(C,M):u.removeAttribute(C))}),f(S.src),d=S,!0},h=new Kf({element:u,editor:a,node:i,getPos:s,onResize:(b,v)=>{u.style.width=`${b}px`,u.style.height=`${v}px`},onCommit:(b,v)=>{let S=s();S!==void 0&&this.editor.chain().setNodeSelection(S).updateAttributes(this.name,{width:b,height:v}).run()},onUpdate:p,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),g=h.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",u.complete&&u.naturalWidth>0?m():(u.onload=m,u.onerror=m),h}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[ai({find:kS,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),Wm=vS;function ko(e){return e==="left"||e==="right"||e==="center"?e:null}function CS(e){let t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return ko(t||n)}function xS(e){return ko(e?.align)}function Jm(){return{default:null,parseHTML:e=>CS(e),renderHTML:e=>{let t=ko(e.align);return vr(t)?{style:`text-align: ${t}`}:{}}}}function SS(e){var t;let n=e.parentElement,r=e.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(e),i=(t=r.querySelectorAll("colgroup > col")[o])===null||t===void 0?void 0:t.getAttribute("width");return i?[parseInt(i,10)]:null}function Xm(e){let t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):SS(e)}var ES=/[ \t\r\n\f]+/g;function Ym(e){var t;return e.children.length>0?!1:((t=e.textContent)!==null&&t!==void 0?t:"").replace(ES,"")===""}function Qm(e){let t=e.createAndFill();if(!t)throw new Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function ws(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r==="1"||r===null||r===void 0)&&delete e[n]}var MS=ce.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Xm},align:Jm()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:e=>Ym(e)?{}:!1,getContent:(e,t)=>Qm(t.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:e}){let t=U(this.options.HTMLAttributes,e);return ws(t,e,"colspan"),ws(t,e,"rowspan"),["td",t,0]}}),AS=ce.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Xm},align:Jm()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:e=>Ym(e)?{}:!1,getContent:(e,t)=>Qm(t.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:e}){let t=U(this.options.HTMLAttributes,e);return ws(t,e,"colspan"),ws(t,e,"rowspan"),["th",t,0]}}),TS=ce.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",U(this.options.HTMLAttributes,e),0]}});function fc(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Km(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){let{colspan:h,colwidth:g}=u.child(f).attrs;for(let m=0;m<h;m+=1,p+=1){let b=o===p?i:g&&g[m],v=b?`${b}px`:"";if(s+=b||r,b||(l=!1),a){if(a.style.width!==v){let[S,C]=fc(r,b);a.style.setProperty(S,C)}a=a.nextSibling}else{let S=document.createElement("col"),[C,M]=fc(r,b);S.style.setProperty(C,M),t.appendChild(S)}}}for(;a;){var c;let f=a.nextSibling;(c=a.parentNode)===null||c===void 0||c.removeChild(a),a=f}let d=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var pc=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Km(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Km(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function NS(e,t,n,r){let o=0,i=!0,s=[],l=e.firstChild;if(!l)return{};for(let c=0,d=0;c<l.childCount;c+=1){let{colspan:f,colwidth:p}=l.child(c).attrs;for(let h=0;h<f;h+=1,d+=1){let g=n===d?r:p&&p[h];o+=g||t,g||(i=!1);let[m,b]=fc(t,g);s.push(["col",{style:`${m}: ${b}`}])}}let a=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:u}}function Um(e,t){return t?e.createChecked(null,t):e.createAndFill()}function RS(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function OS(e,t,n,r,o){let i=RS(e),s=[],l=[];for(let u=0;u<n;u+=1){let c=Um(i.cell,o);if(c&&l.push(c),r){let d=Um(i.header_cell,o);d&&s.push(d)}}let a=[];for(let u=0;u<t;u+=1)a.push(i.row.createChecked(null,r&&u===0?s:l));return i.table.createChecked(null,a)}function Zm(e){return e instanceof re}var ys=({editor:e})=>{let{selection:t}=e.state;if(!Zm(t))return!1;let n=0,r=yr(t.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==t.ranges.length?!1:(e.commands.deleteTable(),!0)};function qm(e,t){let n=e.mapping.map(t),r=yr(e.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=e.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;e.setSelection(L.near(e.doc.resolve(i),-1))}function DS(e){let t="",n=0;for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<e.length;){if(e[o]!=="`"){o+=1;continue}let s=0;for(;o+s<e.length&&e[o+s]==="`";)s+=1;if(s===r){let l=e.slice(n+r,o);t+=e.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+e.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(t+=e.slice(n,n+r),n+=r)}return t}function LS(e){return e.split(`
|
|
139
|
-
`).map(t=>!t.includes("|")||!t.includes("`")?t:
|
|
140
|
-
`)}function
|
|
141
|
-
`):e}function
|
|
142
|
-
`):g=
|
|
132
|
+
`).trim();if(c){let p=n.blockTokens(c);u.push(...p)}let d=o+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let p=nm(f,Math.min(...f.map(h=>h.indent)),n);u.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:p,raw:f.map(h=>h.raw).join(`
|
|
133
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:u}),o=d}else o+=1}return r}function ux(e,t){return e.map(n=>{if(n.type!=="list_item")return t.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...t.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=t.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=t.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var dx=64;function qh(e,t){let n=[],r=0;for(;n.length<t;){let o=e.indexOf(`
|
|
134
|
+
`,r);if(o===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,o)),r=o+1}return n}function fx(e){let t=e.indexOf(`
|
|
135
|
+
`),n=t===-1?e:e.slice(0,t);if(!as.test(n))return[[],0,[]];let r=dx,o=qh(e,r),i=Uh(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=qh(e,r),i=Uh(o);return[i[0],i[1],o]}var px="listItem",Gh="textStyle",Jh=/^(\d+)\.\s$/;function Xh(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[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}}var ec=re.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:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute("type");if(t)return t;let n=e.getAttribute("style");if(n){let o=Xh(n);if(o)return o}let r=e.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=Xh(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,o=U(this.options.HTMLAttributes,r);return t!==1&&(o.start=t),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{if(e.type!=="list"||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,o=e.items?ux(e.items,t):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
136
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(e,t,n)=>{var r,o;let[i,s,l]=fx(e);if(i.length===0)return;let a=nm(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`
|
|
137
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(px,this.editor.getAttributes(Gh)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new K({props:{handlePaste:(e,t)=>{var n,r;let o=(n=t.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let i=(r=t.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=cx(i);if(!s)return!1;try{let l=e.state.schema.nodeFromJSON(s),a=e.state.tr.replaceSelectionWith(l);return e.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let e=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],t=pn({find:Jh,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=pn({find:Jh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Gh)}),joinPredicate:e,editor:this.editor})),[t]}}),hx=/^\s*(\[([( |x])?\])\s$/,mx="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",gx=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||"empty task item"}`},ds=re.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:e=>{let t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>{var t;return(t=e.querySelector("div"))!==null&&t!==void 0?t:e}}]},renderHTML({node:e,HTMLAttributes:t}){return["li",U(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;let r=`- [${!((n=e.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return ea(e,t,r)},addExtensions(){return this.options.nested?[Yh(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=mx;let u=d=>{let f=gx(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),s.textContent=f};u(e),i.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}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{let h=n();if(typeof h!="number")return!1;let g=p.doc.nodeAt(h);return p.setNodeMarkup(h,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=e.attrs.checked,l.checked=e.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(t).forEach(([d,f])=>{o.setAttribute(d,f)});let c=new Set(Object.keys(t));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d);let f=r.extensionManager.attributes,p=At(d,f),h=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return c.forEach(m=>{h.has(m)||(m in g?o.setAttribute(m,g[m]):o.removeAttribute(m))}),Object.entries(p).forEach(([m,b])=>{b==null?m in g?o.setAttribute(m,g[m]):o.removeAttribute(m):o.setAttribute(m,b)}),c=h,!0}}}},addInputRules(){return[pn({find:hx,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),fs=re.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:e}){return["ul",U(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
138
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||t===void 0?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){let r=i=>{let s=Zl(i,{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){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=Zl(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),jA=le.create({name:"listKit",addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Ga.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Za.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(ec.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(ds.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(fs.configure(this.options.taskList)),e}});var ps=" ",tc="\xA0",rm=re.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",U(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ps||n[0].text===ps||n[0].raw===tc||n[0].text===tc)&&r.length===1&&r[0].type==="text"&&(r[0].text===ps||r[0].text===tc)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return"";let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?ps:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var bx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,yx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,om=Ve.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",U(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rt({find:bx,type:this.type})]},addPasteRules(){return[Ze({find:yx,type:this.type})]}});var im=re.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""});var sm=Ve.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",U(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function lm(e={}){return new K({view(t){return new nc(t,e)}})}var nc=class{constructor(t,n){var r;this.editorView=t,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(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){if(this.cursorPos!=null&&n.doc!=t.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=t.nodeBefore,f=t.nodeAfter;if(d||f){let p=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(p){let h=p.getBoundingClientRect(),g=d?h.bottom:h.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,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 u,c;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,p=d.height/a.offsetHeight;u=d.left-a.scrollLeft*f,c=d.top-a.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-c)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,t):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ro(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let n=this.computeTarget(t);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};var cT=le.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){let n=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(n)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new K({key:new ne("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){e=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,u=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(a,u);return e=!0,c}e=!0},filterTransaction:(t,n)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:t.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!t.getMeta("paste"))return!1;let s=t.selection.$head.pos,l=s-(i-r),a=s;return t.deleteRange(l,a),!(this.storage.characters({node:t.doc})>r)}})]}}),um=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lm(this.options)]}}),uT=le.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new K({key:new ne("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!n||!r)return ue.create(e,[]);let s=0;this.options.mode==="deepest"&&e.descendants((a,u)=>{if(!a.isText){if(!(o>=u&&o<=u+a.nodeSize-1))return!1;s+=1}});let l=0;return e.descendants((a,u)=>{if(a.isText||!(o>=u&&o<=u+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";i.push(Ee.node(u,u+a.nodeSize,{class:this.options.className}))}),ue.create(e,i)}}})]}}),dm=le.create({name:"gapCursor",addProseMirrorPlugins(){return[Mp()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=de(P(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),fm="placeholder",am=new ne("tiptap__placeholder");function pm(e){let{editor:t,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:u}}=e,c=[a];return s&&c.push(u),Ee.node(o,o+i.nodeSize,{class:c.join(" "),[r]:typeof n=="function"?n({editor:t,node:i,pos:o,hasAnchor:l}):n})}function hm(e,t){return typeof e=="function"?e(t):e}function mm({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],u=e.isEmpty;return r.nodesBetween(i,s,(c,d)=>{let f=l>=d&&l<=d+c.nodeSize,p=!c.isLeaf&&xr(c);return c.type.isTextblock&&(f||!t.showOnlyCurrent)&&p&&a.push(pm({editor:e,isEmptyDoc:u,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:hm(t.emptyNodeClass,{editor:e,node:c,pos:d,hasAnchor:f})},node:c,pos:d})),t.includeChildren}),a}function gm({editor:e,options:t,dataAttribute:n,doc:r,selection:o}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let a=r.resolve(i),u=a.depth>0?a.node(1):a.nodeAfter,c=a.depth>0?a.before(1):i;if(u&&u.type.isTextblock&&xr(u)){let d=i>=c&&i<=c+u.nodeSize;s.push(pm({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:hm(t.emptyNodeClass,{editor:e,node:u,pos:c,hasAnchor:d})},node:u,pos:c}))}}else s.push(...mm({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return ue.create(r,s)}function bo(e,t){let n=e.resolve(t);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:t,to:t};let s=n.nodeAfter?t:t-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function yo(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function wx(e,t,n){let r=[];return e.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,u=l+1;a<n&&u>t&&r.push({from:s,to:l})}),r}function kx(e){if(e.length===0)return[];let t=[...e].sort((r,o)=>r.from-o.from),n=[{...t[0]}];for(let r=1;r<t.length;r+=1){let o=n[n.length-1],i=t[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function vx(e,t){let n=wx(e,t.from,t.to);return n.push(yo(e,bo(e,t.from))),t.to>t.from?n.push(yo(e,bo(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(yo(e,bo(e,Math.min(t.from+1,e.content.size)))),n}function Cx(e,t,n){let r=[];if(e.docChanged){let o=Cr(e);for(let i of o)r.push(...vx(n.doc,i.newRange))}return e.selectionSet&&(r.push(yo(n.doc,bo(n.doc,e.mapping.map(t.selection.anchor)))),r.push(yo(n.doc,bo(n.doc,n.selection.anchor)))),kx(r)}function xx(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function Sx({decorations:e,ranges:t,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=e;for(let a of t){let{from:u,to:c}=xx(a.from,a.to,i),d=l.find(u,c).filter(p=>p.from>=u&&p.to<=c);d.length&&(l=l.remove(d));let f=mm({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:u,to:c});f.length&&(l=l.add(i,f))}return l}function Ex({editor:e,options:t,dataAttribute:n}){return{init(r,o){let i=gm({editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection});return i??ue.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Sx({decorations:o.map(r.mapping,r.doc),ranges:Cx(r,i,s),editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Mx(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Ax({editor:e,options:t}){let n=t.dataAttribute?`data-${Mx(t.dataAttribute)}`:`data-${fm}`,r=t.showOnlyCurrent&&!t.includeChildren;return new K({key:am,...r?{}:{state:Ex({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>gm({editor:e,options:t,dataAttribute:n,doc:o,selection:i}):o=>{var i;return t.showOnlyWhenEditable&&!e.isEditable?ue.empty:(i=am.getState(o))!==null&&i!==void 0?i:ue.empty}}})}var oc=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:fm,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Ax({editor:this.editor,options:this.options})]}});function rc(e,t){return!e.selection.empty&&!li(e.selection)&&t.isEditable}function Tx(e,t){return rc(e,t)&&!t.isFocused&&!t.view.dragging}function Nx(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function Rx(e){e.focus()}var dT=le.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new K({key:new ne("selection"),props:{decorations(n){return Tx(n,e)?ue.create(n.doc,[Ee.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(n){return rc(n.state,e)&&Nx(),!1},focus(n){return rc(n.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&n.hasFocus()&&Rx(n)}),!1}}}})]}});function cm({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var bm=le.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new ne(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)===null||e===void 0?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new K({key:t,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:u}=s,c=t.getState(s),d=l.content.size,f=u.nodes[n];if(!o.some(p=>p.getMeta("skipTrailingNode"))&&c)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!cm({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!cm({node:s,types:r})}}})]}}),ym=le.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>zl(e,t),redo:()=>({state:e,dispatch:t})=>Hl(e,t)}},addProseMirrorPlugins(){return[Qd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Ox=le.create({name:"starterKit",addExtensions(){let e=[];if(this.options.bold!==!1&&e.push(gh.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(mh.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Ga.configure(this.options.bulletList)),this.options.code!==!1&&e.push(bh.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Si.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(yh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(um.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(dm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(wh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(kh.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(ym.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(vh.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Ch.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1){var t;e.push(Za.configure((t=this.options)===null||t===void 0?void 0:t.listKeymap))}if(this.options.link!==!1){var n;e.push(Vh.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&e.push(ec.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(rm.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(om.configure(this.options.strike)),this.options.text!==!1&&e.push(im.configure(this.options.text)),this.options.underline!==!1){var r;e.push(sm.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;e.push(bm.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return e}}),wm=Ox;var _m=ye(Hm(),1);var Vm=_m.default;function Wm(e,t=[]){return e.flatMap(n=>{let r=[...t,...n.properties?n.properties.className:[]];return n.children?Wm(n.children,r):{text:n.value,classes:r}})}function jm(e){return e.value||e.children||[]}function vS(e){return!!Vm.getLanguage(e)}function Fm({doc:e,name:t,lowlight:n,defaultLanguage:r}){let o=[];return qn(e,i=>i.type.name===t).forEach(i=>{var s;let l=i.pos+1,a=i.node.attrs.language||r,u=n.listLanguages();Wm(a&&(u.includes(a)||vS(a)||!((s=n.registered)===null||s===void 0)&&s.call(n,a))?jm(n.highlight(a,i.node.textContent)):jm(n.highlightAuto(i.node.textContent))).forEach(c=>{let d=l+c.text.length;if(c.classes.length){let f=Ee.inline(l,d,{class:c.classes.join(" ")});o.push(f)}l=d})}),ue.create(e,o)}function CS(e){return typeof e=="function"}function xS({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(o=>CS(t[o])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new K({key:new ne("lowlight"),state:{init:(o,{doc:i})=>Fm({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(o,i,s,l)=>{let a=s.selection.$head.parent.type.name,u=l.selection.$head.parent.type.name,c=qn(s.doc,f=>f.type.name===e),d=qn(l.doc,f=>f.type.name===e);return o.docChanged&&([a,u].includes(e)||d.length!==c.length||o.steps.some(f=>f.from!==void 0&&f.to!==void 0&&c.some(p=>p.pos>=f.from&&p.pos+p.node.nodeSize<=f.to)))?Fm({doc:o.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(o.mapping,o.doc)}},props:{decorations(o){return r.getState(o)}}});return r}var SS=Si.extend({addOptions(){var e;return{...(e=this.parent)===null||e===void 0?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...((e=this.parent)===null||e===void 0?void 0:e.call(this))||[],xS({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),Km=SS;var Um=Km.extend({addProseMirrorPlugins(){return(this.parent?.()??[]).map(e=>{let t=e.spec.state;if(!t||!e.props.decorations)return e;let n=this.name;return new K({...e.spec,state:{...t,apply(r,o,i,s){if(r.docChanged){let l=qn(i.doc,u=>u.type.name===n),a=qn(s.doc,u=>u.type.name===n);if(l.length!==a.length||a.some((u,c)=>!u.node.eq(l[c].node)))return t.init.call(this,{},s)}return o.map(r.mapping,r.doc)}}})})}}).configure({lowlight:du,HTMLAttributes:{class:"code-block"}});var qm=oc;var ES=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,MS=re.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",U(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,n,r,o,i,s;let l=(t=(n=e.attrs)===null||n===void 0?void 0:n.src)!==null&&t!==void 0?t:"",a=(r=(o=e.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",u=(i=(s=e.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let u=document.createElement("img");u.draggable=!1;let c=U(this.options.HTMLAttributes,l);Object.entries(c).forEach(([b,k])=>{if(k!=null)switch(b){case"src":case"width":case"height":break;default:u.setAttribute(b,k)}}),c.src!==null&&(u.src=c.src);let d={...l},f=b=>{if(typeof b=="string"&&b!==""){u.getAttribute("src")!==b&&(u.src=b);return}u.hasAttribute("src")&&u.removeAttribute("src"),u.src!==""&&(u.src="")};f(l.src);let p=b=>{if(b.type!==i.type)return!1;let k=a.extensionManager.attributes.filter(x=>x.type===b.type.name),C=At(b,k);return Object.keys(d).forEach(x=>{!o.has(x)&&!(x in C)&&u.removeAttribute(x)}),Object.entries(C).forEach(([x,E])=>{o.has(x)||(E!=null?u.setAttribute(x,E):u.removeAttribute(x))}),f(C.src),d=C,!0},h=new Jf({element:u,editor:a,node:i,getPos:s,onResize:(b,k)=>{u.style.width=`${b}px`,u.style.height=`${k}px`},onCommit:(b,k)=>{let C=s();C!==void 0&&this.editor.chain().setNodeSelection(C).updateAttributes(this.name,{width:b,height:k}).run()},onUpdate:p,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),g=h.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",u.complete&&u.naturalWidth>0?m():(u.onload=m,u.onerror=m),h}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[ci({find:ES,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),Gm=MS;function vo(e){return e==="left"||e==="right"||e==="center"?e:null}function AS(e){let t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return vo(t||n)}function TS(e){return vo(e?.align)}function Zm(){return{default:null,parseHTML:e=>AS(e),renderHTML:e=>{let t=vo(e.align);return Sr(t)?{style:`text-align: ${t}`}:{}}}}function NS(e){var t;let n=e.parentElement,r=e.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(e),i=(t=r.querySelectorAll("colgroup > col")[o])===null||t===void 0?void 0:t.getAttribute("width");return i?[parseInt(i,10)]:null}function eg(e){let t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):NS(e)}var RS=/[ \t\r\n\f]+/g;function tg(e){var t;return e.children.length>0?!1:((t=e.textContent)!==null&&t!==void 0?t:"").replace(RS,"")===""}function ng(e){let t=e.createAndFill();if(!t)throw new Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function ks(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r==="1"||r===null||r===void 0)&&delete e[n]}var OS=re.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:eg},align:Zm()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:e=>tg(e)?{}:!1,getContent:(e,t)=>ng(t.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:e}){let t=U(this.options.HTMLAttributes,e);return ks(t,e,"colspan"),ks(t,e,"rowspan"),["td",t,0]}}),DS=re.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:eg},align:Zm()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:e=>tg(e)?{}:!1,getContent:(e,t)=>ng(t.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:e}){let t=U(this.options.HTMLAttributes,e);return ks(t,e,"colspan"),ks(t,e,"rowspan"),["th",t,0]}}),LS=re.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",U(this.options.HTMLAttributes,e),0]}});function fc(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Jm(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild,u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){let{colspan:h,colwidth:g}=u.child(f).attrs;for(let m=0;m<h;m+=1,p+=1){let b=o===p?i:g&&g[m],k=b?`${b}px`:"";if(s+=b||r,b||(l=!1),a){if(a.style.width!==k){let[C,x]=fc(r,b);a.style.setProperty(C,x)}a=a.nextSibling}else{let C=document.createElement("col"),[x,E]=fc(r,b);C.style.setProperty(x,E),t.appendChild(C)}}}for(;a;){var c;let f=a.nextSibling;(c=a.parentNode)===null||c===void 0||c.removeChild(a),a=f}let d=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var pc=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Jm(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Jm(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function IS(e,t,n,r){let o=0,i=!0,s=[],l=e.firstChild;if(!l)return{};for(let c=0,d=0;c<l.childCount;c+=1){let{colspan:f,colwidth:p}=l.child(c).attrs;for(let h=0;h<f;h+=1,d+=1){let g=n===d?r:p&&p[h];o+=g||t,g||(i=!1);let[m,b]=fc(t,g);s.push(["col",{style:`${m}: ${b}`}])}}let a=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:u}}function Xm(e,t){return t?e.createChecked(null,t):e.createAndFill()}function PS(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function $S(e,t,n,r,o){let i=PS(e),s=[],l=[];for(let u=0;u<n;u+=1){let c=Xm(i.cell,o);if(c&&l.push(c),r){let d=Xm(i.header_cell,o);d&&s.push(d)}}let a=[];for(let u=0;u<t;u+=1)a.push(i.row.createChecked(null,r&&u===0?s:l));return i.table.createChecked(null,a)}function rg(e){return e instanceof oe}var ws=({editor:e})=>{let{selection:t}=e.state;if(!rg(t))return!1;let n=0,r=vr(t.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==t.ranges.length?!1:(e.commands.deleteTable(),!0)};function Ym(e,t){let n=e.mapping.map(t),r=vr(e.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=e.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;e.setSelection(L.near(e.doc.resolve(i),-1))}function BS(e){let t="",n=0;for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<e.length;){if(e[o]!=="`"){o+=1;continue}let s=0;for(;o+s<e.length&&e[o+s]==="`";)s+=1;if(s===r){let l=e.slice(n+r,o);t+=e.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+e.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(t+=e.slice(n,n+r),n+=r)}return t}function zS(e){return e.split(`
|
|
139
|
+
`).map(t=>!t.includes("|")||!t.includes("`")?t:BS(t)).join(`
|
|
140
|
+
`)}function HS(e){return(e||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function Qm(e,t){return t?e.split(t).join(`
|
|
141
|
+
`):e}function _S(e){return e.replace(/\\.|\|/g,t=>t==="|"?"\\|":t)}function VS(e,t,n={}){if(!e||!e.content||e.content.length===0)return"";let r=[];e.content.forEach(f=>{let p=[];f.content&&f.content.forEach(h=>{let g="";h.content&&Array.isArray(h.content)&&h.content.length>1?g=h.content.map(C=>Qm(t.renderChildren(C),n.cellLineSeparator)).join(`
|
|
142
|
+
`):g=Qm(h.content?t.renderChildren(h.content):"",n.cellLineSeparator);let m=_S(HS(g.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),b=h.type==="tableHeader",k=TS(h.attrs);p.push({text:m,isHeader:b,align:k})}),r.push(p)});let o=r.reduce((f,p)=>Math.max(f,p.length),0);if(o===0)return"";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let h=0;h<o;h+=1){var p;let g=(((p=f[h])===null||p===void 0?void 0:p.text)||"").length;g>i[h]&&(i[h]=g),i[h]<3&&(i[h]=3)}});let s=(f,p)=>f+" ".repeat(Math.max(0,p-f.length)),l=r[0],a=l.some(f=>f.isHeader),u=Array.from({length:o}).fill(null);r.forEach(f=>{for(let h=0;h<o;h+=1){var p;!u[h]&&(!((p=f[h])===null||p===void 0)&&p.align)&&(u[h]=f[h].align)}});let c=`
|
|
143
143
|
`,d=Array.from({length:o}).map((f,p)=>a&&l[p]&&l[p].text||"");return c+=`| ${d.map((f,p)=>s(f,i[p])).join(" | ")} |
|
|
144
144
|
`,c+=`| ${i.map((f,p)=>{let h=Math.max(3,f),g=u[p];return g==="left"?`:${"-".repeat(h)}`:g==="right"?`${"-".repeat(h)}:`:g==="center"?`:${"-".repeat(h)}:`:"-".repeat(h)}).join(" | ")} |
|
|
145
145
|
`,(a?r.slice(1):r).forEach(f=>{c+=`| ${Array.from({length:o}).fill(0).map((p,h)=>s(f[h]&&f[h].text||"",i[h])).join(" | ")} |
|
|
146
|
-
`}),c}var
|
|
146
|
+
`}),c}var jS=new ne("preserveCellSelectionOnContextMenu");function FS(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function WS(e,t){let n=!1;return e.forEachCell((r,o)=>{t>=o&&t<o+r.nodeSize&&(n=!0)}),n}function KS(){return new K({key:jS,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!rg(n)||n.ranges.length<2)return!1;let r=FS(e,t);return r==null||!WS(n,r)?!1:(t.preventDefault(),!0)}}}})}var US=re.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:pc,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=IS(e,this.options.cellMinWidth),i=t.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",U(this.options.HTMLAttributes,t,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let o=[];e.header.forEach((i,s)=>{var l;let a=vo((l=r[s])!==null&&l!==void 0?l:i.align),u=a?{align:a}:{};o.push(t.createNode("tableHeader",u,[{type:"paragraph",content:t.parseInline(i.tokens)}]))}),n.push(t.createNode("tableRow",{},o))}return e.rows&&e.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let u=vo((a=r[l])!==null&&a!==void 0?a:s.align),c=u?{align:u}:{};i.push(t.createNode("tableCell",c,[{type:"paragraph",content:t.parseInline(s.tokens)}]))}),n.push(t.createNode("tableRow",{},i))}),t.createNode("table",void 0,n)},renderMarkdown:(e,t)=>VS(e,t),markdownTokenizer:{name:"table",level:"block",start:e=>{let t=e.split(`
|
|
147
147
|
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:t[0].includes("|")?0:-1},tokenize(e,t,n){let r=e.indexOf(`
|
|
148
148
|
|
|
149
149
|
`),o=r>=0?e.slice(0,r):e,i=o.split(`
|
|
150
|
-
`);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=
|
|
150
|
+
`);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=zS(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let u=a.raw.split(`
|
|
151
151
|
`).length,c=e.split(`
|
|
152
152
|
`).slice(0,u).join(`
|
|
153
|
-
`);return{...a,raw:c}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=OS(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(L.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>zp(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Hp(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=yr(e.selection.$from,r=>r.type.name==="table");return _p(e,t&&(r=>{n&&qm(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>jp(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Fp(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=yr(e.selection.$from,r=>r.type.name==="table");return Wp(e,t&&(r=>{n&&qm(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>qp(e,t),mergeCells:()=>({state:e,dispatch:t})=>ba(e,t),splitCell:()=>({state:e,dispatch:t})=>ya(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Ar("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Ar("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Up(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>ba(e,t)?!0:ya(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Kp(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>wa(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>wa(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ga(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let r=re.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ys,"Mod-Backspace":ys,Delete:ys,"Mod-Delete":ys}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Jp({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Yp({allowTableNodeSelection:this.options.allowTableNodeSelection}),_S()]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:n,view:r,HTMLAttributes:o})=>{let i=U(this.options.HTMLAttributes,o);return new t(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:de(P(e,"tableRole",t))}}}),eg=se.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(VS.configure(this.options.table)),this.options.tableCell!==!1&&e.push(MS.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(AS.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(TS.configure(this.options.tableRow)),e}});var tg=ds;var ng=us;var jS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,FS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,WS=_e.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||Vf(e,"background-color")||e.style.backgroundColor,renderHTML:e=>vr(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",U(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[rt({find:jS,type:this.type})]},addPasteRules(){return[Ze({find:FS,type:this.type})]}}),rg=WS;var og=rg.extend({addAttributes(){let e={...this.parent?.(),mode:{default:"lower",parseHTML:t=>t.getAttribute("data-highlight-mode")==="full"?"full":"lower",renderHTML:({mode:t})=>({"data-highlight-mode":t==="full"?"full":"lower"})}};return this.options.multicolor?{...e,color:{...e.color,renderHTML:({color:t})=>t?{"data-color":t,style:`--showai-highlight-color: ${t}`}:{}}}:e}});var KS=se.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!vr(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),ig=KS;var sg=se.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new W({view(e){let t=e.dom.ownerDocument,n=t.defaultView,r=()=>{let o=t.createEvent("Event");o.initEvent("dragleave",!1,!1),e.dom.dispatchEvent(o)};return t.addEventListener("drop",r,!0),t.addEventListener("dragend",r,!0),n?.addEventListener("blur",r),{destroy(){t.removeEventListener("drop",r,!0),t.removeEventListener("dragend",r,!0),n?.removeEventListener("blur",r)}}}})]}});var Lr=be(tn(),1);var xe=be(Xe(),1);function lg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,Lr.useContext)(Do),s=di({editor:n,selector:({editor:l})=>l.isEditable});return(0,xe.jsx)(Sr,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(Bs(l.target,l.clientX,l.clientY)){let u=Mr(n.state);u&&n.view.dispatch(u);return}let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(Bs(l.target,l.clientX,l.clientY)||l.target.closest('[data-text-selection="true"]')){l.stopPropagation();return}let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:i({kind:e.attrs.kind,data:e.attrs.data,onChange:l=>{n.isEditable&&t({data:l})},readOnly:!s})})}var hc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],mc=["sage","sand","blue","rose"];function ag({node:e,updateAttributes:t,editor:n}){let r=Fe($e),o=di({editor:n,selector:({editor:i})=>i.isEditable});return(0,xe.jsxs)(Sr,{style:Nn(e.attrs.componentStyle),className:`document-callout tone-${e.attrs.tone}`,"data-block-id":e.attrs.id??void 0,children:[(0,xe.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,xe.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>t({icon:hc[(hc.indexOf(e.attrs.icon)+1)%hc.length]}),children:e.attrs.icon}),o&&(0,xe.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>t({tone:mc[(mc.indexOf(e.attrs.tone)+1)%mc.length]})})]}),(0,xe.jsxs)("div",{children:[e.attrs.title&&(0,xe.jsx)("strong",{children:e.attrs.title}),(0,xe.jsx)(oa,{className:"callout-content"})]})]})}function cg({node:e,updateAttributes:t,editor:n}){let r=Fe($e),o=di({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,Lr.useState)(!!e.attrs.open);return(0,Lr.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]),(0,xe.jsxs)(Sr,{style:Nn(e.attrs.componentStyle),className:`document-toggle${i?" is-open":""}`,"data-block-id":e.attrs.id??void 0,children:[(0,xe.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,xe.jsx)("button",{"aria-label":r(i?"toggle.collapse":"toggle.expand"),"aria-expanded":i,onClick:()=>{s(!i),n.isEditable&&t({open:!i})},children:(0,xe.jsx)(Co,{size:16})}),o?(0,xe.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:e.attrs.title,onChange:l=>t({title:l.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,xe.jsx)("span",{children:e.attrs.title})]}),(0,xe.jsx)("div",{className:"toggle-body",hidden:!i,children:(0,xe.jsx)(oa,{})})]})}function ug({node:e,updateAttributes:t,editor:n,selected:r}){let o=Fe($e),i=e.type.name==="mathBlock"||e.attrs.display;return(0,xe.jsxs)(Sr,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,xe.jsx)("span",{dangerouslySetInnerHTML:{__html:Qc(e.attrs.latex,i)}}),r&&n.isEditable&&(0,xe.jsx)("input",{"aria-label":o("math.source"),value:e.attrs.latex,onChange:s=>t({latex:s.target.value}),onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),n.commands.focus())}})]})}function dg({node:e}){return(0,xe.jsx)(Sr,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,xe.jsx)(lu,{attrs:e.attrs})})}var hg=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","widget","mathInline","mathBlock"],ks=new ne("showaiBlockIds");function US(e){let t=new Set([...hg,"region","richText","pageModule"]);return new W({key:ks,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta(ks)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!t.has(l.type.name))return;let u=l.attrs.id;if(typeof u=="string"&&u.trim()&&!i.has(u)){i.add(u);return}let c;do c=globalThis.crypto.randomUUID();while(i.has(c));i.add(c),s.setNodeAttribute(a,"id",c)}),s.docChanged?s.setMeta(ks,!0).setMeta("addToHistory",!1):null}})}var qS=se.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...hg,"region","richText","pageModule"],attributes:{id:{default:null,parseHTML:e=>e.getAttribute("data-block-id"),renderHTML:e=>typeof e.id=="string"&&e.id.trim()?{"data-block-id":e.id}:{}}}}]},addProseMirrorPlugins(){return[US(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(ks,!0).setMeta("addToHistory",!1))}}),GS=ce.create({name:"widget",group:"block",atom:!0,draggable:!0,addAttributes(){return{kind:{default:"chart"},data:{default:{},parseHTML:e=>{let t=e.getAttribute("data-widget-content");if(!t)return{};try{return JSON.parse(t)}catch{return{}}},renderHTML:e=>({"data-widget-content":JSON.stringify(e.data)})}}},parseHTML:()=>[{tag:"div[data-showai-widget]"}],renderHTML:({HTMLAttributes:e})=>["div",U(e,{"data-showai-widget":""})],addNodeView:()=>Er(lg)}),JS=ce.create({name:"callout",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({icon:{default:"\u{1F4A1}"},tone:{default:"sage"},title:{default:""}}),parseHTML:()=>[{tag:"aside[data-callout]"}],renderHTML:({HTMLAttributes:e})=>["aside",U(e,{"data-callout":""}),0],addNodeView:()=>Er(ag)}),XS=ce.create({name:"toggle",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({title:{default:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A"},open:{default:!0}}),parseHTML:()=>[{tag:"section[data-toggle]"}],renderHTML:({HTMLAttributes:e})=>["section",U(e,{"data-toggle":""}),0],addNodeView:()=>Er(cg)}),YS=ce.create({name:"richText",priority:50,group:"block",content:"block*",defining:!0,addAttributes:()=>({id:{default:null},name:{default:"\u5BCC\u6587\u672C"},data:{default:{},parseHTML:e=>JSON.parse(e.getAttribute("data-rich-text-settings")||"{}"),renderHTML:()=>({})}}),parseHTML:()=>[{tag:'div[data-component-kind="text"]'},{tag:'div[data-page-flow="richText"]'}],renderHTML:({node:e,HTMLAttributes:t})=>["div",U(t,{"data-component-kind":"text","data-rich-text-settings":JSON.stringify(e.attrs.data),class:"page-document-flow rich-text-component",style:Object.entries(Nn(e.attrs.data)).filter(([,n])=>n!==void 0).map(([n,r])=>`${n.replace(/[A-Z]/g,o=>"-"+o.toLowerCase())}:${typeof r=="number"?`${r}px`:r}`).join(";")}),0]}),QS=_e.create({name:"textStyle",addAttributes:()=>Object.fromEntries(["color","fontFamily","fontSize"].map(e=>[e,{default:null,parseHTML:t=>t.style[e],renderHTML:t=>t[e]?{style:`${e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}: ${t[e]}`}:{}}])),parseHTML:()=>[{tag:"span[style]"}],renderHTML:({HTMLAttributes:e})=>["span",U(e),0]}),fg=e=>ce.create({name:e?"mathInline":"mathBlock",group:e?"inline":"block",inline:e,atom:!0,addAttributes:()=>({latex:{default:""},display:{default:!e}}),parseHTML:()=>[{tag:e?"span[data-math]":"div[data-math]"}],renderHTML:({node:t,HTMLAttributes:n})=>[e?"span":"div",{...n,"data-math":t.attrs.latex}],addNodeView:()=>Er(ug)}),pg=tr($e);function mg(e={}){return[ZS,YS,QS,fg(!0),fg(!1),qS.configure({readOnly:e.readOnly??!1}),sg,mm.configure({trailingNode:e.trailingNode===!1?!1:{},heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:e.readOnly??!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}},codeBlock:!1}),jm,Fm.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?pg("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??pg("placeholderDefault"),includeChildren:!1}),Wm.extend({addNodeView:()=>Er(dg)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),eg.configure({table:{resizable:!0,View:gc}}),th,tg,ng.configure({nested:!0}),og.configure({multicolor:!0}),ig.configure({types:["heading","paragraph"]}),JS,XS,GS]}var ZS=se.create({name:"showaiContentAttributes",addGlobalAttributes(){let e=t=>({default:null,parseHTML:n=>{let r=n.getAttribute(`data-content-${t.toLowerCase()}`);if(r===null)return null;try{return t==="title"?r:JSON.parse(r)}catch{return null}},renderHTML:n=>n[t]==null?{}:{[`data-content-${t.toLowerCase()}`]:t==="title"?String(n[t]):JSON.stringify(n[t]),...t==="componentStyle"?{style:Object.entries({...Nn(n[t]),borderTopColor:n[t]?.color}).filter(([,r])=>r!==void 0).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${typeof o=="number"?`${o}px`:o}`).join(";")}:{}}});return[{types:["image","codeBlock","table","callout","toggle","horizontalRule"],attributes:{componentStyle:e("componentStyle")}},{types:["image"],attributes:Object.fromEntries(["caption","fit","nativeInk","width","height","align"].map(t=>[t,e(t)]))},{types:["table"],attributes:{title:e("title")}}]}}),gc=class extends pc{constructor(...t){super(...t),this.syncMetadata()}syncMetadata(){let t=Nn(this.node.attrs.componentStyle);this.dom.style.cssText="",Object.assign(this.dom.style,Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,o])=>[r,typeof o=="number"?`${o}px`:o]))),this.node.attrs.id&&(this.table.dataset.blockId=this.node.attrs.id);let n=this.node.attrs.title;if(n){let r=this.table.caption??this.table.createCaption();r.textContent=n}else this.table.caption?.remove();this.dom.tabIndex=0}update(t){return super.update(t)?(this.syncMetadata(),!0):!1}};var k=be(Xe(),1),gg=new WeakSet,bg=tr($e);function Ot({label:e,children:t,onClick:n,active:r,disabled:o}){return(0,k.jsx)("button",{type:"button",className:`editor-tool${r?" is-active":""}`,"aria-label":e,title:e,"aria-pressed":r,disabled:o,onMouseDown:i=>i.preventDefault(),onClick:n,children:t})}function e1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function yg(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)}function wg(e){return e.startsWith("page-tail-")}function bc(e,t){let n=e.view.coordsAtPos(Math.min(t,e.state.doc.content.size));return{left:Math.max(12,Math.min(n.left,window.innerWidth-340)),top:Math.max(70,Math.min(n.bottom+8,window.innerHeight-370))}}function t1({content:e,onChange:t,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:u}){let c=Fe($e),d=(0,$.useRef)(t),f=(0,$.useId)();d.current=t;let p=(0,$.useRef)(null),h=(0,$.useRef)(null),g=(0,$.useRef)(null),m=(0,$.useRef)(null),b=(0,$.useRef)(null),v=(0,$.useRef)([]),S=(0,$.useRef)(()=>{}),C=(0,$.useRef)(0),M=(0,$.useRef)(null),[T,E]=(0,$.useState)(null),{useCatalog:B,registerComponent:oe,assistant:Q}=(0,$.useContext)(Do),me=B(!!T),[it,Ve]=(0,$.useState)(!1),Re=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>{Re.current++},[]);let[Me,A]=(0,$.useState)(0),[R,q]=(0,$.useState)(null),[ie,le]=(0,$.useState)(!1),Ie=(0,$.useRef)(null),gt=(0,$.useRef)(ie);gt.current=ie;let Dt=(0,$.useRef)(0),je=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>cancelAnimationFrame(Dt.current),[]);let Oe=(0,$.useCallback)(()=>{Ie.current!==null&&(clearTimeout(Ie.current),Ie.current=null)},[]),Ir=(0,$.useCallback)(()=>{Ie.current===null&&(Ie.current=setTimeout(()=>{Ie.current=null;let y=p.current?.querySelector(".block-handle");gt.current||M.current!==null||y?.contains(document.activeElement)||q(null)},450))},[]);(0,$.useEffect)(()=>Oe,[Oe]);let[Qt,Lt]=(0,$.useState)(!1),[yn,ct]=(0,$.useState)(!1),[Ce,tt]=(0,$.useState)(null),[wn,kn]=(0,$.useState)(""),[Je,Zt]=(0,$.useState)(""),[kt,V]=(0,$.useState)(null),It=(0,$.useRef)(null),ke=(0,$.useRef)(!1),[,ge]=(0,$.useState)(0),vt=(0,$.useRef)(null);m.current=T,C.current=Me;let Pt=(0,$.useMemo)(()=>[...mg({placeholder:({empty:y})=>bg(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,$.useLayoutEffect)(()=>{if(!ie)return;let y=p.current,x=y?.querySelector(".block-menu"),D=y?.querySelector(".block-handle");if(!x||!D)return;let F=()=>{let X=D.getBoundingClientRect(),pe=x.getBoundingClientRect();Object.assign(x.style,{position:"fixed",left:`${Math.max(12,Math.min(X.right,window.innerWidth-pe.width-12))}px`,top:`${Math.max(12,Math.min(X.top,window.innerHeight-pe.height-12))}px`})};F();let K=new ResizeObserver(F);return K.observe(x),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{K.disconnect(),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[ie,R?.pos]);let w=yp({retentionKey:u,extensions:Pt,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":bg("documentContent"),spellcheck:"false"},handleKeyDown:(y,x)=>{if(x.isComposing)return!1;if(x.key==="Escape"&&!m.current&&!y.state.selection.empty)return It.current=`${y.state.selection.from}:${y.state.selection.to}`,V(null),x.preventDefault(),!0;if(!m.current)return!1;if(x.key==="Escape")return vn(),!0;if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let D=v.current.length;return A(F=>D?(F+(x.key==="ArrowDown"?1:-1)+D)%D:0),!0}return x.key==="Enter"&&v.current.length?(S.current(C.current),!0):!1},handleClick:(y,x,D)=>{let F=D.target.closest?.("a[href]");if(!F||!n&&!D.metaKey&&!D.ctrlKey)return!1;let K=F.getAttribute("href")??"";return yg(K)&&(K.startsWith("#")?document.getElementById(K.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(K,"_blank","noopener,noreferrer")),!0},handlePaste:(y,x)=>{let D=[...x.clipboardData?.files??[]].filter(F=>F.type.startsWith("image/"));return D.length?(x.preventDefault(),I(D),!0):!1}},onUpdate:({editor:y,transaction:x})=>d.current(la(y.state.doc),{separateHistory:!!x.getMeta(Jn),historyGroup:x.getMeta(ru)})});(0,$.useEffect)(()=>w?ou(w):void 0,[w]),(0,$.useEffect)(()=>{w&&o?.(w)},[w,o]),(0,$.useEffect)(()=>{w&&w.isEditable===n&&(w.setEditable(!n,!1),w.view.dispatch(w.state.tr.setMeta("editableChanged",!0))),ge(y=>y+1),n&&(E(null),q(null),le(!1),Lt(!1),ct(!1),tt(null),V(null))},[w,n]),(0,$.useLayoutEffect)(()=>{if(!w)return;let y,x=()=>{if(w.isDestroyed)return;if(w.view.composing){y=setTimeout(x,25);return}let F=xp(w.state,e);if(!F)return;let K=w.state.selection instanceof H&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,X=w.state.selection instanceof re?w.state.selection:null;if(w.view.dispatch(F),X){let pe=Zp(w.state.doc,X);pe&&w.view.dispatch(w.state.tr.setSelection(pe))}if(K){let pe;if(w.state.doc.descendants((we,Z)=>{we.type.name==="widget"&&we.attrs.id===K&&(pe=Z)}),pe!==void 0)w.commands.setNodeSelection(pe);else{let we=Mr(w.state);we&&w.view.dispatch(we)}}},D=()=>{y=setTimeout(x,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",D):x(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",D)}},[e,w]),(0,$.useEffect)(()=>{if(!Ce)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),x=D=>{if(D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),tt(null),w?.commands.focus()),D.key!=="Tab")return;let F=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),K=F[0],X=F[F.length-1];D.shiftKey&&document.activeElement===K?(D.preventDefault(),X?.focus()):!D.shiftKey&&document.activeElement===X&&(D.preventDefault(),K?.focus())};return document.addEventListener("keydown",x,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",x,!0)}},[!!Ce,w]),(0,$.useEffect)(()=>{if(!w||n)return;let y=()=>{let D=Mr(w.state);D&&w.view.dispatch(D)};!gg.has(w)&&!bp(w)&&(gg.add(w),w.isInitialized?y():w.on("create",y));let x=D=>{if(D.button!==0||!(D.target instanceof Element))return;let F=D.target,K=F.closest(".document-widget");if(K&&w.view.dom.contains(K)||!K&&F.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let X=Mr(w.state);if(!X)return;let pe=document.activeElement;pe instanceof HTMLElement&&w.view.dom.contains(pe)&&pe.blur(),w.view.dispatch(X),w.view.dom.contains(F)&&!F.closest("[data-block-id]")&&D.preventDefault()};return document.addEventListener("pointerdown",x,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",x,!0)}},[w,n]),(0,$.useEffect)(()=>{if(!T?.manual)return;let y=requestAnimationFrame(()=>g.current?.focus());return()=>cancelAnimationFrame(y)},[T?.manual]),(0,$.useEffect)(()=>{if(!Qt&&!yn&&!ie)return;let y=x=>{x.key==="Escape"&&(x.preventDefault(),Lt(!1),ct(!1),le(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[Qt,yn,ie,w]),(0,$.useEffect)(()=>{if(!Je)return;let y=window.setTimeout(()=>Zt(""),4500);return()=>window.clearTimeout(y)},[Je]),(0,$.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&ge(Sn=>Sn+1),!w.isEditable)return;let{selection:Z}=w.state,{$from:Pe,from:Cn,to:en,empty:xn}=Z;if((xn||It.current&&It.current!==`${Cn}:${en}`)&&(It.current=null),!m.current?.manual){let Sn=Pe.parent.isTextblock?Pe.parent.textBetween(0,Pe.parentOffset,`
|
|
154
|
-
`):"",En=xn&&Sn.match(/^\/([^\n/]*)$/);if(En){let vc=Cn-En[0].length;b.current!==`${vc}:${en}:${En[1]}`&&(b.current=null,E({from:vc,to:en,query:En[1],...bc(w,Cn)}))}else E(null),b.current=null}if(!xn&&It.current!==`${Cn}:${en}`&&(w.isFocused||ke.current)&&!w.isActive("codeBlock")&&!w.isActive("widget")&&!w.isActive("pageModule")){let Sn=w.view.coordsAtPos(Cn),En=w.view.coordsAtPos(en);V({left:(Sn.left+En.right)/2,top:Sn.top,bottom:Math.max(Sn.bottom,En.bottom)})}else V(null)},x=Z=>Z instanceof Element&&Z.closest(".editor-bubble")?.id===f,D=Z=>{x(Z.relatedTarget)&&(ke.current=!0)},F=()=>{ke.current=!1,V(null)},K=Z=>{ke.current=x(Z.target),!ke.current&&(!(Z.target instanceof Node)||!w.view.dom.contains(Z.target))&&F()},X=({event:Z})=>{!ke.current&&!x(Z.relatedTarget)&&F()},pe=Z=>{x(Z.target)||F()},we=Z=>{!(Z.target instanceof Element)||!Z.target.contains(w.view.dom)||(V(null),E(null),le(!1),q(null))};return w.on("transaction",y),w.on("focus",y),w.on("blur",X),w.view.dom.addEventListener("blur",D,!0),document.addEventListener("pointerdown",K,!0),document.addEventListener("focusin",K,!0),w.view.dom.addEventListener("contextmenu",F),window.addEventListener("scroll",pe,!0),window.addEventListener("resize",y),window.addEventListener("showai:viewport-change",we),()=>{w.off("transaction",y),w.off("focus",y),w.off("blur",X),w.view.dom.removeEventListener("blur",D,!0),document.removeEventListener("pointerdown",K,!0),document.removeEventListener("focusin",K,!0),w.view.dom.removeEventListener("contextmenu",F),window.removeEventListener("scroll",pe,!0),window.removeEventListener("resize",y),window.removeEventListener("showai:viewport-change",we)}},[w,f,r]),(0,$.useEffect)(()=>A(0),[T?.query]),(0,$.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[Me]);function vn(){let y=m.current;y&&!y.manual&&(b.current=`${y.from}:${y.to}:${y.query}`),m.current=null,E(null)}let O=(0,$.useCallback)(y=>{w&&(vt.current={from:w.state.selection.from,to:w.state.selection.to},tt({type:y,value:y==="link"?w.getAttributes("link").href??"":"",alt:""}),kn(""),ct(!1),V(null))},[w]);async function I(y,x=!1){if(!w||!w.isEditable)return;x&&vt.current&&w.commands.setTextSelection(vt.current);let D=w.state.selection.getBookmark(),F=({transaction:K})=>{D=D.map(K.mapping)};w.on("transaction",F);for(let K of y){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(K.type)){Zt(c("notice.imageTypes"));continue}if(K.size>Ds.resourceBytes){Zt(c("notice.imageTooLarge",{name:K.name,size:Ls(K.size),limit:Ls(Ds.resourceBytes)}));continue}let X;try{X=await new Promise((we,Z)=>{let Pe=new FileReader;Pe.onload=()=>we(String(Pe.result)),Pe.onerror=()=>Z(Pe.error),Pe.onabort=()=>Z(new Error(c("notice.readCancelled"))),Pe.readAsDataURL(K)})}catch{Zt(c("notice.imageUnreadable",{name:K.name}));continue}if(w.isDestroyed||!w.isEditable)break;let pe=D.resolve(w.state.doc);w.view.dispatch(w.state.tr.setSelection(pe)),w.chain().focus().setImage({src:X,alt:K.name}).run(),D=w.state.selection.getBookmark()}w.off("transaction",F),tt(null)}let G=(0,$.useMemo)(()=>[{id:"text",title:c("block.text"),keywords:`text paragraph ${c("block.textKeywords")}`,icon:(0,k.jsx)(Mo,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(y=>({id:`heading-${y}`,title:c("block.heading",{level:y}),keywords:`heading h${y} ${c("block.headingKeywords")}`,icon:y===1?(0,k.jsx)(Ic,{size:20}):y===2?(0,k.jsx)(Pc,{size:20}):(0,k.jsx)($c,{size:20}),group:c("group.basic"),run:x=>{x.chain().focus().setHeading({level:y}).run()}})),{id:"bullet",title:c("block.bullet"),keywords:`bullet list ${c("block.bulletKeywords")}`,icon:(0,k.jsx)(Ss,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBulletList().run()}},{id:"ordered",title:c("block.ordered"),keywords:`ordered numbered list ${c("block.orderedKeywords")}`,icon:(0,k.jsx)(xs,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleOrderedList().run()}},{id:"todo",title:c("block.todo"),keywords:`todo task check ${c("block.todoKeywords")}`,icon:(0,k.jsx)(As,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleTaskList().run()}},{id:"quote",title:c("block.quote"),keywords:`blockquote quote ${c("block.quoteKeywords")}`,icon:(0,k.jsx)(Es,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBlockquote().run()}},{id:"callout",title:c("block.callout"),keywords:`callout note ${c("block.calloutKeywords")}`,icon:(0,k.jsx)(Hc,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().insertContent({type:"callout",attrs:{icon:"\u{1F4A1}",tone:"sage"},content:[{type:"paragraph",content:[{type:"text",text:"\u5728\u8FD9\u91CC\u8BB0\u5F55\u4E00\u4E2A\u503C\u5F97\u6CE8\u610F\u7684\u53D1\u73B0\u3002"}]}]}).run()}},{id:"toggle",title:c("block.toggle"),keywords:`toggle details ${c("block.toggleKeywords")}`,icon:(0,k.jsx)(Co,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"divider",title:c("block.divider"),keywords:`divider hr ${c("block.dividerKeywords")}`,icon:(0,k.jsx)(_c,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setHorizontalRule().run()}},{id:"image",title:c("block.image"),keywords:`image photo ${c("block.imageKeywords")}`,icon:(0,k.jsx)(xo,{size:20}),group:c("group.rich"),run:()=>O("image")},{id:"code",title:c("block.code"),keywords:`code snippet ${c("block.codeKeywords")}`,icon:(0,k.jsx)(Ac,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().toggleCodeBlock().run()}},{id:"table",title:c("block.table"),keywords:`table ${c("block.tableKeywords")}`,icon:(0,k.jsx)(Ts,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...me.items.filter(y=>!("kind"in y&&Is[y.kind])&&(!("kind"in y&&y.insertion)||!!i)).map(y=>({id:"catalog:"+("kind"in y?y.kind:`${y.id}@${y.version}#${y.integrity}`),title:me.displayName(y),keywords:`${"kind"in y?y.kind:y.id} ${y.name} ${y.description} ${me.displayDescription(y)}`,icon:(0,k.jsx)(Vc,{size:20}),group:c("group.components"),component:y,run:()=>{}}))],[O,i,me.items,me.displayName,me.displayDescription,c]),te=G.filter(y=>`${y.title} ${y.keywords}`.toLowerCase().includes(T?.query.toLowerCase()??""));v.current=te;let Ae=async y=>{let x=m.current,D=v.current[y];if(!(!w||!x||!D||it)){if(D.component){let F=w.state.doc,K=++Re.current;Ve(!0);try{let X=await me.resolve(D.component);if(K!==Re.current||w.isDestroyed||m.current!==x||!w.state.doc.eq(F))return;if(E(null),m.current=null,X.component&&oe(X.component),X.native&&i){let pe=w.state.tr.delete(x.from,x.to);i(X.kind,X.data,hu(pe.doc,x.from))}else w.chain().focus().deleteRange({from:x.from,to:x.to}).insertContent({...Is[X.kind]?Zc(X.kind,X.data):{type:"widget",attrs:{kind:X.kind,data:X.data}}}).run()}catch(X){Zt(X.message)}finally{K===Re.current&&Ve(!1)}return}E(null),m.current=null,x.from!==x.to?w.chain().focus().deleteRange({from:x.from,to:x.to}).run():w.commands.focus(),D.run(w)}};S.current=Ae;let ut=()=>{if(!w)return;b.current=null;let{from:y,to:x}=w.state.selection;E({from:y,to:x,query:"",manual:!0,...bc(w,y)}),A(0),ct(!1)},vs=()=>{if(!w||!R)return;let y=R.pos+R.size;w.chain().focus().insertContentAt(y,{type:"paragraph"}).setTextSelection(y+1).run(),E({from:y+1,to:y+1,query:"",manual:!0,...bc(w,y+1)}),le(!1)};function vo(y,x){if(!w)return;let D=[];w.state.doc.forEach((Z,Pe)=>D.push({pos:Pe,size:Z.nodeSize}));let F=D.findIndex(Z=>Z.pos===y),K=D[F+x],X=w.state.doc.nodeAt(y);if(!K||!X)return;let pe=x===-1?K.pos:K.pos+K.size-X.nodeSize,we=w.state.tr.delete(y,y+X.nodeSize).insert(pe,X);we.setSelection(J.near(we.doc.resolve(pe+1))),w.view.dispatch(we),w.view.focus(),le(!1),q(null)}function kg(y){if(!w||!w.isEditable)return;let x=M.current;if(x!==null){y.preventDefault(),y.stopPropagation(),M.current=null,q(null);let F=w.state.doc.nodeAt(x);if(!F)return;let K=w.state.doc.content.size,X=!1;if(w.state.doc.forEach((pe,we)=>{let Z=w.view.nodeDOM(we);if(!(Z instanceof HTMLElement)||X)return;let Pe=Z.getBoundingClientRect();y.clientY<Pe.top+Pe.height/2&&(K=we,X=!0)}),K!==x&&K!==x+F.nodeSize){let pe=K>x?K-F.nodeSize:K,we=w.state.tr.delete(x,x+F.nodeSize).insert(pe,F);we.setSelection(J.near(we.doc.resolve(pe+1))),w.view.dispatch(we)}return}let D=[...y.dataTransfer.files].filter(F=>F.type.startsWith("image/"));if(D.length){y.preventDefault(),y.stopPropagation();let F=w.view.posAtCoords({left:y.clientX,top:y.clientY});F&&w.commands.setTextSelection(F.pos),I(D)}}if(!w)return(0,k.jsx)("div",{className:"editor-loading","aria-label":c("openingDocument")});let vg=w.isActive("heading")?c("block.heading",{level:w.getAttributes("heading").level}):c("block.text"),wc=kt&&Q?pi(w.state.doc,w.state.selection.from,w.state.selection.to).length:0,kc=(!r||kt)&&(0,k.jsx)(lh,{editor:w,onLink:()=>O("link")});return(0,k.jsxs)("div",{className:`document-editor${n?" is-readonly":""}${r?" is-minimal":""}`,children:[!n&&!r&&(0,k.jsxs)("div",{className:"editor-toolbar",role:"toolbar","aria-label":c("format.toolbar"),children:[(0,k.jsxs)("div",{className:"toolbar-style",children:[(0,k.jsxs)("button",{className:"text-style-button",onMouseDown:y=>y.preventDefault(),onClick:()=>{Lt(!Qt),ct(!1)},"aria-expanded":Qt,children:[vg,(0,k.jsx)(Pr,{size:13})]}),Qt&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Lt(!1)}),(0,k.jsx)("div",{className:"editor-small-menu style-menu",children:G.slice(0,7).map(y=>(0,k.jsxs)("button",{onMouseDown:x=>x.preventDefault(),onClick:()=>{y.run(w),Lt(!1)},children:[y.icon,(0,k.jsx)("span",{children:y.title})]},y.id))})]})]}),(0,k.jsx)("span",{className:"toolbar-divider"}),kc,(0,k.jsx)("span",{className:"toolbar-divider"}),(0,k.jsx)(Ot,{label:c("block.bullet"),active:w.isActive("bulletList"),onClick:()=>w.chain().focus().toggleBulletList().run(),children:(0,k.jsx)(Ss,{size:17})}),(0,k.jsx)(Ot,{label:c("block.todo"),active:w.isActive("taskList"),onClick:()=>w.chain().focus().toggleTaskList().run(),children:(0,k.jsx)(As,{size:16})}),(0,k.jsxs)("div",{className:"toolbar-insert",children:[(0,k.jsx)(Ot,{label:c("format.more"),active:yn,onClick:()=>{ct(!yn),Lt(!1)},children:(0,k.jsx)(nn,{size:17})}),yn&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>ct(!1)}),(0,k.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,k.jsxs)("button",{onClick:ut,children:[(0,k.jsx)(nn,{size:16}),c("insert.content"),(0,k.jsx)("span",{className:"menu-key",children:"/"})]}),(0,k.jsxs)("button",{onClick:()=>{w.chain().focus().toggleOrderedList().run(),ct(!1)},children:[(0,k.jsx)(xs,{size:16}),c("block.ordered")]}),(0,k.jsxs)("button",{onClick:()=>{w.chain().focus().toggleBlockquote().run(),ct(!1)},children:[(0,k.jsx)(Es,{size:16}),c("block.quote")]}),(0,k.jsxs)("button",{onClick:()=>O("image"),children:[(0,k.jsx)(xo,{size:16}),c("insert.image")]}),(0,k.jsxs)("button",{onClick:()=>{w.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),ct(!1)},children:[(0,k.jsx)(Ts,{size:16}),c("insert.table")]}),(0,k.jsx)("div",{className:"menu-rule"}),(0,k.jsxs)("div",{className:"align-tools",children:[(0,k.jsx)(Ot,{label:c("format.alignLeft"),active:w.isActive({textAlign:"left"}),onClick:()=>w.chain().focus().setTextAlign("left").run(),children:(0,k.jsx)(Tn,{size:17})}),(0,k.jsx)(Ot,{label:c("format.alignCenter"),active:w.isActive({textAlign:"center"}),onClick:()=>w.chain().focus().setTextAlign("center").run(),children:(0,k.jsx)(Mn,{size:17})}),(0,k.jsx)(Ot,{label:c("format.alignRight"),active:w.isActive({textAlign:"right"}),onClick:()=>w.chain().focus().setTextAlign("right").run(),children:(0,k.jsx)(An,{size:17})})]})]})]})]}),(0,k.jsx)("div",{className:"toolbar-spacer"}),(0,k.jsx)(Ot,{label:c("format.undo"),disabled:!w.can().undo(),onClick:()=>w.chain().focus().undo().run(),children:(0,k.jsx)(Xc,{size:16})}),(0,k.jsx)(Ot,{label:c("format.redo"),disabled:!w.can().redo(),onClick:()=>w.chain().focus().redo().run(),children:(0,k.jsx)(jc,{size:16})})]}),(0,k.jsxs)("div",{className:"editor-canvas",ref:p,onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.shiftKey&&y.key.toLowerCase()==="k"&&!n&&(y.preventDefault(),y.stopPropagation(),O("link"))},onMouseEnter:Oe,onMouseMove:y=>{if(n||ie||M.current!==null)return;if(y.target.closest(".block-handle")){Oe();return}let x=p.current;x&&y.target.closest(".document-editor")===x.closest(".document-editor")&&(je.current=y.clientY,!Dt.current&&(Dt.current=requestAnimationFrame(()=>{Dt.current=0;let D=p.current;if(!D||M.current!==null||w.isDestroyed)return;let F=je.current,K=D.getBoundingClientRect(),X=K.width/D.offsetWidth||1,pe=null;w.state.doc.forEach((Z,Pe,Cn)=>{let en=w.view.nodeDOM(Pe);if(!(en instanceof HTMLElement))return;let xn=en.getBoundingClientRect();F>=xn.top-3&&F<=xn.bottom+3&&(pe={pos:Pe,size:Z.nodeSize,index:Cn,top:(xn.top-K.top)/X})});let we=pe;we?(Oe(),q(Z=>Z&&Z.pos===we.pos&&Z.size===we.size&&Z.index===we.index&&Math.abs(Z.top-we.top)<.5?Z:we)):Ir()})))},onMouseLeave:Ir,onDragOver:y=>{(M.current!==null||[...y.dataTransfer.types].includes("Files"))&&y.preventDefault()},onDropCapture:kg,children:[(0,k.jsx)(fi,{editor:w}),!n&&(0,k.jsx)(sh,{editor:w}),!n&&R&&(0,k.jsxs)("div",{className:"block-handle",style:{top:R.top},onMouseEnter:Oe,onFocus:Oe,children:[(0,k.jsx)("button",{"aria-label":c("insert.addBelow"),title:c("insert.addContent"),onMouseDown:y=>y.preventDefault(),onClick:vs,children:(0,k.jsx)(nn,{size:15})}),(0,k.jsx)("button",{"aria-label":c("block.handle"),title:c("block.handleTitle"),draggable:!0,onDragStart:y=>{Oe(),M.current=R.pos,y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("application/x-showai-block",String(R.pos));let x=w.view.nodeDOM(R.pos);x instanceof HTMLElement&&y.dataTransfer.setDragImage(x,0,0),le(!1)},onDragEnd:()=>{M.current=null},onClick:()=>le(!ie),children:(0,k.jsx)(Lc,{size:15})}),ie&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>le(!1)}),(0,k.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(w.state.doc.nodeAt(R.pos)?.type.name??"")&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"align-tools",role:"group","aria-label":c("block.style"),children:G.slice(0,7).map((y,x)=>(0,k.jsx)(Ot,{label:y.title,active:x===0?w.state.doc.nodeAt(R.pos)?.type.name==="paragraph":w.state.doc.nodeAt(R.pos)?.attrs.level===x,onClick:()=>{w.chain().focus().setTextSelection(R.pos+1).run(),y.run(w),le(!1)},children:y.icon},y.id))}),(0,k.jsx)("div",{className:"align-tools",children:[["left",c("format.alignLeft"),(0,k.jsx)(Tn,{size:16},"left")],["center",c("format.alignCenter"),(0,k.jsx)(Mn,{size:16},"center")],["right",c("format.alignRight"),(0,k.jsx)(An,{size:16},"right")]].map(([y,x,D])=>(0,k.jsx)(Ot,{label:x,active:w.state.doc.nodeAt(R.pos)?.attrs.textAlign===y,onClick:()=>{w.chain().focus().setTextSelection(R.pos+1).setTextAlign(y).run(),le(!1)},children:D},y))}),(0,k.jsx)("div",{className:"menu-rule"})]}),(0,k.jsx)(pu,{editor:w,position:R.pos}),s&&(0,k.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(R.pos);y&&s(y.toJSON()),le(!1),q(null)},children:[(0,k.jsx)(Oc,{size:15}),c("block.detach")]}),(0,k.jsxs)("button",{disabled:R.index===0,onClick:()=>vo(R.pos,-1),children:[(0,k.jsx)(Sc,{size:15}),c("block.moveUp")]}),(0,k.jsxs)("button",{disabled:R.index===w.state.doc.childCount-1,onClick:()=>vo(R.pos,1),children:[(0,k.jsx)(xc,{size:15}),c("block.moveDown")]}),(0,k.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(R.pos);y&&w.chain().focus().insertContentAt(R.pos+y.nodeSize,y.toJSON()).run(),le(!1)},children:[(0,k.jsx)(Nc,{size:15}),c("block.duplicate")]}),Q&&(0,k.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(R.pos)?.attrs.id,D=y.currentTarget.closest(".block-handle").getBoundingClientRect();le(!1),typeof x=="string"&&!wg(x)&&Q.open({kind:"blocks",blockIds:[x],anchor:{left:D.right+160,top:D.top,bottom:D.bottom}})},children:[(0,k.jsx)(Ms,{size:15}),c("assistant.askBlock")]}),Q&&(0,k.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(R.pos)?.attrs.id,D=y.currentTarget.closest(".block-handle").getBoundingClientRect();le(!1),typeof x=="string"&&!wg(x)&&Q.reference({kind:"blocks",blockIds:[x],anchor:{left:D.right,top:D.top,bottom:D.bottom}})},children:[(0,k.jsx)(Cs,{size:15}),c("assistant.referenceBlock")]}),(0,k.jsx)("div",{className:"menu-rule"}),(0,k.jsxs)("button",{className:"danger",onClick:()=>{w.chain().focus().deleteRange({from:R.pos,to:R.pos+R.size}).run(),le(!1),q(null)},children:[(0,k.jsx)(Eo,{size:15}),c("block.delete")]})]})]})]})]}),!n&&!r&&(0,k.jsxs)("button",{className:"document-add-block",onClick:()=>{w.chain().focus("end").run(),(w.state.selection.$from.parent.type.name!=="paragraph"||w.state.selection.$from.parent.content.size)&&w.chain().insertContentAt(w.state.doc.content.size,{type:"paragraph"}).focus("end").run(),ut()},children:[(0,k.jsx)(nn,{size:15}),(0,k.jsx)("span",{children:c("insert.addContent")}),(0,k.jsx)("kbd",{children:"/"})]}),(0,k.jsx)("input",{ref:h,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"editor-hidden-input",onChange:y=>{let x=y.target.files?.[0];x&&I([x],!0),y.target.value=""}}),Je&&(0,k.jsxs)("div",{className:"editor-notice",role:"status",children:[Je,(0,k.jsx)("button",{"aria-label":c("dismissNotice"),onClick:()=>Zt(""),children:(0,k.jsx)($r,{size:14})})]}),kt&&!n&&(0,k.jsxs)(uu,{id:f,className:"rich-text-selection-toolbar",anchor:kt,viewportTop:Math.max(0,...Array.from(p.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],y=>y.getBoundingClientRect().bottom))+8,onEscape:()=>{ke.current=!1,It.current=`${w.state.selection.from}:${w.state.selection.to}`,w.state.selection instanceof re&&w.view.dispatch(w.state.tr.setSelection(L.near(w.state.selection.$from))),V(null),w.view.focus()},children:[kc,(0,k.jsx)(vi,{editor:w}),Q&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,k.jsxs)("button",{type:"button",className:"editor-bubble-assistant","aria-label":c("assistant.ask"),title:c("assistant.ask"),onClick:()=>{let{from:y,to:x}=w.state.selection,D=kt;ke.current=!1,V(null),Q.open({kind:"text",blockIds:pi(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
|
|
155
|
-
`),anchor:D})},children:[(0,
|
|
156
|
-
`),anchor:D})},children:(0,
|
|
153
|
+
`);return{...a,raw:c}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=$S(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(L.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>jp(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Fp(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vr(e.selection.$from,r=>r.type.name==="table");return Wp(e,t&&(r=>{n&&Ym(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>Up(e,t),addRowAfter:()=>({state:e,dispatch:t})=>qp(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vr(e.selection.$from,r=>r.type.name==="table");return Gp(e,t&&(r=>{n&&Ym(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>Yp(e,t),mergeCells:()=>({state:e,dispatch:t})=>ba(e,t),splitCell:()=>({state:e,dispatch:t})=>ya(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Tr("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Tr("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Xp(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>ba(e,t)?!0:ya(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Jp(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>wa(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>wa(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ga(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let r=oe.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ws,"Mod-Backspace":ws,Delete:ws,"Mod-Delete":ws}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Zp({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],th({allowTableNodeSelection:this.options.allowTableNodeSelection}),KS()]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:n,view:r,HTMLAttributes:o})=>{let i=U(this.options.HTMLAttributes,o);return new t(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:de(P(e,"tableRole",t))}}}),og=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(US.configure(this.options.table)),this.options.tableCell!==!1&&e.push(OS.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(DS.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(LS.configure(this.options.tableRow)),e}});var ig=fs;var sg=ds;var qS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,GS=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,JS=Ve.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||Kf(e,"background-color")||e.style.backgroundColor,renderHTML:e=>Sr(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",U(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[rt({find:qS,type:this.type})]},addPasteRules(){return[Ze({find:GS,type:this.type})]}}),lg=JS;var ag=lg.extend({addAttributes(){let e={...this.parent?.(),mode:{default:"lower",parseHTML:t=>t.getAttribute("data-highlight-mode")==="full"?"full":"lower",renderHTML:({mode:t})=>({"data-highlight-mode":t==="full"?"full":"lower"})}};return this.options.multicolor?{...e,color:{...e.color,renderHTML:({color:t})=>t?{"data-color":t,style:`--showai-highlight-color: ${t}`}:{}}}:e}});var XS=le.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Sr(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),cg=XS;var ug=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new K({view(e){let t=e.dom.ownerDocument,n=t.defaultView,r=()=>{let o=t.createEvent("Event");o.initEvent("dragleave",!1,!1),e.dom.dispatchEvent(o)};return t.addEventListener("drop",r,!0),t.addEventListener("dragend",r,!0),n?.addEventListener("blur",r),{destroy(){t.removeEventListener("drop",r,!0),t.removeEventListener("dragend",r,!0),n?.removeEventListener("blur",r)}}}})]}});var wn=ye(tn(),1);var pe=ye(Xe(),1);function dg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,wn.useContext)(Lo),s=ro({editor:n,selector:({editor:l})=>l.isEditable});return(0,pe.jsx)(Jn,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":e.attrs.kind,"data-block-id":e.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(zs(l.target,l.clientX,l.clientY)){let u=Ar(n.state);u&&n.view.dispatch(u);return}let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;if(zs(l.target,l.clientX,l.clientY)||l.target.closest('[data-text-selection="true"]')){l.stopPropagation();return}let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:i({kind:e.attrs.kind,data:e.attrs.data,onChange:l=>{n.isEditable&&t({data:l})},readOnly:!s})})}var hc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],mc=["sage","sand","blue","rose"];function fg({node:e,updateAttributes:t,editor:n}){let r=Be($e),o=ro({editor:n,selector:({editor:i})=>i.isEditable});return(0,pe.jsxs)(Jn,{style:rn(e.attrs.componentStyle),className:`document-callout tone-${e.attrs.tone}`,"data-block-id":e.attrs.id??void 0,children:[(0,pe.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,pe.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>t({icon:hc[(hc.indexOf(e.attrs.icon)+1)%hc.length]}),children:e.attrs.icon}),o&&(0,pe.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>t({tone:mc[(mc.indexOf(e.attrs.tone)+1)%mc.length]})})]}),(0,pe.jsxs)("div",{children:[e.attrs.title&&(0,pe.jsx)("strong",{children:e.attrs.title}),(0,pe.jsx)(fi,{className:"callout-content"})]})]})}function pg({node:e,updateAttributes:t,editor:n}){let r=Be($e),o=ro({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,wn.useState)(!!e.attrs.open);return(0,wn.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]),(0,pe.jsxs)(Jn,{style:rn(e.attrs.componentStyle),className:`document-toggle${i?" is-open":""}`,"data-block-id":e.attrs.id??void 0,children:[(0,pe.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,pe.jsx)("button",{"aria-label":r(i?"toggle.collapse":"toggle.expand"),"aria-expanded":i,onClick:()=>{s(!i),n.isEditable&&t({open:!i})},children:(0,pe.jsx)(xo,{size:16})}),o?(0,pe.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:e.attrs.title,onChange:l=>t({title:l.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,pe.jsx)("span",{children:e.attrs.title})]}),(0,pe.jsx)("div",{className:"toggle-body",hidden:!i,children:(0,pe.jsx)(fi,{})})]})}function hg({node:e,editor:t,getPos:n}){let r=Be($e),o=ro({editor:t,selector:({editor:b})=>b.isEditable}),[i,s]=(0,wn.useState)(0),l=e.childCount,a=Math.min(i,l-1),u=Array.from({length:l},(b,k)=>fu(e.child(k).attrs.title,k)),c=()=>{let b=n();if(typeof b!="number")throw new Error("The stepper is detached.");return b+1},d=b=>{let k=c();for(let C=0;C<b;C+=1)k+=e.child(C).nodeSize;return k};(0,wn.useEffect)(()=>{let b=()=>{let k=n(),C=typeof k=="number"?t.state.doc.nodeAt(k):null;if(!C||C.type.name!=="stepper")return;let{from:x}=t.state.selection;if(x<=k||x>=k+C.nodeSize)return;let E=k+1;for(let A=0;A<C.childCount;A+=1)if(E+=C.child(A).nodeSize,x<E)return s(A)};return t.on("selectionUpdate",b),()=>{t.off("selectionUpdate",b)}},[t,n]);let f=b=>{let{tr:k}=t.state,C=b(k);return t.view.dispatch(k),s(C),C},p=b=>f(k=>(k.setNodeMarkup(d(a),void 0,{...e.child(a).attrs,title:b}),a)),h=()=>{f(b=>{let{schema:k}=t.state,C=d(a)+e.child(a).nodeSize;return b.insert(C,k.nodes.step.create({title:""},k.nodes.paragraph.create())),b.setSelection(L.create(b.doc,C+2)),a+1}),t.view.focus()},g=()=>f(b=>{let k=d(a);return b.delete(k,k+e.child(a).nodeSize),Math.max(0,a-1)}),m=b=>f(k=>{let C=a+b,x=e.child(a),E=d(a),A=b<0?d(C):d(C)+e.child(C).nodeSize;return k.delete(E,E+x.nodeSize),k.insert(k.mapping.map(A),x),C});return(0,pe.jsxs)(Jn,{style:rn(e.attrs.componentStyle),className:"document-stepper","data-block-id":e.attrs.id??void 0,children:[(0,pe.jsx)(pu,{titles:u,active:a,onSelect:s}),o&&(0,pe.jsxs)("div",{className:"stepper-edit",contentEditable:!1,children:[(0,pe.jsx)("input",{"aria-label":r("stepper.titleLabel"),placeholder:r("stepper.titlePlaceholder"),value:e.child(a).attrs.title??"",onChange:b=>p(b.target.value)}),(0,pe.jsx)("button",{type:"button",title:r("stepper.moveEarlier"),"aria-label":r("stepper.moveEarlier"),disabled:a===0,onClick:()=>m(-1),children:"\u21A4"}),(0,pe.jsx)("button",{type:"button",title:r("stepper.moveLater"),"aria-label":r("stepper.moveLater"),disabled:a===l-1,onClick:()=>m(1),children:"\u21A6"}),(0,pe.jsx)("button",{type:"button",title:r("stepper.add"),"aria-label":r("stepper.add"),disabled:l>=tu,onClick:h,children:"+"}),(0,pe.jsx)("button",{type:"button",title:r("stepper.remove"),"aria-label":r("stepper.remove"),disabled:l<=1,onClick:g,children:"\xD7"})]}),(0,pe.jsx)(fi,{className:"stepper-steps","data-active":a})]})}function mg({node:e,updateAttributes:t,editor:n,selected:r}){let o=Be($e),i=e.type.name==="mathBlock"||e.attrs.display;return(0,pe.jsxs)(Jn,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,pe.jsx)("span",{dangerouslySetInnerHTML:{__html:Zc(e.attrs.latex,i)}}),r&&n.isEditable&&(0,pe.jsx)("input",{"aria-label":o("math.source"),value:e.attrs.latex,onChange:s=>t({latex:s.target.value}),onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),n.commands.focus())}})]})}function gg({node:e}){return(0,pe.jsx)(Jn,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,pe.jsx)(cu,{attrs:e.attrs})})}var wg=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","mathInline","mathBlock"],vs=new ne("showaiBlockIds");function YS(e){let t=new Set([...wg,"region","richText","pageModule"]);return new K({key:vs,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta(vs)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!t.has(l.type.name))return;let u=l.attrs.id;if(typeof u=="string"&&u.trim()&&!i.has(u)){i.add(u);return}let c;do c=globalThis.crypto.randomUUID();while(i.has(c));i.add(c),s.setNodeAttribute(a,"id",c)}),s.docChanged?s.setMeta(vs,!0).setMeta("addToHistory",!1):null}})}var QS=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...wg,"region","richText","pageModule"],attributes:{id:{default:null,parseHTML:e=>e.getAttribute("data-block-id"),renderHTML:e=>typeof e.id=="string"&&e.id.trim()?{"data-block-id":e.id}:{}}}}]},addProseMirrorPlugins(){return[YS(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(vs,!0).setMeta("addToHistory",!1))}}),ZS=re.create({name:"widget",group:"block",atom:!0,draggable:!0,addAttributes(){return{kind:{default:"chart"},data:{default:{},parseHTML:e=>{let t=e.getAttribute("data-widget-content");if(!t)return{};try{return JSON.parse(t)}catch{return{}}},renderHTML:e=>({"data-widget-content":JSON.stringify(e.data)})}}},parseHTML:()=>[{tag:"div[data-showai-widget]"}],renderHTML:({HTMLAttributes:e})=>["div",U(e,{"data-showai-widget":""})],addNodeView:()=>Xn(dg)}),e1=re.create({name:"callout",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({icon:{default:"\u{1F4A1}"},tone:{default:"sage"},title:{default:""}}),parseHTML:()=>[{tag:"aside[data-callout]"}],renderHTML:({HTMLAttributes:e})=>["aside",U(e,{"data-callout":""}),0],addNodeView:()=>Xn(fg)}),t1=re.create({name:"toggle",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({title:{default:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A"},open:{default:!0}}),parseHTML:()=>[{tag:"section[data-toggle]"}],renderHTML:({HTMLAttributes:e})=>["section",U(e,{"data-toggle":""}),0],addNodeView:()=>Xn(pg)}),n1=re.create({name:"stepper",group:"block",content:"step+",defining:!0,draggable:!0,isolating:!0,parseHTML:()=>[{tag:"section[data-stepper]"}],renderHTML:({HTMLAttributes:e})=>["section",U(e,{"data-stepper":""}),0],addNodeView:()=>Xn(hg)}),r1=re.create({name:"step",content:"block+",defining:!0,isolating:!0,addAttributes:()=>({title:{default:""}}),parseHTML:()=>[{tag:"section[data-step]"}],renderHTML:({HTMLAttributes:e})=>["section",U(e,{"data-step":""}),0]}),o1=re.create({name:"richText",priority:50,group:"block",content:"block*",defining:!0,addAttributes:()=>({id:{default:null},name:{default:"\u5BCC\u6587\u672C"},data:{default:{},parseHTML:e=>JSON.parse(e.getAttribute("data-rich-text-settings")||"{}"),renderHTML:()=>({})}}),parseHTML:()=>[{tag:'div[data-component-kind="text"]'},{tag:'div[data-page-flow="richText"]'}],renderHTML:({node:e,HTMLAttributes:t})=>["div",U(t,{"data-component-kind":"text","data-rich-text-settings":JSON.stringify(e.attrs.data),class:"page-document-flow rich-text-component",style:Object.entries(rn(e.attrs.data)).filter(([,n])=>n!==void 0).map(([n,r])=>`${n.replace(/[A-Z]/g,o=>"-"+o.toLowerCase())}:${typeof r=="number"?`${r}px`:r}`).join(";")}),0]}),i1=Ve.create({name:"textStyle",addAttributes:()=>Object.fromEntries(["color","fontFamily","fontSize"].map(e=>[e,{default:null,parseHTML:t=>t.style[e],renderHTML:t=>t[e]?{style:`${e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}: ${t[e]}`}:{}}])),parseHTML:()=>[{tag:"span[style]"}],renderHTML:({HTMLAttributes:e})=>["span",U(e),0]}),bg=e=>re.create({name:e?"mathInline":"mathBlock",group:e?"inline":"block",inline:e,atom:!0,addAttributes:()=>({latex:{default:""},display:{default:!e}}),parseHTML:()=>[{tag:e?"span[data-math]":"div[data-math]"}],renderHTML:({node:t,HTMLAttributes:n})=>[e?"span":"div",{...n,"data-math":t.attrs.latex}],addNodeView:()=>Xn(mg)}),yg=or($e);function kg(e={}){return[s1,o1,i1,bg(!0),bg(!1),QS.configure({readOnly:e.readOnly??!1}),ug,wm.configure({trailingNode:e.trailingNode===!1?!1:{},heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:e.readOnly??!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}},codeBlock:!1}),Um,qm.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?yg("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??yg("placeholderDefault"),includeChildren:!1}),Gm.extend({addNodeView:()=>Xn(gg)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),og.configure({table:{resizable:!0,View:gc}}),ih,ig,sg.configure({nested:!0}),ag.configure({multicolor:!0}),cg.configure({types:["heading","paragraph"]}),e1,t1,n1,r1,ZS]}var s1=le.create({name:"showaiContentAttributes",addGlobalAttributes(){let e=t=>({default:null,parseHTML:n=>{let r=n.getAttribute(`data-content-${t.toLowerCase()}`);if(r===null)return null;try{return t==="title"?r:JSON.parse(r)}catch{return null}},renderHTML:n=>n[t]==null?{}:{[`data-content-${t.toLowerCase()}`]:t==="title"?String(n[t]):JSON.stringify(n[t]),...t==="componentStyle"?{style:Object.entries({...rn(n[t]),borderTopColor:n[t]?.color}).filter(([,r])=>r!==void 0).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${typeof o=="number"?`${o}px`:o}`).join(";")}:{}}});return[{types:["image","codeBlock","table","callout","toggle","stepper","horizontalRule"],attributes:{componentStyle:e("componentStyle")}},{types:["image"],attributes:Object.fromEntries(["caption","fit","nativeInk","width","height","align"].map(t=>[t,e(t)]))},{types:["table"],attributes:{title:e("title")}}]}}),gc=class extends pc{constructor(...t){super(...t),this.syncMetadata()}syncMetadata(){let t=rn(this.node.attrs.componentStyle);this.dom.style.cssText="",Object.assign(this.dom.style,Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,o])=>[r,typeof o=="number"?`${o}px`:o]))),this.node.attrs.id&&(this.table.dataset.blockId=this.node.attrs.id);let n=this.node.attrs.title;if(n){let r=this.table.caption??this.table.createCaption();r.textContent=n}else this.table.caption?.remove();this.dom.tabIndex=0}update(t){return super.update(t)?(this.syncMetadata(),!0):!1}};var v=ye(Xe(),1),vg=new WeakSet,Cg=or($e);function Ot({label:e,children:t,onClick:n,active:r,disabled:o}){return(0,v.jsx)("button",{type:"button",className:`editor-tool${r?" is-active":""}`,"aria-label":e,title:e,"aria-pressed":r,disabled:o,onMouseDown:i=>i.preventDefault(),onClick:n,children:t})}function l1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function xg(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)}function Sg(e){return e.startsWith("page-tail-")}function bc(e,t){let n=e.view.coordsAtPos(Math.min(t,e.state.doc.content.size));return{left:Math.max(12,Math.min(n.left,window.innerWidth-340)),top:Math.max(70,Math.min(n.bottom+8,window.innerHeight-370))}}function a1({content:e,onChange:t,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:u}){let c=Be($e),d=(0,$.useRef)(t),f=(0,$.useId)();d.current=t;let p=(0,$.useRef)(null),h=(0,$.useRef)(null),g=(0,$.useRef)(null),m=(0,$.useRef)(null),b=(0,$.useRef)(null),k=(0,$.useRef)([]),C=(0,$.useRef)(()=>{}),x=(0,$.useRef)(0),E=(0,$.useRef)(null),[A,M]=(0,$.useState)(null),{useCatalog:B,registerComponent:ie,assistant:Q}=(0,$.useContext)(Lo),ge=B(!!A),[it,je]=(0,$.useState)(!1),Re=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>{Re.current++},[]);let[Me,T]=(0,$.useState)(0),[R,q]=(0,$.useState)(null),[se,ae]=(0,$.useState)(!1),Ie=(0,$.useRef)(null),gt=(0,$.useRef)(se);gt.current=se;let Dt=(0,$.useRef)(0),Fe=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>cancelAnimationFrame(Dt.current),[]);let Oe=(0,$.useCallback)(()=>{Ie.current!==null&&(clearTimeout(Ie.current),Ie.current=null)},[]),Ir=(0,$.useCallback)(()=>{Ie.current===null&&(Ie.current=setTimeout(()=>{Ie.current=null;let y=p.current?.querySelector(".block-handle");gt.current||E.current!==null||y?.contains(document.activeElement)||q(null)},450))},[]);(0,$.useEffect)(()=>Oe,[Oe]);let[Qt,Lt]=(0,$.useState)(!1),[kn,ct]=(0,$.useState)(!1),[xe,tt]=(0,$.useState)(null),[vn,Cn]=(0,$.useState)(""),[Je,Zt]=(0,$.useState)(""),[kt,F]=(0,$.useState)(null),It=(0,$.useRef)(null),ve=(0,$.useRef)(!1),[,be]=(0,$.useState)(0),vt=(0,$.useRef)(null);m.current=A,x.current=Me;let Pt=(0,$.useMemo)(()=>[...kg({placeholder:({empty:y})=>Cg(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,$.useLayoutEffect)(()=>{if(!se)return;let y=p.current,S=y?.querySelector(".block-menu"),D=y?.querySelector(".block-handle");if(!S||!D)return;let H=()=>{let J=D.getBoundingClientRect(),fe=S.getBoundingClientRect();Object.assign(S.style,{position:"fixed",left:`${Math.max(12,Math.min(J.right,window.innerWidth-fe.width-12))}px`,top:`${Math.max(12,Math.min(J.top,window.innerHeight-fe.height-12))}px`})};H();let j=new ResizeObserver(H);return j.observe(S),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{j.disconnect(),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[se,R?.pos]);let w=Cp({retentionKey:u,extensions:Pt,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":Cg("documentContent"),spellcheck:"false"},handleKeyDown:(y,S)=>{if(S.isComposing)return!1;if(S.key==="Escape"&&!m.current&&!y.state.selection.empty)return It.current=`${y.state.selection.from}:${y.state.selection.to}`,F(null),S.preventDefault(),!0;if(!m.current)return!1;if(S.key==="Escape")return xn(),!0;if(S.key==="ArrowDown"||S.key==="ArrowUp"){S.preventDefault();let D=k.current.length;return T(H=>D?(H+(S.key==="ArrowDown"?1:-1)+D)%D:0),!0}return S.key==="Enter"&&k.current.length?(C.current(x.current),!0):!1},handleClick:(y,S,D)=>{let H=D.target.closest?.("a[href]");if(!H||!n&&!D.metaKey&&!D.ctrlKey)return!1;let j=H.getAttribute("href")??"";return xg(j)&&(j.startsWith("#")?document.getElementById(j.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(j,"_blank","noopener,noreferrer")),!0},handlePaste:(y,S)=>{let D=[...S.clipboardData?.files??[]].filter(H=>H.type.startsWith("image/"));return D.length?(S.preventDefault(),I(D),!0):!1}},onUpdate:({editor:y,transaction:S})=>d.current(la(y.state.doc),{separateHistory:!!S.getMeta(Qn),historyGroup:S.getMeta(iu)})});(0,$.useEffect)(()=>w?su(w):void 0,[w]),(0,$.useEffect)(()=>{w&&o?.(w)},[w,o]),(0,$.useEffect)(()=>{w&&w.isEditable===n&&(w.setEditable(!n,!1),w.view.dispatch(w.state.tr.setMeta("editableChanged",!0))),be(y=>y+1),n&&(M(null),q(null),ae(!1),Lt(!1),ct(!1),tt(null),F(null))},[w,n]),(0,$.useLayoutEffect)(()=>{if(!w)return;let y,S=()=>{if(w.isDestroyed)return;if(w.view.composing){y=setTimeout(S,25);return}let H=Ap(w.state,e);if(!H)return;let j=w.state.selection instanceof _&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,J=w.state.selection instanceof oe?w.state.selection:null;if(w.view.dispatch(H),J){let fe=rh(w.state.doc,J);fe&&w.view.dispatch(w.state.tr.setSelection(fe))}if(j){let fe;if(w.state.doc.descendants((ke,Z)=>{ke.type.name==="widget"&&ke.attrs.id===j&&(fe=Z)}),fe!==void 0)w.commands.setNodeSelection(fe);else{let ke=Ar(w.state);ke&&w.view.dispatch(ke)}}},D=()=>{y=setTimeout(S,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",D):S(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",D)}},[e,w]),(0,$.useEffect)(()=>{if(!xe)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),S=D=>{if(D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),tt(null),w?.commands.focus()),D.key!=="Tab")return;let H=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),j=H[0],J=H[H.length-1];D.shiftKey&&document.activeElement===j?(D.preventDefault(),J?.focus()):!D.shiftKey&&document.activeElement===J&&(D.preventDefault(),j?.focus())};return document.addEventListener("keydown",S,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",S,!0)}},[!!xe,w]),(0,$.useEffect)(()=>{if(!w||n)return;let y=()=>{let D=Ar(w.state);D&&w.view.dispatch(D)};!vg.has(w)&&!vp(w)&&(vg.add(w),w.isInitialized?y():w.on("create",y));let S=D=>{if(D.button!==0||!(D.target instanceof Element))return;let H=D.target,j=H.closest(".document-widget");if(j&&w.view.dom.contains(j)||!j&&H.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let J=Ar(w.state);if(!J)return;let fe=document.activeElement;fe instanceof HTMLElement&&w.view.dom.contains(fe)&&fe.blur(),w.view.dispatch(J),w.view.dom.contains(H)&&!H.closest("[data-block-id]")&&D.preventDefault()};return document.addEventListener("pointerdown",S,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",S,!0)}},[w,n]),(0,$.useEffect)(()=>{if(!A?.manual)return;let y=requestAnimationFrame(()=>g.current?.focus());return()=>cancelAnimationFrame(y)},[A?.manual]),(0,$.useEffect)(()=>{if(!Qt&&!kn&&!se)return;let y=S=>{S.key==="Escape"&&(S.preventDefault(),Lt(!1),ct(!1),ae(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[Qt,kn,se,w]),(0,$.useEffect)(()=>{if(!Je)return;let y=window.setTimeout(()=>Zt(""),4500);return()=>window.clearTimeout(y)},[Je]),(0,$.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&be(Mn=>Mn+1),!w.isEditable)return;let{selection:Z}=w.state,{$from:Pe,from:Sn,to:en,empty:En}=Z;if((En||It.current&&It.current!==`${Sn}:${en}`)&&(It.current=null),!m.current?.manual){let Mn=Pe.parent.isTextblock?Pe.parent.textBetween(0,Pe.parentOffset,`
|
|
154
|
+
`):"",An=En&&Mn.match(/^\/([^\n/]*)$/);if(An){let vc=Sn-An[0].length;b.current!==`${vc}:${en}:${An[1]}`&&(b.current=null,M({from:vc,to:en,query:An[1],...bc(w,Sn)}))}else M(null),b.current=null}if(!En&&It.current!==`${Sn}:${en}`&&(w.isFocused||ve.current)&&!w.isActive("codeBlock")&&!w.isActive("widget")&&!w.isActive("pageModule")){let Mn=w.view.coordsAtPos(Sn),An=w.view.coordsAtPos(en);F({left:(Mn.left+An.right)/2,top:Mn.top,bottom:Math.max(Mn.bottom,An.bottom)})}else F(null)},S=Z=>Z instanceof Element&&Z.closest(".editor-bubble")?.id===f,D=Z=>{S(Z.relatedTarget)&&(ve.current=!0)},H=()=>{ve.current=!1,F(null)},j=Z=>{ve.current=S(Z.target),!ve.current&&(!(Z.target instanceof Node)||!w.view.dom.contains(Z.target))&&H()},J=({event:Z})=>{!ve.current&&!S(Z.relatedTarget)&&H()},fe=Z=>{S(Z.target)||H()},ke=Z=>{!(Z.target instanceof Element)||!Z.target.contains(w.view.dom)||(F(null),M(null),ae(!1),q(null))};return w.on("transaction",y),w.on("focus",y),w.on("blur",J),w.view.dom.addEventListener("blur",D,!0),document.addEventListener("pointerdown",j,!0),document.addEventListener("focusin",j,!0),w.view.dom.addEventListener("contextmenu",H),window.addEventListener("scroll",fe,!0),window.addEventListener("resize",y),window.addEventListener("showai:viewport-change",ke),()=>{w.off("transaction",y),w.off("focus",y),w.off("blur",J),w.view.dom.removeEventListener("blur",D,!0),document.removeEventListener("pointerdown",j,!0),document.removeEventListener("focusin",j,!0),w.view.dom.removeEventListener("contextmenu",H),window.removeEventListener("scroll",fe,!0),window.removeEventListener("resize",y),window.removeEventListener("showai:viewport-change",ke)}},[w,f,r]),(0,$.useEffect)(()=>T(0),[A?.query]),(0,$.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[Me]);function xn(){let y=m.current;y&&!y.manual&&(b.current=`${y.from}:${y.to}:${y.query}`),m.current=null,M(null)}let O=(0,$.useCallback)(y=>{w&&(vt.current={from:w.state.selection.from,to:w.state.selection.to},tt({type:y,value:y==="link"?w.getAttributes("link").href??"":"",alt:""}),Cn(""),ct(!1),F(null))},[w]);async function I(y,S=!1){if(!w||!w.isEditable)return;S&&vt.current&&w.commands.setTextSelection(vt.current);let D=w.state.selection.getBookmark(),H=({transaction:j})=>{D=D.map(j.mapping)};w.on("transaction",H);for(let j of y){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(j.type)){Zt(c("notice.imageTypes"));continue}if(j.size>Ls.resourceBytes){Zt(c("notice.imageTooLarge",{name:j.name,size:Is(j.size),limit:Is(Ls.resourceBytes)}));continue}let J;try{J=await new Promise((ke,Z)=>{let Pe=new FileReader;Pe.onload=()=>ke(String(Pe.result)),Pe.onerror=()=>Z(Pe.error),Pe.onabort=()=>Z(new Error(c("notice.readCancelled"))),Pe.readAsDataURL(j)})}catch{Zt(c("notice.imageUnreadable",{name:j.name}));continue}if(w.isDestroyed||!w.isEditable)break;let fe=D.resolve(w.state.doc);w.view.dispatch(w.state.tr.setSelection(fe)),w.chain().focus().setImage({src:J,alt:j.name}).run(),D=w.state.selection.getBookmark()}w.off("transaction",H),tt(null)}let G=(0,$.useMemo)(()=>[{id:"text",title:c("block.text"),keywords:`text paragraph ${c("block.textKeywords")}`,icon:(0,v.jsx)(Ao,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(y=>({id:`heading-${y}`,title:c("block.heading",{level:y}),keywords:`heading h${y} ${c("block.headingKeywords")}`,icon:y===1?(0,v.jsx)(Pc,{size:20}):y===2?(0,v.jsx)($c,{size:20}):(0,v.jsx)(Bc,{size:20}),group:c("group.basic"),run:S=>{S.chain().focus().setHeading({level:y}).run()}})),{id:"bullet",title:c("block.bullet"),keywords:`bullet list ${c("block.bulletKeywords")}`,icon:(0,v.jsx)(Es,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBulletList().run()}},{id:"ordered",title:c("block.ordered"),keywords:`ordered numbered list ${c("block.orderedKeywords")}`,icon:(0,v.jsx)(Ss,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleOrderedList().run()}},{id:"todo",title:c("block.todo"),keywords:`todo task check ${c("block.todoKeywords")}`,icon:(0,v.jsx)(Ts,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleTaskList().run()}},{id:"quote",title:c("block.quote"),keywords:`blockquote quote ${c("block.quoteKeywords")}`,icon:(0,v.jsx)(Ms,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().toggleBlockquote().run()}},{id:"callout",title:c("block.callout"),keywords:`callout note ${c("block.calloutKeywords")}`,icon:(0,v.jsx)(_c,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().insertContent({type:"callout",attrs:{icon:"\u{1F4A1}",tone:"sage"},content:[{type:"paragraph",content:[{type:"text",text:"\u5728\u8FD9\u91CC\u8BB0\u5F55\u4E00\u4E2A\u503C\u5F97\u6CE8\u610F\u7684\u53D1\u73B0\u3002"}]}]}).run()}},{id:"toggle",title:c("block.toggle"),keywords:`toggle details ${c("block.toggleKeywords")}`,icon:(0,v.jsx)(xo,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"stepper",title:c("block.stepper"),keywords:`stepper steps ${c("block.stepperKeywords")}`,icon:(0,v.jsx)(Sc,{size:20}),group:c("group.basic"),run:y=>{let S={type:"step",content:[{type:"paragraph"}]},{from:D}=y.state.selection;y.chain().focus().insertContent({type:"stepper",content:[S,S]}).command(({tr:H})=>{let j=-1;return H.doc.nodesBetween(Math.max(0,D-1),H.doc.content.size,(J,fe)=>(j<0&&J.type.name==="stepper"&&(j=fe),j<0)),j>=0&&H.setSelection(L.create(H.doc,j+3)),!0}).run()}},{id:"divider",title:c("block.divider"),keywords:`divider hr ${c("block.dividerKeywords")}`,icon:(0,v.jsx)(Vc,{size:20}),group:c("group.basic"),run:y=>{y.chain().focus().setHorizontalRule().run()}},{id:"image",title:c("block.image"),keywords:`image photo ${c("block.imageKeywords")}`,icon:(0,v.jsx)(So,{size:20}),group:c("group.rich"),run:()=>O("image")},{id:"code",title:c("block.code"),keywords:`code snippet ${c("block.codeKeywords")}`,icon:(0,v.jsx)(Tc,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().toggleCodeBlock().run()}},{id:"table",title:c("block.table"),keywords:`table ${c("block.tableKeywords")}`,icon:(0,v.jsx)(Ns,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...ge.items.filter(y=>!("kind"in y&&Ps[y.kind])&&(!("kind"in y&&y.insertion)||!!i)).map(y=>({id:"catalog:"+("kind"in y?y.kind:`${y.id}@${y.version}#${y.integrity}`),title:ge.displayName(y),keywords:`${"kind"in y?y.kind:y.id} ${y.name} ${y.description} ${ge.displayDescription(y)}`,icon:(0,v.jsx)(jc,{size:20}),group:c("group.components"),component:y,run:()=>{}}))],[O,i,ge.items,ge.displayName,ge.displayDescription,c]),te=G.filter(y=>`${y.title} ${y.keywords}`.toLowerCase().includes(A?.query.toLowerCase()??""));k.current=te;let Ae=async y=>{let S=m.current,D=k.current[y];if(!(!w||!S||!D||it)){if(D.component){let H=w.state.doc,j=++Re.current;je(!0);try{let J=await ge.resolve(D.component);if(j!==Re.current||w.isDestroyed||m.current!==S||!w.state.doc.eq(H))return;if(M(null),m.current=null,J.component&&ie(J.component),J.native&&i){let fe=w.state.tr.delete(S.from,S.to);i(J.kind,J.data,yu(fe.doc,S.from))}else w.chain().focus().deleteRange({from:S.from,to:S.to}).insertContent({...Ps[J.kind]?eu(J.kind,J.data):{type:"widget",attrs:{kind:J.kind,data:J.data}}}).run()}catch(J){Zt(J.message)}finally{j===Re.current&&je(!1)}return}M(null),m.current=null,S.from!==S.to?w.chain().focus().deleteRange({from:S.from,to:S.to}).run():w.commands.focus(),D.run(w)}};C.current=Ae;let ut=()=>{if(!w)return;b.current=null;let{from:y,to:S}=w.state.selection;M({from:y,to:S,query:"",manual:!0,...bc(w,y)}),T(0),ct(!1)},Cs=()=>{if(!w||!R)return;let y=R.pos+R.size;w.chain().focus().insertContentAt(y,{type:"paragraph"}).setTextSelection(y+1).run(),M({from:y+1,to:y+1,query:"",manual:!0,...bc(w,y+1)}),ae(!1)};function Co(y,S){if(!w)return;let D=[];w.state.doc.forEach((Z,Pe)=>D.push({pos:Pe,size:Z.nodeSize}));let H=D.findIndex(Z=>Z.pos===y),j=D[H+S],J=w.state.doc.nodeAt(y);if(!j||!J)return;let fe=S===-1?j.pos:j.pos+j.size-J.nodeSize,ke=w.state.tr.delete(y,y+J.nodeSize).insert(fe,J);ke.setSelection(X.near(ke.doc.resolve(fe+1))),w.view.dispatch(ke),w.view.focus(),ae(!1),q(null)}function Eg(y){if(!w||!w.isEditable)return;let S=E.current;if(S!==null){y.preventDefault(),y.stopPropagation(),E.current=null,q(null);let H=w.state.doc.nodeAt(S);if(!H)return;let j=w.state.doc.content.size,J=!1;if(w.state.doc.forEach((fe,ke)=>{let Z=w.view.nodeDOM(ke);if(!(Z instanceof HTMLElement)||J)return;let Pe=Z.getBoundingClientRect();y.clientY<Pe.top+Pe.height/2&&(j=ke,J=!0)}),j!==S&&j!==S+H.nodeSize){let fe=j>S?j-H.nodeSize:j,ke=w.state.tr.delete(S,S+H.nodeSize).insert(fe,H);ke.setSelection(X.near(ke.doc.resolve(fe+1))),w.view.dispatch(ke)}return}let D=[...y.dataTransfer.files].filter(H=>H.type.startsWith("image/"));if(D.length){y.preventDefault(),y.stopPropagation();let H=w.view.posAtCoords({left:y.clientX,top:y.clientY});H&&w.commands.setTextSelection(H.pos),I(D)}}if(!w)return(0,v.jsx)("div",{className:"editor-loading","aria-label":c("openingDocument")});let Mg=w.isActive("heading")?c("block.heading",{level:w.getAttributes("heading").level}):c("block.text"),wc=kt&&Q?hi(w.state.doc,w.state.selection.from,w.state.selection.to).length:0,kc=(!r||kt)&&(0,v.jsx)(dh,{editor:w,onLink:()=>O("link")});return(0,v.jsxs)("div",{className:`document-editor${n?" is-readonly":""}${r?" is-minimal":""}`,children:[!n&&!r&&(0,v.jsxs)("div",{className:"editor-toolbar",role:"toolbar","aria-label":c("format.toolbar"),children:[(0,v.jsxs)("div",{className:"toolbar-style",children:[(0,v.jsxs)("button",{className:"text-style-button",onMouseDown:y=>y.preventDefault(),onClick:()=>{Lt(!Qt),ct(!1)},"aria-expanded":Qt,children:[Mg,(0,v.jsx)(Pr,{size:13})]}),Qt&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Lt(!1)}),(0,v.jsx)("div",{className:"editor-small-menu style-menu",children:G.slice(0,7).map(y=>(0,v.jsxs)("button",{onMouseDown:S=>S.preventDefault(),onClick:()=>{y.run(w),Lt(!1)},children:[y.icon,(0,v.jsx)("span",{children:y.title})]},y.id))})]})]}),(0,v.jsx)("span",{className:"toolbar-divider"}),kc,(0,v.jsx)("span",{className:"toolbar-divider"}),(0,v.jsx)(Ot,{label:c("block.bullet"),active:w.isActive("bulletList"),onClick:()=>w.chain().focus().toggleBulletList().run(),children:(0,v.jsx)(Es,{size:17})}),(0,v.jsx)(Ot,{label:c("block.todo"),active:w.isActive("taskList"),onClick:()=>w.chain().focus().toggleTaskList().run(),children:(0,v.jsx)(Ts,{size:16})}),(0,v.jsxs)("div",{className:"toolbar-insert",children:[(0,v.jsx)(Ot,{label:c("format.more"),active:kn,onClick:()=>{ct(!kn),Lt(!1)},children:(0,v.jsx)(nn,{size:17})}),kn&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>ct(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,v.jsxs)("button",{onClick:ut,children:[(0,v.jsx)(nn,{size:16}),c("insert.content"),(0,v.jsx)("span",{className:"menu-key",children:"/"})]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleOrderedList().run(),ct(!1)},children:[(0,v.jsx)(Ss,{size:16}),c("block.ordered")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleBlockquote().run(),ct(!1)},children:[(0,v.jsx)(Ms,{size:16}),c("block.quote")]}),(0,v.jsxs)("button",{onClick:()=>O("image"),children:[(0,v.jsx)(So,{size:16}),c("insert.image")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),ct(!1)},children:[(0,v.jsx)(Ns,{size:16}),c("insert.table")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("div",{className:"align-tools",children:[(0,v.jsx)(Ot,{label:c("format.alignLeft"),active:w.isActive({textAlign:"left"}),onClick:()=>w.chain().focus().setTextAlign("left").run(),children:(0,v.jsx)(Rn,{size:17})}),(0,v.jsx)(Ot,{label:c("format.alignCenter"),active:w.isActive({textAlign:"center"}),onClick:()=>w.chain().focus().setTextAlign("center").run(),children:(0,v.jsx)(Tn,{size:17})}),(0,v.jsx)(Ot,{label:c("format.alignRight"),active:w.isActive({textAlign:"right"}),onClick:()=>w.chain().focus().setTextAlign("right").run(),children:(0,v.jsx)(Nn,{size:17})})]})]})]})]}),(0,v.jsx)("div",{className:"toolbar-spacer"}),(0,v.jsx)(Ot,{label:c("format.undo"),disabled:!w.can().undo(),onClick:()=>w.chain().focus().undo().run(),children:(0,v.jsx)(Yc,{size:16})}),(0,v.jsx)(Ot,{label:c("format.redo"),disabled:!w.can().redo(),onClick:()=>w.chain().focus().redo().run(),children:(0,v.jsx)(Fc,{size:16})})]}),(0,v.jsxs)("div",{className:"editor-canvas",ref:p,onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.shiftKey&&y.key.toLowerCase()==="k"&&!n&&(y.preventDefault(),y.stopPropagation(),O("link"))},onMouseEnter:Oe,onMouseMove:y=>{if(n||se||E.current!==null)return;if(y.target.closest(".block-handle")){Oe();return}let S=p.current;S&&y.target.closest(".document-editor")===S.closest(".document-editor")&&(Fe.current=y.clientY,!Dt.current&&(Dt.current=requestAnimationFrame(()=>{Dt.current=0;let D=p.current;if(!D||E.current!==null||w.isDestroyed)return;let H=Fe.current,j=D.getBoundingClientRect(),J=j.width/D.offsetWidth||1,fe=null;w.state.doc.forEach((Z,Pe,Sn)=>{let en=w.view.nodeDOM(Pe);if(!(en instanceof HTMLElement))return;let En=en.getBoundingClientRect();H>=En.top-3&&H<=En.bottom+3&&(fe={pos:Pe,size:Z.nodeSize,index:Sn,top:(En.top-j.top)/J})});let ke=fe;ke?(Oe(),q(Z=>Z&&Z.pos===ke.pos&&Z.size===ke.size&&Z.index===ke.index&&Math.abs(Z.top-ke.top)<.5?Z:ke)):Ir()})))},onMouseLeave:Ir,onDragOver:y=>{(E.current!==null||[...y.dataTransfer.types].includes("Files"))&&y.preventDefault()},onDropCapture:Eg,children:[(0,v.jsx)(pi,{editor:w}),!n&&(0,v.jsx)(uh,{editor:w}),!n&&R&&(0,v.jsxs)("div",{className:"block-handle",style:{top:R.top},onMouseEnter:Oe,onFocus:Oe,children:[(0,v.jsx)("button",{"aria-label":c("insert.addBelow"),title:c("insert.addContent"),onMouseDown:y=>y.preventDefault(),onClick:Cs,children:(0,v.jsx)(nn,{size:15})}),(0,v.jsx)("button",{"aria-label":c("block.handle"),title:c("block.handleTitle"),draggable:!0,onDragStart:y=>{Oe(),E.current=R.pos,y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("application/x-showai-block",String(R.pos));let S=w.view.nodeDOM(R.pos);S instanceof HTMLElement&&y.dataTransfer.setDragImage(S,0,0),ae(!1)},onDragEnd:()=>{E.current=null},onClick:()=>ae(!se),children:(0,v.jsx)(Ic,{size:15})}),se&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>ae(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(w.state.doc.nodeAt(R.pos)?.type.name??"")&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"align-tools",role:"group","aria-label":c("block.style"),children:G.slice(0,7).map((y,S)=>(0,v.jsx)(Ot,{label:y.title,active:S===0?w.state.doc.nodeAt(R.pos)?.type.name==="paragraph":w.state.doc.nodeAt(R.pos)?.attrs.level===S,onClick:()=>{w.chain().focus().setTextSelection(R.pos+1).run(),y.run(w),ae(!1)},children:y.icon},y.id))}),(0,v.jsx)("div",{className:"align-tools",children:[["left",c("format.alignLeft"),(0,v.jsx)(Rn,{size:16},"left")],["center",c("format.alignCenter"),(0,v.jsx)(Tn,{size:16},"center")],["right",c("format.alignRight"),(0,v.jsx)(Nn,{size:16},"right")]].map(([y,S,D])=>(0,v.jsx)(Ot,{label:S,active:w.state.doc.nodeAt(R.pos)?.attrs.textAlign===y,onClick:()=>{w.chain().focus().setTextSelection(R.pos+1).setTextAlign(y).run(),ae(!1)},children:D},y))}),(0,v.jsx)("div",{className:"menu-rule"})]}),(0,v.jsx)(bu,{editor:w,position:R.pos}),s&&(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(R.pos);y&&s(y.toJSON()),ae(!1),q(null)},children:[(0,v.jsx)(Dc,{size:15}),c("block.detach")]}),(0,v.jsxs)("button",{disabled:R.index===0,onClick:()=>Co(R.pos,-1),children:[(0,v.jsx)(Ec,{size:15}),c("block.moveUp")]}),(0,v.jsxs)("button",{disabled:R.index===w.state.doc.childCount-1,onClick:()=>Co(R.pos,1),children:[(0,v.jsx)(xc,{size:15}),c("block.moveDown")]}),(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(R.pos);y&&w.chain().focus().insertContentAt(R.pos+y.nodeSize,y.toJSON()).run(),ae(!1)},children:[(0,v.jsx)(Rc,{size:15}),c("block.duplicate")]}),Q&&(0,v.jsxs)("button",{onClick:y=>{let S=w.state.doc.nodeAt(R.pos)?.attrs.id,D=y.currentTarget.closest(".block-handle").getBoundingClientRect();ae(!1),typeof S=="string"&&!Sg(S)&&Q.open({kind:"blocks",blockIds:[S],anchor:{left:D.right+160,top:D.top,bottom:D.bottom}})},children:[(0,v.jsx)(As,{size:15}),c("assistant.askBlock")]}),Q&&(0,v.jsxs)("button",{onClick:y=>{let S=w.state.doc.nodeAt(R.pos)?.attrs.id,D=y.currentTarget.closest(".block-handle").getBoundingClientRect();ae(!1),typeof S=="string"&&!Sg(S)&&Q.reference({kind:"blocks",blockIds:[S],anchor:{left:D.right,top:D.top,bottom:D.bottom}})},children:[(0,v.jsx)(xs,{size:15}),c("assistant.referenceBlock")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("button",{className:"danger",onClick:()=>{w.chain().focus().deleteRange({from:R.pos,to:R.pos+R.size}).run(),ae(!1),q(null)},children:[(0,v.jsx)(Mo,{size:15}),c("block.delete")]})]})]})]})]}),!n&&!r&&(0,v.jsxs)("button",{className:"document-add-block",onClick:()=>{w.chain().focus("end").run(),(w.state.selection.$from.parent.type.name!=="paragraph"||w.state.selection.$from.parent.content.size)&&w.chain().insertContentAt(w.state.doc.content.size,{type:"paragraph"}).focus("end").run(),ut()},children:[(0,v.jsx)(nn,{size:15}),(0,v.jsx)("span",{children:c("insert.addContent")}),(0,v.jsx)("kbd",{children:"/"})]}),(0,v.jsx)("input",{ref:h,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"editor-hidden-input",onChange:y=>{let S=y.target.files?.[0];S&&I([S],!0),y.target.value=""}}),Je&&(0,v.jsxs)("div",{className:"editor-notice",role:"status",children:[Je,(0,v.jsx)("button",{"aria-label":c("dismissNotice"),onClick:()=>Zt(""),children:(0,v.jsx)($r,{size:14})})]}),kt&&!n&&(0,v.jsxs)(hu,{id:f,className:"rich-text-selection-toolbar",anchor:kt,viewportTop:Math.max(0,...Array.from(p.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],y=>y.getBoundingClientRect().bottom))+8,onEscape:()=>{ve.current=!1,It.current=`${w.state.selection.from}:${w.state.selection.to}`,w.state.selection instanceof oe&&w.view.dispatch(w.state.tr.setSelection(L.near(w.state.selection.$from))),F(null),w.view.focus()},children:[kc,(0,v.jsx)(Ci,{editor:w}),Q&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,v.jsxs)("button",{type:"button",className:"editor-bubble-assistant","aria-label":c("assistant.ask"),title:c("assistant.ask"),onClick:()=>{let{from:y,to:S}=w.state.selection,D=kt;ve.current=!1,F(null),Q.open({kind:"text",blockIds:hi(w.state.doc,y,S),text:w.state.doc.textBetween(y,S,`
|
|
155
|
+
`),anchor:D})},children:[(0,v.jsx)(As,{size:15}),(0,v.jsx)("span",{children:"AI"})]}),(0,v.jsx)("button",{type:"button",className:"editor-tool editor-bubble-reference","aria-label":c("assistant.referenceSelection",{count:wc}),title:c("assistant.referenceSelection",{count:wc}),onClick:()=>{let{from:y,to:S}=w.state.selection,D=kt;ve.current=!1,F(null),Q.reference({kind:"text",blockIds:hi(w.state.doc,y,S),text:w.state.doc.textBetween(y,S,`
|
|
156
|
+
`),anchor:D})},children:(0,v.jsx)(xs,{size:16})})]})]}),A&&!n&&(0,yc.createPortal)((0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"slash-dismiss",onClick:()=>{xn(),w.commands.focus()}}),(0,v.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":c("insert.content"),style:{left:A.left,top:A.top},children:[(0,v.jsxs)("div",{className:"slash-search",children:[A.manual?(0,v.jsx)(au,{label:c("insert.search"),placeholder:c("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:g,value:A.query,onChange:y=>M({...A,query:y}),onKeyDown:y=>{y.key==="Escape"&&(xn(),w.commands.focus()),y.key==="Enter"&&(y.preventDefault(),Ae(Me)),(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),T(S=>te.length?(S+(y.key==="ArrowDown"?1:-1)+te.length)%te.length:0))}}):(0,v.jsx)("span",{children:A.query||c("insert.addToDocument")}),(0,v.jsx)("kbd",{children:"esc"})]}),(0,v.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":c("insert.blockTypes"),"aria-busy":it||ge.loading,children:[ge.error&&(0,v.jsx)("p",{role:"alert",className:"slash-empty",children:ge.error}),te.length===0&&(0,v.jsx)("div",{className:"slash-empty",children:c("insert.noResults")}),te.map((y,S)=>(0,v.jsxs)("div",{children:[(S===0||te[S-1].group!==y.group)&&(0,v.jsx)("div",{className:"slash-group",children:y.group}),(0,v.jsxs)("button",{role:"option",disabled:it,"aria-selected":S===Me,className:`slash-item${S===Me?" is-selected":""}`,onMouseEnter:()=>T(S),onMouseDown:D=>D.preventDefault(),onClick:()=>Ae(S),children:[(0,v.jsx)("span",{className:"slash-item-icon",children:y.icon}),(0,v.jsx)("span",{children:(0,v.jsx)("strong",{children:y.title})}),S===Me&&(0,v.jsx)("span",{className:"slash-enter",children:"\u21B5"})]})]},y.id))]})]})]}),document.body),xe&&(0,yc.createPortal)((0,v.jsx)("div",{className:"editor-modal-backdrop",onMouseDown:y=>{y.target===y.currentTarget&&tt(null)},children:(0,v.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":"true","aria-labelledby":"editor-dialog-title",onKeyDown:y=>{y.key==="Escape"&&tt(null)},onSubmit:y=>{y.preventDefault();let S=xe.value.trim();if(xe.type==="image"&&!l1(S)){Cn(c("dialog.invalidImageUrl"));return}if(xe.type==="link"&&S&&!xg(S)){Cn(c("dialog.invalidLinkUrl"));return}vt.current&&w.commands.setTextSelection(vt.current),xe.type==="image"?w.chain().focus().setImage({src:S,alt:xe.alt}).run():S?w.state.selection.empty&&!w.isActive("link")?w.chain().focus().insertContent({type:"text",text:S,marks:[{type:"link",attrs:{href:S}}]}).run():w.chain().focus().extendMarkRange("link").setLink({href:S}).run():w.chain().focus().extendMarkRange("link").unsetLink().run(),tt(null)},children:[(0,v.jsxs)("div",{className:"editor-modal-heading",children:[(0,v.jsx)("div",{className:"editor-modal-symbol",children:xe.type==="image"?(0,v.jsx)(So,{size:21}):(0,v.jsx)(Eo,{size:21})}),(0,v.jsx)("h3",{id:"editor-dialog-title",children:xe.type==="image"?c("insert.image"):c("dialog.addLink")}),(0,v.jsx)("button",{type:"button","aria-label":c("dialog.close"),onClick:()=>tt(null),children:(0,v.jsx)($r,{size:18})})]}),xe.type==="image"&&(0,v.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>h.current?.click(),children:[(0,v.jsx)(Qc,{size:23}),(0,v.jsx)("strong",{children:c("dialog.chooseImage")}),(0,v.jsx)("span",{children:c("dialog.imageFormats")})]}),(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:xe.type==="image"?c("dialog.imageUrl"):c("dialog.linkUrl")}),(0,v.jsx)("input",{autoFocus:!0,type:"text",placeholder:"https://",value:xe.value,onChange:y=>{tt({...xe,value:y.target.value}),Cn("")}})]}),xe.type==="image"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsxs)("span",{children:[c("dialog.imageAlt")," ",(0,v.jsx)("small",{children:c("dialog.optional")})]}),(0,v.jsx)("input",{placeholder:c("dialog.imageAltPlaceholder"),value:xe.alt,onChange:y=>tt({...xe,alt:y.target.value})})]}),vn&&(0,v.jsx)("p",{className:"editor-field-error",role:"alert",children:vn}),(0,v.jsxs)("div",{className:"editor-modal-actions",children:[xe.type==="link"&&w.isActive("link")&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{w.chain().focus().extendMarkRange("link").unsetLink().run(),tt(null)},children:c("dialog.removeLink")}),(0,v.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>tt(null),children:c("dialog.cancel")}),(0,v.jsxs)("button",{type:"submit",className:"editor-primary",disabled:xe.type==="image"&&!xe.value.trim(),children:[(0,v.jsx)(Ac,{size:15}),xe.type==="image"?c("insert.image"):c("dialog.confirm")]})]})]})}),document.body),n&&(0,v.jsxs)("span",{className:"editor-readonly-note",children:[(0,v.jsx)(Lc,{size:12}),c("readOnlyNote")]})]})}export{a1 as default};
|