showai-reader 0.10.0-reader.bewbunls → 0.10.0-reader.cdylp2e5
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-XIOKVIEI.js → CardGrid-TRO37NZO.js} +1 -1
- package/chunks/{CommandReference-7FQV6W44.js → CommandReference-YOBZ67AR.js} +1 -1
- package/chunks/{ComparisonMatrix-LFBHHO3A.js → ComparisonMatrix-P3TVMSP7.js} +1 -1
- package/chunks/{EventTimeline-TS5HI5GA.js → EventTimeline-PL6EEZLL.js} +1 -1
- package/chunks/{ExperimentTracker-MSRAHV5J.js → ExperimentTracker-QLIXOBDQ.js} +1 -1
- package/chunks/{ExternalDiagram-HKK3NBZH.js → ExternalDiagram-ZTY4TDJJ.js} +1 -1
- package/chunks/{Flowchart-VG42T332.js → Flowchart-PRS65CS3.js} +1 -1
- package/chunks/{G2Chart-QP5UF6HK.js → G2Chart-TOPADKCR.js} +2 -2
- package/chunks/{LayerDiagram-FHPQBNNP.js → LayerDiagram-3CLVCITA.js} +1 -1
- package/chunks/{Mindmap-E5X5CQBX.js → Mindmap-3XJLR4JB.js} +1 -1
- package/chunks/{RichTextEditor-BA5YF46E.js → RichTextEditor-JTG5RWOK.js} +50 -50
- package/chunks/{Roadmap-QWD7IZHX.js → Roadmap-SPBI3665.js} +1 -1
- package/chunks/{Scene3D-Q5MGPU3X.js → Scene3D-MUQ74HZI.js} +2 -2
- package/chunks/{SequenceDiagram-AG2F4GAU.js → SequenceDiagram-OOQN7BWQ.js} +1 -1
- package/chunks/{StatusTree-EHNSDOVH.js → StatusTree-B6NZDDIZ.js} +1 -1
- package/chunks/StepGuide-MWZV4NYU.js +1 -0
- package/chunks/{StructureBrowser-VZYKCSL6.js → StructureBrowser-CVA2IQML.js} +1 -1
- package/chunks/{Waterfall-A5MPISUU.js → Waterfall-B2BPYBF3.js} +1 -1
- package/chunks/chunk-2MWQ4I4F.js +1 -0
- package/chunks/{chunk-RLCYUTAH.js → chunk-4RYRJOIW.js} +1 -1
- package/chunks/{chunk-RHJ236MQ.js → chunk-6G2M37RQ.js} +1 -1
- package/chunks/{chunk-VSZNYGH7.js → chunk-AAGG3TEN.js} +1 -1
- package/chunks/{chunk-BZT4BVM4.js → chunk-BR33OQJ3.js} +1 -1
- package/chunks/{chunk-WRXJZR6G.js → chunk-H7ALO2Q6.js} +36 -36
- package/chunks/{chunk-UNH6G7NO.js → chunk-MLBEJ7IZ.js} +1 -1
- package/chunks/{chunk-PTZCSSDG.js → chunk-PDHAXJXJ.js} +1 -1
- package/chunks/{chunk-R2RMNI2B.js → chunk-QD4XRUJK.js} +1 -1
- package/chunks/{chunk-L2ZHJIET.js → chunk-S7HOQGTC.js} +1 -1
- package/chunks/chunk-TBEPAJ5C.js +9 -0
- package/chunks/{chunk-JAQUAFGK.js → chunk-WP3ME37P.js} +2 -2
- package/chunks/{chunk-M5RCHTSV.js → chunk-XXZZVMLJ.js} +1 -1
- package/index.js +1 -1
- package/manifest.json +4 -4
- package/package.json +1 -1
- package/{reader-BEWBUNLS.js → reader-CDYLP2E5.js} +34 -34
- package/chunks/StepGuide-GUW3ELME.js +0 -1
- package/chunks/chunk-5X5EO4YB.js +0 -9
- package/chunks/chunk-7K7GQKOA.js +0 -1
- /package/chunks/{G2Chart-QP5UF6HK.js.LEGAL.txt → G2Chart-TOPADKCR.js.LEGAL.txt} +0 -0
- /package/chunks/{Scene3D-Q5MGPU3X.js.LEGAL.txt → Scene3D-MUQ74HZI.js.LEGAL.txt} +0 -0
- /package/chunks/{chunk-WRXJZR6G.js.LEGAL.txt → chunk-H7ALO2Q6.js.LEGAL.txt} +0 -0
- /package/chunks/{chunk-JAQUAFGK.js.LEGAL.txt → chunk-WP3ME37P.js.LEGAL.txt} +0 -0
- /package/{reader-BEWBUNLS.js.LEGAL.txt → reader-CDYLP2E5.js.LEGAL.txt} +0 -0
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{db as yu,ga as zs,ha as Hs,lb as $o,mb as He,nb as Bo,ob as wu,pb as xu,qb as Su,sa as nn,ta as _s,ua as du,wa as fu}from"./chunk-5X5EO4YB.js";import"./chunk-3RZMLHCB.js";import"./chunk-JXKAISUX.js";import"./chunk-C4JCEMQN.js";import{A as rn,B as Hr,C as U,D as te,E as mu,G as gu,K as Fs,d as V,e as pu,f as ce,g as Ro,h as Vs,i as Nn,j as Rn,k as Oo,l as hu,m as On,n as St,o as Pt,p as rr,q as ht,r as kt,s as or,t as Do,u as Lo,v as Io,w as X,x as js,y as D,z as j}from"./chunk-KQR52I3G.js";import"./chunk-SNEZ3O5V.js";import"./chunk-77DN5DLU.js";import"./chunk-AIBH6MTQ.js";import"./chunk-BZT4BVM4.js";import"./chunk-RLCYUTAH.js";import"./chunk-UNH6G7NO.js";import{a as Ws,b as zo,c as ku,e as vu}from"./chunk-7G6RMB6W.js";import{a as Hg,b as _g}from"./chunk-JAQUAFGK.js";import"./chunk-GLP5VV7P.js";import{a as bu}from"./chunk-5AW2WUSZ.js";import{a as Eu}from"./chunk-RHJ236MQ.js";import"./chunk-DG67SWQA.js";import"./chunk-KF47DKNH.js";import{$ as Wc,$a as Mn,A as Br,Ab as Le,B as So,Da as tn,Eb as Cu,G as Bc,Ga as Os,H as zc,Ha as Qc,J as Hc,M as _c,O as Vc,Oa as Ds,P as jc,Pa as Ls,Qa as Zc,Ta as eu,Va as Is,Wa as tu,Xa as Ps,Ya as nu,Z as Fc,Za as ru,_a as $s,a as Oc,aa as Kc,ab as An,ba as Uc,bb as ou,c as en,ca as qc,cb as Tn,da as Eo,db as To,eb as No,fa as Gc,fb as iu,gb as su,ib as lu,ja as Mo,ka as Ns,lb as zr,m as Dc,ma as Rs,mb as Ze,nb as Bs,o as Lc,q as Ic,r as Ts,ra as Jc,s as Pc,sa as Ao,ta as Xc,tb as au,ub as cu,xb as uu,ya as Yc,z as $c}from"./chunk-WRXJZR6G.js";import{a as Po,f as ir}from"./chunk-J6IRWTF7.js";import{a as zg,c as ye}from"./chunk-DCANE7XH.js";var Xm=zg((qT,Jm)=>{function Bm(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)&&Bm(n)}),e}var ks=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function zm(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 Fx="</span>",Om=e=>!!e.scope,Wx=(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}`},dc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=zm(t)}openNode(t){if(!Om(t))return;let n=Wx(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Om(t)&&(this.buffer+=Fx)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},Dm=(e={})=>{let t={children:[]};return Object.assign(t,e),t},fc=class e{constructor(){this.rootNode=Dm(),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=Dm({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)}))}},pc=class extends fc{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 dc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function vo(e){return e?typeof e=="string"?e:e.source:null}function Hm(e){return tr("(?=",e,")")}function Kx(e){return tr("(?:",e,")*")}function Ux(e){return tr("(?:",e,")?")}function tr(...e){return e.map(n=>vo(n)).join("")}function qx(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Cs(...e){return"("+(qx(e).capture?"":"?:")+e.map(r=>vo(r)).join("|")+")"}function _m(e){return new RegExp(e.toString()+"|").exec("").length-1}function Gx(e,t){let n=e&&e.exec(t);return n&&n.index===0}var Jx=new RegExp(Cs(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function mc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=vo(r),s="";for(;i.length>0;){let l=Jx.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 Xx=/\b\B/,Vm="[a-zA-Z]\\w*",gc="[a-zA-Z_]\\w*",jm="\\b\\d+(\\.\\d+)?",Fm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Wm="\\b(0b[01]+)",Yx="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Qx=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=tr(t,/.*\b/,e.binary,/\b.*/)),bn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},Co={begin:"\\\\[\\s\\S]",relevance:0},Zx={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Co]},eS={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Co]},tS={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/},xs=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=Cs("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:tr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},nS=xs("//","$"),rS=xs("/\\*","\\*/"),oS=xs("#","$"),iS={scope:"number",begin:jm,relevance:0},sS={scope:"number",begin:Fm,relevance:0},lS={scope:"number",begin:Wm,relevance:0},aS={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Co,{begin:/\[/,end:/\]/,relevance:0,contains:[Co]}]},cS={scope:"title",begin:Vm,relevance:0},uS={scope:"title",begin:gc,relevance:0},dS={begin:"\\.\\s*"+gc,relevance:0},fS=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()}})},ws=Object.freeze({__proto__:null,APOS_STRING_MODE:Zx,BACKSLASH_ESCAPE:Co,BINARY_NUMBER_MODE:lS,BINARY_NUMBER_RE:Wm,COMMENT:xs,C_BLOCK_COMMENT_MODE:rS,C_LINE_COMMENT_MODE:nS,C_NUMBER_MODE:sS,C_NUMBER_RE:Fm,END_SAME_AS_BEGIN:fS,HASH_COMMENT_MODE:oS,IDENT_RE:Vm,MATCH_NOTHING_RE:Xx,METHOD_GUARD:dS,NUMBER_MODE:iS,NUMBER_RE:jm,PHRASAL_WORDS_MODE:tS,QUOTE_STRING_MODE:eS,REGEXP_MODE:aS,RE_STARTERS_RE:Yx,SHEBANG:Qx,TITLE_MODE:cS,UNDERSCORE_IDENT_RE:gc,UNDERSCORE_TITLE_MODE:uS});function pS(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function hS(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function mS(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=pS,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function gS(e,t){Array.isArray(e.illegal)&&(e.illegal=Cs(...e.illegal))}function bS(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 yS(e,t){e.relevance===void 0&&(e.relevance=1)}var wS=(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=tr(n.beforeMatch,Hm(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},kS=["of","and","for","in","not","or","if","then","parent","list","value"],vS="keyword";function Km(e,t,n=vS){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,Km(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,CS(a[0],a[1])]})}}function CS(e,t){return t?Number(t):xS(e)?0:1}function xS(e){return kS.includes(e.toLowerCase())}var Lm={},er=e=>{console.error(e)},Im=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Or=(e,t)=>{Lm[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Lm[`${e}/${t}`]=!0)},vs=new Error;function Um(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+=_m(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function SS(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw er("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),vs;if(typeof e.beginScope!="object"||e.beginScope===null)throw er("beginScope must be object"),vs;Um(e,e.begin,{key:"beginScope"}),e.begin=mc(e.begin,{joinWith:""})}}function ES(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw er("skip, excludeEnd, returnEnd not compatible with endScope: {}"),vs;if(typeof e.endScope!="object"||e.endScope===null)throw er("endScope must be object"),vs;Um(e,e.end,{key:"endScope"}),e.end=mc(e.end,{joinWith:""})}}function MS(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function AS(e){MS(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),SS(e),ES(e)}function TS(e){function t(s,l){return new RegExp(vo(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+=_m(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(mc(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;[hS,bS,AS,wS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[mS,gS,yS].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=Km(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=vo(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 NS(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 qm(e){return e?e.endsWithParent||qm(e.starts):!1}function NS(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return bn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:qm(e)?bn(e,{starts:e.starts?bn(e.starts):null}):Object.isFrozen(e)?bn(e):e}var RS="11.12.0",hc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},uc=zm,Pm=bn,$m=Symbol("nomatch"),OS=7,Gm=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:pc};function a(T){return l.noHighlightRe.test(T)}function u(T){let H=T.className+" ";H+=T.parentNode?T.parentNode.className:"";let I=l.languageDetectRe.exec(H);if(I){let ae=L(I[1]);return ae||(Im(i.replace("{}",I[1])),Im("Falling back to no-highlight mode for this block.",T)),ae?I[1]:"no-highlight"}return H.split(/\s+/).find(ae=>a(ae)||L(ae))}function c(T,H,I){let ae="",be="";typeof H=="object"?(ae=T,I=H.ignoreIllegals,be=H.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(Pr>1e5&&Pr>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ie+=J,J.length}let Oe=L(T);if(!Oe)throw er(i.replace("{}",T)),new Error('Unknown language: "'+T+'"');let nr=TS(Oe),xt="",q=ae||nr,at={},Se=new l.__emitter(l);ee();let ie="",vn=0,Qe=0,Pr=0,w=!1;try{if(Oe.__emitTokens)Oe.__emitTokens(H,Se);else{for(q.matcher.considerAll();;){Pr++,w?w=!1:q.matcher.considerAll(),q.matcher.lastIndex=Qe;let O=q.matcher.exec(H);if(!O)break;let B=H.substring(Qe,O.index),J=Ir(B,O);Qe=O.index+J}Ir(H.substring(Qe))}return Se.finalize(),xt=Se.toHTML(),{language:T,value:xt,relevance:vn,illegal:!1,_emitter:Se,_top:q}}catch(O){if(O.message&&O.message.includes("Illegal"))return{language:T,value:uc(H),illegal:!0,relevance:0,_illegalBy:{message:O.message,index:Qe,context:H.slice(Qe-100,Qe+100),mode:O.mode,resultSoFar:xt},_emitter:Se};if(o)return{language:T,value:uc(H),illegal:!1,relevance:0,errorRaised:O,_emitter:Se,_top:q};throw O}}function f(T){let H={value:uc(T),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return H._emitter.addText(T),H}function p(T,H){H=H||l.languages||Object.keys(t);let I=f(T),ae=H.filter(L).filter(he).map(Be=>d(Be,T,!1));ae.unshift(I);let be=ae.sort((Be,lt)=>{if(Be.relevance!==lt.relevance)return lt.relevance-Be.relevance;if(Be.language&<.language){if(L(Be.language).supersetOf===lt.language)return 1;if(L(lt.language).supersetOf===Be.language)return-1}return 0}),[Ce,Ye]=be,wn=Ce;return wn.secondBest=Ye,wn}function h(T,H,I){let ae=H&&n[H]||I;T.classList.add("hljs"),T.classList.add(`language-${ae}`)}function b(T){let H=null,I=u(T);if(a(I))return;if(je("before:highlightElement",{el:T,language:I}),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 hc("One of your code blocks includes unescaped HTML.",T.innerHTML);H=T;let ae=H.textContent,be=I?c(ae,{language:I,ignoreIllegals:!0}):p(ae);T.innerHTML=be.value,T.dataset.highlighted="yes",h(T,I,be.language),T.result={language:be.language,re:be.relevance,relevance:be.relevance},be.secondBest&&(T.secondBest={language:be.secondBest.language,relevance:be.secondBest.relevance}),je("after:highlightElement",{el:T,result:be,text:ae})}function m(T){l=Pm(l,T)}let g=()=>{S(),Or("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function k(){S(),Or("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function S(){function T(){S()}if(document.readyState==="loading"){C||window.addEventListener("DOMContentLoaded",T,!1),C=!0;return}document.querySelectorAll(l.cssSelector).forEach(b)}function A(T,H){let I=null;try{I=H(e)}catch(ae){if(er("Language definition for '{}' could not be registered.".replace("{}",T)),o)er(ae);else throw ae;I=s}I.name||(I.name=T),t[T]=I,I.rawDefinition=H.bind(null,e),I.aliases&&oe(I.aliases,{languageName:T})}function E(T){delete t[T];for(let H of Object.keys(n))n[H]===T&&delete n[H]}function M(){return Object.keys(t)}function L(T){return T=(T||"").toLowerCase(),t[T]||t[n[T]]}function oe(T,{languageName:H}){typeof T=="string"&&(T=[T]),T.forEach(I=>{n[I.toLowerCase()]=H})}function he(T){let H=L(T);return H&&!H.disableAutodetect}function ve(T){T["before:highlightBlock"]&&!T["before:highlightElement"]&&(T["before:highlightElement"]=H=>{T["before:highlightBlock"](Object.assign({block:H.el},H))}),T["after:highlightBlock"]&&!T["after:highlightElement"]&&(T["after:highlightElement"]=H=>{T["after:highlightBlock"](Object.assign({block:H.el},H))})}function Ae(T){ve(T),r.push(T)}function Ve(T){let H=r.indexOf(T);H!==-1&&r.splice(H,1)}function je(T,H){let I=T;r.forEach(function(ae){ae[I]&&ae[I](H)})}function $e(T){return Or("10.7.0","highlightBlock will be removed entirely in v12.0"),Or("10.7.0","Please use highlightElement now."),b(T)}Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:S,highlightElement:b,highlightBlock:$e,configure:m,initHighlighting:g,initHighlightingOnLoad:k,registerLanguage:A,unregisterLanguage:E,listLanguages:M,getLanguage:L,registerAliases:oe,autoDetection:he,inherit:Pm,addPlugin:Ae,removePlugin:Ve}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=RS,e.regex={concat:tr,lookahead:Hm,either:Cs,optional:Ux,anyNumberOfTimes:Kx};for(let T in ws)typeof ws[T]=="object"&&Bm(ws[T]);return Object.assign(e,ws),e},Dr=Gm({});Dr.newInstance=()=>Gm({});Jm.exports=Dr;Dr.HighlightJS=Dr;Dr.default=Dr});var Au=ye(en(),1);var Mu=Po("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(Ze(),1);function Tu({editor:e,position:t}){let n=Le(Mu),[r,o]=(0,Au.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:zo(i.attrs.language),onChange:f=>l("language",f.target.value),children:[(0,we.jsx)("option",{value:"plaintext",children:n("plainText")}),!Ws.includes(zo(i.attrs.language))&&(0,we.jsxs)("option",{value:zo(i.attrs.language),children:[i.attrs.language,ku(i.attrs.language)?"":` (${n("plainText")})`]}),Ws.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))]})]})}var Ho=Po("richTextNotes",{"zh-CN":{"format.note":"\u6CE8\u91CA","dialog.addNote":"\u6DFB\u52A0\u6CE8\u91CA","dialog.editNote":"\u4FEE\u6539\u6CE8\u91CA","dialog.noteText":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u6240\u9009\u6587\u5B57\u4E0A\u65F6\u663E\u793A\uFF09","dialog.noteFormula":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u8FD9\u4E2A\u516C\u5F0F\u4E0A\u65F6\u663E\u793A\uFF09","dialog.notePlaceholder":"\u4F8B\u5982\uFF1A\u7B2C t \u6B65\u7684\u5E26\u566A\u6F5C\u53D8\u91CF\uFF0C\u5F62\u72B6\u4E0E\u56FE\u50CF\u6F5C\u53D8\u91CF\u76F8\u540C","dialog.noteHint":"\u53EF\u7528 $\u2026$ \u5199\u516C\u5F0F\uFF1B\u53EA\u6CE8\u91CA\u516C\u5F0F\u4E2D\u7684\u67D0\u4E2A\u53D8\u91CF\u65F6\uFF0C\u5728\u516C\u5F0F\u6E90\u7801\u91CC\u5199 \\note{x_t}{\u2026}\u3002\u2318\u21A9 \u4FDD\u5B58\u3002","dialog.removeNote":"\u5220\u9664\u6CE8\u91CA","dialog.noteNeedsSelection":"\u5148\u9009\u4E2D\u8981\u52A0\u6CE8\u91CA\u7684\u6587\u5B57\u6216\u516C\u5F0F\u3002","dialog.noteTargetMissing":"\u8981\u6CE8\u91CA\u7684\u516C\u5F0F\u5DF2\u7ECF\u4E0D\u5728\u539F\u4F4D\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002","dialog.noteTooLong":"\u6CE8\u91CA\u6700\u591A {max} \u4E2A\u5B57\u7B26\u3002"},en:{"format.note":"Note","dialog.addNote":"Add note","dialog.editNote":"Edit note","dialog.noteText":"Note (shown when readers hover the selected text)","dialog.noteFormula":"Note (shown when readers hover this formula)","dialog.notePlaceholder":"For example: the noisy latent at step t, shaped like the image latent","dialog.noteHint":"Use $\u2026$ for formulas. To annotate one variable inside a formula, write \\note{x_t}{\u2026} in its source. \u2318\u21A9 saves.","dialog.removeNote":"Remove note","dialog.noteNeedsSelection":"Select the text or formula to annotate first.","dialog.noteTargetMissing":"The formula moved. Select it again.","dialog.noteTooLong":"Notes can have at most {max} characters."}});function Nu(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(en(),1),Ec=ye(Bs(),1);var Z=ye(en(),1);var gi=ye(Bs(),1),Sp=ye(Hg(),1);var Ru=Object.defineProperty,Ou=(e,t)=>{let n={};for(var r in e)Ru(n,r,{get:e[r],enumerable:!0});return t||Ru(n,Symbol.toStringTag,{value:"Module"}),n};var Lu=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Iu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var Us=(e,t,n)=>{let r=Iu(e,n);if(!r)return!1;let o=Gs(r);if(!o){let s=r.blockRange(),l=s&&Pt(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Fu(e,o,t,-1))return!0;if(r.parent.content.size==0&&(sr(i,"end")||j.isSelectable(i)))for(let s=r.depth;;s--){let l=Lo(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(sr(i,"end")?X.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):j.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},Pu=(e,t,n)=>{let r=Iu(e,n);if(!r)return!1;let o=Gs(r);return o?Bu(e,o,t):!1},$u=(e,t,n)=>{let r=zu(e,n);if(!r)return!1;let o=Ys(r);return o?Bu(e,o,t):!1};function Bu(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=Lo(e.doc,i,a,ce.empty);if(!u||u.from!=i||u instanceof On&&u.slice.size>=a-i)return!1;if(n){let c=e.tr.step(u);c.setSelection(D.create(c.doc,i)),n(c.scrollIntoView())}return!0}function sr(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 qs=(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=Gs(r)}let s=i&&i.nodeBefore;return!s||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Gs(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 zu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Js=(e,t,n)=>{let r=zu(e,n);if(!r)return!1;let o=Ys(r);if(!o)return!1;let i=o.nodeAfter;if(Fu(e,o,t,1))return!0;if(r.parent.content.size==0&&(sr(i,"start")||j.isSelectable(i))){let s=Lo(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(sr(i,"start")?X.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):j.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},Xs=(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=Ys(r)}let s=i&&i.nodeAfter;return!s||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,i.pos)).scrollIntoView()),!0)};function Ys(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 Hu=(e,t)=>{let n=e.selection,r=n instanceof j,o;if(r){if(n.node.isTextblock||!kt(e.doc,n.from))return!1;o=n.from}else if(o=or(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(j.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},_u=(e,t)=>{let n=e.selection,r;if(n instanceof j){if(n.node.isTextblock||!kt(e.doc,n.to))return!1;r=n.to}else if(r=or(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Vu=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&Pt(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 Zs(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 el=(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=Zs(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},tl=(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=Zs(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(D.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},nl=(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(ht(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Pt(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function Vg(e){return(t,n)=>{if(t.selection instanceof j&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!ht(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 D||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=Zs(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let b=e&&e(o.parent,u,o);s.unshift(b||(u&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=o.pos,f=ht(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=ht(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)),b=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(b.index(),b.index()+1,a)&&r.setNodeMarkup(p.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var jg=Vg();var ju=(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(j.create(e.doc,o))),!0)},Fg=(e,t)=>(t&&t(e.tr.setSelection(new rn(e.doc))),!0);function Wg(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||kt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Fu(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Wg(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=V.empty;for(let g=s.length-1;g>=0;g--)h=V.from(s[g].create(null,h));h=V.from(o.copy(h));let b=e.tr.step(new St(t.pos-1,p,t.pos,p,new ce(h,1,0),s.length,!0)),m=b.doc.resolve(p+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&kt(b.doc,m.pos)&&b.join(m.pos),n(b.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&&Pt(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(u&&sr(i,"start",!0)&&sr(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let b=i,m=1;for(;!b.isTextblock;b=b.firstChild)m++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(n){let g=V.empty;for(let C=h.length-1;C>=0;C--)g=V.from(h[C].copy(g));let k=e.tr.step(new St(t.pos-h.length,t.pos+i.nodeSize,t.pos+m,t.pos+i.nodeSize-m,new ce(g,h.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Wu(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(D.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var rl=Wu(-1),ol=Wu(1);function Ku(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&rr(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function il(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 sl(...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 Ks=sl(Lu,Us,qs),Du=sl(Lu,Js,Xs),on={Enter:sl(Qs,tl,nl,jg),"Mod-Enter":el,Backspace:Ks,"Mod-Backspace":Ks,"Shift-Backspace":Ks,Delete:Du,"Mod-Delete":Du,"Mod-a":Fg},Kg={"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":rl,"Ctrl-e":ol};for(let e in on)Kg[e]=on[e];var $1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Uu(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 Ug(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Ug(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 Ro(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new Ro(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=rr(i,n,r,t);return l?(e&&qg(e,t,l,o,n),!0):!1}function qg(e,t,n,r,o){let i=V.empty;for(let c=n.length-1;c>=0;c--)i=V.from(n[c].type.create(n[c].attrs,i));e.step(new St(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&&ht(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=u.child(c).nodeSize;return e}function qu(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?Gg(t,n,e,i):Jg(t,n,i):!0:!1}}function Gg(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new St(i-1,s,i,s,new ce(V.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ro(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=Pt(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return kt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}function Jg(e,t,n){let r=e.tr,o=n.parent;for(let p=n.end,h=n.endIndex-1,b=n.startIndex;h>b;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?V.empty:V.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new St(d-(l?1:0),f+(a?1:0),d+1,f-1,new ce((l?V.empty:V.from(o.copy(V.empty))).append(a?V.empty:V.from(o.copy(V.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function Gu(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=V.from(u?e.create():null),d=new ce(V.from(e.create(null,V.from(l.type.create(null,c)))),u?3:1,0),f=i.start,p=i.end;n(t.tr.step(new St(f-(u?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var Fe=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ur=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},dl=null,Bt=function(e,t,n){let r=dl||(dl=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Xg=function(){dl=null},Hn=function(e,t,n,r){return n&&(Ju(e,t,n,r,-1)||Ju(e,t,n,r,1))},Yg=/^(img|br|input|textarea|hr)$/i;function Ju(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:qe(e))){let s=e.parentNode;if(!s||!W(s)||Gr(e)||Yg.test(e.nodeName)||e.contentEditable=="false")return!1;t=Fe(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?qe(e):0}else return!1}}function qe(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function W(e){return e.nodeType==1}function Ie(e){return e.nodeType==3}function _n(e,t){return t?e.contains(W(t)?t:t.parentNode):!1}function Qg(e,t){for(;;){if(Ie(e)&&t)return e;if(W(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=qe(e)}else if(e.parentNode&&!Gr(e))t=Fe(e),e=e.parentNode;else return null}}function Zg(e,t){for(;;){if(Ie(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&&!Gr(e))t=Fe(e)+1,e=e.parentNode;else return null}}function eb(e,t,n){for(let r=t==0,o=t==qe(e);r||o;){if(e==n)return!0;let i=Fe(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==qe(e)}}function Gr(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 Xo=function(e){return e.focusNode&&Hn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Dn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function tb(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function nb(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(qe(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(qe(r.startContainer),r.startOffset)}}}var Et=typeof navigator<"u"?navigator:null,Xu=typeof document<"u"?document:null,un=Et&&Et.userAgent||"",fl=/Edge\/(\d+)/.exec(un),Ed=/MSIE \d/.exec(un),pl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(un),ot=!!(Ed||pl||fl),an=Ed?document.documentMode:pl?+pl[1]:fl?+fl[1]:0,ut=!ot&&/gecko\/(\d+)/i.test(un);ut&&+(/Firefox\/(\d+)/.exec(un)||[0,0])[1];var hl=!ot&&/Chrome\/(\d+)/.exec(un),We=!!hl,Md=hl?+hl[1]:0,Ge=!ot&&!!Et&&/Apple Computer/.test(Et.vendor),dr=Ge&&(/Mobile\/\w+/.test(un)||!!Et&&Et.maxTouchPoints>2),mt=dr||(Et?/Mac/.test(Et.platform):!1),Ad=Et?/Win/.test(Et.platform):!1,zt=/Android \d/.test(un),Yo=!!Xu&&"webkitFontSmoothing"in Xu.documentElement.style,rb=Yo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ob(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 $t(e,t){return typeof e=="number"?e:e[t]}function ib(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 Yu(e,t,n){if(!ml(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=ur(s);continue}let l=s==i.body,a=l?ob(i):ib(s),u=0,c=0;if(t.top<a.top+$t(r,"top")?c=-(a.top-t.top+$t(o,"top")):t.bottom>a.bottom-$t(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+$t(o,"top")-a.top:t.bottom-a.bottom+$t(o,"bottom")),t.left<a.left+$t(r,"left")?u=-(a.left-t.left+$t(o,"left")):t.right>a.right-$t(r,"right")&&(u=t.right-a.right+$t(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,b=s.scrollTop-p;t={left:t.left-h,top:t.top-b,right:t.right-h,bottom:t.bottom-b}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:ur(s)}}function sb(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:Td(e.dom)}}function Td(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=ur(r));return t}function lb({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Nd(n,r==0?0:r-t)}function Nd(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 lr=null;function ab(e){if(e.setActive)return e.setActive();if(lr)return e.focus(lr);let t=Td(e);e.focus(lr==null?{get preventScroll(){return lr={preventScroll:!0},!0}}:void 0),lr||(lr=!1,Nd(t,0))}function Rd(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(Ie(c))f=Bt(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 b=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(b<r){n=c,r=b,o=b&&Ie(n)?{left:h.right<t.left?h.right:h.left,top:t.top}:t,W(c)&&b&&(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&&Ie(n)?cb(n,o):!n||r?{node:e,offset:i}:Rd(n,o)}function cb(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&&Ol(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 Ol(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ub(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function db(e,t,n){let{node:r,offset:o}=Rd(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 fb(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 Od(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(Ol(t,u))return Od(s,t,u)}}if((i=(i+1)%r)==o)break}return e}function pb(e,t){let n=e.dom.ownerDocument,r,o=0,i=nb(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(!Ol(t,u)||(s=Od(e.dom,t,u),!s))return null}if(Ge)for(let u=s;r&&u;u=ur(u))u.draggable&&(r=void 0);if(s=ub(s,t),r){if(ut&&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;Yo&&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=fb(e,r,o,t))}l==null&&(l=db(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ml(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(ml(r))return r}return Array.prototype.find.call(n,ml)||e.getBoundingClientRect()}var hb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dd(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=Yo||ut;if(Ie(r))if(s&&(hb.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=sn(Bt(r,o,o),n);if(ut&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let u=sn(Bt(r,o-1,o-1),-1);if(u.top==a.top){let c=sn(Bt(r,o,o+1),-1);if(c.top!=a.top)return _r(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++,_r(sn(Bt(r,a,u),c),c<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==qe(r))){let a=r.childNodes[o-1];if(W(a))return ll(a.getBoundingClientRect(),!1)}if(i==null&&o<qe(r)){let a=r.childNodes[o];if(W(a))return ll(a.getBoundingClientRect(),!0)}return ll(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==qe(r))){let a=r.childNodes[o-1],u=Ie(a)?Bt(a,qe(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return _r(sn(u,1),!1)}if(i==null&&o<qe(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?Ie(a)?Bt(a,0,s?0:1):W(a)?a:null:null;if(u)return _r(sn(u,-1),!0)}return _r(sn(Ie(r)?Bt(r):r,-n),n>=0)}function _r(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 ll(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 Ld(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 mb(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return Ld(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=Dd(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(Ie(l))a=Bt(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 gb=/[\u0590-\u08ac]/;function bb(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?!gb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Ld(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:b}=e.domSelectionRange(),m=h&&!_n(p,h)||a==h&&u==b;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 Qu=null,Zu=null,ed=!1;function yb(e,t,n){return Qu==t&&Zu==n?ed:(Qu=t,Zu=n,ed=n=="up"||n=="down"?mb(e,t,n):bb(e,t,n))}var gt=0,td=1,Ln=2,vt=3,Vn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=gt,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&&_n(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>Fe(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)?_n(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 jo||i instanceof _o&&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?Fe(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?Fe(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=Fe(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=Fe(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 b=this.children[p],m=h+b.size;if(i>h&&s<m)return b.setSelection(t-h-b.border,n-h-b.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((ut||Ge)&&t==n){let{node:p,offset:h}=l;if(Ie(p)){if(d=!!(h&&p.nodeValue[h-1]==`
|
|
5
|
-
`),d&&h==p.nodeValue.length)for(let b=p,m;b;b=b.parentNode){if(m=b.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:Fe(m)+1});break}let g=b.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let b=p.childNodes[h-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(ut&&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&&Ge)&&Hn(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Hn(a.node,a.offset,c.focusNode,c.focusOffset))return;let f=!1;if((u.extend||t==n)&&!(d&&ut)){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?Ln:td,t==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vt:i.markDirty(t-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ln:vt}r=s}this.dirty=Ln}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?Ln:td;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},_o=class extends Vn{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==gt&&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}},gl=class extends Vn{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}},Pn=class e extends Vn{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=Rn.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&vt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=vt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=gt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=gt}}slice(t,n,r){let o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=kl(i,n,s,r)),t>0&&(i=kl(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 Vn{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(!Ie(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Rn.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=$d(c,r,n),u?a=new bl(t,n,r,o,c,d||null,f,u):n.isText?new Vo(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=()=>V.empty}}return n}matchesNode(t,n,r){return this.dirty==gt&&t.eq(this.node)&&Fo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(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 wl(this,s&&s.node,t),u=this.node.inlineContent,c=u&&this.node.isBlock;Cb(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?pu.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 b;a.findNodeMatch(d,f,p,h)||l&&t.state.selection.from>o&&t.state.selection.to<o+d.nodeSize&&(b=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,p,b,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==Ln)&&(s&&this.protectLocalComposition(t,s),Id(this.contentDOM,this.children,t),dr&&xb(this.dom))}localCompositionInfo(t,n){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof D)||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=Sb(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 gl(this,i,n,o);t.input.compositionNodes.push(s),this.children=kl(this.children,r,r+o.length,t,s)}update(t,n,r,o){return this.dirty==vt||!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=gt}updateOuterDeco(t){if(Fo(t,this.outerDeco))return;let n=!W(this.nodeDOM),r=this.dom;this.dom=Pd(this.dom,this.nodeDOM,yl(this.outerDeco,this.node,n),yl(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 nd(e,t,n,r,o){$d(r,t,e);let i=new cn(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Vo=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==vt||this.dirty!=gt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=gt||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=gt,!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=vt)}get domAtom(){return!1}isText(t){return this.node.text==t}},jo=class extends Vn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==gt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},bl=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==vt)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 Id(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=rd(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Pn){let a=r?r.previousSibling:e.lastChild;Id(s.contentDOM,s.children,n),r=a?a.nextSibling:e.firstChild}}for(;r;)r=rd(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var jr=function(e){e&&(this.nodeName=e)};jr.prototype=Object.create(null);var In=[new jr];function yl(e,t,n){if(e.length==0)return In;let r=n?In[0]:new jr,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new jr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new jr(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 Pd(e,t,n,r){if(n==In&&r==In)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=In[0]),o=a}wb(o,l||In[0],s)}return o}function wb(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 $d(e,t,n){return Pd(e,e,In,yl(t,n,!W(e)))}function Fo(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 rd(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var wl=class{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=kb(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=gt,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 Pn&&c.dirty!=vt&&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=Pn.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==vt&&s.dom==s.contentDOM&&(s.dirty=Ln),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!=vt&&Fo(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=Ln,d.updateChildren(o,s+1),d.dirty=gt),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)||!Fo(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 _o(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 Pn;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof Vo)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ge||We)&&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 jo(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 kb(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 Pn)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 vb(e,t){return e.type.side-t.type.side}function Cb(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(vb);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 g=0;g<l.length;g++)l[g].to<m&&(m=l[g].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 b=f.isInline&&!f.isLeaf?l.filter(m=>!m.inline):l.slice();r(f,b,t.forChild(i,f),p),i=h}}function xb(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 Sb(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 kl(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 Dl(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(Xo(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&j.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&eb(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new j(s==d?l:r.resolve(d))}else if(ut&&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=Ll(e,c,l,d)}return u}function Bd(e){return e.editable?e.hasFocus():Hd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function _t(e,t=!1){let n=e.state.selection;if(zd(e,n),!Bd(e))return;let r=e.input.mouseDown;if(!t&&We&&r){let o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Hn(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;od&&!(n instanceof D)&&(n.$from.parent.inlineContent||(s=id(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=id(e,n.to))),e.docView.setSelection(o,i,e,t),od&&(s&&sd(s),l&&sd(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Eb(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var od=Ge||We&&Md<63;function id(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(Ge&&o&&o.contentEditable=="false")return al(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return al(o);if(i)return al(i)}}function al(e){return e.contentEditable="true",Ge&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function sd(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Eb(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(()=>{(!Bd(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,Fe(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&ot&&an<=11&&(n.disabled=!0,n.disabled=!1)}function zd(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ld(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ld(e)}function ld(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ll(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||D.between(t,n,r)}function ad(e){return e.editable&&!e.hasFocus()?!1:Hd(e)}function Hd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return _n(e.dom,t.anchorNode)&&(e.editable||_n(e.dom,t.focusNode))}catch{return!1}}function Ab(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Hn(t.node,t.offset,n.anchorNode,n.anchorOffset)}function vl(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 ln(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function cd(e,t,n){let r=e.state.selection;if(r instanceof D)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 D(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=vl(e.state,t);return o&&o instanceof j?ln(e,o):!1}else if(!(mt&&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?j.isSelectable(i)?ln(e,new j(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):ln(e,new D(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof j&&r.node.isInline)return ln(e,new D(t>0?r.$to:r.$from));{let o=vl(e.state,t);return o?ln(e,o):!1}}}function Fr(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):W(e)&&e.contentEditable=="false"}function ar(e,t){return t<0?Tb(e):Nb(e)}function Tb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(ut&&W(n)&&r<qe(n)&&Fr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(n))break;let l=n.childNodes[r-1];if(Fr(l,-1))o=n,i=--r;else if(Ie(l))n=l,r=n.nodeValue.length;else break}else{if(_d(n))break;{let l=n.previousSibling;for(;l&&Fr(l,-1);)o=n.parentNode,i=Fe(l),l=l.previousSibling;if(l)n=l,r=qe(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Cl(e,n,r):o&&Cl(e,o,i)}function Nb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=qe(n),i,s;for(;;)if(r<o){if(!W(n))break;let l=n.childNodes[r];if(Fr(l,1))i=n,s=++r;else break}else{if(_d(n))break;{let l=n.nextSibling;for(;l&&Fr(l,1);)i=l.parentNode,s=Fe(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=qe(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&Cl(e,i,s)}function _d(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Rb(e,t){for(;e&&t==e.childNodes.length&&!Gr(e);)t=Fe(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(Ie(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=0}}function Ob(e,t){for(;e&&!t&&!Gr(e);)t=Fe(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(Ie(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Cl(e,t,n){if(!Ie(t)){let i,s;(s=Rb(t,n))?(t=s,n=0):(i=Ob(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Xo(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&&_t(e)},50)}function ud(e,t){let n=e.state.doc.resolve(t);if(!(We||Ad)&&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 dd(e,t,n){let r=e.state.selection;if(r instanceof D&&!r.empty||n.indexOf("s")>-1||mt&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=vl(e.state,t);if(s&&s instanceof j)return ln(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,l=r instanceof rn?X.near(s,t):X.findFrom(s,t);return l?ln(e,l):!1}return!1}function fd(e,t){if(!(e.state.selection instanceof D))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 pd(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Db(e){if(!Ge||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;pd(e,r,"true"),setTimeout(()=>pd(e,r,"false"),20)}return!1}function Lb(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Ib(e,t){let n=t.keyCode,r=Lb(t);if(n==8||mt&&n==72&&r=="c")return fd(e,-1)||ar(e,-1);if(n==46&&!t.shiftKey||mt&&n==68&&r=="c")return fd(e,1)||ar(e,1);if(n==13||n==27)return!0;if(n==37||mt&&n==66&&r=="c"){let o=n==37?ud(e,e.state.selection.from)=="ltr"?-1:1:-1;return cd(e,o,r)||ar(e,o)}else if(n==39||mt&&n==70&&r=="c"){let o=n==39?ud(e,e.state.selection.from)=="ltr"?1:-1:1;return cd(e,o,r)||ar(e,o)}else{if(n==38||mt&&n==80&&r=="c")return dd(e,-1,r)||ar(e,-1);if(n==40||mt&&n==78&&r=="c")return Db(e)||dd(e,1,r)||ar(e,1);if(r==(mt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Il(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")||Rn.fromSchema(e.state.schema),l=Ud(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&W(u)&&(c=Kd[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,`
|
|
1
|
+
import{db as ku,ha as Hs,ia as _s,ib as Bo,jb as He,kb as zo,lb as vu,mb as Eu,nb as Mu,ta as nn,ua as Vs,va as pu,xa as hu}from"./chunk-TBEPAJ5C.js";import"./chunk-3RZMLHCB.js";import"./chunk-JXKAISUX.js";import"./chunk-C4JCEMQN.js";import{A as rn,B as _r,C as U,D as te,E as bu,G as yu,K as Ws,d as V,e as mu,f as ce,g as Do,h as js,i as Nn,j as Rn,k as Oo,l as gu,m as Dn,n as St,o as Pt,p as or,q as ht,r as kt,s as ir,t as Lo,u as Io,v as Po,w as X,x as Fs,y as O,z as j}from"./chunk-KQR52I3G.js";import"./chunk-SNEZ3O5V.js";import"./chunk-77DN5DLU.js";import"./chunk-AIBH6MTQ.js";import"./chunk-BR33OQJ3.js";import"./chunk-4RYRJOIW.js";import"./chunk-MLBEJ7IZ.js";import{a as Ks,b as Ho,c as Cu,e as xu}from"./chunk-7G6RMB6W.js";import{a as jg,b as Fg}from"./chunk-WP3ME37P.js";import"./chunk-GLP5VV7P.js";import{a as wu}from"./chunk-5AW2WUSZ.js";import{a as Au}from"./chunk-6G2M37RQ.js";import"./chunk-DG67SWQA.js";import"./chunk-KF47DKNH.js";import{$ as Uc,$a as Mn,A as zr,Ab as Le,B as Eo,Bb as Su,Da as tn,G as zc,Ga as Os,H as Hc,Ha as eu,J as _c,K as Vc,M as jc,O as Fc,Oa as Ls,P as Wc,Pa as Is,Qa as tu,Ta as nu,Va as Ps,Wa as ru,Xa as $s,Ya as ou,Z as Kc,Za as iu,_a as Bs,a as Oc,aa as qc,ab as An,ba as Gc,bb as su,c as en,ca as Jc,cb as Tn,da as Mo,db as No,eb as Ro,fa as Xc,fb as lu,gb as au,ib as cu,ja as Ao,ka as Rs,lb as Hr,m as Lc,ma as Ds,mb as Ze,nb as zs,o as Ic,q as Pc,r as Ns,ra as Yc,s as $c,sa as To,ta as Qc,tb as uu,ub as du,xb as fu,ya as Zc,z as Bc}from"./chunk-H7ALO2Q6.js";import{a as $o,f as sr}from"./chunk-J6IRWTF7.js";import{a as Vg,c as we}from"./chunk-DCANE7XH.js";var Zm=Vg((QT,Qm)=>{function _m(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)&&_m(n)}),e}var vs=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function Vm(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 qx="</span>",Im=e=>!!e.scope,Gx=(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}`},fc=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=Vm(t)}openNode(t){if(!Im(t))return;let n=Gx(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Im(t)&&(this.buffer+=qx)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},Pm=(e={})=>{let t={children:[]};return Object.assign(t,e),t},pc=class e{constructor(){this.rootNode=Pm(),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=Pm({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)}))}},hc=class extends pc{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 fc(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Co(e){return e?typeof e=="string"?e:e.source:null}function jm(e){return nr("(?=",e,")")}function Jx(e){return nr("(?:",e,")*")}function Xx(e){return nr("(?:",e,")?")}function nr(...e){return e.map(n=>Co(n)).join("")}function Yx(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function xs(...e){return"("+(Yx(e).capture?"":"?:")+e.map(r=>Co(r)).join("|")+")"}function Fm(e){return new RegExp(e.toString()+"|").exec("").length-1}function Qx(e,t){let n=e&&e.exec(t);return n&&n.index===0}var Zx=new RegExp(xs(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function gc(e,{joinWith:t}){let n=0;return e.map(r=>{n+=1;let o=n,i=Co(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 eS=/\b\B/,Wm="[a-zA-Z]\\w*",bc="[a-zA-Z_]\\w*",Km="\\b\\d+(\\.\\d+)?",Um="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",qm="\\b(0b[01]+)",tS="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",nS=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=nr(t,/.*\b/,e.binary,/\b.*/)),bn({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},e)},xo={begin:"\\\\[\\s\\S]",relevance:0},rS={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[xo]},oS={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[xo]},iS={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/},Ss=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=xs("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:nr(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},sS=Ss("//","$"),lS=Ss("/\\*","\\*/"),aS=Ss("#","$"),cS={scope:"number",begin:Km,relevance:0},uS={scope:"number",begin:Um,relevance:0},dS={scope:"number",begin:qm,relevance:0},fS={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[xo,{begin:/\[/,end:/\]/,relevance:0,contains:[xo]}]},pS={scope:"title",begin:Wm,relevance:0},hS={scope:"title",begin:bc,relevance:0},mS={begin:"\\.\\s*"+bc,relevance:0},gS=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()}})},ks=Object.freeze({__proto__:null,APOS_STRING_MODE:rS,BACKSLASH_ESCAPE:xo,BINARY_NUMBER_MODE:dS,BINARY_NUMBER_RE:qm,COMMENT:Ss,C_BLOCK_COMMENT_MODE:lS,C_LINE_COMMENT_MODE:sS,C_NUMBER_MODE:uS,C_NUMBER_RE:Um,END_SAME_AS_BEGIN:gS,HASH_COMMENT_MODE:aS,IDENT_RE:Wm,MATCH_NOTHING_RE:eS,METHOD_GUARD:mS,NUMBER_MODE:cS,NUMBER_RE:Km,PHRASAL_WORDS_MODE:iS,QUOTE_STRING_MODE:oS,REGEXP_MODE:fS,RE_STARTERS_RE:tS,SHEBANG:nS,TITLE_MODE:pS,UNDERSCORE_IDENT_RE:bc,UNDERSCORE_TITLE_MODE:hS});function bS(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function yS(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function wS(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=bS,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function kS(e,t){Array.isArray(e.illegal)&&(e.illegal=xs(...e.illegal))}function vS(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 CS(e,t){e.relevance===void 0&&(e.relevance=1)}var xS=(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=nr(n.beforeMatch,jm(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},SS=["of","and","for","in","not","or","if","then","parent","list","value"],ES="keyword";function Gm(e,t,n=ES){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,Gm(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,MS(a[0],a[1])]})}}function MS(e,t){return t?Number(t):AS(e)?0:1}function AS(e){return SS.includes(e.toLowerCase())}var $m={},tr=e=>{console.error(e)},Bm=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Or=(e,t)=>{$m[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),$m[`${e}/${t}`]=!0)},Cs=new Error;function Jm(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+=Fm(t[l-1]);e[n]=s,e[n]._emit=i,e[n]._multi=!0}function TS(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw tr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Cs;if(typeof e.beginScope!="object"||e.beginScope===null)throw tr("beginScope must be object"),Cs;Jm(e,e.begin,{key:"beginScope"}),e.begin=gc(e.begin,{joinWith:""})}}function NS(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw tr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Cs;if(typeof e.endScope!="object"||e.endScope===null)throw tr("endScope must be object"),Cs;Jm(e,e.end,{key:"endScope"}),e.end=gc(e.end,{joinWith:""})}}function RS(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function DS(e){RS(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),TS(e),NS(e)}function OS(e){function t(s,l){return new RegExp(Co(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+=Fm(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let l=this.regexes.map(a=>a[1]);this.matcherRe=t(gc(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;[yS,vS,DS,xS].forEach(c=>c(s,l)),e.compilerExtensions.forEach(c=>c(s,l)),s.__beforeBegin=null,[wS,kS,CS].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=Gm(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=Co(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 LS(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 Xm(e){return e?e.endsWithParent||Xm(e.starts):!1}function LS(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return bn(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Xm(e)?bn(e,{starts:e.starts?bn(e.starts):null}):Object.isFrozen(e)?bn(e):e}var IS="11.12.0",mc=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},dc=Vm,zm=bn,Hm=Symbol("nomatch"),PS=7,Ym=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:hc};function a(T){return l.noHighlightRe.test(T)}function u(T){let H=T.className+" ";H+=T.parentNode?T.parentNode.className:"";let I=l.languageDetectRe.exec(H);if(I){let ae=L(I[1]);return ae||(Bm(i.replace("{}",I[1])),Bm("Falling back to no-highlight mode for this block.",T)),ae?I[1]:"no-highlight"}return H.split(/\s+/).find(ae=>a(ae)||L(ae))}function c(T,H,I){let ae="",ye="";typeof H=="object"?(ae=T,I=H.ignoreIllegals,ye=H.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`),ye=T,ae=H),I===void 0&&(I=!0);let ke={code:ae,language:ye};je("before:highlight",ke);let Ye=ke.result?ke.result:d(ke.language,ke.code,I);return Ye.code=ke.code,je("after:highlight",Ye),Ye}function d(T,H,I,ae){let ye=Object.create(null);function ke(D,B){return D.keywords[B]}function Ye(){if(!q.keywords){Se.addText(ie);return}let D=0;q.keywordPatternRe.lastIndex=0;let B=q.keywordPatternRe.exec(ie),J="";for(;B;){J+=ie.substring(D,B.index);let se=De.case_insensitive?B[0].toLowerCase():B[0],Oe=ke(q,se);if(Oe){let[ct,Br]=Oe;if(Se.addText(J),J="",ye[se]=(ye[se]||0)+1,ye[se]<=PS&&(vn+=Br),ct.startsWith("_"))J+=B[0];else{let It=De.classNameAliases[ct]||ct;lt(B[0],It)}}else J+=B[0];D=q.keywordPatternRe.lastIndex,B=q.keywordPatternRe.exec(ie)}J+=ie.substring(D),Se.addText(J)}function wn(){if(ie==="")return;let D=null;if(typeof q.subLanguage=="string"){if(!t[q.subLanguage]){Se.addText(ie);return}D=d(q.subLanguage,ie,!0,at[q.subLanguage]),at[q.subLanguage]=D._top}else D=p(ie,q.subLanguage.length?q.subLanguage:null);q.relevance>0&&(vn+=D.relevance),Se.__addSublanguage(D._emitter,D.language)}function Be(){q.subLanguage!=null?wn():Ye(),ie=""}function lt(D,B){D!==""&&(Se.startScope(B),Se.addText(D),Se.endScope())}function wt(D,B){let J=1,se=B.length-1;for(;J<=se;){if(!D._emit[J]){J++;continue}let Oe=De.classNameAliases[D[J]]||D[J],ct=B[J];Oe?lt(ct,Oe):(ie=ct,Ye(),ie=""),J++}}function Ir(D,B){return D.scope&&typeof D.scope=="string"&&Se.openNode(De.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(lt(ie,De.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),ie=""):D.beginScope._multi&&(wt(D.beginScope,B),ie="")),q=Object.create(D,{parent:{value:q}}),q}function Yt(D,B,J){let se=Qx(D.endRe,J);if(se){if(D["on:end"]){let Oe=new vs(D);D["on:end"](B,Oe),Oe.isMatchIgnored&&(se=!1)}if(se){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return Yt(D.parent,B,J)}function Qt(D){return q.matcher.regexIndex===0?(ie+=D[0],1):(w=!0,0)}function kn(D){let B=D[0],J=D.rule,se=new vs(J),Oe=[J.__beforeBegin,J["on:begin"]];for(let ct of Oe)if(ct&&(ct(D,se),se.isMatchIgnored))return Qt(B);return J.skip?ie+=B:(J.excludeBegin&&(ie+=B),Be(),!J.returnBegin&&!J.excludeBegin&&(ie=B)),Ir(J,D),J.returnBegin?0:B.length}function pt(D){let B=D[0],J=H.substring(D.index),se=Yt(q,D,J);if(!se)return Hm;let Oe=q;q.endScope&&q.endScope._wrap?(Be(),lt(B,q.endScope._wrap)):q.endScope&&q.endScope._multi?(Be(),wt(q.endScope,D)):Oe.skip?ie+=B:(Oe.returnEnd||Oe.excludeEnd||(ie+=B),Be(),Oe.excludeEnd&&(ie=B));do q.scope&&Se.closeNode(),!q.skip&&!q.subLanguage&&(vn+=q.relevance),q=q.parent;while(q!==se.parent);return se.starts&&Ir(se.starts,D),Oe.returnEnd?0:B.length}function ee(){let D=[];for(let B=q;B!==De;B=B.parent)B.scope&&D.unshift(B.scope);D.forEach(B=>Se.openNode(B))}let Te={};function Pr(D,B){let J=B&&B[0];if(ie+=D,J==null)return Be(),0;if(Te.type==="begin"&&B.type==="end"&&Te.index===B.index&&J===""){if(ie+=H.slice(B.index,B.index+1),!o){let se=new Error(`0 width match regex (${T})`);throw se.languageName=T,se.badRule=Te.rule,se}return 1}if(Te=B,B.type==="begin")return kn(B);if(B.type==="illegal"&&!I){let se=new Error('Illegal lexeme "'+J+'" for mode "'+(q.scope||"<unnamed>")+'"');throw se.mode=q,se}else if(B.type==="end"){let se=pt(B);if(se!==Hm)return se}if(B.type==="illegal"&&J==="")return B.index===H.length||(ie+=`
|
|
3
|
+
`),1;if($r>1e5&&$r>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ie+=J,J.length}let De=L(T);if(!De)throw tr(i.replace("{}",T)),new Error('Unknown language: "'+T+'"');let rr=OS(De),xt="",q=ae||rr,at={},Se=new l.__emitter(l);ee();let ie="",vn=0,Qe=0,$r=0,w=!1;try{if(De.__emitTokens)De.__emitTokens(H,Se);else{for(q.matcher.considerAll();;){$r++,w?w=!1:q.matcher.considerAll(),q.matcher.lastIndex=Qe;let D=q.matcher.exec(H);if(!D)break;let B=H.substring(Qe,D.index),J=Pr(B,D);Qe=D.index+J}Pr(H.substring(Qe))}return Se.finalize(),xt=Se.toHTML(),{language:T,value:xt,relevance:vn,illegal:!1,_emitter:Se,_top:q}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:T,value:dc(H),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:Qe,context:H.slice(Qe-100,Qe+100),mode:D.mode,resultSoFar:xt},_emitter:Se};if(o)return{language:T,value:dc(H),illegal:!1,relevance:0,errorRaised:D,_emitter:Se,_top:q};throw D}}function f(T){let H={value:dc(T),illegal:!1,relevance:0,_top:s,_emitter:new l.__emitter(l)};return H._emitter.addText(T),H}function p(T,H){H=H||l.languages||Object.keys(t);let I=f(T),ae=H.filter(L).filter(he).map(Be=>d(Be,T,!1));ae.unshift(I);let ye=ae.sort((Be,lt)=>{if(Be.relevance!==lt.relevance)return lt.relevance-Be.relevance;if(Be.language&<.language){if(L(Be.language).supersetOf===lt.language)return 1;if(L(lt.language).supersetOf===Be.language)return-1}return 0}),[ke,Ye]=ye,wn=ke;return wn.secondBest=Ye,wn}function h(T,H,I){let ae=H&&n[H]||I;T.classList.add("hljs"),T.classList.add(`language-${ae}`)}function g(T){let H=null,I=u(T);if(a(I))return;if(je("before:highlightElement",{el:T,language:I}),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 mc("One of your code blocks includes unescaped HTML.",T.innerHTML);H=T;let ae=H.textContent,ye=I?c(ae,{language:I,ignoreIllegals:!0}):p(ae);T.innerHTML=ye.value,T.dataset.highlighted="yes",h(T,I,ye.language),T.result={language:ye.language,re:ye.relevance,relevance:ye.relevance},ye.secondBest&&(T.secondBest={language:ye.secondBest.language,relevance:ye.secondBest.relevance}),je("after:highlightElement",{el:T,result:ye,text:ae})}function m(T){l=zm(l,T)}let b=()=>{S(),Or("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function k(){S(),Or("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function S(){function T(){S()}if(document.readyState==="loading"){C||window.addEventListener("DOMContentLoaded",T,!1),C=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function A(T,H){let I=null;try{I=H(e)}catch(ae){if(tr("Language definition for '{}' could not be registered.".replace("{}",T)),o)tr(ae);else throw ae;I=s}I.name||(I.name=T),t[T]=I,I.rawDefinition=H.bind(null,e),I.aliases&&oe(I.aliases,{languageName:T})}function E(T){delete t[T];for(let H of Object.keys(n))n[H]===T&&delete n[H]}function M(){return Object.keys(t)}function L(T){return T=(T||"").toLowerCase(),t[T]||t[n[T]]}function oe(T,{languageName:H}){typeof T=="string"&&(T=[T]),T.forEach(I=>{n[I.toLowerCase()]=H})}function he(T){let H=L(T);return H&&!H.disableAutodetect}function Ce(T){T["before:highlightBlock"]&&!T["before:highlightElement"]&&(T["before:highlightElement"]=H=>{T["before:highlightBlock"](Object.assign({block:H.el},H))}),T["after:highlightBlock"]&&!T["after:highlightElement"]&&(T["after:highlightElement"]=H=>{T["after:highlightBlock"](Object.assign({block:H.el},H))})}function Ae(T){Ce(T),r.push(T)}function Ve(T){let H=r.indexOf(T);H!==-1&&r.splice(H,1)}function je(T,H){let I=T;r.forEach(function(ae){ae[I]&&ae[I](H)})}function $e(T){return Or("10.7.0","highlightBlock will be removed entirely in v12.0"),Or("10.7.0","Please use highlightElement now."),g(T)}Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:S,highlightElement:g,highlightBlock:$e,configure:m,initHighlighting:b,initHighlightingOnLoad:k,registerLanguage:A,unregisterLanguage:E,listLanguages:M,getLanguage:L,registerAliases:oe,autoDetection:he,inherit:zm,addPlugin:Ae,removePlugin:Ve}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=IS,e.regex={concat:nr,lookahead:jm,either:xs,optional:Xx,anyNumberOfTimes:Jx};for(let T in ks)typeof ks[T]=="object"&&_m(ks[T]);return Object.assign(e,ks),e},Lr=Ym({});Lr.newInstance=()=>Ym({});Qm.exports=Lr;Lr.HighlightJS=Lr;Lr.default=Lr});var Nu=we(en(),1);var Tu=$o("primitives",{"zh-CN":{sharedData:"\u5171\u4EAB\u6570\u636E\u2026",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:{sharedData:"Shared data\u2026",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 me=we(Ze(),1),Ru="showai:shared-data";function Wg(){if(typeof window>"u")return!1;let e=new CustomEvent(Ru,{cancelable:!0,detail:null});return window.dispatchEvent(e),e.defaultPrevented}function Du({editor:e,position:t,onDone:n}){let r=Le(Tu),[o,i]=(0,Nu.useState)(""),s=e.state.doc.nodeAt(t);if(!s||!e.isEditable)return null;let l=s.type.name,a=(p,h)=>{e.view.dispatch(e.state.tr.setNodeAttribute(t,p,h))},u=(p,h)=>(0,me.jsxs)("label",{children:[h,(0,me.jsx)("input",{value:s.attrs[p]??"",onChange:g=>a(p,g.target.value)})]},p),c=["image","table","codeBlock","callout","toggle","stepper","horizontalRule"].includes(l),d=s.attrs.componentStyle??{},f=(p,h)=>{let g={...d};h===void 0?delete g[p]:g[p]=h,a("componentStyle",g)};if(l==="widget"&&s.attrs.kind!=="text"&&Wg()){let p=s.attrs.id,h=g=>{let m=-1;e.state.doc.descendants((b,k)=>(m<0&&b.attrs?.id===p&&(m=k),m<0)),m>=0&&e.view.dispatch(e.state.tr.setNodeAttribute(m,"data",g))};return(0,me.jsxs)("button",{type:"button",onClick:()=>{window.dispatchEvent(new CustomEvent(Ru,{cancelable:!0,detail:{kind:s.attrs.kind,data:s.attrs.data,apply:h}})),n?.()},children:[(0,me.jsx)(Vc,{size:15}),r("sharedData")]})}return(0,me.jsxs)("div",{className:"content-node-fields",children:[l==="image"&&(0,me.jsxs)(me.Fragment,{children:[u("src",r("imageSrc")),u("alt",r("imageAlt")),u("caption",r("imageCaption")),["width","height"].map(p=>(0,me.jsxs)("label",{children:[r(p),(0,me.jsx)("input",{inputMode:"decimal",value:s.attrs[p]??"",onChange:h=>{let g=h.target.value;(!g||/^\d+(?:px|%)?$/.test(g)&&parseInt(g)>0&&parseInt(g)<=1e4)&&a(p,g?/^\d+$/.test(g)?Number(g):g:null)}})]},p)),(0,me.jsxs)("label",{children:[r("fit"),(0,me.jsxs)("select",{value:s.attrs.fit??"contain",onChange:p=>a("fit",p.target.value),children:[(0,me.jsx)("option",{value:"contain",children:r("contain")}),(0,me.jsx)("option",{value:"cover",children:r("cover")})]})]})]}),["table","callout","toggle"].includes(l)&&u("title",r("title")),l==="codeBlock"&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("label",{children:[r("language"),(0,me.jsxs)("select",{value:Ho(s.attrs.language),onChange:p=>a("language",p.target.value),children:[(0,me.jsx)("option",{value:"plaintext",children:r("plainText")}),!Ks.includes(Ho(s.attrs.language))&&(0,me.jsxs)("option",{value:Ho(s.attrs.language),children:[s.attrs.language,Cu(s.attrs.language)?"":` (${r("plainText")})`]}),Ks.filter(p=>p!=="plaintext").map(p=>(0,me.jsx)("option",{value:p,children:p},p))]})]}),(0,me.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(s.textContent).then(()=>i(r("copied"))).catch(p=>i(p.message))},children:r("copy")}),o&&(0,me.jsx)("span",{role:"status",children:o})]}),c&&(0,me.jsxs)("details",{children:[(0,me.jsx)("summary",{children:r("appearance")}),["color","backgroundColor"].map(p=>(0,me.jsxs)("label",{children:[r(p),(0,me.jsx)("input",{value:d[p]??"",onChange:h=>f(p,h.target.value||void 0)})]},p)),["fontSize","padding","radius"].map(p=>(0,me.jsxs)("label",{children:[r(p),(0,me.jsx)("input",{type:"number",min:p==="fontSize"?8:0,max:"200",value:d[p]??"",onChange:h=>{let g=h.target.value;(!g||Number(g)>=(p==="fontSize"?8:0)&&Number(g)<=200)&&f(p,g?Number(g):void 0)}})]},p))]})]})}var _o=$o("richTextNotes",{"zh-CN":{"format.note":"\u6CE8\u91CA","dialog.addNote":"\u6DFB\u52A0\u6CE8\u91CA","dialog.editNote":"\u4FEE\u6539\u6CE8\u91CA","dialog.noteText":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u6240\u9009\u6587\u5B57\u4E0A\u65F6\u663E\u793A\uFF09","dialog.noteFormula":"\u6CE8\u91CA\u5185\u5BB9\uFF08\u8BFB\u8005\u628A\u9F20\u6807\u79FB\u5230\u8FD9\u4E2A\u516C\u5F0F\u4E0A\u65F6\u663E\u793A\uFF09","dialog.notePlaceholder":"\u4F8B\u5982\uFF1A\u7B2C t \u6B65\u7684\u5E26\u566A\u6F5C\u53D8\u91CF\uFF0C\u5F62\u72B6\u4E0E\u56FE\u50CF\u6F5C\u53D8\u91CF\u76F8\u540C","dialog.noteHint":"\u53EF\u7528 $\u2026$ \u5199\u516C\u5F0F\uFF1B\u53EA\u6CE8\u91CA\u516C\u5F0F\u4E2D\u7684\u67D0\u4E2A\u53D8\u91CF\u65F6\uFF0C\u5728\u516C\u5F0F\u6E90\u7801\u91CC\u5199 \\note{x_t}{\u2026}\u3002\u2318\u21A9 \u4FDD\u5B58\u3002","dialog.removeNote":"\u5220\u9664\u6CE8\u91CA","dialog.noteNeedsSelection":"\u5148\u9009\u4E2D\u8981\u52A0\u6CE8\u91CA\u7684\u6587\u5B57\u6216\u516C\u5F0F\u3002","dialog.noteTargetMissing":"\u8981\u6CE8\u91CA\u7684\u516C\u5F0F\u5DF2\u7ECF\u4E0D\u5728\u539F\u4F4D\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002","dialog.noteTooLong":"\u6CE8\u91CA\u6700\u591A {max} \u4E2A\u5B57\u7B26\u3002"},en:{"format.note":"Note","dialog.addNote":"Add note","dialog.editNote":"Edit note","dialog.noteText":"Note (shown when readers hover the selected text)","dialog.noteFormula":"Note (shown when readers hover this formula)","dialog.notePlaceholder":"For example: the noisy latent at step t, shaped like the image latent","dialog.noteHint":"Use $\u2026$ for formulas. To annotate one variable inside a formula, write \\note{x_t}{\u2026} in its source. \u2318\u21A9 saves.","dialog.removeNote":"Remove note","dialog.noteNeedsSelection":"Select the text or formula to annotate first.","dialog.noteTargetMissing":"The formula moved. Select it again.","dialog.noteTooLong":"Notes can have at most {max} characters."}});function Ou(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 $=we(en(),1),Mc=we(zs(),1);var Z=we(en(),1);var bi=we(zs(),1),Ap=we(jg(),1);var Lu=Object.defineProperty,Iu=(e,t)=>{let n={};for(var r in e)Lu(n,r,{get:e[r],enumerable:!0});return t||Lu(n,Symbol.toStringTag,{value:"Module"}),n};var $u=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Bu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var qs=(e,t,n)=>{let r=Bu(e,n);if(!r)return!1;let o=Js(r);if(!o){let s=r.blockRange(),l=s&&Pt(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Uu(e,o,t,-1))return!0;if(r.parent.content.size==0&&(lr(i,"end")||j.isSelectable(i)))for(let s=r.depth;;s--){let l=Io(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):j.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},zu=(e,t,n)=>{let r=Bu(e,n);if(!r)return!1;let o=Js(r);return o?_u(e,o,t):!1},Hu=(e,t,n)=>{let r=Vu(e,n);if(!r)return!1;let o=Qs(r);return o?_u(e,o,t):!1};function _u(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=Io(e.doc,i,a,ce.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(O.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 Gs=(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||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.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 Vu(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Xs=(e,t,n)=>{let r=Vu(e,n);if(!r)return!1;let o=Qs(r);if(!o)return!1;let i=o.nodeAfter;if(Uu(e,o,t,1))return!0;if(r.parent.content.size==0&&(lr(i,"start")||j.isSelectable(i))){let s=Io(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):j.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},Ys=(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=Qs(r)}let s=i&&i.nodeAfter;return!s||!j.isSelectable(s)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,i.pos)).scrollIntoView()),!0)};function Qs(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 ju=(e,t)=>{let n=e.selection,r=n instanceof j,o;if(r){if(n.node.isTextblock||!kt(e.doc,n.from))return!1;o=n.from}else if(o=ir(e.doc,n.from,-1),o==null)return!1;if(t){let i=e.tr.join(o);r&&i.setSelection(j.create(i.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0},Fu=(e,t)=>{let n=e.selection,r;if(n instanceof j){if(n.node.isTextblock||!kt(e.doc,n.to))return!1;r=n.to}else if(r=ir(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Wu=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&Pt(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},Zs=(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 el(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 tl=(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=el(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},nl=(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=el(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(O.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},rl=(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(ht(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Pt(r);return o==null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function Kg(e){return(t,n)=>{if(t.selection instanceof j&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!ht(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 O||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=el(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=ht(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=ht(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 Ug=Kg();var Ku=(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(j.create(e.doc,o))),!0)},qg=(e,t)=>(t&&t(e.tr.setSelection(new rn(e.doc))),!0);function Gg(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||kt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Uu(e,t,n,r){let o=t.nodeBefore,i=t.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Gg(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=V.empty;for(let b=s.length-1;b>=0;b--)h=V.from(s[b].create(null,h));h=V.from(o.copy(h));let g=e.tr.step(new St(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&&kt(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&&Pt(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=V.empty;for(let C=h.length-1;C>=0;C--)b=V.from(h[C].copy(b));let k=e.tr.step(new St(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 qu(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(O.create(t.doc,e<0?o.start(i):o.end(i)))),!0):!1}}var ol=qu(-1),il=qu(1);function Gu(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&or(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function sl(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 ll(...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 Us=ll($u,qs,Gs),Pu=ll($u,Xs,Ys),on={Enter:ll(Zs,nl,rl,Ug),"Mod-Enter":tl,Backspace:Us,"Mod-Backspace":Us,"Shift-Backspace":Us,Delete:Pu,"Mod-Delete":Pu,"Mod-a":qg},Jg={"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":ol,"Ctrl-e":il};for(let e in on)Jg[e]=on[e];var V1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Ju(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 Xg(l,s,e,t)?(r&&r(l.scrollIntoView()),!0):!1}}function Xg(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 Do(a,a,t.depth),t.endIndex<t.parent.childCount&&(t=new Do(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=or(i,n,r,t);return l?(e&&Yg(e,t,l,o,n),!0):!1}function Yg(e,t,n,r,o){let i=V.empty;for(let c=n.length-1;c>=0;c--)i=V.from(n[c].type.create(n[c].attrs,i));e.step(new St(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&&ht(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=u.child(c).nodeSize;return e}function Xu(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?Qg(t,n,e,i):Zg(t,n,i):!0:!1}}function Qg(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new St(i-1,s,i,s,new ce(V.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Do(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=Pt(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return kt(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?V.empty:V.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new St(d-(l?1:0),f+(a?1:0),d+1,f-1,new ce((l?V.empty:V.from(o.copy(V.empty))).append(a?V.empty:V.from(o.copy(V.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}function Yu(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=V.from(u?e.create():null),d=new ce(V.from(e.create(null,V.from(l.type.create(null,c)))),u?3:1,0),f=i.start,p=i.end;n(t.tr.step(new St(f-(u?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var Fe=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},fl=null,Bt=function(e,t,n){let r=fl||(fl=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},eb=function(){fl=null},Hn=function(e,t,n,r){return n&&(Qu(e,t,n,r,-1)||Qu(e,t,n,r,1))},tb=/^(img|br|input|textarea|hr)$/i;function Qu(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:qe(e))){let s=e.parentNode;if(!s||!W(s)||Jr(e)||tb.test(e.nodeName)||e.contentEditable=="false")return!1;t=Fe(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?qe(e):0}else return!1}}function qe(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function W(e){return e.nodeType==1}function Ie(e){return e.nodeType==3}function _n(e,t){return t?e.contains(W(t)?t:t.parentNode):!1}function nb(e,t){for(;;){if(Ie(e)&&t)return e;if(W(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=qe(e)}else if(e.parentNode&&!Jr(e))t=Fe(e),e=e.parentNode;else return null}}function rb(e,t){for(;;){if(Ie(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&&!Jr(e))t=Fe(e)+1,e=e.parentNode;else return null}}function ob(e,t,n){for(let r=t==0,o=t==qe(e);r||o;){if(e==n)return!0;let i=Fe(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,o=o&&i==qe(e)}}function Jr(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 Yo=function(e){return e.focusNode&&Hn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function On(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function ib(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function sb(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(qe(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(qe(r.startContainer),r.startOffset)}}}var Et=typeof navigator<"u"?navigator:null,Zu=typeof document<"u"?document:null,un=Et&&Et.userAgent||"",pl=/Edge\/(\d+)/.exec(un),Td=/MSIE \d/.exec(un),hl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(un),ot=!!(Td||hl||pl),an=Td?document.documentMode:hl?+hl[1]:pl?+pl[1]:0,ut=!ot&&/gecko\/(\d+)/i.test(un);ut&&+(/Firefox\/(\d+)/.exec(un)||[0,0])[1];var ml=!ot&&/Chrome\/(\d+)/.exec(un),We=!!ml,Nd=ml?+ml[1]:0,Ge=!ot&&!!Et&&/Apple Computer/.test(Et.vendor),fr=Ge&&(/Mobile\/\w+/.test(un)||!!Et&&Et.maxTouchPoints>2),mt=fr||(Et?/Mac/.test(Et.platform):!1),Rd=Et?/Win/.test(Et.platform):!1,zt=/Android \d/.test(un),Qo=!!Zu&&"webkitFontSmoothing"in Zu.documentElement.style,lb=Qo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ab(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 $t(e,t){return typeof e=="number"?e:e[t]}function cb(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 ed(e,t,n){if(!gl(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?ab(i):cb(s),u=0,c=0;if(t.top<a.top+$t(r,"top")?c=-(a.top-t.top+$t(o,"top")):t.bottom>a.bottom-$t(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+$t(o,"top")-a.top:t.bottom-a.bottom+$t(o,"bottom")),t.left<a.left+$t(r,"left")?u=-(a.left-t.left+$t(o,"left")):t.right>a.right-$t(r,"right")&&(u=t.right-a.right+$t(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 ub(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:Dd(e.dom)}}function Dd(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 db({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Od(n,r==0?0:r-t)}function Od(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 fb(e){if(e.setActive)return e.setActive();if(ar)return e.focus(ar);let t=Dd(e);e.focus(ar==null?{get preventScroll(){return ar={preventScroll:!0},!0}}:void 0),ar||(ar=!1,Od(t,0))}function Ld(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(Ie(c))f=Bt(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&&Ie(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&&Ie(n)?pb(n,o):!n||r?{node:e,offset:i}:Ld(n,o)}function pb(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&&Ol(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 Ol(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function hb(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function mb(e,t,n){let{node:r,offset:o}=Ld(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 gb(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 Id(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(Ol(t,u))return Id(s,t,u)}}if((i=(i+1)%r)==o)break}return e}function bb(e,t){let n=e.dom.ownerDocument,r,o=0,i=sb(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(!Ol(t,u)||(s=Id(e.dom,t,u),!s))return null}if(Ge)for(let u=s;r&&u;u=dr(u))u.draggable&&(r=void 0);if(s=hb(s,t),r){if(ut&&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;Qo&&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=gb(e,r,o,t))}l==null&&(l=mb(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function gl(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(gl(r))return r}return Array.prototype.find.call(n,gl)||e.getBoundingClientRect()}var yb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pd(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=Qo||ut;if(Ie(r))if(s&&(yb.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=sn(Bt(r,o,o),n);if(ut&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let u=sn(Bt(r,o-1,o-1),-1);if(u.top==a.top){let c=sn(Bt(r,o,o+1),-1);if(c.top!=a.top)return Vr(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++,Vr(sn(Bt(r,a,u),c),c<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==qe(r))){let a=r.childNodes[o-1];if(W(a))return al(a.getBoundingClientRect(),!1)}if(i==null&&o<qe(r)){let a=r.childNodes[o];if(W(a))return al(a.getBoundingClientRect(),!0)}return al(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==qe(r))){let a=r.childNodes[o-1],u=Ie(a)?Bt(a,qe(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Vr(sn(u,1),!1)}if(i==null&&o<qe(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?Ie(a)?Bt(a,0,s?0:1):W(a)?a:null:null;if(u)return Vr(sn(u,-1),!0)}return Vr(sn(Ie(r)?Bt(r):r,-n),n>=0)}function Vr(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 al(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 $d(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 wb(e,t,n){let r=t.selection,o=n=="up"?r.$from:r.$to;return $d(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=Pd(e,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(Ie(l))a=Bt(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 kb=/[\u0590-\u08ac]/;function vb(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?!kb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:$d(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&&!_n(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 td=null,nd=null,rd=!1;function Cb(e,t,n){return td==t&&nd==n?rd:(td=t,nd=n,rd=n=="up"||n=="down"?wb(e,t,n):vb(e,t,n))}var gt=0,od=1,Ln=2,vt=3,Vn=class{constructor(t,n,r,o){this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=gt,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&&_n(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>Fe(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)?_n(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 Fo||i instanceof Vo&&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?Fe(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?Fe(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=Fe(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=Fe(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((ut||Ge)&&t==n){let{node:p,offset:h}=l;if(Ie(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:Fe(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(ut&&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&&Ge)&&Hn(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Hn(a.node,a.offset,c.focusNode,c.focusOffset))return;let f=!1;if((u.extend||t==n)&&!(d&&ut)){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?Ln:od,t==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vt:i.markDirty(t-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ln:vt}r=s}this.dirty=Ln}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?Ln:od;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},Vo=class extends Vn{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==gt&&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}},bl=class extends Vn{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}},Pn=class e extends Vn{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=Rn.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&vt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=vt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=gt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=gt}}slice(t,n,r){let o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=vl(i,n,s,r)),t>0&&(i=vl(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 Vn{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(!Ie(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Rn.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=Hd(c,r,n),u?a=new yl(t,n,r,o,c,d||null,f,u):n.isText?new jo(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=()=>V.empty}}return n}matchesNode(t,n,r){return this.dirty==gt&&t.eq(this.node)&&Wo(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 kl(this,s&&s.node,t),u=this.node.inlineContent,c=u&&this.node.isBlock;Mb(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?mu.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==Ln)&&(s&&this.protectLocalComposition(t,s),Bd(this.contentDOM,this.children,t),fr&&Ab(this.dom))}localCompositionInfo(t,n){let{from:r,to:o}=t.state.selection;if(!(t.state.selection instanceof O)||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=Tb(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 bl(this,i,n,o);t.input.compositionNodes.push(s),this.children=vl(this.children,r,r+o.length,t,s)}update(t,n,r,o){return this.dirty==vt||!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=gt}updateOuterDeco(t){if(Wo(t,this.outerDeco))return;let n=!W(this.nodeDOM),r=this.dom;this.dom=zd(this.dom,this.nodeDOM,wl(this.outerDeco,this.node,n),wl(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 id(e,t,n,r,o){Hd(r,t,e);let i=new cn(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var jo=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==vt||this.dirty!=gt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=gt||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=gt,!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=vt)}get domAtom(){return!1}isText(t){return this.node.text==t}},Fo=class extends Vn{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==gt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},yl=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==vt)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 Bd(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=sd(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Pn){let a=r?r.previousSibling:e.lastChild;Bd(s.contentDOM,s.children,n),r=a?a.nextSibling:e.firstChild}}for(;r;)r=sd(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var Fr=function(e){e&&(this.nodeName=e)};Fr.prototype=Object.create(null);var In=[new Fr];function wl(e,t,n){if(e.length==0)return In;let r=n?In[0]:new Fr,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Fr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Fr(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 zd(e,t,n,r){if(n==In&&r==In)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=In[0]),o=a}xb(o,l||In[0],s)}return o}function xb(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 Hd(e,t,n){return zd(e,e,In,wl(t,n,!W(e)))}function Wo(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 sd(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var kl=class{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=Sb(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=gt,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 Pn&&c.dirty!=vt&&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=Pn.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==vt&&s.dom==s.contentDOM&&(s.dirty=Ln),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!=vt&&Wo(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=Ln,d.updateChildren(o,s+1),d.dirty=gt),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)||!Wo(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 Vo(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 Pn;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof jo)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ge||We)&&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 Fo(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 Sb(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 Pn)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 Eb(e,t){return e.type.side-t.type.side}function Mb(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(Eb);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 Ab(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 Tb(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 vl(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 Ll(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(Yo(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&j.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&ob(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new j(s==d?l:r.resolve(d))}else if(ut&&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=Il(e,c,l,d)}return u}function _d(e){return e.editable?e.hasFocus():jd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function _t(e,t=!1){let n=e.state.selection;if(Vd(e,n),!_d(e))return;let r=e.input.mouseDown;if(!t&&We&&r){let o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Hn(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Rb(e);else{let{anchor:o,head:i}=n,s,l;ld&&!(n instanceof O)&&(n.$from.parent.inlineContent||(s=ad(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=ad(e,n.to))),e.docView.setSelection(o,i,e,t),ld&&(s&&cd(s),l&&cd(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Nb(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var ld=Ge||We&&Nd<63;function ad(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(Ge&&o&&o.contentEditable=="false")return cl(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return cl(o);if(i)return cl(i)}}function cl(e){return e.contentEditable="true",Ge&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function cd(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Nb(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(()=>{(!_d(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rb(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Fe(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&ot&&an<=11&&(n.disabled=!0,n.disabled=!1)}function Vd(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ud(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ud(e)}function ud(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Il(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||O.between(t,n,r)}function dd(e){return e.editable&&!e.hasFocus()?!1:jd(e)}function jd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return _n(e.dom,t.anchorNode)&&(e.editable||_n(e.dom,t.focusNode))}catch{return!1}}function Db(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Hn(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Cl(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 ln(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function fd(e,t,n){let r=e.state.selection;if(r instanceof O)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 O(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=Cl(e.state,t);return o&&o instanceof j?ln(e,o):!1}else if(!(mt&&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?j.isSelectable(i)?ln(e,new j(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):ln(e,new O(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof j&&r.node.isInline)return ln(e,new O(t>0?r.$to:r.$from));{let o=Cl(e.state,t);return o?ln(e,o):!1}}}function Wr(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?Ob(e):Lb(e)}function Ob(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(ut&&W(n)&&r<qe(n)&&Wr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(n))break;let l=n.childNodes[r-1];if(Wr(l,-1))o=n,i=--r;else if(Ie(l))n=l,r=n.nodeValue.length;else break}else{if(Fd(n))break;{let l=n.previousSibling;for(;l&&Wr(l,-1);)o=n.parentNode,i=Fe(l),l=l.previousSibling;if(l)n=l,r=qe(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?xl(e,n,r):o&&xl(e,o,i)}function Lb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=qe(n),i,s;for(;;)if(r<o){if(!W(n))break;let l=n.childNodes[r];if(Wr(l,1))i=n,s=++r;else break}else{if(Fd(n))break;{let l=n.nextSibling;for(;l&&Wr(l,1);)i=l.parentNode,s=Fe(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=qe(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&xl(e,i,s)}function Fd(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ib(e,t){for(;e&&t==e.childNodes.length&&!Jr(e);)t=Fe(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(Ie(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=0}}function Pb(e,t){for(;e&&!t&&!Jr(e);)t=Fe(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(Ie(n))return n;if(W(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function xl(e,t,n){if(!Ie(t)){let i,s;(s=Ib(t,n))?(t=s,n=0):(i=Pb(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Yo(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&&_t(e)},50)}function pd(e,t){let n=e.state.doc.resolve(t);if(!(We||Rd)&&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 hd(e,t,n){let r=e.state.selection;if(r instanceof O&&!r.empty||n.indexOf("s")>-1||mt&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=Cl(e.state,t);if(s&&s instanceof j)return ln(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,l=r instanceof rn?X.near(s,t):X.findFrom(s,t);return l?ln(e,l):!1}return!1}function md(e,t){if(!(e.state.selection instanceof O))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 gd(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function $b(e){if(!Ge||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;gd(e,r,"true"),setTimeout(()=>gd(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 zb(e,t){let n=t.keyCode,r=Bb(t);if(n==8||mt&&n==72&&r=="c")return md(e,-1)||cr(e,-1);if(n==46&&!t.shiftKey||mt&&n==68&&r=="c")return md(e,1)||cr(e,1);if(n==13||n==27)return!0;if(n==37||mt&&n==66&&r=="c"){let o=n==37?pd(e,e.state.selection.from)=="ltr"?-1:1:-1;return fd(e,o,r)||cr(e,o)}else if(n==39||mt&&n==70&&r=="c"){let o=n==39?pd(e,e.state.selection.from)=="ltr"?1:-1:1;return fd(e,o,r)||cr(e,o)}else{if(n==38||mt&&n==80&&r=="c")return hd(e,-1,r)||cr(e,-1);if(n==40||mt&&n==78&&r=="c")return $b(e)||hd(e,1,r)||cr(e,1);if(r==(mt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Pl(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")||Rn.fromSchema(e.state.schema),l=Jd(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&W(u)&&(c=Gd[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=Rn.fromSchema(p);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let m=s.appendChild(document.createElement("p"));b&&m.appendChild(h.serializeNode(p.text(b,f)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),s=zb(n),Yo&&Hb(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")||Nn.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Pb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)l=_b(hd(l,+c[1],+c[2]),c[4]);else if(l=ce.maxOpen($b(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=hd(l,d,f)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var Pb=/^(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 $b(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&&Fd(a,i,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=Wd(s[s.length-1],i.length));let c=jd(l,a);s.push(c),o=o.matchType(c.type),i=a}}),s)return V.from(s)}return e}function jd(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,V.from(e));return e}function Fd(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Fd(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(V.from(jd(n,e,o+1))))}}function Wd(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Wd(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(V.empty,!0);return e.copy(n.append(r))}function xl(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=xl(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(V.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function hd(e,t,n){return t<e.openStart&&(e=new ce(xl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ce(xl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Kd={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 Ud(){return document.implementation.createHTMLDocument("title")}var Vr=null;function Bb(e){let t=window.trustedTypes;if(!t)return e;if(!Vr){if(Vr=t.defaultPolicy)try{return Vr.createHTML(e)}catch{}Vr=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Vr.createHTML(e)}function zb(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Ud(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(e),i;if((i=o&&Kd[o[1].toLowerCase()])&&(e=i.map(s=>"<"+s+">").join("")+e+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Bb(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 Hb(e){let t=e.querySelectorAll(We?"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 _b(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=V.from(a.create(r[l+1],o))}catch{break}i++,s++}return new ce(o,i,s)}var et={},tt={},Vb={touchstart:!0,touchmove:!0},Sl=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 jb(e){for(let t in et){let n=et[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{Wb(e,r)&&!Pl(e,r)&&(e.editable||!(r.type in tt))&&n(e,r)},Vb[t]?{passive:!0}:void 0)}Ge&&e.dom.addEventListener("input",()=>null),El(e)}function Ht(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Fb(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 El(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>Pl(e,r))})}function Pl(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Wb(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 Kb(e,t){!Pl(e,t)&&et[t.type]&&(e.editable||!(t.type in tt))&&et[t.type](e,t)}tt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Jd(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(zt&&We&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),dr&&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,Dn(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Ib(e,n)?n.preventDefault():Ht(e,"key")};tt.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};tt.keypress=(e,t)=>{let n=t;if(Jd(e)||!n.charCode||n.ctrlKey&&!n.altKey||mt&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof D)||!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 Jr(e){return{left:e.clientX,top:e.clientY}}function Ub(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function $l(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 Xr(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 qb(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Xr(e,new j(n)),!0):!1}function Gb(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof j&&(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(j.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?(Xr(e,j.create(e.state.doc,o)),!0):!1}function Jb(e,t,n,r,o){return $l(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(o?Gb(e,n):qb(e,n))}function Xb(e,t,n,r){return $l(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function Yb(e,t,n,r){return $l(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||Qb(e,n,r)}function Qb(e,t,n){if(n.button!=0)return!1;let r=qd(e,t,!0),o=e.state.doc;return r?(Xr(e,r),r instanceof D&&o.eq(e.state.doc)&&(e.input.mouseDown=new Al(e,r)),!0):!1}function qd(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?D.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 D.create(r,l+1,l+1+s.content.size);if(n&&j.isSelectable(s))return j.create(r,l)}return null}function Bl(e){return Ko(e)}var Gd=mt?"metaKey":"ctrlKey";et.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Bl(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&Ub(n,e.input.lastClick)&&!n[Gd]&&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(Jr(n));s&&(i=="singleClick"?e.input.mouseDown=new Ml(e,s,n,!!r):(i=="doubleClick"?Xb:Yb)(e,s.pos,s.inside,n)?n.preventDefault():Ht(e,"pointer"))};var Wo=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}},Ml=class extends Wo{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[Gd],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 j&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ut&&!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()),Ht(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||_t(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(Jr(t))),this.updateAllowDefault(t),this.allowDefault||!n?Ht(this.view,"pointer"):Jb(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Ge&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!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)?(Xr(this.view,X.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Ht(this.view,"pointer")}move(t){this.updateAllowDefault(t),Ht(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}},Al=class extends Wo{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(),Ht(this.view,"pointer");let n=this.view.posAtCoords(Jr(t)),r=n&&qd(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];Xr(this.view,D.create(o,s,l))}};et.touchstart=e=>{e.input.lastTouch=Date.now(),Bl(e),Ht(e,"pointer")};et.touchmove=e=>{e.input.lastTouch=Date.now(),Ht(e,"pointer")};et.contextmenu=e=>Bl(e);function Jd(e,t){return e.composing?!0:Ge&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Zb=zt?5e3:-1;tt.compositionstart=tt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof D&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||We&&Ad&&ey(e)))e.markCursor=e.state.storedMarks||n.marks(),Ko(e,!0),e.markCursor=null;else if(Ko(e,!t.selection.empty),ut&&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(Ie(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}Xd(e,Zb)};function ey(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"}tt.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++,Xd(e,20))};function Xd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ko(e),t))}function Yd(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ty(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Qg(t.focusNode,t.focusOffset),r=Zg(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 Ko(e,t=!1){if(!(zt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Yd(e),t||e.docView&&e.docView.dirty){let n=Dl(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 ny(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 Wr=ot&&an<15||dr&&rb<604;et.copy=tt.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let i=Wr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Il(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):ny(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ry(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function oy(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?Kr(e,r.value,null,o,t):Kr(e,r.textContent,r.innerHTML,o,t)},50)}function Kr(e,t,n,r,o){let i=Vd(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=ry(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 Qd(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," "):""}tt.paste=(e,t)=>{let n=t;if(e.composing&&!zt)return;let r=Wr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Kr(e,Qd(r),r.getData("text/html"),o,n)?n.preventDefault():oy(e,n)};var Uo=class{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}},iy=mt?"altKey":"ctrlKey";function Zd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[iy]}et.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(Jr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof j?o.to-1:o.to))){if(r&&r.mightDrag)s=j.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=j.create(e.state.doc,d.posBefore))}}let l=(s||e.state.selection).content(),{dom:a,text:u,slice:c}=Il(e,l);(!n.dataTransfer.files.length||!We||Md>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wr||n.dataTransfer.setData("text/plain",u),e.dragging=new Uo(c,Zd(e,n),s)};et.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};tt.dragover=tt.dragenter=(e,t)=>t.preventDefault();tt.drop=(e,t)=>{try{sy(e,t,e.dragging)}finally{e.dragging=null}};function sy(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Jr(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=Vd(e,Qd(t.dataTransfer),Wr?null:t.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&Zd(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?Do(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&&j.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new j(f));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,b,m,g)=>p=g),a.setSelection(Ll(e,f,a.doc.resolve(p)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}et.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())&&_t(e)},20))};et.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)};et.beforeinput=(e,t)=>{if(zt&&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,Dn(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 tt)et[e]=tt[e];function Ur(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 qo=class e{constructor(t,n){this.toDOM=t,this.spec=n||Bn,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 Me(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&&Ur(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},$n=class e{constructor(t,n){this.attrs=t,this.spec=n||Bn}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 Me(i,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof e&&Ur(this.attrs,t.attrs)&&Ur(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Tl=class e{constructor(t,n){this.attrs=t,this.spec=n||Bn}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 Me(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&&Ur(this.attrs,t.attrs)&&Ur(this.spec,t.spec)}destroy(){}},Me=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 qo(n,r))}static inline(t,n,r,o){return new e(t,n,new $n(r,o))}static node(t,n,r,o){return new e(t,n,new Tl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $n}get widget(){return this.type instanceof qo}},cr=[],Bn={},de=class e{constructor(t,n){this.local=t.length?t:cr,this.children=n.length?n:cr}static create(t,n){return n.length?Jo(n,t,0,Bn):Ue}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==Ue||t.maps.length==0?this:this.mapInner(t,n,0,0,r||Bn)}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?ly(this.children,s||[],t,n,r,o,i):s?new e(s.sort(zn),cr):Ue}add(t,n){return n.length?this==Ue?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=tf(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,Jo(c,l,u+1,Bn)),i+=3}});let s=ef(i?nf(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(zn):this.local,o||this.children)}remove(t){return t.length==0||this==Ue?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!=Ue?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):Ue}forChild(t,n){if(this==Ue)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 $n){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(zn),cr);return r?new Go([l,r]):l}return r||Ue}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 zl(this.localsInner(t))}localsInner(t){if(this==Ue)return cr;if(t.inlineContent||!this.local.some($n.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $n||n.push(this.local[r]);return n}forEachSet(t){t(this)}};de.empty=new de([],[]);de.removeOverlap=zl;var Ue=de.empty,Go=class e{constructor(t){this.members=t}map(t,n){let r=this.members.map(o=>o.map(t,n,Bn));return e.from(r)}forChild(t,n){if(n.isLeaf)return de.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,n);i!=Ue&&(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?zl(r?n:n.sort(zn)):cr}static from(t){switch(t.length){case 0:return Ue;case 1:return t[0];default:return new e(t.every(n=>n instanceof de)?t:t.reduce((n,r)=>n.concat(r instanceof de?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function ly(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,b)=>{let m=b-h-(p-f);for(let g=0;g<l.length;g+=3){let k=l[g+1];if(k<0||f>k+c-d)continue;let C=l[g]+c-d;p>=C?l[g+1]=f<=C?-2:-1:f>=c&&m&&(l[g]+=m,l[g+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:b}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&b==d&&b+m.nodeSize==p){let g=l[u+2].mapInner(n,m,c+1,e[u]+i+1,s);g!=Ue?(l[u]=d,l[u+1]=p,l[u+2]=g):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=ay(l,e,t,n,o,i,s),c=Jo(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 de(t.sort(zn),l)}function ef(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 Me(o.from+t,o.to+t,o.type))}return n}function ay(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 tf(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 nf(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Jo(e,t,n,r){let o=[],i=!1;t.forEach((l,a)=>{let u=tf(e,l,a+n);if(u){i=!0;let c=Jo(u,l,n+a+1,r);c!=Ue&&o.push(a,a+l.nodeSize,c)}});let s=ef(i?nf(e):e,-n).sort(zn);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 de(s,o):Ue}function zn(e,t){return e.from-t.from||e.to-t.to}function zl(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),md(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),md(t,o,r.copy(i.from,r.to)));break}}}return t}function md(e,t,n){for(;t<e.length&&zn(n,e[t])>0;)t++;e.splice(t,0,n)}function cl(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Ue&&t.push(r)}),e.cursorWrapper&&t.push(de.create(e.state.doc,[e.cursorWrapper.deco])),Go.from(t)}var cy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},uy=ot&&an<=11,Nl=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}},Rl=class{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Nl,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]);ot&&an<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Ge&&t.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),uy&&(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,cy)),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(ad(this.view)){if(this.suppressingSelectionUpdates)return _t(this.view);if(ot&&an<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Hn(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=ur(i))n.add(i);for(let i=t.anchorNode;i;i=ur(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:Ie(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)&&ad(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||We&&(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(ut&&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||py(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&&Xo(r)&&(u=Dl(t))&&u.eq(X.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,_t(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),dy(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,hy(t,a)),this.handleDOMChange(i,s,l,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||_t(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),Ie(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(ot&&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?Fe(o)+1:0,l=r.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?Fe(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})}},gd=new WeakMap,bd=!1;function dy(e){if(!gd.has(e)&&(gd.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=ut,bd)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."),bd=!0}}function yd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Hn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function fy(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return yd(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?yd(e,n):null}function py(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 hy(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 my(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&&_n(e.dom,d)&&(c=[{node:d,offset:u.anchorOffset}],Xo(u)||c.push({node:u.focusNode,offset:u.focusOffset})),We&&e.input.lastKeyCode===8)for(let g=s;g>i;g--){let k=o.childNodes[g-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){s=g;break}if(!C||C.size)break}let f=e.state.doc,p=e.someProp("domParser")||Nn.fromSchema(e.state.schema),h=f.resolve(l),b=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:gy(r),context:h});if(c&&c[0].pos!=null){let g=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=g),b={anchor:g+l,head:k+l}}return{doc:m,sel:b,from:l,to:a}}var gy=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Ge&&/^(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||Ge&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},by=/^(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 yy(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,L=Dl(e,M);if(L&&!e.state.selection.eq(L)){if(We&&zt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",he=>he(e,Dn(13,"Enter"))))return;let oe=e.state.tr.setSelection(L);M=="pointer"?oe.setMeta("pointer",!0):M=="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=my(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=Cy(d.content,u.doc.content,u.from,f,p);if(h&&e.input.domChangeCount++,(dr&&e.input.lastIOSEnter>Date.now()-225||zt)&&o.some(M=>W(M)&&!by.test(M.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",M=>M(e,Dn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof D&&!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=wd(e,e.state.doc,u.sel);if(M&&!M.eq(e.state.selection)){let L=e.state.tr.setSelection(M);i&&L.setMeta("composition",i),e.dispatch(L)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof D&&(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)),ot&&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 b=u.doc.resolveNoCache(h.start-u.from),m=u.doc.resolveNoCache(h.endB-u.from),g=c.resolve(h.start),k=b.sameParent(m)&&b.parent.inlineContent&&g.end()>=h.endA;if((dr&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!k&&vy(u.doc,b.pos,m.pos))&&e.someProp("handleKeyDown",M=>M(e,Dn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&ky(c,h.start,h.endA,b,m)&&e.someProp("handleKeyDown",M=>M(e,Dn(8,"Backspace")))){zt&&We&&e.domObserver.suppressSelectionUpdates();return}We&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),zt&&!k&&b.start()!=m.start()&&m.parentOffset==0&&b.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,Dn(13,"Enter"))})},20));let C=h.start,S=h.endA,A=M=>{let L=M||e.state.tr.replace(C,S,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let oe=wd(e,L.doc,u.sel);oe&&!(We&&e.composing&&oe.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(oe.head==C||oe.head==L.mapping.map(S)-1)||ot&&oe.empty&&oe.head==C)&&L.setSelection(oe)}return i&&L.setMeta("composition",i),L.scrollIntoView()},E;if(k)if(b.pos==m.pos){ot&&an<=11&&b.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>_t(e),20));let M=A(e.state.tr.delete(C,S)),L=c.resolve(h.start).marksAcross(c.resolve(h.endA));L&&M.ensureMarks(L),e.dispatch(M)}else if(h.endA==h.endB&&(E=wy(b.parent.content.cut(b.parentOffset,m.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start())))){let M=A(e.state.tr);E.type=="add"?M.addMark(C,S,E.mark):M.removeMark(C,S,E.mark),e.dispatch(M)}else if(b.parent.child(b.index()).isText&&b.index()==m.index()-(m.textOffset?0:1)){let M=b.parent.textBetween(b.parentOffset,m.parentOffset),L=()=>A(e.state.tr.insertText(M,C,S));e.someProp("handleTextInput",oe=>oe(e,C,S,M,L))||e.dispatch(L())}else e.dispatch(A());else e.dispatch(A())}function wd(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ll(e,t.resolve(n.anchor),t.resolve(n.head))}function wy(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(V.from(u).eq(e))return{mark:l,type:s}}function ky(e,t,n,r,o){if(n-t<=o.pos-r.pos||ul(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(ul(i,!0,!0));return!s.parent.isTextblock||s.pos>n||ul(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function vy(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 ul(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 Cy(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 qr=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 Sl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Sd),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=Cd(this),vd(this),this.nodeViews=xd(this),this.docView=nd(this.state.doc,kd(this),cl(this),this.dom,this),this.domObserver=new Rl(this,(r,o,i,s)=>yy(this,r,o,i,s)),this.domObserver.start(),jb(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&&El(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Sd),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&&(Yd(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=xd(this);Sy(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&El(this),this.editable=Cd(this),vd(this);let a=cl(this),u=kd(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&&sb(this);if(s){this.domObserver.stop();let p=d&&(ot||We)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&xy(o.selection,t.selection);if(d){let b=We?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ty(this)),(i||!this.docView.update(t.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=nd(t.doc,u,a,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let h=this.input.mouseDown;p||!(h&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ab(this)&&h.delaySelUpdate())?_t(this,p):(zd(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&&lb(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!_n(this.dom,t))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof j){let n=this.docView.domAfterPos(this.state.selection.from);W(n)&&Yu(this,n.getBoundingClientRect(),t)}else Yu(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 Uo(t.slice,t.move,o<0?void 0:j.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(ot){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&&ab(this.dom),_t(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 pb(this,t)}coordsAtPos(t,n=1){return Dd(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 yb(this,n||this.state,t)}pasteHTML(t,n){return Kr(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return Kr(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return Il(this,t)}destroy(){this.docView&&(Fb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],cl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xg())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Kb(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?Ge&&this.root.nodeType===11&&tb(this.dom.ownerDocument)==this.dom&&fy(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};qr.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function kd(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"),[Me.node(0,e.state.doc.content.size,t)]}function vd(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:Me.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Cd(e){return!e.someProp("editable",t=>t(e.state)===!1)}function xy(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 xd(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 Sy(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 Sd(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 Vt={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:"'"},Zo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ey=typeof navigator<"u"&&/Mac/.test(navigator.platform),My=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Ne=0;Ne<10;Ne++)Vt[48+Ne]=Vt[96+Ne]=String(Ne);var Ne;for(Ne=1;Ne<=24;Ne++)Vt[Ne+111]="F"+Ne;var Ne;for(Ne=65;Ne<=90;Ne++)Vt[Ne]=String.fromCharCode(Ne+32),Zo[Ne]=String.fromCharCode(Ne);var Ne;for(Qo in Vt)Zo.hasOwnProperty(Qo)||(Zo[Qo]=Vt[Qo]);var Qo;function rf(e){var t=Ey&&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?Zo:Vt)[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 Ay=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ty=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ny(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))Ay?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 Ry(e){let t=Object.create(null);for(let n in e)t[Ny(n)]=e[n];return t}function Hl(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 of(e){return new U({props:{handleKeyDown:Yr(e)}})}function Yr(e){let t=Ry(e);return function(n,r){let o=rf(r),i,s=t[Hl(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=t[Hl(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ty&&r.ctrlKey&&r.altKey)&&(i=Vt[r.keyCode])&&i!=o){let l=t[Hl(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var ei=200,Ke=function(){};Ke.prototype.append=function(t){return t.length?(t=Ke.from(t),!this.length&&t||t.length<ei&&this.leafAppend(t)||this.length<ei&&t.leafPrepend(this)||this.appendInner(t)):this};Ke.prototype.prepend=function(t){return t.length?Ke.from(t).append(this):this};Ke.prototype.appendInner=function(t){return new Oy(this,t)};Ke.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Ke.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};Ke.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Ke.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)};Ke.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};Ke.from=function(t){return t instanceof Ke?t:t&&t.length?new sf(t):Ke.empty};var sf=(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<=ei)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=ei)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})(Ke);Ke.empty=new sf([]);var Oy=(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})(Ke),_l=Ke;var Dy=500,jn=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 Mt(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 Mt(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 Mt(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>Iy&&(l=Ly(l,u),s-=u),new e(l.append(i),s)}remapping(t,n){let r=new Oo;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 Mt(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 b=t.steps[p].invert(t.docs[p]),m=f.selection&&f.selection.map(i.slice(a+1,p));m&&l++,r.push(new Mt(h,b,m))}else r.push(new Mt(h))},o);let u=[];for(let f=n;f<s;f++)u.push(new Mt(i.maps[f]));let c=this.items.slice(0,o).append(u).append(r),d=new e(c,l);return d.emptyItemCount()>Dy&&(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 Mt(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(_l.from(o.reverse()),i)}};jn.empty=new jn(_l.empty,0);function Ly(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}var Mt=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)}}},At=class{constructor(t,n,r,o,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Iy=20;function Py(e,t,n,r){let o=n.getMeta(dn),i;if(o)return o.historyState;n.getMeta(cf)&&(e=new At(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 At(e.done.addTransform(n,void 0,r,ti(t)),e.undone,lf(n.mapping.maps),e.prevTime,e.prevComposition):new At(e.done,e.undone.addTransform(n,void 0,r,ti(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||!$y(n,e.prevRanges)),u=s?Vl(e.prevRanges,n.mapping):lf(n.mapping.maps);return new At(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,ti(t)),jn.empty,u,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new At(e.done.rebased(n,i),e.undone.rebased(n,i),Vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new At(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function $y(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 lf(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 Vl(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 By(e,t,n){let r=ti(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 At(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(dn,{redo:n,historyState:a})}var jl=!1,af=null;function ti(e){let t=e.plugins;if(af!=t){jl=!1,af=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){jl=!0;break}}return jl}function fr(e){return e.setMeta(cf,!0)}var dn=new te("history"),cf=new te("closeHistory");function uf(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new U({key:dn,state:{init(){return new At(jn.empty,jn.empty,null,0,-1)},apply(t,n,r){return Py(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?Fl:r=="historyRedo"?Wl:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function ni(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=By(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var Fl=ni(!1,!0),Wl=ni(!0,!0),lE=ni(!1,!1),aE=ni(!0,!1);function df(e){return e.getMeta(dn)!=null}function ai(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 br=class Af{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,(...b)=>{let m=this.buildProps(u,n),g=p(...b)(m);return l.push(g),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=Af.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:ai({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}},zy=()=>({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),Hy=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),_y=()=>({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=Pt(p);if(l.type.isTextblock){let{defaultType:b}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(p.start,b)}(h||h===0)&&t.lift(p,h)})}),!0},Vy=e=>t=>e(t),jy=()=>({state:e,dispatch:t})=>tl(e,t),Fy=(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 D(r.doc.resolve(Math.max(s-1,0)))),!0},Wy=()=>({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 Re(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 Ky=e=>({tr:t,state:n,dispatch:r})=>{let o=Re(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},Uy=e=>({tr:t,dispatch:n})=>{let{from:r,to:o}=e;return n&&t.delete(r,o),!0},qy=e=>e.content?/^text(\*|\+)/.test(e.content):!1,ff=(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 qy(r)?n==="left"?e.start()-1:e.end()+1:e.pos},Gy=(e,t,n)=>({from:ff(e,n,"left"),to:ff(t,n,"right")}),Jy=()=>({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}=Gy(l,a,e.schema);n.deleteRange(u,c)}),n.selection.empty||n.setSelection(D.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},Xy=()=>({commands:e})=>e.keyboardShortcut("Enter"),Yy=()=>({state:e,dispatch:t})=>el(e,t);function Ql(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function li(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 Tf(e,t,n={}){return e.find(r=>r.type===t&&li(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function pf(e,t,n={}){return!!Tf(e,t,n)}function Zl(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(!Tf([...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&&pf([...e.parent.child(o-1).marks],t,n);)o-=1,i-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&pf([...e.parent.child(s).marks],t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function jt(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 Qy=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=jt(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:u,to:c}=l;if(o){let d=Zl(a,i,t);if(d&&d.from<=u&&d.to>=c){let f=D.create(s,d.from,d.to);n.setSelection(f)}}return!0},Zy=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 ci(e){return e instanceof D}function Fn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Gl(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"?D.create(e,Fn(0,o,i),Fn(e.content.size,o,i)):D.create(e,Fn(t,o,i),Fn(t,o,i))}function eo(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Wn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function e0(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var t0=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(Wn()||eo())&&r.dom.focus(),e0()&&!Wn()&&!eo()&&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&&!ci(n.state.selection))return s(),!0;let l=Gl(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},n0=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),r0=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Nf=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&&Nf(r)}return e};function ri(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 Nf(n)}function Rf(e){return typeof e?.nodesBetween=="function"}function yr(e,t,n){if(Rf(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 V.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),yr("",t,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new Vs({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?Nn.fromSchema(a).parseSlice(ri(e),n.parseOptions):Nn.fromSchema(a).parse(ri(e),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Nn.fromSchema(t);return n.slice?i.parseSlice(ri(e),n.parseOptions).content:i.parse(ri(e),n.parseOptions)}return yr("",t,n)}function Of(e){return!("type"in e)}function Df(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof On||o instanceof St))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 o0=(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{yr(t,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(m){a(m)}try{var s;l=yr(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=Of(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 b;if(f)Array.isArray(t)?b=t.map(m=>m.text||"").join(""):Rf(t)?b=h.map(m=>{var g;return(g=m.text)!==null&&g!==void 0?g:""}).join(""):typeof t=="object"&&t&&t.text?b=t.text:b=t,r.insertText(b,c,d);else{b=V.from(h);let m=r.doc.resolve(c),g=m.node(),k=m.parentOffset===0,C=g.isText||g.isTextblock,S=g.content.size>0;k&&C&&S&&p&&(c=Math.max(0,c-1)),r.replaceWith(c,d,h)}n.updateSelection&&Df(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:b})}return!0};function Lf(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 i0=(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=Lf(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=yr(s,r.schema);f=u.createAndFill(d,p)}else f=u.createAndFill(d);return f?(n&&(t.insert(a.pos,f),l&&Df(t,t.steps.length-1,-1)),!0):!1},s0=()=>({state:e,dispatch:t})=>Hu(e,t),l0=()=>({state:e,dispatch:t})=>_u(e,t),a0=()=>({state:e,dispatch:t})=>Us(e,t),c0=()=>({state:e,dispatch:t})=>Js(e,t),If=(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},u0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=or(e.doc,e.selection.$from.pos,-1);return r==null||!If(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},d0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=or(e.doc,e.selection.$from.pos,1);return r==null||!If(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},f0=()=>({state:e,dispatch:t})=>Pu(e,t),p0=()=>({state:e,dispatch:t})=>$u(e,t);function Pf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function h0(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))Wn()||Pf()?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 m0=e=>({editor:t,view:n,tr:r,dispatch:o})=>{let i=h0(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 Tt(e,t,n={}){let{from:r,to:o,empty:i}=e.selection,s=t?Re(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=>li(c.node.attrs,n,{strict:!1}));return i?!!u.length:u.reduce((c,d)=>c+d.to-d.from,0)>=a}var g0=(e,t={})=>({state:n,dispatch:r})=>Tt(n,Re(e,n.schema),t)?Vu(n,r):!1,b0=()=>({state:e,dispatch:t})=>nl(e,t),y0=e=>({state:t,dispatch:n})=>{let r=Re(e,t.schema);return qu(r)(t,n)},w0=()=>({state:e,dispatch:t})=>Qs(e,t);function ui(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function hf(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 k0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ui(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Re(e,r.schema)),l==="mark"&&(s=jt(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,hf(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(hf(f.attrs,t))))})})}),a},v0=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),C0=()=>({tr:e,dispatch:t})=>{if(t){let n=new rn(e.doc);e.setSelection(n)}return!0},x0=()=>({state:e,dispatch:t})=>qs(e,t),S0=()=>({state:e,dispatch:t})=>Xs(e,t),E0=()=>({state:e,dispatch:t})=>ju(e,t),M0=()=>({state:e,dispatch:t})=>ol(e,t),A0=()=>({state:e,dispatch:t})=>rl(e,t);function Jl(e,t,n={},r={}){return yr(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var T0=(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=Jl(e,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});if(s){let c=Of(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 $f(e,t){let n=jt(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 ea(e,t){let n=new Io(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Kn(e,t){let n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function Bf(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function kr(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 di(e){return t=>kr(t.$from,e)}function z(e,t,n){return e.config[t]===void 0&&e.parent?z(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?z(e.parent,t,n):null}):e.config[t]}function ta(e){return e.map(t=>{let n=z(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return n?[t,...ta(n())]:t}).flat(10)}function na(e,t){let n=Rn.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Xl(e){return typeof e=="function"}function fe(e,t=void 0,...n){return Xl(e)?t?e.bind(t)(...n):e(...n):e}function N0(e={}){return Object.keys(e).length===0&&e.constructor===Object}function wr(e){return{baseExtensions:e.filter(t=>t.type==="extension"),nodeExtensions:e.filter(t=>t.type==="node"),markExtensions:e.filter(t=>t.type==="mark")}}function zf(e){let t=[],{nodeExtensions:n,markExtensions:r}=wr(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=z(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,b])=>{t.push({type:p,name:h,attribute:{...i,...b}})})})})}),o.forEach(u=>{let c=z(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 R0(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 mf(e){let t=[],n=R0(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 K(...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([...mf(r[o]),...mf(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function Nt(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)=>K(n,r),{})}function O0(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function gf(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):O0(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function bf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&N0(n)?!1:n!=null))}function yf(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 D0(e,t){var n;let r=zf(e),{nodeExtensions:o,markExtensions:i}=wr(e),s=(n=o.find(u=>z(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=bf({...e.reduce((m,g)=>{let k=z(g,"extendNodeSchema",d);return{...m,...k?k(u):{}}},{}),content:fe(z(u,"content",d)),marks:fe(z(u,"marks",d)),group:fe(z(u,"group",d)),inline:fe(z(u,"inline",d)),atom:fe(z(u,"atom",d)),selectable:fe(z(u,"selectable",d)),draggable:fe(z(u,"draggable",d)),code:fe(z(u,"code",d)),whitespace:fe(z(u,"whitespace",d)),linebreakReplacement:fe(z(u,"linebreakReplacement",d)),defining:fe(z(u,"defining",d)),isolating:fe(z(u,"isolating",d)),attrs:Object.fromEntries(c.map(yf))}),p=fe(z(u,"parseHTML",d));p&&(f.parseDOM=p.map(m=>gf(m,c)));let h=z(u,"renderHTML",d);h&&(f.toDOM=m=>h({node:m,HTMLAttributes:Nt(m,c)}));let b=z(u,"renderText",d);return b&&(f.toText=b),[u.name,f]})),a=Object.fromEntries(i.map(u=>{let c=r.filter(b=>b.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:t},f=bf({...e.reduce((b,m)=>{let g=z(m,"extendMarkSchema",d);return{...b,...g?g(u):{}}},{}),inclusive:fe(z(u,"inclusive",d)),excludes:fe(z(u,"excludes",d)),group:fe(z(u,"group",d)),spanning:fe(z(u,"spanning",d)),code:fe(z(u,"code",d)),attrs:Object.fromEntries(c.map(yf))}),p=fe(z(u,"parseHTML",d));p&&(f.parseDOM=p.map(b=>gf(b,c)));let h=z(u,"renderHTML",d);return h&&(f.toDOM=b=>h({mark:b,HTMLAttributes:Nt(b,c)})),[u.name,f]}));return new Vs({topNode:s,nodes:l,marks:a})}function L0(e){let t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}function Zr(e){return e.sort((n,r)=>{let o=z(n,"priority")||100,i=z(r,"priority")||100;return o>i?-1:o<i?1:0})}function Hf(e){let t=Zr(ta(e)),n=L0(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 _f(e,t,n){let{from:r,to:o}=t,{blockSeparator:i=`
|
|
7
|
+
`);return{dom:a,text:f,slice:t}}function Wd(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(V.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=Rn.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=jb(n),Qo&&Fb(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")||Nn.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Hb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Wb(bd(l,+c[1],+c[2]),c[4]);else if(l=ce.maxOpen(_b(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=bd(l,d,f)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var Hb=/^(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 _b(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&&Ud(a,i,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=qd(s[s.length-1],i.length));let c=Kd(l,a);s.push(c),o=o.matchType(c.type),i=a}}),s)return V.from(s)}return e}function Kd(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,V.from(e));return e}function Ud(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Ud(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(V.from(Kd(n,e,o+1))))}}function qd(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,qd(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(V.empty,!0);return e.copy(n.append(r))}function Sl(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=Sl(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(V.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function bd(e,t,n){return t<e.openStart&&(e=new ce(Sl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ce(Sl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Gd={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 Jd(){return document.implementation.createHTMLDocument("title")}var jr=null;function Vb(e){let t=window.trustedTypes;if(!t)return e;if(!jr){if(jr=t.defaultPolicy)try{return jr.createHTML(e)}catch{}jr=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return jr.createHTML(e)}function jb(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Jd(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(e),i;if((i=o&&Gd[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 Fb(e){let t=e.querySelectorAll(We?"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 Wb(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=V.from(a.create(r[l+1],o))}catch{break}i++,s++}return new ce(o,i,s)}var et={},tt={},Kb={touchstart:!0,touchmove:!0},El=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 Ub(e){for(let t in et){let n=et[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{Gb(e,r)&&!$l(e,r)&&(e.editable||!(r.type in tt))&&n(e,r)},Kb[t]?{passive:!0}:void 0)}Ge&&e.dom.addEventListener("input",()=>null),Ml(e)}function Ht(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function qb(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 Ml(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>$l(e,r))})}function $l(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Gb(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 Jb(e,t){!$l(e,t)&&et[t.type]&&(e.editable||!(t.type in tt))&&et[t.type](e,t)}tt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Qd(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(zt&&We&&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,On(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||zb(e,n)?n.preventDefault():Ht(e,"key")};tt.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};tt.keypress=(e,t)=>{let n=t;if(Qd(e)||!n.charCode||n.ctrlKey&&!n.altKey||mt&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof O)||!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 Xr(e){return{left:e.clientX,top:e.clientY}}function Xb(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Bl(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 Yr(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 Yb(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Yr(e,new j(n)),!0):!1}function Qb(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof j&&(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(j.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?(Yr(e,j.create(e.state.doc,o)),!0):!1}function Zb(e,t,n,r,o){return Bl(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(o?Qb(e,n):Yb(e,n))}function ey(e,t,n,r){return Bl(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function ty(e,t,n,r){return Bl(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||ny(e,n,r)}function ny(e,t,n){if(n.button!=0)return!1;let r=Xd(e,t,!0),o=e.state.doc;return r?(Yr(e,r),r instanceof O&&o.eq(e.state.doc)&&(e.input.mouseDown=new Tl(e,r)),!0):!1}function Xd(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?O.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 O.create(r,l+1,l+1+s.content.size);if(n&&j.isSelectable(s))return j.create(r,l)}return null}function zl(e){return Uo(e)}var Yd=mt?"metaKey":"ctrlKey";et.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=zl(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&Xb(n,e.input.lastClick)&&!n[Yd]&&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(Xr(n));s&&(i=="singleClick"?e.input.mouseDown=new Al(e,s,n,!!r):(i=="doubleClick"?ey:ty)(e,s.pos,s.inside,n)?n.preventDefault():Ht(e,"pointer"))};var Ko=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}},Al=class extends Ko{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[Yd],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 j&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ut&&!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()),Ht(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||_t(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(Xr(t))),this.updateAllowDefault(t),this.allowDefault||!n?Ht(this.view,"pointer"):Zb(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Ge&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!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)?(Yr(this.view,X.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Ht(this.view,"pointer")}move(t){this.updateAllowDefault(t),Ht(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}},Tl=class extends Ko{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(),Ht(this.view,"pointer");let n=this.view.posAtCoords(Xr(t)),r=n&&Xd(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];Yr(this.view,O.create(o,s,l))}};et.touchstart=e=>{e.input.lastTouch=Date.now(),zl(e),Ht(e,"pointer")};et.touchmove=e=>{e.input.lastTouch=Date.now(),Ht(e,"pointer")};et.contextmenu=e=>zl(e);function Qd(e,t){return e.composing?!0:Ge&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var ry=zt?5e3:-1;tt.compositionstart=tt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof O&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||We&&Rd&&oy(e)))e.markCursor=e.state.storedMarks||n.marks(),Uo(e,!0),e.markCursor=null;else if(Uo(e,!t.selection.empty),ut&&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(Ie(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}Zd(e,ry)};function oy(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"}tt.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++,Zd(e,20))};function Zd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Uo(e),t))}function ef(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function iy(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=nb(t.focusNode,t.focusOffset),r=rb(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 Uo(e,t=!1){if(!(zt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ef(e),t||e.docView&&e.docView.dirty){let n=Ll(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 sy(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 Kr=ot&&an<15||fr&&lb<604;et.copy=tt.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let i=Kr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Pl(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):sy(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ly(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function ay(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?Ur(e,r.value,null,o,t):Ur(e,r.textContent,r.innerHTML,o,t)},50)}function Ur(e,t,n,r,o){let i=Wd(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=ly(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 tf(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," "):""}tt.paste=(e,t)=>{let n=t;if(e.composing&&!zt)return;let r=Kr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Ur(e,tf(r),r.getData("text/html"),o,n)?n.preventDefault():ay(e,n)};var qo=class{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}},cy=mt?"altKey":"ctrlKey";function nf(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[cy]}et.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(Xr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof j?o.to-1:o.to))){if(r&&r.mightDrag)s=j.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=j.create(e.state.doc,d.posBefore))}}let l=(s||e.state.selection).content(),{dom:a,text:u,slice:c}=Pl(e,l);(!n.dataTransfer.files.length||!We||Nd>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Kr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Kr||n.dataTransfer.setData("text/plain",u),e.dragging=new qo(c,nf(e,n),s)};et.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};tt.dragover=tt.dragenter=(e,t)=>t.preventDefault();tt.drop=(e,t)=>{try{uy(e,t,e.dragging)}finally{e.dragging=null}};function uy(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Xr(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=Wd(e,tf(t.dataTransfer),Kr?null:t.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&nf(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?Lo(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&&j.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new j(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(Il(e,f,a.doc.resolve(p)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}et.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())&&_t(e)},20))};et.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)};et.beforeinput=(e,t)=>{if(zt&&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,On(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 tt)et[e]=tt[e];function qr(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 Go=class e{constructor(t,n){this.toDOM=t,this.spec=n||Bn,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 Me(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&&qr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},$n=class e{constructor(t,n){this.attrs=t,this.spec=n||Bn}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 Me(i,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof e&&qr(this.attrs,t.attrs)&&qr(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Nl=class e{constructor(t,n){this.attrs=t,this.spec=n||Bn}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 Me(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&&qr(this.attrs,t.attrs)&&qr(this.spec,t.spec)}destroy(){}},Me=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 Go(n,r))}static inline(t,n,r,o){return new e(t,n,new $n(r,o))}static node(t,n,r,o){return new e(t,n,new Nl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $n}get widget(){return this.type instanceof Go}},ur=[],Bn={},de=class e{constructor(t,n){this.local=t.length?t:ur,this.children=n.length?n:ur}static create(t,n){return n.length?Xo(n,t,0,Bn):Ue}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==Ue||t.maps.length==0?this:this.mapInner(t,n,0,0,r||Bn)}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?dy(this.children,s||[],t,n,r,o,i):s?new e(s.sort(zn),ur):Ue}add(t,n){return n.length?this==Ue?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=of(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,Xo(c,l,u+1,Bn)),i+=3}});let s=rf(i?sf(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(zn):this.local,o||this.children)}remove(t){return t.length==0||this==Ue?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!=Ue?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):Ue}forChild(t,n){if(this==Ue)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 $n){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(zn),ur);return r?new Jo([l,r]):l}return r||Ue}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 Hl(this.localsInner(t))}localsInner(t){if(this==Ue)return ur;if(t.inlineContent||!this.local.some($n.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $n||n.push(this.local[r]);return n}forEachSet(t){t(this)}};de.empty=new de([],[]);de.removeOverlap=Hl;var Ue=de.empty,Jo=class e{constructor(t){this.members=t}map(t,n){let r=this.members.map(o=>o.map(t,n,Bn));return e.from(r)}forChild(t,n){if(n.isLeaf)return de.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(t,n);i!=Ue&&(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?Hl(r?n:n.sort(zn)):ur}static from(t){switch(t.length){case 0:return Ue;case 1:return t[0];default:return new e(t.every(n=>n instanceof de)?t:t.reduce((n,r)=>n.concat(r instanceof de?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function dy(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!=Ue?(l[u]=d,l[u+1]=p,l[u+2]=b):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=fy(l,e,t,n,o,i,s),c=Xo(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 de(t.sort(zn),l)}function rf(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 Me(o.from+t,o.to+t,o.type))}return n}function fy(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 of(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 sf(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Xo(e,t,n,r){let o=[],i=!1;t.forEach((l,a)=>{let u=of(e,l,a+n);if(u){i=!0;let c=Xo(u,l,n+a+1,r);c!=Ue&&o.push(a,a+l.nodeSize,c)}});let s=rf(i?sf(e):e,-n).sort(zn);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 de(s,o):Ue}function zn(e,t){return e.from-t.from||e.to-t.to}function Hl(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),yd(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),yd(t,o,r.copy(i.from,r.to)));break}}}return t}function yd(e,t,n){for(;t<e.length&&zn(n,e[t])>0;)t++;e.splice(t,0,n)}function ul(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Ue&&t.push(r)}),e.cursorWrapper&&t.push(de.create(e.state.doc,[e.cursorWrapper.deco])),Jo.from(t)}var py={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hy=ot&&an<=11,Rl=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}},Dl=class{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Rl,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]);ot&&an<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Ge&&t.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hy&&(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,py)),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(dd(this.view)){if(this.suppressingSelectionUpdates)return _t(this.view);if(ot&&an<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Hn(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:Ie(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)&&dd(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||We&&(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(ut&&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||by(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&&Yo(r)&&(u=Ll(t))&&u.eq(X.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,_t(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),my(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,yy(t,a)),this.handleDOMChange(i,s,l,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||_t(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),Ie(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(ot&&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?Fe(o)+1:0,l=r.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?Fe(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})}},wd=new WeakMap,kd=!1;function my(e){if(!wd.has(e)&&(wd.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=ut,kd)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."),kd=!0}}function vd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Hn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function gy(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return vd(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?vd(e,n):null}function by(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 yy(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 wy(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&&_n(e.dom,d)&&(c=[{node:d,offset:u.anchorOffset}],Yo(u)||c.push({node:u.focusNode,offset:u.focusOffset})),We&&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")||Nn.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:ky(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 ky=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Ge&&/^(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||Ge&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},vy=/^(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 Cy(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,L=Ll(e,M);if(L&&!e.state.selection.eq(L)){if(We&&zt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",he=>he(e,On(13,"Enter"))))return;let oe=e.state.tr.setSelection(L);M=="pointer"?oe.setMeta("pointer",!0):M=="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=wy(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=My(d.content,u.doc.content,u.from,f,p);if(h&&e.input.domChangeCount++,(fr&&e.input.lastIOSEnter>Date.now()-225||zt)&&o.some(M=>W(M)&&!vy.test(M.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",M=>M(e,On(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof O&&!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=Cd(e,e.state.doc,u.sel);if(M&&!M.eq(e.state.selection)){let L=e.state.tr.setSelection(M);i&&L.setMeta("composition",i),e.dispatch(L)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof O&&(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)),ot&&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),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&&Ey(u.doc,g.pos,m.pos))&&e.someProp("handleKeyDown",M=>M(e,On(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&Sy(c,h.start,h.endA,g,m)&&e.someProp("handleKeyDown",M=>M(e,On(8,"Backspace")))){zt&&We&&e.domObserver.suppressSelectionUpdates();return}We&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),zt&&!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,On(13,"Enter"))})},20));let C=h.start,S=h.endA,A=M=>{let L=M||e.state.tr.replace(C,S,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let oe=Cd(e,L.doc,u.sel);oe&&!(We&&e.composing&&oe.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(oe.head==C||oe.head==L.mapping.map(S)-1)||ot&&oe.empty&&oe.head==C)&&L.setSelection(oe)}return i&&L.setMeta("composition",i),L.scrollIntoView()},E;if(k)if(g.pos==m.pos){ot&&an<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>_t(e),20));let M=A(e.state.tr.delete(C,S)),L=c.resolve(h.start).marksAcross(c.resolve(h.endA));L&&M.ensureMarks(L),e.dispatch(M)}else if(h.endA==h.endB&&(E=xy(g.parent.content.cut(g.parentOffset,m.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start())))){let M=A(e.state.tr);E.type=="add"?M.addMark(C,S,E.mark):M.removeMark(C,S,E.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),L=()=>A(e.state.tr.insertText(M,C,S));e.someProp("handleTextInput",oe=>oe(e,C,S,M,L))||e.dispatch(L())}else e.dispatch(A());else e.dispatch(A())}function Cd(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Il(e,t.resolve(n.anchor),t.resolve(n.head))}function xy(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(V.from(u).eq(e))return{mark:l,type:s}}function Sy(e,t,n,r,o){if(n-t<=o.pos-r.pos||dl(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(dl(i,!0,!0));return!s.parent.isTextblock||s.pos>n||dl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Ey(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 dl(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 My(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 Gr=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 El,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Ad),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=Ed(this),Sd(this),this.nodeViews=Md(this),this.docView=id(this.state.doc,xd(this),ul(this),this.dom,this),this.domObserver=new Dl(this,(r,o,i,s)=>Cy(this,r,o,i,s)),this.domObserver.start(),Ub(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&&Ml(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Ad),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&&(ef(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=Md(this);Ty(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ml(this),this.editable=Ed(this),Sd(this);let a=ul(this),u=xd(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&&ub(this);if(s){this.domObserver.stop();let p=d&&(ot||We)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&Ay(o.selection,t.selection);if(d){let g=We?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=iy(this)),(i||!this.docView.update(t.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=id(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())?_t(this,p):(Vd(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&&db(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!_n(this.dom,t))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof j){let n=this.docView.domAfterPos(this.state.selection.from);W(n)&&ed(this,n.getBoundingClientRect(),t)}else ed(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 qo(t.slice,t.move,o<0?void 0:j.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(ot){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&&fb(this.dom),_t(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 bb(this,t)}coordsAtPos(t,n=1){return Pd(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 Cb(this,n||this.state,t)}pasteHTML(t,n){return Ur(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return Ur(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return Pl(this,t)}destroy(){this.docView&&(qb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ul(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,eb())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Jb(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?Ge&&this.root.nodeType===11&&ib(this.dom.ownerDocument)==this.dom&&gy(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Gr.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function xd(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"),[Me.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:Me.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Ed(e){return!e.someProp("editable",t=>t(e.state)===!1)}function Ay(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 Md(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 Ty(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 Ad(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 Vt={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:"'"},ei={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ny=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ry=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Ne=0;Ne<10;Ne++)Vt[48+Ne]=Vt[96+Ne]=String(Ne);var Ne;for(Ne=1;Ne<=24;Ne++)Vt[Ne+111]="F"+Ne;var Ne;for(Ne=65;Ne<=90;Ne++)Vt[Ne]=String.fromCharCode(Ne+32),ei[Ne]=String.fromCharCode(Ne);var Ne;for(Zo in Vt)ei.hasOwnProperty(Zo)||(ei[Zo]=Vt[Zo]);var Zo;function lf(e){var t=Ny&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ry&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?ei:Vt)[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),Oy=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ly(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 Iy(e){let t=Object.create(null);for(let n in e)t[Ly(n)]=e[n];return t}function _l(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 af(e){return new U({props:{handleKeyDown:Qr(e)}})}function Qr(e){let t=Iy(e);return function(n,r){let o=lf(r),i,s=t[_l(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=t[_l(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Oy&&r.ctrlKey&&r.altKey)&&(i=Vt[r.keyCode])&&i!=o){let l=t[_l(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var ti=200,Ke=function(){};Ke.prototype.append=function(t){return t.length?(t=Ke.from(t),!this.length&&t||t.length<ti&&this.leafAppend(t)||this.length<ti&&t.leafPrepend(this)||this.appendInner(t)):this};Ke.prototype.prepend=function(t){return t.length?Ke.from(t).append(this):this};Ke.prototype.appendInner=function(t){return new Py(this,t)};Ke.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Ke.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};Ke.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Ke.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)};Ke.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};Ke.from=function(t){return t instanceof Ke?t:t&&t.length?new cf(t):Ke.empty};var cf=(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<=ti)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=ti)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})(Ke);Ke.empty=new cf([]);var Py=(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})(Ke),Vl=Ke;var $y=500,jn=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 Mt(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 Mt(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 Mt(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>zy&&(l=By(l,u),s-=u),new e(l.append(i),s)}remapping(t,n){let r=new Oo;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 Mt(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 Mt(h,g,m))}else r.push(new Mt(h))},o);let u=[];for(let f=n;f<s;f++)u.push(new Mt(i.maps[f]));let c=this.items.slice(0,o).append(u).append(r),d=new e(c,l);return d.emptyItemCount()>$y&&(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 Mt(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(Vl.from(o.reverse()),i)}};jn.empty=new jn(Vl.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 Mt=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)}}},At=class{constructor(t,n,r,o,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},zy=20;function Hy(e,t,n,r){let o=n.getMeta(dn),i;if(o)return o.historyState;n.getMeta(ff)&&(e=new At(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 At(e.done.addTransform(n,void 0,r,ni(t)),e.undone,uf(n.mapping.maps),e.prevTime,e.prevComposition):new At(e.done,e.undone.addTransform(n,void 0,r,ni(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||!_y(n,e.prevRanges)),u=s?jl(e.prevRanges,n.mapping):uf(n.mapping.maps);return new At(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,ni(t)),jn.empty,u,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new At(e.done.rebased(n,i),e.undone.rebased(n,i),jl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new At(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),jl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function _y(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 uf(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 jl(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=ni(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 At(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(dn,{redo:n,historyState:a})}var Fl=!1,df=null;function ni(e){let t=e.plugins;if(df!=t){Fl=!1,df=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Fl=!0;break}}return Fl}function pr(e){return e.setMeta(ff,!0)}var dn=new te("history"),ff=new te("closeHistory");function pf(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new U({key:dn,state:{init(){return new At(jn.empty,jn.empty,null,0,-1)},apply(t,n,r){return Hy(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?Wl:r=="historyRedo"?Kl:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function ri(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 Wl=ri(!1,!0),Kl=ri(!0,!0),fE=ri(!1,!1),pE=ri(!0,!1);function hf(e){return e.getMeta(dn)!=null}function ci(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 Rf{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=Rf.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:ci({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}},jy=()=>({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),Fy=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),Wy=()=>({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=Pt(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},Ky=e=>t=>e(t),Uy=()=>({state:e,dispatch:t})=>nl(e,t),qy=(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 O(r.doc.resolve(Math.max(s-1,0)))),!0},Gy=()=>({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 Re(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 Jy=e=>({tr:t,state:n,dispatch:r})=>{let o=Re(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},Xy=e=>({tr:t,dispatch:n})=>{let{from:r,to:o}=e;return n&&t.delete(r,o),!0},Yy=e=>e.content?/^text(\*|\+)/.test(e.content):!1,mf=(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 Yy(r)?n==="left"?e.start()-1:e.end()+1:e.pos},Qy=(e,t,n)=>({from:mf(e,n,"left"),to:mf(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}=Qy(l,a,e.schema);n.deleteRange(u,c)}),n.selection.empty||n.setSelection(O.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},e0=()=>({commands:e})=>e.keyboardShortcut("Enter"),t0=()=>({state:e,dispatch:t})=>tl(e,t);function Zl(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ai(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:Zl(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function Df(e,t,n={}){return e.find(r=>r.type===t&&ai(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function gf(e,t,n={}){return!!Df(e,t,n)}function ea(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(!Df([...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&&gf([...e.parent.child(o-1).marks],t,n);)o-=1,i-=e.parent.child(o).nodeSize;for(;s<e.parent.childCount&&gf([...e.parent.child(s).marks],t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function jt(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 n0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=jt(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:u,to:c}=l;if(o){let d=ea(a,i,t);if(d&&d.from<=u&&d.to>=c){let f=O.create(s,d.from,d.to);n.setSelection(f)}}return!0},r0=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 ui(e){return e instanceof O}function Fn(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=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"?O.create(e,Fn(0,o,i),Fn(e.content.size,o,i)):O.create(e,Fn(t,o,i),Fn(t,o,i))}function to(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Wn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function o0(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var i0=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};let s=()=>{(Wn()||to())&&r.dom.focus(),o0()&&!Wn()&&!to()&&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&&!ui(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},s0=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),l0=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Of=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&&Of(r)}return e};function oi(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 Of(n)}function Lf(e){return typeof e?.nodesBetween=="function"}function wr(e,t,n){if(Lf(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 V.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 js({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?Nn.fromSchema(a).parseSlice(oi(e),n.parseOptions):Nn.fromSchema(a).parse(oi(e),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Nn.fromSchema(t);return n.slice?i.parseSlice(oi(e),n.parseOptions).content:i.parse(oi(e),n.parseOptions)}return wr("",t,n)}function If(e){return!("type"in e)}function Pf(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Dn||o instanceof St))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 a0=(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=If(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(""):Lf(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=V.from(h);let m=r.doc.resolve(c),b=m.node(),k=m.parentOffset===0,C=b.isText||b.isTextblock,S=b.content.size>0;k&&C&&S&&p&&(c=Math.max(0,c-1)),r.replaceWith(c,d,h)}n.updateSelection&&Pf(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 $f(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 c0=(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=$f(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&&Pf(t,t.steps.length-1,-1)),!0):!1},u0=()=>({state:e,dispatch:t})=>ju(e,t),d0=()=>({state:e,dispatch:t})=>Fu(e,t),f0=()=>({state:e,dispatch:t})=>qs(e,t),p0=()=>({state:e,dispatch:t})=>Xs(e,t),Bf=(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},h0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=ir(e.doc,e.selection.$from.pos,-1);return r==null||!Bf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},m0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=ir(e.doc,e.selection.$from.pos,1);return r==null||!Bf(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},g0=()=>({state:e,dispatch:t})=>zu(e,t),b0=()=>({state:e,dispatch:t})=>Hu(e,t);function zf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function y0(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))Wn()||zf()?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 w0=e=>({editor:t,view:n,tr:r,dispatch:o})=>{let i=y0(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 Tt(e,t,n={}){let{from:r,to:o,empty:i}=e.selection,s=t?Re(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=>ai(c.node.attrs,n,{strict:!1}));return i?!!u.length:u.reduce((c,d)=>c+d.to-d.from,0)>=a}var k0=(e,t={})=>({state:n,dispatch:r})=>Tt(n,Re(e,n.schema),t)?Wu(n,r):!1,v0=()=>({state:e,dispatch:t})=>rl(e,t),C0=e=>({state:t,dispatch:n})=>{let r=Re(e,t.schema);return Xu(r)(t,n)},x0=()=>({state:e,dispatch:t})=>Zs(e,t);function di(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function bf(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 S0=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=di(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Re(e,r.schema)),l==="mark"&&(s=jt(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,bf(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(bf(f.attrs,t))))})})}),a},E0=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),M0=()=>({tr:e,dispatch:t})=>{if(t){let n=new rn(e.doc);e.setSelection(n)}return!0},A0=()=>({state:e,dispatch:t})=>Gs(e,t),T0=()=>({state:e,dispatch:t})=>Ys(e,t),N0=()=>({state:e,dispatch:t})=>Ku(e,t),R0=()=>({state:e,dispatch:t})=>il(e,t),D0=()=>({state:e,dispatch:t})=>ol(e,t);function Xl(e,t,n={},r={}){return wr(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var O0=(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=Xl(e,o.schema,r,{errorOnInvalidContent:t??o.options.enableContentCheck});if(s){let c=If(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 Hf(e,t){let n=jt(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 ta(e,t){let n=new Po(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Kn(e,t){let n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function _f(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 fi(e){return t=>vr(t.$from,e)}function z(e,t,n){return e.config[t]===void 0&&e.parent?z(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?z(e.parent,t,n):null}):e.config[t]}function na(e){return e.map(t=>{let n=z(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return n?[t,...na(n())]:t}).flat(10)}function ra(e,t){let n=Rn.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Yl(e){return typeof e=="function"}function fe(e,t=void 0,...n){return Yl(e)?t?e.bind(t)(...n):e(...n):e}function L0(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 Vf(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=z(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=z(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 I0(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 yf(e){let t=[],n=I0(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 K(...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([...yf(r[o]),...yf(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function Nt(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)=>K(n,r),{})}function P0(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function wf(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):P0(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function kf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&L0(n)?!1:n!=null))}function vf(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 $0(e,t){var n;let r=Vf(e),{nodeExtensions:o,markExtensions:i}=kr(e),s=(n=o.find(u=>z(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=kf({...e.reduce((m,b)=>{let k=z(b,"extendNodeSchema",d);return{...m,...k?k(u):{}}},{}),content:fe(z(u,"content",d)),marks:fe(z(u,"marks",d)),group:fe(z(u,"group",d)),inline:fe(z(u,"inline",d)),atom:fe(z(u,"atom",d)),selectable:fe(z(u,"selectable",d)),draggable:fe(z(u,"draggable",d)),code:fe(z(u,"code",d)),whitespace:fe(z(u,"whitespace",d)),linebreakReplacement:fe(z(u,"linebreakReplacement",d)),defining:fe(z(u,"defining",d)),isolating:fe(z(u,"isolating",d)),attrs:Object.fromEntries(c.map(vf))}),p=fe(z(u,"parseHTML",d));p&&(f.parseDOM=p.map(m=>wf(m,c)));let h=z(u,"renderHTML",d);h&&(f.toDOM=m=>h({node:m,HTMLAttributes:Nt(m,c)}));let g=z(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=kf({...e.reduce((g,m)=>{let b=z(m,"extendMarkSchema",d);return{...g,...b?b(u):{}}},{}),inclusive:fe(z(u,"inclusive",d)),excludes:fe(z(u,"excludes",d)),group:fe(z(u,"group",d)),spanning:fe(z(u,"spanning",d)),code:fe(z(u,"code",d)),attrs:Object.fromEntries(c.map(vf))}),p=fe(z(u,"parseHTML",d));p&&(f.parseDOM=p.map(g=>wf(g,c)));let h=z(u,"renderHTML",d);return h&&(f.toDOM=g=>h({mark:g,HTMLAttributes:Nt(g,c)})),[u.name,f]}));return new js({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 eo(e){return e.sort((n,r)=>{let o=z(n,"priority")||100,i=z(r,"priority")||100;return o>i?-1:o<i?1:0})}function jf(e){let t=eo(na(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 Ff(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 I0(e,t){return _f(e,{from:0,to:e.content.size},t)}function Vf(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function P0(e,t){let n=Re(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 ra(e,t){let n=ui(typeof t=="string"?t:t.name,e.schema);return n==="node"?P0(e,t):n==="mark"?$f(e,t):{}}function $0(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 B0(e){let t=$0(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 vr(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}})})}),B0(r)}function to(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(o=>{let i=Zl(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 jf=(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]},Ff=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 pr(e,t){return t.nodes[e]||t.marks[e]||null}function si(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 z0=(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 Yl(e,t,n={}){let{empty:r,ranges:o}=e.selection,i=t?jt(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(c=>i?i.name===c.type.name:!0).find(c=>li(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,b)=>{if(i&&h.inlineContent&&!h.type.allowsMarkType(i))return!1;if(!h.isText&&!h.marks.length)return;let m=Math.max(f,b),g=Math.min(p,b+h.nodeSize),k=g-m;s+=k,l.push(...h.marks.map(C=>({mark:C,from:m,to:g})))})}),s===0)return!1;let a=l.filter(c=>i?i.name===c.mark.type.name:!0).filter(c=>li(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 H0(e,t,n={}){if(!t)return Tt(e,null,n)||Yl(e,null,n);let r=ui(t,e.schema);return r==="node"?Tt(e,t,n):r==="mark"?Yl(e,t,n):!1}var Wf=(e,t)=>{let{$from:n,$to:r,$anchor:o}=e.selection;if(t){let i=di(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)},Kf=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function wf(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function Kl(e,t){let{nodeExtensions:n}=wr(t),r=n.find(i=>i.name===e);if(!r)return!1;let o=fe(z(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function Cr(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&&(Cr(i,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function fi(e){return e instanceof j}var Uf=class qf{constructor(t){this.position=t}static fromJSON(t){return new qf(t.position)}toJSON(){return{position:this.position}}};function _0(e,t){let n=t.mapping.mapResult(e.position);return{position:new Uf(n.pos),mapResult:n}}function V0(e){return new Uf(e)}function j0(e,t,n){let{selection:r}=t,o=null;if(ci(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(b=>b.type.excludes(n));u=p&&h}return!u}),u})}var F0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=jt(e,r.schema);if(o)if(s){let u=$f(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),b=Math.min(p+f.nodeSize,d);f.marks.find(m=>m.type===a)?f.marks.forEach(m=>{a===m.type&&n.addMark(h,b,a.create({...m.attrs,...t}))}):n.addMark(h,b,a.create(t))})});return j0(r,n,a)},W0=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),K0=(e,t={})=>({state:n,dispatch:r,chain:o})=>{let i=Re(e,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>il(i,{...s,...t})(n)?!0:l.clearNodes()).command(({state:l})=>il(i,{...s,...t})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},U0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,o=Fn(e,0,r.content.size),i=j.create(r,o);t.setSelection(i)}return!0},q0=(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},G0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:o,to:i}=typeof e=="number"?{from:e,to:e}:e,s=D.atStart(r).from,l=D.atEnd(r).to,a=Fn(o,s,l),u=Fn(i,s,l),c=D.create(r,a,u);t.setSelection(c)}return!0},J0=e=>({state:t,dispatch:n})=>{let r=Re(e,t.schema);return Gu(r)(t,n)};function kf(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 X0=({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=si(u,l.node().type.name,l.node().attrs);if(i instanceof j&&i.node.isBlock)return!l.parentOffset||!ht(s,l.pos)?!1:(r&&(e&&kf(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:Lf(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=d&&f?[{type:f,attrs:c}]:void 0,h=i instanceof D&&!i.empty?Hr.create({doc:t.doc,selection:i}).tr.deleteSelection():null,b=h?h.doc:t.doc,m=h?h.mapping.map(l.pos):l.pos,g=ht(b,m,1,p);if(!p&&!g&&ht(b,m,1,f?[{type:f}]:void 0)&&(g=!0,p=f?[{type:f,attrs:c}]:void 0),r){if(g){let k=t.steps.length;if(i instanceof D&&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()),S=t.doc.resolve(C);l.node(-1).canReplaceWith(S.index(),S.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(k).map(l.before()),f)}}e&&kf(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return g},Y0=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Re(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 S=V.empty,A=l.index(-1)?1:l.index(-2)?2:3;for(let ve=l.depth-A;ve>=l.depth-3;ve-=1)S=V.from(l.node(ve).copy(S));let E=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,M={...si(d,l.node().type.name,l.node().attrs),...t},L=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(M))||void 0;S=S.append(V.from(s.createAndFill(null,L)||void 0));let oe=l.before(l.depth-(A-1));n.replace(oe,l.after(-E),new ce(S,4-A,0));let he=-1;n.doc.nodesBetween(oe,n.doc.content.size,(ve,Ae)=>{if(he>-1)return!1;ve.isTextblock&&ve.content.size===0&&(he=Ae+1)}),he>-1&&n.setSelection(D.near(n.doc.resolve(he))),n.scrollIntoView()}return!0}let p=a.pos===l.end()?c.contentMatchAt(0).defaultType:null,h={...si(d,c.type.name,c.attrs),...t},b={...si(d,l.node().type.name,l.node().attrs),...t},m=l.parentOffset===0&&l.index(-1)===0,g=l.before(-1);n.delete(l.pos,a.pos);let k=m?c.attrs:h,C=p?[{type:s,attrs:k},{type:p,attrs:b}]:[{type:s,attrs:k}];if(!ht(n.doc,l.pos,2))return!1;if(o){let{selection:S,storedMarks:A}=r,{splittableMarks:E}=i.extensionManager,M=A||S.$to.parentOffset&&S.$from.marks();if(n.split(l.pos,2,C).scrollIntoView(),m&&n.setNodeMarkup(g,void 0,h),!M||!o)return!0;let L=M.filter(oe=>E.includes(oe.type.name));n.ensureMarks(L)}return!0};function vf(e){return!e||e==="1"?null:e}function Gf(e,t){return vf(e)===vf(t)}var Ul=(e,t)=>{let n=di(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&&kt(e.doc,n.pos))||!Gf(n.node.attrs.type,o?.attrs.type)||e.join(n.pos),!0},ql=(e,t)=>{let n=di(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&&kt(e.doc,r))||!Gf(n.node.attrs.type,o?.attrs.type)||e.join(r),!0};function Q0(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),o=t.resolve(n.nodeSize-1);return D.between(r,o)}var Z0=(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=Re(e,s.schema),h=Re(t,s.schema),{selection:b,storedMarks:m}=s,{$from:g,$to:k}=b,C=g.blockRange(k),S=m||b.$to.parentOffset&&b.$from.marks();if(!C)return!1;let A=di(Ve=>Kl(Ve.type.name,d))(b),E=b.from===0&&b.to===s.doc.content.size,M=s.doc.content.content,L=M.length===1?M[0]:null,oe=E&&L&&Kl(L.type.name,d)?{node:L,pos:0,depth:0}:null,he=A??oe,ve=!!A&&C.depth>=1&&C.depth-A.depth<=1,Ae=!!oe;if((ve||Ae)&&he){if(he.node.type===p)return E&&Ae?a().command(({tr:Ve,dispatch:je})=>{let $e=Q0(Ve);return $e?(Ve.setSelection($e),je&&je(Ve),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(Kl(he.node.type.name,d)&&p.validContent(he.node.content))return a().command(()=>(i.setNodeMarkup(he.pos,p),!0)).command(()=>Ul(i,p)).command(()=>ql(i,p)).run()}return!n||!S||!l?a().command(()=>c().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Ul(i,p)).command(()=>ql(i,p)).run():a().command(()=>{let Ve=c().wrapInList(p,r),je=S.filter($e=>f.includes($e.type.name));return i.ensureMarks(je),Ve?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Ul(i,p)).command(()=>ql(i,p)).run()},ew=(e,t={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=jt(e,r.schema);return Yl(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},tw=(e,t,n={})=>({state:r,commands:o})=>{let i=Re(e,r.schema),s=Re(t,r.schema),l=Tt(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})},nw=(e,t={})=>({state:n,commands:r})=>{let o=Re(e,n.schema);return Tt(n,o,t)?r.lift(o):r.wrapIn(o,t)},rw=()=>({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},ow=(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},iw=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=t,{selection:s}=n,l=jt(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=Zl(a,l,(d=a.marks().find(b=>b.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},sw=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},lw=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ui(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Re(e,r.schema)),l==="mark"&&(s=jt(e,r.schema));let a=!1;return n.selection.ranges.forEach(u=>{let c=u.$from.pos,d=u.$to.pos,f,p,h,b;n.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(a=!0,h=Math.max(g,c),b=Math.min(g+m.nodeSize,d),f=g,p=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g<c&&i&&i===m.type&&(a=!0,h=Math.max(g,c),b=Math.min(g+m.nodeSize,d),f=g,p=m),g>=c&&g<=d&&(i&&i===m.type&&(a=!0,o&&n.setNodeMarkup(g,void 0,{...m.attrs,...t})),s&&m.marks.length&&m.marks.forEach(k=>{if(s===k.type&&(a=!0,o)){let C=Math.max(g,c),S=Math.min(g+m.nodeSize,d);n.addMark(C,S,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,b,s.create({...m.attrs,...t}))}))}),a},mr=new te("__tiptap_decorations__"),aw=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(mr,{type:"force",name:e}),!0),cw=(e,t={})=>({state:n,dispatch:r})=>{let o=Re(e,n.schema);return Ku(o,t)(n,r)},uw=(e,t={})=>({state:n,dispatch:r})=>{let o=Re(e,n.schema);return Uu(o,t)(n,r)},dw=Ou({blur:()=>zy,clearContent:()=>Hy,clearNodes:()=>_y,command:()=>Vy,createParagraphNear:()=>jy,cut:()=>Fy,deleteCurrentNode:()=>Wy,deleteNode:()=>Ky,deleteRange:()=>Uy,deleteSelection:()=>Jy,enter:()=>Xy,exitCode:()=>Yy,extendMarkRange:()=>Qy,first:()=>Zy,focus:()=>t0,forEach:()=>n0,insertContent:()=>r0,insertContentAt:()=>o0,insertDefaultBlock:()=>i0,joinBackward:()=>a0,joinDown:()=>l0,joinForward:()=>c0,joinItemBackward:()=>u0,joinItemForward:()=>d0,joinTextblockBackward:()=>f0,joinTextblockForward:()=>p0,joinUp:()=>s0,keyboardShortcut:()=>m0,lift:()=>g0,liftEmptyBlock:()=>b0,liftListItem:()=>y0,newlineInCode:()=>w0,resetAttributes:()=>k0,scrollIntoView:()=>v0,selectAll:()=>C0,selectNodeBackward:()=>x0,selectNodeForward:()=>S0,selectParentNode:()=>E0,selectTextblockEnd:()=>M0,selectTextblockStart:()=>A0,setContent:()=>T0,setMark:()=>F0,setMeta:()=>W0,setNode:()=>K0,setNodeSelection:()=>U0,setTextDirection:()=>q0,setTextSelection:()=>G0,sinkListItem:()=>J0,splitBlock:()=>X0,splitListItem:()=>Y0,toggleList:()=>Z0,toggleMark:()=>ew,toggleNode:()=>tw,toggleWrap:()=>nw,undoInputRule:()=>rw,unsetAllMarks:()=>ow,unsetMark:()=>iw,unsetTextDirection:()=>sw,updateAttributes:()=>lw,updateDecorations:()=>aw,wrapIn:()=>cw,wrapInList:()=>uw}),gr=new WeakMap;function fw(e,t){var n;gr.set(e,((n=gr.get(e))!==null&&n!==void 0?n:0)+1);try{return t()}finally{var r;let o=((r=gr.get(e))!==null&&r!==void 0?r:1)-1;o>0?gr.set(e,o):gr.delete(e)}}function pw(e){return gr.has(e)}var hw=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={}}},Jf=typeof process<"u"&&!1;function mw(e){return e.kind==="widget"}function Xf(e,t){let n=[],r=new Set;for(let o of e)o.kind==="widget"&&mw(o)&&r.add(o.key),n.push(o.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function gw(e,t,n){let{decorations:r,widgetKeys:o}=Xf(t,n);return{set:de.create(e,r),widgetKeys:o}}function Yf({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n?!0:e===n&&n===r}function bw({decorations:e,from:t,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return e.filter(s=>Yf({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 Qf(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n=="string"?n:void 0}function yw(e){let t=new Map,n=new Map;for(let s of e.find()){var r,o,i;let l=Qf(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 ww(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 kw(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 vw(e,t){if(e.steps.some(i=>!ww(i)))return{type:"full"};let n=vr(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=kw(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 ep(e,t,n,r){return e.map(t,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function Cw(e,t,n){var r,o;let i=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:de.empty,s=new Set((o=t.widgetKeysByExtension[e])!==null&&o!==void 0?o:[]);return{set:ep(i,n.mapping,n.doc,s),widgetKeys:s}}function Cf(e,t){let n=Object.values(t).flatMap(r=>r.find());return de.create(e,n)}function xf(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function xw(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 Sw(e,t,n){return n?!0:e.update==="manual"?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var Ew=new Set;var Mw=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:t})=>{let n=mr.getState(t);n&&this.warnDuplicateWidgetKeys(n)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:t,spec:n})=>xw(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=mr.getState(this.editor.state))===null||t===void 0?void 0:t.widgetKeys)!==null&&e!==void 0?e:Ew}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 U({key:mr,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:xf(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(mr),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,u={},c={},d=new Set;return fw(e,()=>{for(let{name:f,spec:p}of t){let h=l||a===f;if(Sw(p,{editor:e,tr:n,oldState:o,newState:i},h))if(p.update==="changedRanges"&&n.docChanged&&!h){let b=this.applyChangedRangesRecompute(f,p,r,n,i);u[f]=b.set,c[f]=b.widgetKeys,d.add(f)}else{let{set:b,widgetKeys:m}=this.buildFullSet(f,p,i);u[f]=b,c[f]=m,d.add(f)}else{let b=Cw(f,r,n);u[f]=b.set,c[f]=b.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:xf(c)}}},props:{decorations(n){var r,o;return(r=(o=mr.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:de.empty}}})}applyChangedRangesRecompute(e,t,n,r,o){let i=vw(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:de.empty,u=new Set((l=n.widgetKeysByExtension[e])!==null&&l!==void 0?l:[]),c=ep(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(g=>Yf({position:g.from,from:f,to:p,docSize:d}));for(let g of h){let k=Qf(g);k&&u.delete(k)}c=c.remove(h);let{decorations:b,widgetKeys:m}=Xf(bw({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,b);for(let g of m)u.add(g)}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 gw(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(!Jf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=yw(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]]:Cf(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):Cf(n.doc,r)}};function tp(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof j){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 Aw(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 np(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 Tw(e){return typeof e=="number"}function Nw(e){return Object.prototype.toString.call(e).slice(8,-1)}function oi(e){return Nw(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function xr(e){return typeof e=="string"&&e.trim().length>0&&!/[;{}]/.test(e)}function oa(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 z0(e,t){return Ff(e,{from:0,to:e.content.size},t)}function Wf(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function H0(e,t){let n=Re(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 oa(e,t){let n=di(typeof t=="string"?t:t.name,e.schema);return n==="node"?H0(e,t):n==="mark"?Hf(e,t):{}}function _0(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=_0(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}})})}),V0(r)}function no(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(o=>{let i=ea(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 Kf=(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]},Uf=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 li(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 j0=(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 Ql(e,t,n={}){let{empty:r,ranges:o}=e.selection,i=t?jt(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(c=>i?i.name===c.type.name:!0).find(c=>ai(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=>ai(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 F0(e,t,n={}){if(!t)return Tt(e,null,n)||Ql(e,null,n);let r=di(t,e.schema);return r==="node"?Tt(e,t,n):r==="mark"?Ql(e,t,n):!1}var qf=(e,t)=>{let{$from:n,$to:r,$anchor:o}=e.selection;if(t){let i=fi(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)},Gf=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function Cf(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function Ul(e,t){let{nodeExtensions:n}=kr(t),r=n.find(i=>i.name===e);if(!r)return!1;let o=fe(z(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 pi(e){return e instanceof j}var Jf=class Xf{constructor(t){this.position=t}static fromJSON(t){return new Xf(t.position)}toJSON(){return{position:this.position}}};function W0(e,t){let n=t.mapping.mapResult(e.position);return{position:new Jf(n.pos),mapResult:n}}function K0(e){return new Jf(e)}function U0(e,t,n){let{selection:r}=t,o=null;if(ui(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 q0=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=jt(e,r.schema);if(o)if(s){let u=Hf(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 U0(r,n,a)},G0=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),J0=(e,t={})=>({state:n,dispatch:r,chain:o})=>{let i=Re(e,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>sl(i,{...s,...t})(n)?!0:l.clearNodes()).command(({state:l})=>sl(i,{...s,...t})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},X0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,o=Fn(e,0,r.content.size),i=j.create(r,o);t.setSelection(i)}return!0},Y0=(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},Q0=e=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:o,to:i}=typeof e=="number"?{from:e,to:e}:e,s=O.atStart(r).from,l=O.atEnd(r).to,a=Fn(o,s,l),u=Fn(i,s,l),c=O.create(r,a,u);t.setSelection(c)}return!0},Z0=e=>({state:t,dispatch:n})=>{let r=Re(e,t.schema);return Yu(r)(t,n)};function xf(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 ew=({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=li(u,l.node().type.name,l.node().attrs);if(i instanceof j&&i.node.isBlock)return!l.parentOffset||!ht(s,l.pos)?!1:(r&&(e&&xf(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:$f(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=d&&f?[{type:f,attrs:c}]:void 0,h=i instanceof O&&!i.empty?_r.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=ht(g,m,1,p);if(!p&&!b&&ht(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 O&&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()),S=t.doc.resolve(C);l.node(-1).canReplaceWith(S.index(),S.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(k).map(l.before()),f)}}e&&xf(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return b},tw=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Re(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 S=V.empty,A=l.index(-1)?1:l.index(-2)?2:3;for(let Ce=l.depth-A;Ce>=l.depth-3;Ce-=1)S=V.from(l.node(Ce).copy(S));let E=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,M={...li(d,l.node().type.name,l.node().attrs),...t},L=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(M))||void 0;S=S.append(V.from(s.createAndFill(null,L)||void 0));let oe=l.before(l.depth-(A-1));n.replace(oe,l.after(-E),new ce(S,4-A,0));let he=-1;n.doc.nodesBetween(oe,n.doc.content.size,(Ce,Ae)=>{if(he>-1)return!1;Ce.isTextblock&&Ce.content.size===0&&(he=Ae+1)}),he>-1&&n.setSelection(O.near(n.doc.resolve(he))),n.scrollIntoView()}return!0}let p=a.pos===l.end()?c.contentMatchAt(0).defaultType:null,h={...li(d,c.type.name,c.attrs),...t},g={...li(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(!ht(n.doc,l.pos,2))return!1;if(o){let{selection:S,storedMarks:A}=r,{splittableMarks:E}=i.extensionManager,M=A||S.$to.parentOffset&&S.$from.marks();if(n.split(l.pos,2,C).scrollIntoView(),m&&n.setNodeMarkup(b,void 0,h),!M||!o)return!0;let L=M.filter(oe=>E.includes(oe.type.name));n.ensureMarks(L)}return!0};function Sf(e){return!e||e==="1"?null:e}function Yf(e,t){return Sf(e)===Sf(t)}var ql=(e,t)=>{let n=fi(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&&kt(e.doc,n.pos))||!Yf(n.node.attrs.type,o?.attrs.type)||e.join(n.pos),!0},Gl=(e,t)=>{let n=fi(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&&kt(e.doc,r))||!Yf(n.node.attrs.type,o?.attrs.type)||e.join(r),!0};function nw(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),o=t.resolve(n.nodeSize-1);return O.between(r,o)}var rw=(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=Re(e,s.schema),h=Re(t,s.schema),{selection:g,storedMarks:m}=s,{$from:b,$to:k}=g,C=b.blockRange(k),S=m||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;let A=fi(Ve=>Ul(Ve.type.name,d))(g),E=g.from===0&&g.to===s.doc.content.size,M=s.doc.content.content,L=M.length===1?M[0]:null,oe=E&&L&&Ul(L.type.name,d)?{node:L,pos:0,depth:0}:null,he=A??oe,Ce=!!A&&C.depth>=1&&C.depth-A.depth<=1,Ae=!!oe;if((Ce||Ae)&&he){if(he.node.type===p)return E&&Ae?a().command(({tr:Ve,dispatch:je})=>{let $e=nw(Ve);return $e?(Ve.setSelection($e),je&&je(Ve),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(Ul(he.node.type.name,d)&&p.validContent(he.node.content))return a().command(()=>(i.setNodeMarkup(he.pos,p),!0)).command(()=>ql(i,p)).command(()=>Gl(i,p)).run()}return!n||!S||!l?a().command(()=>c().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>ql(i,p)).command(()=>Gl(i,p)).run():a().command(()=>{let Ve=c().wrapInList(p,r),je=S.filter($e=>f.includes($e.type.name));return i.ensureMarks(je),Ve?!0:u.clearNodes()}).wrapInList(p,r).command(()=>ql(i,p)).command(()=>Gl(i,p)).run()},ow=(e,t={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=jt(e,r.schema);return Ql(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},iw=(e,t,n={})=>({state:r,commands:o})=>{let i=Re(e,r.schema),s=Re(t,r.schema),l=Tt(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})},sw=(e,t={})=>({state:n,commands:r})=>{let o=Re(e,n.schema);return Tt(n,o,t)?r.lift(o):r.wrapIn(o,t)},lw=()=>({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},aw=(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},cw=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=t,{selection:s}=n,l=jt(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=ea(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},uw=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},dw=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=di(typeof e=="string"?e:e.name,r.schema);if(!l)return!1;l==="node"&&(i=Re(e,r.schema)),l==="mark"&&(s=jt(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),S=Math.min(b+m.nodeSize,d);n.addMark(C,S,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 te("__tiptap_decorations__"),fw=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(gr,{type:"force",name:e}),!0),pw=(e,t={})=>({state:n,dispatch:r})=>{let o=Re(e,n.schema);return Gu(o,t)(n,r)},hw=(e,t={})=>({state:n,dispatch:r})=>{let o=Re(e,n.schema);return Ju(o,t)(n,r)},mw=Iu({blur:()=>jy,clearContent:()=>Fy,clearNodes:()=>Wy,command:()=>Ky,createParagraphNear:()=>Uy,cut:()=>qy,deleteCurrentNode:()=>Gy,deleteNode:()=>Jy,deleteRange:()=>Xy,deleteSelection:()=>Zy,enter:()=>e0,exitCode:()=>t0,extendMarkRange:()=>n0,first:()=>r0,focus:()=>i0,forEach:()=>s0,insertContent:()=>l0,insertContentAt:()=>a0,insertDefaultBlock:()=>c0,joinBackward:()=>f0,joinDown:()=>d0,joinForward:()=>p0,joinItemBackward:()=>h0,joinItemForward:()=>m0,joinTextblockBackward:()=>g0,joinTextblockForward:()=>b0,joinUp:()=>u0,keyboardShortcut:()=>w0,lift:()=>k0,liftEmptyBlock:()=>v0,liftListItem:()=>C0,newlineInCode:()=>x0,resetAttributes:()=>S0,scrollIntoView:()=>E0,selectAll:()=>M0,selectNodeBackward:()=>A0,selectNodeForward:()=>T0,selectParentNode:()=>N0,selectTextblockEnd:()=>R0,selectTextblockStart:()=>D0,setContent:()=>O0,setMark:()=>q0,setMeta:()=>G0,setNode:()=>J0,setNodeSelection:()=>X0,setTextDirection:()=>Y0,setTextSelection:()=>Q0,sinkListItem:()=>Z0,splitBlock:()=>ew,splitListItem:()=>tw,toggleList:()=>rw,toggleMark:()=>ow,toggleNode:()=>iw,toggleWrap:()=>sw,undoInputRule:()=>lw,unsetAllMarks:()=>aw,unsetMark:()=>cw,unsetTextDirection:()=>uw,updateAttributes:()=>dw,updateDecorations:()=>fw,wrapIn:()=>pw,wrapInList:()=>hw}),br=new WeakMap;function gw(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 bw(e){return br.has(e)}var yw=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={}}},Qf=typeof process<"u"&&!1;function ww(e){return e.kind==="widget"}function Zf(e,t){let n=[],r=new Set;for(let o of e)o.kind==="widget"&&ww(o)&&r.add(o.key),n.push(o.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function kw(e,t,n){let{decorations:r,widgetKeys:o}=Zf(t,n);return{set:de.create(e,r),widgetKeys:o}}function ep({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n?!0:e===n&&n===r}function vw({decorations:e,from:t,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return e.filter(s=>ep({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 tp(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n=="string"?n:void 0}function Cw(e){let t=new Map,n=new Map;for(let s of e.find()){var r,o,i;let l=tp(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 np(e){return e.jsonID==="attr"}function xw(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||np(e))return!0;let n=e;return typeof n.from=="number"&&typeof n.to=="number"}function Sw(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 Ew(e,t){if(e.steps.some(i=>!xw(i)))return{type:"full"};let n=Cr(e).map(({newRange:i})=>i);e.steps.forEach((i,s)=>{if(!np(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=Sw(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 rp(e,t,n,r){return e.map(t,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function Mw(e,t,n){var r,o;let i=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:de.empty,s=new Set((o=t.widgetKeysByExtension[e])!==null&&o!==void 0?o:[]);return{set:rp(i,n.mapping,n.doc,s),widgetKeys:s}}function Ef(e,t){let n=Object.values(t).flatMap(r=>r.find());return de.create(e,n)}function Mf(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function Aw(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 Tw(e,t,n){return n?!0:e.update==="manual"?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var Nw=new Set;var Rw=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})=>Aw(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:Nw}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 U({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:Mf(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 gw(e,()=>{for(let{name:f,spec:p}of t){let h=l||a===f;if(Tw(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=Mw(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:Mf(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:de.empty}}})}applyChangedRangesRecompute(e,t,n,r,o){let i=Ew(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:de.empty,u=new Set((l=n.widgetKeysByExtension[e])!==null&&l!==void 0?l:[]),c=rp(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=>ep({position:b.from,from:f,to:p,docSize:d}));for(let b of h){let k=tp(b);k&&u.delete(k)}c=c.remove(h);let{decorations:g,widgetKeys:m}=Zf(vw({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 kw(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(!Qf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=Cw(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]]:Ef(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):Ef(n.doc,r)}};function op(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof j){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 ip(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 Ow(e){return typeof e=="number"}function Lw(e){return Object.prototype.toString.call(e).slice(8,-1)}function ii(e){return Lw(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 ia(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
|
|
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)
|
|
15
|
-
`,s+=1;else break}let m,g
|
|
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
|
|
13
|
+
`;let g=[h];for(s+=1;s<r.length;){var a;let C=r[s];if(C.trim()===""){var u;let S=r.slice(s+1).findIndex(A=>A.trim()!=="");if(S===-1)break;if((((u=r[s+1+S].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(S=>S.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 Af=4;function Tf(e){let t=0;for(let n of e)t=n===" "?t+Af-t%Af:t+1;return t}function sa(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=Tf(i);return(Tf(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
|
-
${
|
|
21
|
-
${
|
|
22
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var
|
|
20
|
+
${g}`:`
|
|
21
|
+
${g}`}}),a}function sp(e,t){let n={...e};return ii(e)&&ii(t)&&Object.keys(t).forEach(r=>{ii(t[r])&&ii(e[r])?n[r]=sp(e[r],t[r]):n[r]=t[r]}),n}function Iw(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}},Pw=(e,t)=>{if(Zl(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 $w(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:_r.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function Bw(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}=$w({editor:t,from:n,to:r,text:o,insertText:a}),f=c?n+o.length:r,p=ci({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 zw(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 si(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=j0(c)+i;for(let f of s){let p=Pw(d,f.find);if(!(!p||!zw(c,p,i))&&Bw({editor:n,from:r,to:o,text:i,rule:f,match:p,plugin:l,insertText:a}))return!0}return!1}function Hw(e){let{editor:t,rules:n}=e,r=new U({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=ra(V.from(u),s.schema);let{from:c}=a,d=c+u.length;si({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 si({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&&si({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?si({editor:t,from:s.pos,to:s.pos,text:`
|
|
22
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var la=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{...fe(z(this,"addOptions",{name:this.name}))}}get storage(){return{...fe(z(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>sp(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}},_e=class lp extends la{constructor(...t){super(...t),this.type="mark"}static create(t={}){let n=typeof t=="function"?t():t;return new lp(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)}},aa=class{constructor(e){this.find=e.find,this.handler=e.handler}},_w=(e,t,n)=>{if(Zl(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 Vw(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),S=Math.min(o,p+k);if(C>=S)return;let A=f.isText?f.text||"":f.textBetween(C-p,S-p,void 0,"\uFFFC");_w(A,i.find,s).forEach(E=>{if(E.index===void 0)return;let M=C+E.index+1,L=M+E[0].length,oe={from:n.tr.mapping.map(M),to:n.tr.mapping.map(L)},he=i.handler({state:n,range:oe,match:E,commands:a,chain:u,can:c,pasteEvent:s,dropEvent:l});d.push(he)})}),d.every(f=>f!==null)}var mr=null,jw=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 Fw(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=ci({state:u,transaction:h});if(!(!Vw({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 U({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:S}=m;typeof S=="string"?S=S:S=ra(V.from(S),f.schema);let{from:A}=m,E=A+S.length,M=jw(S);return a({rule:u,state:f,from:A,to:{b:E},pasteEvt:M})}let k=d.doc.content.findDiffStart(f.doc.content),C=d.doc.content.findDiffEnd(f.doc.content);if(!(!Ow(k)||!C||k===C.b))return a({rule:u,state:f,from:k,to:C,pasteEvt:s})}}))}var hi=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=jf(e),this.schema=$0(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=z(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=eo([...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=z(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&z(r,"exitable",o)&&(l.ArrowRight=()=>_e.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=af(l);i.push(a);let u=z(r,"addInputRules",o);if(Cf(r,e.options.enableInputRules)&&u){let f=u();if(f&&f.length){let p=Hw({editor:e,rules:f}),h=Array.isArray(p)?p:[p];i.push(...h)}}let c=z(r,"addPasteRules",o);if(Cf(r,e.options.enablePasteRules)&&c){let f=c();if(f&&f.length){let p=Fw({editor:e,rules:f});i.push(...p)}}let d=z(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=z(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 Rw({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){return Vf(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=kr(this.extensions);return Object.fromEntries(t.filter(n=>!!z(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=z(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Re(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,u,c,d)=>{let f=Nt(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 eo([...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=z(r,"dispatchTransaction",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},e)}transformPastedHTML(e){let{editor:t}=this;return eo([...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=z(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=>!!z(n,"addMarkView")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=z(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:jt(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let u=Nt(s,r);return o()({mark:s,view:l,inline:a,editor:e,extension:n,HTMLAttributes:u,updateAttributes:c=>{Iw(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=fe(z(t,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(t.name),!((o=fe(z(t,"clearable",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(t.name)}let i=z(t,"onBeforeCreate",n),s=z(t,"onCreate",n),l=z(t,"onUpdate",n),a=z(t,"onSelectionUpdate",n),u=z(t,"onTransaction",n),c=z(t,"onFocus",n),d=z(t,"onBlur",n),f=z(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)})}};hi.resolve=jf;hi.sort=eo;hi.flatten=na;var le=class ap extends la{constructor(...t){super(...t),this.type="extension"}static create(t={}){let n=typeof t=="function"?t():t;return new ap(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},Ww=le.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new U({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,i=Wf(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})=>Ff(r,{from:a.pos,to:u.pos},l)).join(s??`
|
|
23
23
|
|
|
24
|
-
`)}}})]}}),
|
|
24
|
+
`)}}})]}}),Kw=le.create({name:"commands",addCommands(){return{...mw}}}),Uw=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=ta(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 gu){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(S=>S.eq(c.mark)):!1,C=(p=a.doc.nodeAt(g))===null||p===void 0?void 0:p.marks.some(S=>S.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()}}),qw=le.create({name:"drop",addProseMirrorPlugins(){return[new U({key:new te("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Gw=le.create({name:"editable",addProseMirrorPlugins(){return[new U({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Jw=new te("focusEvents"),Xw=le.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new U({key:Jw,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}}}})]}}),Yw=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 Wn()||zf()?i:o},addProseMirrorPlugins(){return[new U({key:new te("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=ci({state:n,transaction:c}),{commands:f}=new yr({editor:this.editor,state:d});if(f.clearNodes(),!!c.steps.length)return c}})]}}),Qw=le.create({name:"paste",addProseMirrorPlugins(){return[new U({key:new te("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 U({key:new te("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"}}}})]}}),ek=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 U({key:new te("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}});var Nf=!1;function tk(e){if(Nf)return;Nf=!0;let t;try{t=Dn.fromJSON(e,{from:0,to:0}).slice.content}catch{return}t instanceof V||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 nk=class Zr{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 Zr(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 Zr(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 Zr(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 Zr(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)}},rk=`.ProseMirror {
|
|
25
25
|
position: relative;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -91,66 +91,66 @@ img.ProseMirror-separator {
|
|
|
91
91
|
|
|
92
92
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
93
93
|
display: block;
|
|
94
|
-
}`,
|
|
94
|
+
}`,ca=class extends yw{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:W0,createMappablePosition:K0},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=Jl(t,this.options.autofocus);this.editorState=_r.create({doc:t,schema:this.schema,selection:n||void 0})}tk(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=Dw(rk,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 Qf&&!this.hasWarnedStaleDecorationRead&&bw(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=Yl(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?[Gw,Ww.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),Kw,Xw,Yw,Zw.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),qw,Qw,Uw,ek.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 hi(n,this)}createCommandManager(){this.commandManager=new yr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Xl(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=Xl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=_r.create({doc:n,schema:this.schema,selection:Jl(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 Yl(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 Gr(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 oa(this.state,e)}isActive(e,t){let n=typeof e=="string"?e:null,r=typeof e=="string"?t:e;return F0(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ra(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
95
95
|
|
|
96
|
-
`,textSerializers:n={}}=e||{};return I0(this.state.doc,{blockSeparator:t,textSerializers:{...Vf(this.schema),...n}})}get isEmpty(){return Cr(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 Qw(t,this,!1,n)}get $doc(){return this.$pos(0)}};function it(e){return new Sr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=fe(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(to(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 hi(e){return new Sr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=fe(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 no(e){return new Sr({find:e.find,handler:({state:t,range:n,match:r})=>{let o=t.doc.resolve(n.from),i=fe(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 Sr({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{let i=fe(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&rr(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(b=>f.includes(b.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&&kt(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&s.join(n.from-1)},undoable:e.undoable})}var ek=e=>"touches"in e,sp=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,ek(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 ne=class lp extends sa{constructor(...t){super(...t),this.type="node"}static create(t={}){let n=typeof t=="function"?t():t;return new lp(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},ap=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(),S=(a=e.offsetX)!==null&&a!==void 0?a:(u=e.nativeEvent)===null||u===void 0?void 0:u.offsetX,A=(c=e.offsetY)!==null&&c!==void 0?c:(d=e.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=C.x-k.x+S,l=C.y-k.y+A}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 b=this.getPos();if(typeof b!="number")return;let m=j.create(r.state.doc,b),g=r.state.tr.setSelection(m);r.dispatch(g)}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=j.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"&&(Wn()||eo())&&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 nt(e){return new la({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{let i=fe(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(to(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 Je=ye(Ze(),1);var{getOwnPropertyNames:tk,getOwnPropertySymbols:nk}=Object,{hasOwnProperty:rk}=Object.prototype;function ro(e,t){return function(r,o,i){return e(r,o,i)&&t(r,o,i)}}function oo(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 ok(e){return e?.[Symbol.toStringTag]}function cp(e){return tk(e).concat(nk(e))}var ik=Object.hasOwn||((e,t)=>rk.call(e,t));function Un(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var sk="__v",lk="__o",ak="_owner",ck=typeof Float16Array<"u",{getOwnPropertyDescriptor:up,keys:dp}=Object;function uk(e,t){return e.byteLength===t.byteLength&&mi(new Uint8Array(e),new Uint8Array(t))}function dk(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 fk(e,t){return e.byteLength===t.byteLength&&mi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function pk(e,t){return Un(e.getTime(),t.getTime())}function fp(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 hk(e,t){return e===t}function pp(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 mk=Un;function hp(e,t,n){let r=dp(e),o=r.length;if(dp(t).length!==o)return!1;for(;o-- >0;)if(!bp(e,t,n,r[o]))return!1;return!0}function Er(e,t,n){let r=cp(e),o=r.length;if(cp(t).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!bp(e,t,n,i)||(s=up(e,i),l=up(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function gk(e,t){return Un(e.valueOf(),t.valueOf())}function bk(e,t){return e.source===t.source&&e.flags===t.flags}function mp(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 mi(e,t){let n=e.length;if(t.length!==n||e.byteOffset!==t.byteOffset)return!1;if(e instanceof Float64Array||e instanceof Float32Array||ck&&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 yk(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&&wk(e.searchParams,t.searchParams)}function wk(e,t){let n=e.toString(),r=t.toString();return n===r||gp(n)===gp(r)}function gp(e){return e.split("&").sort().join("&")}function bp(e,t,n,r){return(r===ak||r===lk||r===sk)&&(e.$$typeof||t.$$typeof)?!0:ik(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var kk="[object ArrayBuffer]",vk="[object Arguments]",Ck="[object Boolean]",xk="[object DataView]",Sk="[object Date]",Ek="[object Error]",Mk="[object Map]",Ak="[object Number]",Tk="[object Object]",Nk="[object RegExp]",Rk="[object Set]",Ok="[object String]",Dk={"[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},Lk="[object URL]",Ik=Object.prototype.toString;function Pk({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,g,k){if(m===g)return!0;if(m==null||g==null)return!1;let C=typeof m;if(C!==typeof g)return!1;if(C!=="object")return C==="number"?l(m,g,k):C==="function"?i(m,g,k):!1;let S=m.constructor;if(S!==g.constructor)return!1;if(S===Object)return a(m,g,k);if(Array.isArray(m))return t(m,g,k);if(S===Date)return r(m,g,k);if(S===RegExp)return c(m,g,k);if(S===Map)return s(m,g,k);if(S===Set)return d(m,g,k);if(S==null)return a(m,g,k);let A=Ik.call(m);if(A===Sk)return r(m,g,k);if(A===Nk)return c(m,g,k);if(A===Mk)return s(m,g,k);if(A===Rk)return d(m,g,k);if(A===Tk)return typeof m.then!="function"&&typeof g.then!="function"&&a(m,g,k);if(A===Lk)return p(m,g,k);if(A===Ek)return o(m,g,k);if(A===vk)return a(m,g,k);if(Dk[A])return f(m,g,k);if(A===kk)return e(m,g,k);if(A===xk)return n(m,g,k);if(A===Ck||A===Ak||A===Ok)return u(m,g,k);if(h){let E=h[A];if(!E){let M=ok(m);M&&(E=h[M])}if(E)return E(m,g,k)}return!1}}function $k({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:uk,areArraysEqual:n?Er:dk,areDataViewsEqual:fk,areDatesEqual:pk,areErrorsEqual:n?ro(fp,Er):ro(fp,hp),areFunctionsEqual:hk,areMapsEqual:n?ro(pp,Er):pp,areNumbersEqual:mk,areObjectsEqual:n?Er:hp,arePrimitiveWrappersEqual:gk,areRegExpsEqual:bk,areSetsEqual:n?ro(mp,Er):mp,areTypedArraysEqual:n?ro(mi,Er):mi,areUrlsEqual:yk,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let o=oo(r.areArraysEqual),i=oo(r.areErrorsEqual),s=oo(r.areMapsEqual),l=oo(r.areObjectsEqual),a=oo(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function Bk(e){return function(t,n,r,o,i,s,l){return e(t,n,l)}}function zk({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 yp=pn(),DE=pn({strict:!0}),LE=pn({circular:!0}),IE=pn({circular:!0,strict:!0}),PE=pn({createInternalComparator:()=>Un}),$E=pn({strict:!0,createInternalComparator:()=>Un}),BE=pn({circular:!0,createInternalComparator:()=>Un}),zE=pn({circular:!0,createInternalComparator:()=>Un,strict:!0});function pn(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:o=!1}=e,i=$k(e),s=Pk(i),l=n?n(s):Bk(s);return zk({circular:t,comparator:s,createState:r,equals:l,strict:o})}var Ep=ye(_g(),1);function Hk(e,t){var n,r;if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!=="insertParagraph"&&t.inputType!=="insertLineBreak"||!Wn()&&!eo())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 wp=new te("reactMobileEnter"),_k=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Vk=({contentComponent:e})=>{let t=(0,Sp.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,Je.jsx)(Je.Fragment,{children:Object.values(t)})};function jk(){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]:gi.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...t};delete i[o],t=i,r()}}}var ca=class extends Z.default.Component{constructor(e){super(e),this.editorContentRef=Z.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=jk(),t.createNodeViews(),t.registerPlugin(new U({key:wp,props:{handleDOMEvents:{beforeinput:(r,o)=>Hk(t,o)}}})),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(wp),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,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)("div",{ref:_k(t,this.editorContentRef),...n}),e?.contentComponent&&(0,Je.jsx)(Vk,{contentComponent:e.contentComponent})]})}},Fk=(0,Z.forwardRef)((e,t)=>{let n=Z.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Z.default.createElement(ca,{key:n,innerRef:t,...e})}),Wk=Z.default.memo(Fk),Kk=typeof window<"u"?Z.useLayoutEffect:Z.useEffect,Uk=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 io(e){var t;let[n]=(0,Z.useState)(()=>new Uk(e.editor)),r=(0,Ep.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:yp);return Kk(()=>n.watch(e.editor),[e.editor,n]),(0,Z.useDebugValue)(r),r}var qk=typeof window>"u",KE=qk||!!(typeof window<"u"&&window.next);var Mp=(0,Z.createContext)({editor:null}),UE=Mp.Consumer;var Ap=(0,Z.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var Tp=()=>(0,Z.useContext)(Ap);function bi({as:e="div",...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Tp();return(0,Je.jsx)(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var qn=Z.default.forwardRef((e,t)=>{let{onDragStart:n}=Tp(),r=e.as||"div";return(0,Je.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function kp(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function vp(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.forward_ref)"||e.$$typeof.description==="react.forward_ref"))}function Gk(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function Jk(e){if(kp(e)||vp(e))return!0;if(Gk(e)){let t=e.type;if(t)return kp(t)||vp(t)}return!1}function Xk(){try{if(Z.version)return parseInt(Z.version.split(".")[0],10)>=19}catch{}return!1}var Yk=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,gi.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=Xk(),i=Jk(t),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,Je.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])})}},qE=Z.default.createContext({markViewContentRef:()=>{}});function Qk(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 Zk(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function Np(e){if(!ci(e))return[];let{$from:t,$to:n}=e,r=[],o=Math.min(t.depth,n.depth);for(let i=1;i<=o&&Zk(t,n,i);i+=1)r.push(t.before(i));return r}var ev=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 Np(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}},Cp=new WeakMap;function xp(e){let t=Cp.get(e);return t||(t=new ev(e),Cp.set(e,t)),t}var tv=class extends ap{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,Z.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=Qk(this.contentDOMElement);a.appendChild(this.contentDOMElement),u?.()}}},o=this.component,i=(0,Z.memo)(a=>(0,Je.jsx)(Ap.Provider,{value:r,children:(0,Z.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 Yk(i,{editor:this.editor,props:e,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),xp(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"&&Np(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),xp(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=Nt(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Gn(e,t){return n=>n.editor.contentComponent?new tv(e,n,t):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var ua=(0,Z.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});ua.displayName="TiptapContext";var nv=()=>(0,Z.useContext)(ua);function Rp({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,Z.useMemo)(()=>({editor:n}),[n]),o=(0,Z.useMemo)(()=>({editor:n}),[n]);return(0,Je.jsx)(Mp.Provider,{value:o,children:(0,Je.jsx)(ua.Provider,{value:r,children:e})})}Rp.displayName="Tiptap";function Op({...e}){let{editor:t}=nv();return(0,Je.jsx)(Wk,{editor:t,...e})}Op.displayName="Tiptap.Content";var GE=Object.assign(Rp,{Content:Op});var yi=class extends ca{componentWillUnmount(){let t=this.editorContentRef.current;queueMicrotask(()=>{t?.isConnected||super.componentWillUnmount()})}};var rt=ye(en(),1);var rv=new WeakSet,Dp=e=>rv.has(e);var ov=(0,rt.createContext)(null);function Lp(e){let t=(0,rt.useContext)(ov),n=(0,rt.useId)(),r=(0,rt.useRef)(e.retentionKey??n).current,o=(0,rt.useRef)(e);o.current=e;let i=(0,rt.useRef)(t?.find(r)??null),[s,l]=(0,rt.useState)(i.current),a=(0,rt.useRef)(void 0);return(0,rt.useLayoutEffect)(()=>{clearTimeout(a.current);let u=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:p,...h}=o.current;return new aa({...h,onUpdate:b=>o.current.onUpdate?.(b),editorProps:{...h.editorProps,handleKeyDown:(b,m)=>o.current.editorProps?.handleKeyDown?.(b,m)??!1,handleClick:(b,m,g)=>o.current.editorProps?.handleClick?.(b,m,g)??!1,handlePaste:(b,m,g)=>o.current.editorProps?.handlePaste?.(b,m,g)??!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 da=new WeakMap;function fa(e){let t=da.get(e);if(t)return t;let n={type:e.type.name};Object.keys(e.attrs).length&&(n.attrs=e.attrs),e.content.size&&(n.content=[],e.content.forEach(o=>n.content.push(fa(o)))),e.marks.length&&(n.marks=e.marks.map(o=>o.toJSON())),e.isText&&(n.text=e.text);let r=$o(n);return da.set(e,r),r}function Ip(e,t){let n=da.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(!Ip(e.child(r),t.content[r]))return!1;return!0}function Pp(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(!Ip(e.child(n),t.content[n]))return!1;return!0}function wi(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 Pe=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 pa(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!iv(t)||!sv(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&&!j.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}}};Pe.prototype.visible=!1;Pe.findFrom=Pe.findGapCursorFrom;X.jsonID("gapcursor",Pe);var pa=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 Pe.valid(n)?new Pe(n):X.near(n)}};function $p(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function iv(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||$p(o.type))return!0;if(o.inlineContent)return!1}}return!0}function sv(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||$p(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Bp(){return new U({props:{decorations:uv,createSelectionBetween(e,t,n){return t.pos==n.pos&&Pe.valid(n)?new Pe(n):null},handleClick:av,handleKeyDown:lv,handleDOMEvents:{beforeinput:cv}}})}var lv=Yr({ArrowLeft:ki("horiz",-1),ArrowRight:ki("horiz",1),ArrowUp:ki("vert",-1),ArrowDown:ki("vert",1)});function ki(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 D){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(t>0?l.after():l.before())}let u=Pe.findGapCursorFrom(l,t,a);return u?(o&&o(r.tr.setSelection(new Pe(u))),!0):!1}}function av(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Pe.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&j.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Pe(r))),!0)}function cv(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Pe))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=V.empty;for(let s=r.length-1;s>=0;s--)o=V.from(r[s].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new ce(o,0,0));return i.setSelection(D.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function uv(e){if(!(e.selection instanceof Pe))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",de.create(e.doc,[Me.widget(e.selection.head,t,{key:"gapcursor"})])}function Mr(e){let t=e.selection;if(!(t instanceof j)||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 Pe(e.doc.resolve(e.doc.content.size)).map(e.doc,new Oo),o=n??(r instanceof Pe?r:null);return o?e.tr.setSelection(o).setMeta("addToHistory",!1):null}function zp(e,t){if(Pp(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 ma,ga;if(typeof WeakMap<"u"){let e=new WeakMap;ma=t=>e.get(t),ga=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;ma=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},ga=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var ge=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 ma(e)||ga(e,dv(e))}};function dv(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=fv(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 b=d.child(h),{colspan:m,rowspan:g,colwidth:k}=b.attrs;for(let C=0;C<g;C++){if(C+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:g-C});break}let S=o+C*t;for(let A=0;A<m;A++){r[S+A]==0?r[S+A]=c:(i||(i=[])).push({type:"collision",row:u,pos:c,n:m-A});let E=k&&k[A];if(E){let M=(S+A)%t*2,L=s[M];L==null||L!=E&&s[M+1]==1?(s[M]=E,s[M+1]=1):L==E&&s[M+1]++}}}o+=m,c+=b.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 ge(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&&pv(l,s,e),l}function fv(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 pv(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=hv(a)))[u]=c)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function hv(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Xe(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 te("selectingCells");function Wt(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 mv(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 Ct(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 Mi(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=Wt(t.$head)||gv(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function gv(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 ba(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function bv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ka(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Gp(e,t,n){let r=e.node(-1),o=ge.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 Jn(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 Jp(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 yv(e,t,n){let r=Xe(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 Ft extends X{constructor(t,n=t){let r=t.node(-1),o=ge.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 js(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(ba(r)&&ba(o)&&ka(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ft.rowSelection(r,o):i&&this.isColSelection()?Ft.colSelection(r,o):new Ft(r,o)}return D.between(r,o)}content(){let t=this.$anchorCell.node(-1),n=ge.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 b=o.left-p.left,m=p.right-o.right;if(b>0||m>0){let g=h.attrs;if(b>0&&(g=Jn(g,0,b)),m>0&&(g=Jn(g,g.colspan-m,m)),p.left<o.left){if(h=h.type.createAndFill(g),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(g)}`)}else h=h.type.create(g,h.content)}if(p.top<o.top||p.bottom>o.bottom){let g={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(g):h=h.type.create(g,h.content)}u.push(h)}s.push(t.child(a).copy(V.from(u)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new ce(V.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(V.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=ge.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=ge.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 Ft(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=ge.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 Ft&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),o=ge.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 Ft(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Ft(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Ft(t.resolve(n),t.resolve(r))}getBookmark(){return new wv(this.$anchorCell.pos,this.$headCell.pos)}};re.prototype.visible=!1;X.jsonID("cell",re);var wv=class Xp{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Xp(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&&ka(n,r)?new re(n,r):X.near(r,1)}};function kv(e){if(!(e.selection instanceof re))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push(Me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),de.create(e.doc,t)}function vv({$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 Cv({$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 xv(e,t,n){let r=(t||e).selection,o=(t||e).doc,i,s;if(r instanceof j&&(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=ge.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 D&&vv(r)?i=D.create(o,r.from):r instanceof D&&Cv(r)&&(i=D.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var Sv=new te("fix-tables");function Yp(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)?Yp(e.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function va(e,t){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=Ev(e,o,i,n))};return t?t.doc!=e.doc&&Yp(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Ev(e,t,n,r){let o=ge.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,Jn(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 g=Xe(e.schema)[p].createAndFill();g&&h.push(g)}let b=(a==0||s==a-1)&&l==a?u+1:d-1;r.insert(r.mapping.map(b),h)}u=d}return r.setMeta(Sv,{fixTables:!0})}function Rt(e){let t=e.selection,n=Mi(e),r=n.node(-1),o=n.start(-1),i=ge.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 Qp(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;yv(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,Jp(u.attrs,o-t.colCount(a))),s+=u.attrs.rowspan-1}else{let a=i==null?Xe(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(!Ct(e))return!1;if(t){let n=Rt(e);t(Qp(e.tr,n,n.left))}return!0}function eh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(Qp(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,Jn(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 th(e,t){if(!Ct(e))return!1;if(t){let n=Rt(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=ge.get(i)}t(r)}return!0}function Av(e,t,n){var r;let o=Xe(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 nh(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;Av(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?Xe(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,Xe(r.type.schema).row.create(null,s)),e}function rh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(nh(e.tr,n,n.top))}return!0}function oh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(nh(e.tr,n,n.bottom))}return!0}function Tv(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),b=t.positionAt(o+1,u,n);e.insert(e.mapping.slice(l).map(r+b),h),u+=p.colspan-1}}}}function ih(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;Tv(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=ge.get(n.table)}t(r)}return!0}function Hp(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Nv({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 Ca(e,t){let n=e.selection;if(!(n instanceof re)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Rt(e),{map:o}=r;if(Nv(o,r))return!1;if(t){let i=e.tr,s={},l=V.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{Hp(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,{...Jp(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=Hp(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 xa(e,t){let n=Xe(e.schema);return Rv(({node:r})=>n[r.type.spec.tableRole])(e,t)}function Rv(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=mv(r.$from),!o)return!1;i=(s=Wt(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=Rt(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 b=c.left,m=0;b<c.right;b++,m++)b==c.left&&p==c.top||d.insert(f=d.mapping.map(h+c.tableStart,1),e({node:o,row:p,col:b}).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 sh(e,t){return function(n,r){if(!Ct(n))return!1;let o=Mi(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 Ov(e){return function(t,n){if(!Ct(t))return!1;if(n){let r=Xe(t.schema),o=Rt(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 _p(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?Ov(e):function(n,r){if(!Ct(n))return!1;if(r){let o=Xe(n.schema),i=Rt(n),s=n.tr,l=_p("row",i,o),a=_p("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 TM=Ar("row",{useDeprecatedLogic:!0}),NM=Ar("column",{useDeprecatedLogic:!0}),lh=Ar("cell",{useDeprecatedLogic:!0});function Dv(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 Sa(e){return function(t,n){if(!Ct(t))return!1;let r=Dv(Mi(t),e);if(r==null)return!1;if(n){let o=t.doc.resolve(r);n(t.tr.setSelection(D.between(o,bv(o))).scrollIntoView())}return!0}}function ah(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 vi(e,t){let n=e.selection;if(!(n instanceof re))return!1;if(t){let r=e.tr,o=Xe(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 Lv(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=ya(Xe(s).row,new ce(u,c,d)).content),l.push(u)}else if(i=="cell"||i=="header_cell")l.push(n||r?ya(Xe(s).row,new ce(t,n,r)).content:t);else return null;return Iv(s,l)}function Iv(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(V.empty),n[o]<r){let i=Xe(e).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);t[o]=t[o].append(V.from(s))}return{height:t.length,width:r,rows:t}}function ya(e,t){let n=e.createAndFill();return new Io(n).replace(0,n.content.size,t).doc}function Pv({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(Jn(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(V.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(V.from(a))}n=i,t=o}return{width:e,height:t,rows:n}}function $v(e,t,n,r,o,i,s){let l=e.doc.type.schema,a=Xe(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=[],b;p.lastChild==null||p.lastChild.type==a.cell?b=u||(u=a.cell.createAndFill()):b=c||(c=a.header_cell.createAndFill());for(let m=t.width;m<o;m++)h.push(b);e.insert(e.mapping.slice(s).map(f-1+r),h)}if(i>t.height){let d=[];for(let h=0,b=(t.height-1)*t.width;h<Math.max(t.width,o);h++){let m=h>=t.width?!1:n.nodeAt(t.map[b+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,V.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 Vp(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 jp(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,Jn(f.attrs,s-p,f.attrs.colspan-(s-p))),e.insert(h+f.nodeSize,f.type.createAndFill(Jn(f.attrs,0,s-p))),u+=f.attrs.rowspan-1}}return a}function Fp(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=ge.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=ge.get(i),f=d.mapping.maps.length}$v(d,s,i,n,u,c,f)&&p(),Vp(d,s,i,n,a,u,l,f)&&p(),Vp(d,s,i,n,a,u,c,f)&&p(),jp(d,s,i,n,l,c,a,f)&&p(),jp(d,s,i,n,l,c,u,f)&&p();for(let h=l;h<c;h++){let b=s.positionAt(h,a,i),m=s.positionAt(h,u,i);d.replace(d.mapping.slice(f).map(b+n),d.mapping.slice(f).map(m+n),new ce(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 Bv=Yr({ArrowLeft:Ci("horiz",-1),ArrowRight:Ci("horiz",1),ArrowUp:Ci("vert",-1),ArrowDown:Ci("vert",1),"Shift-ArrowLeft":xi("horiz",-1),"Shift-ArrowRight":xi("horiz",1),"Shift-ArrowUp":xi("vert",-1),"Shift-ArrowDown":xi("vert",1),Backspace:vi,"Mod-Backspace":vi,Delete:vi,"Mod-Delete":vi});function Si(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Ci(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof re)return Si(n,r,X.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let s=ch(o,e,t);if(s==null)return!1;if(e=="horiz")return Si(n,r,X.near(n.doc.resolve(i.head+t),t));{let l=n.doc.resolve(s),a=Gp(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),Si(n,r,u)}}}function xi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof re)s=i;else{let a=ch(o,e,t);if(a==null)return!1;s=new re(n.doc.resolve(a))}let l=Gp(s.$headCell,e,t);return l?Si(n,r,new re(s.$anchorCell,l)):!1}}function zv(e,t){let n=e.state.doc,r=Wt(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new re(r))),!0):!1}function Hv(e,t,n){if(!Ct(e.state))return!1;let r=Lv(n),o=e.state.selection;if(o instanceof re){r||(r={width:1,height:1,rows:[V.from(ya(Xe(e.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ge.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=Pv(r,l.right-l.left,l.bottom-l.top),Fp(e.state,e.dispatch,s,l,r),!0}else if(r){let i=Mi(e.state),s=i.start(-1);return Fp(e.state,e.dispatch,s,ge.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function _v(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=Wp(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=Wt(e.state.selection.$anchor))!=null&&((n=ha(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=ha(e,u),d=hn.getState(e.state)==null;if(!c||!ka(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(Wp(e,u.target)!=r&&(d=ha(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 ch(e,t,n){if(!(e.state.selection instanceof D))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 Wp(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function ha(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&&Wt(e.state.doc.resolve(r))||Wt(e.state.doc.resolve(o))}var Vv=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")),wa(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,wa(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function wa(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 b=0;b<p;b++,f++){let m=o==f?i:h&&h[b],g=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=g&&(a.style.width=g),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=g,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 dt=new te("tableColumnResizing");function uh({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Vv,lastColumnResizable:o=!0}={}){let i=new U({key:dt,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=Xe(l.schema).table.name;return r&&u&&(u[c]=(d,f)=>new r(d,n,f)),new jv(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=dt.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Fv(s,l,e,o)},mouseleave:s=>{Wv(s)},mousedown:(s,l)=>{Kv(s,l,t,n)}},decorations:s=>{let l=dt.getState(s);if(l&&l.activeHandle>-1)return Xv(s,l.activeHandle)},nodeViews:{}}});return i}var jv=class Ei{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(dt);if(r&&r.setHandle!=null)return new Ei(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ei(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return ba(t.doc.resolve(o))||(o=-1),new Ei(o,n.dragging)}return n}};function Fv(e,t,n,r){if(!e.editable)return;let o=dt.getState(e.state);if(o&&!o.dragging){let i=qv(t.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();t.clientX-l<=n?s=Kp(e,t,"left",n):a-t.clientX<=n&&(s=Kp(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),a=l.node(-1),u=ge.get(a),c=l.start(-1);if(u.colCount(l.pos-c)+l.nodeAfter.attrs.colspan-1==u.width-1)return}dh(e,s)}}}function Wv(e){if(!e.editable)return;let t=dt.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&dh(e,-1)}function Kv(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=dt.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),a=Uv(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(dt,{setDragging:{startX:t.clientX,startWidth:a}}));function u(d){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",c);let f=dt.getState(e.state);f?.dragging&&(Gv(e,f.activeHandle,Up(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(dt,{setDragging:null})))}function c(d){if(!d.which)return u(d);let f=dt.getState(e.state);if(f&&f.dragging){let p=Up(f.dragging,d,n);qp(e,f.activeHandle,p,r)}}return qp(e,s.activeHandle,a,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",c),t.preventDefault(),!0}function Uv(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 qv(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Kp(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=Wt(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=ge.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 Up(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function dh(e,t){e.dispatch(e.state.tr.setMeta(dt,{setHandle:t}))}function Gv(e,t,n){let r=e.state.doc.resolve(t),o=r.node(-1),i=ge.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():Jv(f.colspan);h[p]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:h})}a.docChanged&&e.dispatch(a)}function qp(e,t,n,r){let o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=ge.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&&wa(i,a.firstChild,a,r,l,n)}function Jv(e){return Array(e).fill(0)}function Xv(e,t){let n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return de.empty;let i=ge.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=dt.getState(e))===null||a===void 0)&&a.dragging&&n.push(Me.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Me.widget(f,p))}}return de.create(e.doc,n)}function fh({allowTableNodeSelection:e=!1}={}){return new U({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:kv,handleDOMEvents:{mousedown:_v},createSelectionBetween(t){return hn.getState(t.state)!=null?t.state.selection:null},handleTripleClick:zv,handleKeyDown:Bv,handlePaste:Hv},appendTransaction(t,n,r){return xv(r,va(r,n),e)}})}var Xn="showaiTableAction";function ph(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:Wt(e.selection.$head),i=o&&o.before(-1)===t?o:e.doc.resolve(t+1+ge.get(r).map[0]),s=n==="row"?re.rowSelection(i):n==="column"?re.colSelection(i):new re(i);return e.tr.setSelection(s)}function so(e){let t=e.selection;if(!(t instanceof re))return null;let n=t.$anchorCell.node(-1),r=t.$anchorCell.start(-1),o=ge.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 hh(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 ft=ye(Ze(),1);function Ai({editor:e,context:t=!1,onAction:n}){let r=Le(He),o=so(e.state);if(!o&&!t&&!e.can().splitCell())return null;let i=s=>{e.view.dispatch(fr(e.state.tr)),e.chain().setMeta(Xn,!0).focus()[s]().run(),n?.()};return(0,ft.jsxs)(ft.Fragment,{children:[!t&&(0,ft.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,ft.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,ft.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"),tu],["splitCell",r("table.splitCell"),nu]].map(([s,l,a])=>(0,ft.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,ft.jsx)(a,{size:16}),t&&(0,ft.jsx)("span",{children:l})]},s)),!t&&o&&(0,ft.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(D.near(e.state.selection.$from))),e.view.focus()},children:(0,ft.jsx)(zr,{size:16})})]})]})}var lo=ye(en(),1),kh=ye(Bs(),1);var Ti=ye(Ze(),1),Yv=[["left","Left",Tn],["center","Center",Mn],["right","Right",An]];function Ea({scope:e,value:t,onChange:n}){let r=Le(bu),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,Ti.jsx)("div",{className:"table-alignment-buttons",role:"group","aria-label":o("Group"),children:Yv.map(([i,s,l])=>(0,Ti.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,Ti.jsx)(l,{size:14})},i))})}var mh=ir(He),gh=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 U({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=ge.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});Qv(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 Qv(e,t,n){e.forEach((r,o)=>r.forEach((i,s)=>n(i,t+2+o+s)))}function Ma(e,t){let r=bh(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 bh(e,t){let n=ge.get(e);if(t!==null&&(!Number.isInteger(t)||t<0||t>=n.width))throw new Error(mh("table.columnOutOfRange"));return[...new Set(t===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+t]))]}function yh(e,t,n,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="table")throw new Error(mh("table.notATable"));let i=e.tr;n===null&&i.setNodeAttribute(t,"textAlign",r);for(let s of bh(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 Kt=ye(en(),1),Zv=()=>!0;function wh(e,t={}){let n=(0,Kt.useId)(),[r,o]=(0,Kt.useState)(null),[,i]=(0,Kt.useState)(0),s=(0,Kt.useRef)({target:r,options:t});s.current={target:r,options:t};let l=t.accept??Zv;return(0,Kt.useEffect)(()=>{if(!e)return;let a,u=()=>{clearTimeout(a),a=void 0},c=E=>E?.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=E=>{let M=E.closest("table");if(!(M instanceof HTMLTableElement)||!e.contains(M)||!l(M))return null;let L=E.closest("td, th");return{table:M,cell:L?.parentElement===M.rows[0]?L:null,context:null}},h=E=>{u(),o(M=>M?.table===E.table&&M.cell===E.cell&&!M.context?M:E)},b=E=>{let M=E.target;if(c(M)){u();return}if(s.current.options.keepOpen||s.current.target?.context){u();return}let L=s.current.target;if(L?.cell?.isConnected){let he=L.cell.getBoundingClientRect(),ve=Aa(L,0).column;if(E.clientX>=Math.min(he.left,ve.left)&&E.clientX<=Math.max(he.right,ve.left+88)&&E.clientY>=he.bottom&&E.clientY<=ve.top){u();return}}let oe=p(M);if(oe){h(oe);return}if(L?.table.isConnected){let he=L.table.getBoundingClientRect();if(E.clientX>=he.left-8&&E.clientX<=he.right+8&&E.clientY>=he.top-44&&E.clientY<=he.bottom+8){u();return}}f()},m=E=>{let M=E.target;if(c(M)){u();return}let L=p(M);L?(s.current.options.onDismiss?.(),h(L)):d()},g=E=>{let M=p(E.target);M&&(E.preventDefault(),E.stopPropagation(),u(),s.current.options.onDismiss?.(),o({...M,cell:null,context:{left:Math.max(8,Math.min(E.clientX,window.innerWidth-140)),top:Math.max(8,Math.min(E.clientY,window.innerHeight-42))}}))},k=E=>{if(c(E.target))u();else{let M=p(E.target);M&&h(M)}},C=E=>{E.key==="Escape"&&d()},S=E=>{E.target instanceof HTMLElement&&E.target.contains(e)&&d()},A=()=>i(E=>E+1);return document.addEventListener("pointermove",b),document.addEventListener("pointerdown",m),document.addEventListener("focusin",k),document.addEventListener("keydown",C),e.addEventListener("contextmenu",g),window.addEventListener("blur",d),window.addEventListener("showai:viewport-change",S),window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{u(),document.removeEventListener("pointermove",b),document.removeEventListener("pointerdown",m),document.removeEventListener("focusin",k),document.removeEventListener("keydown",C),e.removeEventListener("contextmenu",g),window.removeEventListener("blur",d),window.removeEventListener("showai:viewport-change",S),window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[e,l,n]),{target:r,setTarget:o,owner:n}}function Aa(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 me=ye(Ze(),1),eC=e=>!e.closest(".document-widget");function vh({editor:e}){let t=Le(He),[,n]=(0,lo.useState)(0),[r,o]=(0,lo.useState)(!1),i=so(e.state),{target:s,setTarget:l,owner:a}=wh(e.view.dom,{keepOpen:r,accept:eC,onDismiss:()=>o(!1)});if((0,lo.useEffect)(()=>{let A=()=>n(M=>M+1),E=M=>{M.key!=="Escape"||!so(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(D.near(e.state.selection.$from))),o(!1),e.view.focus())};return e.on("transaction",A),document.addEventListener("keydown",E),()=>{e.off("transaction",A),document.removeEventListener("keydown",E)}},[e,a]),!s||!s.table.isConnected||!e.isEditable||!s.context&&(i||e.isFocused&&e.state.selection instanceof D&&!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 A=e.view.posAtDOM(s.cell,0),E=e.state.doc.resolve(A),M=E.depth;for(;M>c&&!["tableCell","tableHeader"].includes(E.node(M).type.name);)M--;M>c&&(p=ge.get(d).findCell(E.before(M)-f-1).left)}let h=Aa(s,128),b=h.global.top>window.innerHeight/2,m=()=>{let{$from:A}=e.state.selection;Array.from({length:A.depth},(M,L)=>L+1).some(M=>A.node(M).type.name==="table"&&A.before(M)===f)||e.view.dispatch(e.state.tr.setSelection(D.near(e.state.doc.resolve(f+3))))},g=A=>{m(),e.view.dispatch(fr(e.state.tr)),A(),o(!1)},k=()=>e.chain().setMeta(Xn,!0).focus(),C=A=>g(()=>{let E=ph(e.state,f,A);E&&e.view.dispatch(E),e.view.focus()}),S=(A,E)=>{e.view.dispatch(yh(e.state,f,A,E).setMeta(Xn,!0)),s.context&&(l(null),e.view.focus())};return(0,kh.createPortal)((0,me.jsxs)(me.Fragment,{children:[(0,me.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,me.jsx)(Ea,{scope:"table",value:Ma(d,null),onChange:A=>S(null,A)}),!s.context&&(0,me.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:A=>A.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,me.jsx)(_c,{size:16})}),(r||s.context)&&(0,me.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":t("table.actionsMenu"),style:{...b?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,b?h.global.top-12:window.innerHeight-h.global.top-46),overflowY:"auto"},onMouseDown:A=>A.preventDefault(),children:[(0,me.jsxs)("button",{role:"menuitem",onClick:()=>g(()=>{k().addRowAfter().run()}),children:[(0,me.jsx)(tn,{size:14}),t("table.addRow")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>g(()=>{k().addColumnAfter().run()}),children:[(0,me.jsx)(tn,{size:14}),t("table.addColumn")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>g(()=>{k().toggleHeaderRow().run()}),children:[(0,me.jsx)(ru,{size:14,"aria-hidden":"true"}),t("table.toggleHeader")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>C("cell"),children:[(0,me.jsx)(Zc,{size:14,"aria-hidden":"true"}),t("table.selectCells")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>C("row"),children:[(0,me.jsx)($s,{size:14,"aria-hidden":"true"}),t("table.selectRow")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>C("column"),children:[(0,me.jsx)(Ps,{size:14,"aria-hidden":"true"}),t("table.selectColumn")]}),s.context&&(0,me.jsx)(Ai,{editor:e,context:!0,onAction:()=>{l(null),o(!1)}}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>g(()=>{k().deleteRow().run()}),children:[(0,me.jsx)($s,{size:14,"aria-hidden":"true"}),t("table.deleteRow")]}),(0,me.jsxs)("button",{role:"menuitem",onClick:()=>g(()=>{k().deleteColumn().run()}),children:[(0,me.jsx)(Ps,{size:14,"aria-hidden":"true"}),t("table.deleteColumn")]}),(0,me.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>g(()=>{k().deleteTable().run(),l(null)}),children:[(0,me.jsx)(To,{size:14}),t("table.deleteTable")]})]})]}),p!==null&&!s.context&&(0,me.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:h.column,children:(0,me.jsx)(Ea,{scope:p,value:Ma(d,p),onChange:A=>S(p,A)})})]}),document.body)}var Ut=ye(en(),1);Oc(`.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 F=
|
|
96
|
+
`,textSerializers:n={}}=e||{};return z0(this.state.doc,{blockSeparator:t,textSerializers:{...Wf(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 nk(t,this,!1,n)}get $doc(){return this.$pos(0)}};function it(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=fe(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(no(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 mi(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=fe(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 ro(e){return new Er({find:e.find,handler:({state:t,range:n,match:r})=>{let o=t.doc.resolve(n.from),i=fe(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 Er({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{let i=fe(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&or(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&&kt(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&s.join(n.from-1)},undoable:e.undoable})}var ok=e=>"touches"in e,cp=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,ok(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 ne=class up extends la{constructor(...t){super(...t),this.type="node"}static create(t={}){let n=typeof t=="function"?t():t;return new up(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t=="function"?t():t;return super.extend(n)}},dp=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(),S=(a=e.offsetX)!==null&&a!==void 0?a:(u=e.nativeEvent)===null||u===void 0?void 0:u.offsetX,A=(c=e.offsetY)!==null&&c!==void 0?c:(d=e.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=C.x-k.x+S,l=C.y-k.y+A}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=j.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=j.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"&&(Wn()||to())&&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 nt(e){return new aa({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{let i=fe(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(no(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 Je=we(Ze(),1);var{getOwnPropertyNames:ik,getOwnPropertySymbols:sk}=Object,{hasOwnProperty:lk}=Object.prototype;function oo(e,t){return function(r,o,i){return e(r,o,i)&&t(r,o,i)}}function io(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 ak(e){return e?.[Symbol.toStringTag]}function fp(e){return ik(e).concat(sk(e))}var ck=Object.hasOwn||((e,t)=>lk.call(e,t));function Un(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var uk="__v",dk="__o",fk="_owner",pk=typeof Float16Array<"u",{getOwnPropertyDescriptor:pp,keys:hp}=Object;function hk(e,t){return e.byteLength===t.byteLength&&gi(new Uint8Array(e),new Uint8Array(t))}function mk(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 gk(e,t){return e.byteLength===t.byteLength&&gi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function bk(e,t){return Un(e.getTime(),t.getTime())}function mp(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 yk(e,t){return e===t}function gp(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 wk=Un;function bp(e,t,n){let r=hp(e),o=r.length;if(hp(t).length!==o)return!1;for(;o-- >0;)if(!kp(e,t,n,r[o]))return!1;return!0}function Mr(e,t,n){let r=fp(e),o=r.length;if(fp(t).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!kp(e,t,n,i)||(s=pp(e,i),l=pp(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function kk(e,t){return Un(e.valueOf(),t.valueOf())}function vk(e,t){return e.source===t.source&&e.flags===t.flags}function yp(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 gi(e,t){let n=e.length;if(t.length!==n||e.byteOffset!==t.byteOffset)return!1;if(e instanceof Float64Array||e instanceof Float32Array||pk&&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 Ck(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&&xk(e.searchParams,t.searchParams)}function xk(e,t){let n=e.toString(),r=t.toString();return n===r||wp(n)===wp(r)}function wp(e){return e.split("&").sort().join("&")}function kp(e,t,n,r){return(r===fk||r===dk||r===uk)&&(e.$$typeof||t.$$typeof)?!0:ck(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var Sk="[object ArrayBuffer]",Ek="[object Arguments]",Mk="[object Boolean]",Ak="[object DataView]",Tk="[object Date]",Nk="[object Error]",Rk="[object Map]",Dk="[object Number]",Ok="[object Object]",Lk="[object RegExp]",Ik="[object Set]",Pk="[object String]",$k={"[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]",zk=Object.prototype.toString;function Hk({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 S=m.constructor;if(S!==b.constructor)return!1;if(S===Object)return a(m,b,k);if(Array.isArray(m))return t(m,b,k);if(S===Date)return r(m,b,k);if(S===RegExp)return c(m,b,k);if(S===Map)return s(m,b,k);if(S===Set)return d(m,b,k);if(S==null)return a(m,b,k);let A=zk.call(m);if(A===Tk)return r(m,b,k);if(A===Lk)return c(m,b,k);if(A===Rk)return s(m,b,k);if(A===Ik)return d(m,b,k);if(A===Ok)return typeof m.then!="function"&&typeof b.then!="function"&&a(m,b,k);if(A===Bk)return p(m,b,k);if(A===Nk)return o(m,b,k);if(A===Ek)return a(m,b,k);if($k[A])return f(m,b,k);if(A===Sk)return e(m,b,k);if(A===Ak)return n(m,b,k);if(A===Mk||A===Dk||A===Pk)return u(m,b,k);if(h){let E=h[A];if(!E){let M=ak(m);M&&(E=h[M])}if(E)return E(m,b,k)}return!1}}function _k({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:hk,areArraysEqual:n?Mr:mk,areDataViewsEqual:gk,areDatesEqual:bk,areErrorsEqual:n?oo(mp,Mr):oo(mp,bp),areFunctionsEqual:yk,areMapsEqual:n?oo(gp,Mr):gp,areNumbersEqual:wk,areObjectsEqual:n?Mr:bp,arePrimitiveWrappersEqual:kk,areRegExpsEqual:vk,areSetsEqual:n?oo(yp,Mr):yp,areTypedArraysEqual:n?oo(gi,Mr):gi,areUrlsEqual:Ck,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let o=io(r.areArraysEqual),i=io(r.areErrorsEqual),s=io(r.areMapsEqual),l=io(r.areObjectsEqual),a=io(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 jk({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 vp=pn(),BE=pn({strict:!0}),zE=pn({circular:!0}),HE=pn({circular:!0,strict:!0}),_E=pn({createInternalComparator:()=>Un}),VE=pn({strict:!0,createInternalComparator:()=>Un}),jE=pn({circular:!0,createInternalComparator:()=>Un}),FE=pn({circular:!0,createInternalComparator:()=>Un,strict:!0});function pn(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:o=!1}=e,i=_k(e),s=Hk(i),l=n?n(s):Vk(s);return jk({circular:t,comparator:s,createState:r,equals:l,strict:o})}var Tp=we(Fg(),1);function Fk(e,t){var n,r;if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!=="insertParagraph"&&t.inputType!=="insertLineBreak"||!Wn()&&!to())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 Cp=new te("reactMobileEnter"),Wk=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Kk=({contentComponent:e})=>{let t=(0,Ap.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,Je.jsx)(Je.Fragment,{children:Object.values(t)})};function Uk(){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]:bi.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...t};delete i[o],t=i,r()}}}var ua=class extends Z.default.Component{constructor(e){super(e),this.editorContentRef=Z.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=Uk(),t.createNodeViews(),t.registerPlugin(new U({key:Cp,props:{handleDOMEvents:{beforeinput:(r,o)=>Fk(t,o)}}})),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(Cp),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,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)("div",{ref:Wk(t,this.editorContentRef),...n}),e?.contentComponent&&(0,Je.jsx)(Kk,{contentComponent:e.contentComponent})]})}},qk=(0,Z.forwardRef)((e,t)=>{let n=Z.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Z.default.createElement(ua,{key:n,innerRef:t,...e})}),Gk=Z.default.memo(qk),Jk=typeof window<"u"?Z.useLayoutEffect:Z.useEffect,Xk=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 so(e){var t;let[n]=(0,Z.useState)(()=>new Xk(e.editor)),r=(0,Tp.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:vp);return Jk(()=>n.watch(e.editor),[e.editor,n]),(0,Z.useDebugValue)(r),r}var Yk=typeof window>"u",XE=Yk||!!(typeof window<"u"&&window.next);var Np=(0,Z.createContext)({editor:null}),YE=Np.Consumer;var Rp=(0,Z.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var Dp=()=>(0,Z.useContext)(Rp);function yi({as:e="div",...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Dp();return(0,Je.jsx)(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var qn=Z.default.forwardRef((e,t)=>{let{onDragStart:n}=Dp(),r=e.as||"div";return(0,Je.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function xp(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 Qk(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function Zk(e){if(xp(e)||Sp(e))return!0;if(Qk(e)){let t=e.type;if(t)return xp(t)||Sp(t)}return!1}function ev(){try{if(Z.version)return parseInt(Z.version.split(".")[0],10)>=19}catch{}return!1}var tv=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,bi.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=ev(),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,Je.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])})}},QE=Z.default.createContext({markViewContentRef:()=>{}});function nv(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 rv(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function Op(e){if(!ui(e))return[];let{$from:t,$to:n}=e,r=[],o=Math.min(t.depth,n.depth);for(let i=1;i<=o&&rv(t,n,i);i+=1)r.push(t.before(i));return r}var ov=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 Op(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}},Ep=new WeakMap;function Mp(e){let t=Ep.get(e);return t||(t=new ov(e),Ep.set(e,t)),t}var iv=class extends dp{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,Z.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=nv(this.contentDOMElement);a.appendChild(this.contentDOMElement),u?.()}}},o=this.component,i=(0,Z.memo)(a=>(0,Je.jsx)(Rp.Provider,{value:r,children:(0,Z.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 tv(i,{editor:this.editor,props:e,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),Mp(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"&&Op(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),Mp(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=Nt(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Gn(e,t){return n=>n.editor.contentComponent?new iv(e,n,t):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var da=(0,Z.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});da.displayName="TiptapContext";var sv=()=>(0,Z.useContext)(da);function Lp({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,Z.useMemo)(()=>({editor:n}),[n]),o=(0,Z.useMemo)(()=>({editor:n}),[n]);return(0,Je.jsx)(Np.Provider,{value:o,children:(0,Je.jsx)(da.Provider,{value:r,children:e})})}Lp.displayName="Tiptap";function Ip({...e}){let{editor:t}=sv();return(0,Je.jsx)(Gk,{editor:t,...e})}Ip.displayName="Tiptap.Content";var ZE=Object.assign(Lp,{Content:Ip});var wi=class extends ua{init(){let t=this.props.editor,n=this.editorContentRef.current,r=t;if(t&&!t.isDestroyed&&n&&r?.contentComponent){let o=t.view.dom.parentElement;if(o&&o!==n){if(o.isConnected)throw new Error("A retained editor cannot occupy two connected hosts.");n.append(...o.childNodes),t.setOptions({element:n})}return}super.init()}componentWillUnmount(){let t=this.editorContentRef.current,n=this.props.editor;queueMicrotask(()=>{t&&!t.isConnected&&n?.options.element===t&&super.componentWillUnmount()})}};var rt=we(en(),1);var lv=new WeakSet,Pp=e=>lv.has(e);var av=(0,rt.createContext)(null),Jn=new WeakMap;function $p(e){let t=(0,rt.useContext)(av),n=(0,rt.useId)(),r=(0,rt.useRef)(e.retentionKey??n).current,o=(0,rt.useRef)(e);o.current=e;let i=(0,rt.useRef)(t?.find(r)??null),[s,l]=(0,rt.useState)(i.current),a=(0,rt.useRef)(void 0);return(0,rt.useLayoutEffect)(()=>{clearTimeout(a.current);let u=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:p,...h}=o.current,g;return g=new ca({...h,onUpdate:m=>Jn.get(m.editor)?.current.onUpdate?.(m),editorProps:{...h.editorProps,handleKeyDown:(m,b)=>Jn.get(g)?.current.editorProps?.handleKeyDown?.(m,b)??!1,handleClick:(m,b,k)=>Jn.get(g)?.current.editorProps?.handleClick?.(m,b,k)??!1,handlePaste:(m,b,k)=>Jn.get(g)?.current.editorProps?.handlePaste?.(m,b,k)??!1}}),g},c=t?t.get(r,u):i.current&&!i.current.isDestroyed?i.current:u();return i.current=c,Jn.set(c,o),c.setEditable(o.current.editable!==!1,!1),l(c),()=>{Jn.get(c)===o&&(Jn.delete(c),c.isDestroyed||c.setEditable(!1,!1)),!t&&(a.current=setTimeout(()=>{i.current===c&&!c.isDestroyed&&c.destroy()},1))}},[t,r]),s}var fa=new WeakMap;function pa(e){let t=fa.get(e);if(t)return t;let n={type:e.type.name};Object.keys(e.attrs).length&&(n.attrs=e.attrs),e.content.size&&(n.content=[],e.content.forEach(o=>n.content.push(pa(o)))),e.marks.length&&(n.marks=e.marks.map(o=>o.toJSON())),e.isText&&(n.text=e.text);let r=Bo(n);return fa.set(e,r),r}function Bp(e,t){let n=fa.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(!Bp(e.child(r),t.content[r]))return!1;return!0}function zp(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(!Bp(e.child(n),t.content[n]))return!1;return!0}function ki(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 Pe=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 ha(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!cv(t)||!uv(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&&!j.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}}};Pe.prototype.visible=!1;Pe.findFrom=Pe.findGapCursorFrom;X.jsonID("gapcursor",Pe);var ha=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 Pe.valid(n)?new Pe(n):X.near(n)}};function Hp(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function cv(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||Hp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function uv(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||Hp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function _p(){return new U({props:{decorations:hv,createSelectionBetween(e,t,n){return t.pos==n.pos&&Pe.valid(n)?new Pe(n):null},handleClick:fv,handleKeyDown:dv,handleDOMEvents:{beforeinput:pv}}})}var dv=Qr({ArrowLeft:vi("horiz",-1),ArrowRight:vi("horiz",1),ArrowUp:vi("vert",-1),ArrowDown:vi("vert",1)});function vi(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 O){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(t>0?l.after():l.before())}let u=Pe.findGapCursorFrom(l,t,a);return u?(o&&o(r.tr.setSelection(new Pe(u))),!0):!1}}function fv(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Pe.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&j.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Pe(r))),!0)}function pv(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Pe))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=V.empty;for(let s=r.length-1;s>=0;s--)o=V.from(r[s].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new ce(o,0,0));return i.setSelection(O.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function hv(e){if(!(e.selection instanceof Pe))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",de.create(e.doc,[Me.widget(e.selection.head,t,{key:"gapcursor"})])}function Ar(e){let t=e.selection;if(!(t instanceof j)||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 Pe(e.doc.resolve(e.doc.content.size)).map(e.doc,new Oo),o=n??(r instanceof Pe?r:null);return o?e.tr.setSelection(o).setMeta("addToHistory",!1):null}function Vp(e,t){if(zp(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 ga,ba;if(typeof WeakMap<"u"){let e=new WeakMap;ga=t=>e.get(t),ba=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;ga=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},ba=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var be=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 ga(e)||ba(e,mv(e))}};function mv(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=gv(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 S=o+C*t;for(let A=0;A<m;A++){r[S+A]==0?r[S+A]=c:(i||(i=[])).push({type:"collision",row:u,pos:c,n:m-A});let E=k&&k[A];if(E){let M=(S+A)%t*2,L=s[M];L==null||L!=E&&s[M+1]==1?(s[M]=E,s[M+1]=1):L==E&&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 be(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&&bv(l,s,e),l}function gv(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 bv(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=yv(a)))[u]=c)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function yv(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Xe(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 te("selectingCells");function Wt(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 wv(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 Ct(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 Ai(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=Wt(t.$head)||kv(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function kv(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 ya(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function vv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function va(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Yp(e,t,n){let r=e.node(-1),o=be.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 Xn(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 Qp(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 Cv(e,t,n){let r=Xe(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 Ft extends X{constructor(t,n=t){let r=t.node(-1),o=be.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 Fs(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(ya(r)&&ya(o)&&va(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ft.rowSelection(r,o):i&&this.isColSelection()?Ft.colSelection(r,o):new Ft(r,o)}return O.between(r,o)}content(){let t=this.$anchorCell.node(-1),n=be.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=Xn(b,0,g)),m>0&&(b=Xn(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(V.from(u)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new ce(V.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(V.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=be.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=be.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 Ft(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=be.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 Ft&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),o=be.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 Ft(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Ft(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Ft(t.resolve(n),t.resolve(r))}getBookmark(){return new xv(this.$anchorCell.pos,this.$headCell.pos)}};re.prototype.visible=!1;X.jsonID("cell",re);var xv=class Zp{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Zp(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&&va(n,r)?new re(n,r):X.near(r,1)}};function Sv(e){if(!(e.selection instanceof re))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push(Me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),de.create(e.doc,t)}function Ev({$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 Mv({$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 Av(e,t,n){let r=(t||e).selection,o=(t||e).doc,i,s;if(r instanceof j&&(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=be.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 O&&Ev(r)?i=O.create(o,r.from):r instanceof O&&Mv(r)&&(i=O.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var Tv=new te("fix-tables");function eh(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)?eh(e.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Ca(e,t){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=Nv(e,o,i,n))};return t?t.doc!=e.doc&&eh(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Nv(e,t,n,r){let o=be.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,Xn(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=Xe(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(Tv,{fixTables:!0})}function Rt(e){let t=e.selection,n=Ai(e),r=n.node(-1),o=n.start(-1),i=be.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 th(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;Cv(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,Qp(u.attrs,o-t.colCount(a))),s+=u.attrs.rowspan-1}else{let a=i==null?Xe(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 nh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(th(e.tr,n,n.left))}return!0}function rh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(th(e.tr,n,n.right))}return!0}function Rv(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,Xn(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 oh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;Rv(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=be.get(i)}t(r)}return!0}function Dv(e,t,n){var r;let o=Xe(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 ih(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?Xe(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,Xe(r.type.schema).row.create(null,s)),e}function sh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(ih(e.tr,n,n.top))}return!0}function lh(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e);t(ih(e.tr,n,n.bottom))}return!0}function Ov(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 ah(e,t){if(!Ct(e))return!1;if(t){let n=Rt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;Ov(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=be.get(n.table)}t(r)}return!0}function jp(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Lv({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 xa(e,t){let n=e.selection;if(!(n instanceof re)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Rt(e),{map:o}=r;if(Lv(o,r))return!1;if(t){let i=e.tr,s={},l=V.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{jp(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,{...Qp(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=jp(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 Sa(e,t){let n=Xe(e.schema);return Iv(({node:r})=>n[r.type.spec.tableRole])(e,t)}function Iv(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=wv(r.$from),!o)return!1;i=(s=Wt(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=Rt(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 ch(e,t){return function(n,r){if(!Ct(n))return!1;let o=Ai(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 Pv(e){return function(t,n){if(!Ct(t))return!1;if(n){let r=Xe(t.schema),o=Rt(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 Fp(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?Pv(e):function(n,r){if(!Ct(n))return!1;if(r){let o=Xe(n.schema),i=Rt(n),s=n.tr,l=Fp("row",i,o),a=Fp("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 LM=Tr("row",{useDeprecatedLogic:!0}),IM=Tr("column",{useDeprecatedLogic:!0}),uh=Tr("cell",{useDeprecatedLogic:!0});function $v(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 Ea(e){return function(t,n){if(!Ct(t))return!1;let r=$v(Ai(t),e);if(r==null)return!1;if(n){let o=t.doc.resolve(r);n(t.tr.setSelection(O.between(o,vv(o))).scrollIntoView())}return!0}}function dh(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 Ci(e,t){let n=e.selection;if(!(n instanceof re))return!1;if(t){let r=e.tr,o=Xe(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 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=wa(Xe(s).row,new ce(u,c,d)).content),l.push(u)}else if(i=="cell"||i=="header_cell")l.push(n||r?wa(Xe(s).row,new ce(t,n,r)).content:t);else return null;return zv(s,l)}function zv(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(V.empty),n[o]<r){let i=Xe(e).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);t[o]=t[o].append(V.from(s))}return{height:t.length,width:r,rows:t}}function wa(e,t){let n=e.createAndFill();return new Po(n).replace(0,n.content.size,t).doc}function Hv({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(Xn(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(V.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(V.from(a))}n=i,t=o}return{width:e,height:t,rows:n}}function _v(e,t,n,r,o,i,s){let l=e.doc.type.schema,a=Xe(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,V.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 Wp(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 Kp(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,Xn(f.attrs,s-p,f.attrs.colspan-(s-p))),e.insert(h+f.nodeSize,f.type.createAndFill(Xn(f.attrs,0,s-p))),u+=f.attrs.rowspan-1}}return a}function Up(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=be.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=be.get(i),f=d.mapping.maps.length}_v(d,s,i,n,u,c,f)&&p(),Wp(d,s,i,n,a,u,l,f)&&p(),Wp(d,s,i,n,a,u,c,f)&&p(),Kp(d,s,i,n,l,c,a,f)&&p(),Kp(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 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=Qr({ArrowLeft:xi("horiz",-1),ArrowRight:xi("horiz",1),ArrowUp:xi("vert",-1),ArrowDown:xi("vert",1),"Shift-ArrowLeft":Si("horiz",-1),"Shift-ArrowRight":Si("horiz",1),"Shift-ArrowUp":Si("vert",-1),"Shift-ArrowDown":Si("vert",1),Backspace:Ci,"Mod-Backspace":Ci,Delete:Ci,"Mod-Delete":Ci});function Ei(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function xi(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof re)return Ei(n,r,X.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let s=fh(o,e,t);if(s==null)return!1;if(e=="horiz")return Ei(n,r,X.near(n.doc.resolve(i.head+t),t));{let l=n.doc.resolve(s),a=Yp(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),Ei(n,r,u)}}}function Si(e,t){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof re)s=i;else{let a=fh(o,e,t);if(a==null)return!1;s=new re(n.doc.resolve(a))}let l=Yp(s.$headCell,e,t);return l?Ei(n,r,new re(s.$anchorCell,l)):!1}}function jv(e,t){let n=e.state.doc,r=Wt(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new re(r))),!0):!1}function Fv(e,t,n){if(!Ct(e.state))return!1;let r=Bv(n),o=e.state.selection;if(o instanceof re){r||(r={width:1,height:1,rows:[V.from(wa(Xe(e.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=be.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=Hv(r,l.right-l.left,l.bottom-l.top),Up(e.state,e.dispatch,s,l,r),!0}else if(r){let i=Ai(e.state),s=i.start(-1);return Up(e.state,e.dispatch,s,be.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Wv(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=qp(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=Wt(e.state.selection.$anchor))!=null&&((n=ma(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=ma(e,u),d=hn.getState(e.state)==null;if(!c||!va(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(qp(e,u.target)!=r&&(d=ma(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 fh(e,t,n){if(!(e.state.selection instanceof O))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 qp(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function ma(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&&Wt(e.state.doc.resolve(r))||Wt(e.state.doc.resolve(o))}var Kv=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")),ka(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,ka(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ka(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 dt=new te("tableColumnResizing");function ph({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Kv,lastColumnResizable:o=!0}={}){let i=new U({key:dt,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=Xe(l.schema).table.name;return r&&u&&(u[c]=(d,f)=>new r(d,n,f)),new Uv(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=dt.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{qv(s,l,e,o)},mouseleave:s=>{Gv(s)},mousedown:(s,l)=>{Jv(s,l,t,n)}},decorations:s=>{let l=dt.getState(s);if(l&&l.activeHandle>-1)return eC(s,l.activeHandle)},nodeViews:{}}});return i}var Uv=class Mi{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(dt);if(r&&r.setHandle!=null)return new Mi(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Mi(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return ya(t.doc.resolve(o))||(o=-1),new Mi(o,n.dragging)}return n}};function qv(e,t,n,r){if(!e.editable)return;let o=dt.getState(e.state);if(o&&!o.dragging){let i=Yv(t.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();t.clientX-l<=n?s=Gp(e,t,"left",n):a-t.clientX<=n&&(s=Gp(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),a=l.node(-1),u=be.get(a),c=l.start(-1);if(u.colCount(l.pos-c)+l.nodeAfter.attrs.colspan-1==u.width-1)return}hh(e,s)}}}function Gv(e){if(!e.editable)return;let t=dt.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&hh(e,-1)}function Jv(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=dt.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),a=Xv(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(dt,{setDragging:{startX:t.clientX,startWidth:a}}));function u(d){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",c);let f=dt.getState(e.state);f?.dragging&&(Qv(e,f.activeHandle,Jp(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(dt,{setDragging:null})))}function c(d){if(!d.which)return u(d);let f=dt.getState(e.state);if(f&&f.dragging){let p=Jp(f.dragging,d,n);Xp(e,f.activeHandle,p,r)}}return Xp(e,s.activeHandle,a,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",c),t.preventDefault(),!0}function Xv(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 Yv(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Gp(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=Wt(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=be.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 Jp(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function hh(e,t){e.dispatch(e.state.tr.setMeta(dt,{setHandle:t}))}function Qv(e,t,n){let r=e.state.doc.resolve(t),o=r.node(-1),i=be.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 Xp(e,t,n,r){let o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=be.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&&ka(i,a.firstChild,a,r,l,n)}function Zv(e){return Array(e).fill(0)}function eC(e,t){let n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return de.empty;let i=be.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=dt.getState(e))===null||a===void 0)&&a.dragging&&n.push(Me.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Me.widget(f,p))}}return de.create(e.doc,n)}function mh({allowTableNodeSelection:e=!1}={}){return new U({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:Sv,handleDOMEvents:{mousedown:Wv},createSelectionBetween(t){return hn.getState(t.state)!=null?t.state.selection:null},handleTripleClick:jv,handleKeyDown:Vv,handlePaste:Fv},appendTransaction(t,n,r){return Av(r,Ca(r,n),e)}})}var Yn="showaiTableAction";function gh(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:Wt(e.selection.$head),i=o&&o.before(-1)===t?o:e.doc.resolve(t+1+be.get(r).map[0]),s=n==="row"?re.rowSelection(i):n==="column"?re.colSelection(i):new re(i);return e.tr.setSelection(s)}function lo(e){let t=e.selection;if(!(t instanceof re))return null;let n=t.$anchorCell.node(-1),r=t.$anchorCell.start(-1),o=be.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 bh(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 ft=we(Ze(),1);function Ti({editor:e,context:t=!1,onAction:n}){let r=Le(He),o=lo(e.state);if(!o&&!t&&!e.can().splitCell())return null;let i=s=>{e.view.dispatch(pr(e.state.tr)),e.chain().setMeta(Yn,!0).focus()[s]().run(),n?.()};return(0,ft.jsxs)(ft.Fragment,{children:[!t&&(0,ft.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,ft.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,ft.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"),ru],["splitCell",r("table.splitCell"),ou]].map(([s,l,a])=>(0,ft.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,ft.jsx)(a,{size:16}),t&&(0,ft.jsx)("span",{children:l})]},s)),!t&&o&&(0,ft.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(O.near(e.state.selection.$from))),e.view.focus()},children:(0,ft.jsx)(Hr,{size:16})})]})]})}var ao=we(en(),1),xh=we(zs(),1);var Ni=we(Ze(),1),tC=[["left","Left",Tn],["center","Center",Mn],["right","Right",An]];function Ma({scope:e,value:t,onChange:n}){let r=Le(wu),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,Ni.jsx)("div",{className:"table-alignment-buttons",role:"group","aria-label":o("Group"),children:tC.map(([i,s,l])=>(0,Ni.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,Ni.jsx)(l,{size:14})},i))})}var yh=sr(He),wh=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 U({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=be.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});nC(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 nC(e,t,n){e.forEach((r,o)=>r.forEach((i,s)=>n(i,t+2+o+s)))}function Aa(e,t){let r=kh(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 kh(e,t){let n=be.get(e);if(t!==null&&(!Number.isInteger(t)||t<0||t>=n.width))throw new Error(yh("table.columnOutOfRange"));return[...new Set(t===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+t]))]}function vh(e,t,n,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="table")throw new Error(yh("table.notATable"));let i=e.tr;n===null&&i.setNodeAttribute(t,"textAlign",r);for(let s of kh(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 Kt=we(en(),1),rC=()=>!0;function Ch(e,t={}){let n=(0,Kt.useId)(),[r,o]=(0,Kt.useState)(null),[,i]=(0,Kt.useState)(0),s=(0,Kt.useRef)({target:r,options:t});s.current={target:r,options:t};let l=t.accept??rC;return(0,Kt.useEffect)(()=>{if(!e)return;let a,u=()=>{clearTimeout(a),a=void 0},c=E=>E?.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=E=>{let M=E.closest("table");if(!(M instanceof HTMLTableElement)||!e.contains(M)||!l(M))return null;let L=E.closest("td, th");return{table:M,cell:L?.parentElement===M.rows[0]?L:null,context:null}},h=E=>{u(),o(M=>M?.table===E.table&&M.cell===E.cell&&!M.context?M:E)},g=E=>{let M=E.target;if(c(M)){u();return}if(s.current.options.keepOpen||s.current.target?.context){u();return}let L=s.current.target;if(L?.cell?.isConnected){let he=L.cell.getBoundingClientRect(),Ce=Ta(L,0).column;if(E.clientX>=Math.min(he.left,Ce.left)&&E.clientX<=Math.max(he.right,Ce.left+88)&&E.clientY>=he.bottom&&E.clientY<=Ce.top){u();return}}let oe=p(M);if(oe){h(oe);return}if(L?.table.isConnected){let he=L.table.getBoundingClientRect();if(E.clientX>=he.left-8&&E.clientX<=he.right+8&&E.clientY>=he.top-44&&E.clientY<=he.bottom+8){u();return}}f()},m=E=>{let M=E.target;if(c(M)){u();return}let L=p(M);L?(s.current.options.onDismiss?.(),h(L)):d()},b=E=>{let M=p(E.target);M&&(E.preventDefault(),E.stopPropagation(),u(),s.current.options.onDismiss?.(),o({...M,cell:null,context:{left:Math.max(8,Math.min(E.clientX,window.innerWidth-140)),top:Math.max(8,Math.min(E.clientY,window.innerHeight-42))}}))},k=E=>{if(c(E.target))u();else{let M=p(E.target);M&&h(M)}},C=E=>{E.key==="Escape"&&d()},S=E=>{E.target instanceof HTMLElement&&E.target.contains(e)&&d()},A=()=>i(E=>E+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",S),window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{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",S),window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[e,l,n]),{target:r,setTarget:o,owner:n}}function Ta(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 ge=we(Ze(),1),oC=e=>!e.closest(".document-widget");function Sh({editor:e}){let t=Le(He),[,n]=(0,ao.useState)(0),[r,o]=(0,ao.useState)(!1),i=lo(e.state),{target:s,setTarget:l,owner:a}=Ch(e.view.dom,{keepOpen:r,accept:oC,onDismiss:()=>o(!1)});if((0,ao.useEffect)(()=>{let A=()=>n(M=>M+1),E=M=>{M.key!=="Escape"||!lo(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(O.near(e.state.selection.$from))),o(!1),e.view.focus())};return e.on("transaction",A),document.addEventListener("keydown",E),()=>{e.off("transaction",A),document.removeEventListener("keydown",E)}},[e,a]),!s||!s.table.isConnected||!e.isEditable||!s.context&&(i||e.isFocused&&e.state.selection instanceof O&&!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 A=e.view.posAtDOM(s.cell,0),E=e.state.doc.resolve(A),M=E.depth;for(;M>c&&!["tableCell","tableHeader"].includes(E.node(M).type.name);)M--;M>c&&(p=be.get(d).findCell(E.before(M)-f-1).left)}let h=Ta(s,128),g=h.global.top>window.innerHeight/2,m=()=>{let{$from:A}=e.state.selection;Array.from({length:A.depth},(M,L)=>L+1).some(M=>A.node(M).type.name==="table"&&A.before(M)===f)||e.view.dispatch(e.state.tr.setSelection(O.near(e.state.doc.resolve(f+3))))},b=A=>{m(),e.view.dispatch(pr(e.state.tr)),A(),o(!1)},k=()=>e.chain().setMeta(Yn,!0).focus(),C=A=>b(()=>{let E=gh(e.state,f,A);E&&e.view.dispatch(E),e.view.focus()}),S=(A,E)=>{e.view.dispatch(vh(e.state,f,A,E).setMeta(Yn,!0)),s.context&&(l(null),e.view.focus())};return(0,xh.createPortal)((0,ge.jsxs)(ge.Fragment,{children:[(0,ge.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,ge.jsx)(Ma,{scope:"table",value:Aa(d,null),onChange:A=>S(null,A)}),!s.context&&(0,ge.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:A=>A.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,ge.jsx)(jc,{size:16})}),(r||s.context)&&(0,ge.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:A=>A.preventDefault(),children:[(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().addRowAfter().run()}),children:[(0,ge.jsx)(tn,{size:14}),t("table.addRow")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().addColumnAfter().run()}),children:[(0,ge.jsx)(tn,{size:14}),t("table.addColumn")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().toggleHeaderRow().run()}),children:[(0,ge.jsx)(iu,{size:14,"aria-hidden":"true"}),t("table.toggleHeader")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>C("cell"),children:[(0,ge.jsx)(tu,{size:14,"aria-hidden":"true"}),t("table.selectCells")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>C("row"),children:[(0,ge.jsx)(Bs,{size:14,"aria-hidden":"true"}),t("table.selectRow")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>C("column"),children:[(0,ge.jsx)($s,{size:14,"aria-hidden":"true"}),t("table.selectColumn")]}),s.context&&(0,ge.jsx)(Ti,{editor:e,context:!0,onAction:()=>{l(null),o(!1)}}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().deleteRow().run()}),children:[(0,ge.jsx)(Bs,{size:14,"aria-hidden":"true"}),t("table.deleteRow")]}),(0,ge.jsxs)("button",{role:"menuitem",onClick:()=>b(()=>{k().deleteColumn().run()}),children:[(0,ge.jsx)($s,{size:14,"aria-hidden":"true"}),t("table.deleteColumn")]}),(0,ge.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>b(()=>{k().deleteTable().run(),l(null)}),children:[(0,ge.jsx)(No,{size:14}),t("table.deleteTable")]})]})]}),p!==null&&!s.context&&(0,ge.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:h.column,children:(0,ge.jsx)(Ma,{scope:p,value:Aa(d,p),onChange:A=>S(p,A)})})]}),document.body)}var Ut=we(en(),1);Oc(`.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 F=we(Ze(),1),iC=["#292733","#787774","#a85b3c","#c44343","#bd861e","#448361","#3979bf","#8864b4"],sC=["#e8eed0","#f9e7a0","#f8d8bb","#f4cfd2","#e9d8f1","#d3e5f7","#cde9df","#e5e5e5"];function Eh({editor:e,onLink:t,onNote:n}){let r=Le(He),o=Le(_o),[i,s]=(0,Ut.useState)(!1),l=(0,Ut.useRef)(null),a=(0,Ut.useRef)(null),u=(0,Ut.useId)(),c=e.getAttributes("textStyle").color??"#292733",d=e.getAttributes("highlight").color??"#e8eed0",f=e.getAttributes("highlight").mode??"lower",p=e.getAttributes(e.isActive("heading")?"heading":"paragraph").textAlign??"left",h=p==="center"?Mn:p==="right"?An:p==="justify"?su:Tn;(0,Ut.useEffect)(()=>{if(!i)return;let b=()=>s(!1),k=C=>{C.target instanceof Node&&!l.current?.contains(C.target)&&b()};return document.addEventListener("pointerdown",k),e.on("selectionUpdate",b),()=>{document.removeEventListener("pointerdown",k),e.off("selectionUpdate",b)}},[i,e]);let g=(b,k,C,S)=>(0,F.jsx)("button",{type:"button",className:`editor-tool${C?" is-active":""}`,"aria-label":b,title:b,"aria-pressed":C,onMouseDown:A=>A.preventDefault(),onClick:S,children:k}),m=(b,k,C="")=>(0,F.jsxs)("label",{className:`rich-format-select ${C}`,title:b,children:[k,(0,F.jsx)(zr,{size:11,"aria-hidden":"true"})]});return(0,F.jsxs)("div",{ref:l,className:"rich-format-controls",onKeyDown:b=>{i&&b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),s(!1),a.current?.focus())},onClickCapture:b=>{b.target.closest(".rich-format-colors-toggle, .rich-format-color-panel")||s(!1)},children:[(0,F.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.textStyle"),children:[m(r("format.textStyle"),(0,F.jsxs)("select",{"aria-label":r("format.textStyle"),value:e.isActive("heading")?String(e.getAttributes("heading").level):"paragraph",onChange:b=>b.target.value==="paragraph"?e.chain().focus().setParagraph().run():e.chain().focus().setHeading({level:Number(b.target.value)}).run(),children:[(0,F.jsx)("option",{value:"paragraph",children:r("block.text")}),[1,2,3,4,5,6].map(b=>(0,F.jsx)("option",{value:b,children:r("block.heading",{level:b})},b))]}),"rich-format-block"),m(r("format.font"),(0,F.jsxs)("select",{"aria-label":r("format.font"),value:e.getAttributes("textStyle").fontFamily??"",onChange:b=>e.chain().focus().setMark("textStyle",{fontFamily:b.target.value||null}).run(),children:[(0,F.jsx)("option",{value:"",children:r("format.fontCompact")}),(0,F.jsx)("option",{value:"sans-serif",children:r("format.fontSans")}),(0,F.jsx)("option",{value:"serif",children:r("format.fontSerif")}),(0,F.jsx)("option",{value:"monospace",children:r("format.fontMono")})]}),"rich-format-font"),m(r("format.fontSize"),(0,F.jsxs)("select",{"aria-label":r("format.fontSize"),value:e.getAttributes("textStyle").fontSize??"",onChange:b=>e.chain().focus().setMark("textStyle",{fontSize:b.target.value||null}).run(),children:[(0,F.jsx)("option",{value:"",children:r("format.sizeCompact")}),[12,14,16,18,20,24,28,32,40,48].map(b=>(0,F.jsx)("option",{value:`${b}px`,children:b},b))]}),"rich-format-size")]}),(0,F.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,F.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.characterStyle"),children:[g(r("format.bold"),(0,F.jsx)($c,{size:16}),e.isActive("bold"),()=>e.chain().focus().toggleBold().run()),g(r("format.italic"),(0,F.jsx)(Xc,{size:16}),e.isActive("italic"),()=>e.chain().focus().toggleItalic().run()),g(r("format.underline"),(0,F.jsx)(lu,{size:16}),e.isActive("underline"),()=>e.chain().focus().toggleUnderline().run()),g(r("format.strike"),(0,F.jsx)(nu,{size:16}),e.isActive("strike"),()=>e.chain().focus().toggleStrike().run()),g(r("format.inlineCode"),(0,F.jsx)(Hc,{size:16}),e.isActive("code"),()=>e.chain().focus().toggleCode().run())]}),(0,F.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,F.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.colors"),children:[(0,F.jsxs)("button",{ref:a,type:"button",className:`rich-format-colors-toggle${i?" is-active":""}`,"aria-label":r("format.colors"),title:r("format.colors"),"aria-expanded":i,"aria-controls":u,onMouseDown:b=>b.preventDefault(),onClick:()=>s(!i),children:[(0,F.jsxs)("span",{className:"rich-format-color-icon",children:[(0,F.jsx)(Ro,{size:16}),(0,F.jsx)("i",{style:{background:c}})]}),(0,F.jsx)(zr,{size:11})]}),g(r("format.highlight"),(0,F.jsxs)("span",{className:"rich-format-color-icon",children:[(0,F.jsx)(Jc,{size:16}),(0,F.jsx)("i",{style:{background:d}})]}),e.isActive("highlight"),()=>e.chain().focus().toggleMark("highlight",{color:d,mode:f}).run())]}),(0,F.jsx)("span",{className:"rich-format-divider","aria-hidden":"true"}),(0,F.jsxs)("div",{className:"rich-format-group",role:"group","aria-label":r("format.alignment"),children:[m(r("format.alignment"),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{size:16,"aria-hidden":"true"}),(0,F.jsxs)("select",{"aria-label":r("format.alignment"),value:p,onChange:b=>e.chain().focus().setTextAlign(b.target.value).run(),children:[(0,F.jsx)("option",{value:"left",children:r("format.alignLeft")}),(0,F.jsx)("option",{value:"center",children:r("format.alignCenter")}),(0,F.jsx)("option",{value:"right",children:r("format.alignRight")}),(0,F.jsx)("option",{value:"justify",children:r("format.alignJustify")})]})]}),"rich-format-alignment"),g(r("format.addLink"),(0,F.jsx)(Ao,{size:16}),e.isActive("link"),t),n&&g(o("format.note"),(0,F.jsx)(To,{size:16}),e.isActive("annotation")||/^\s*\\note\b/.test(String(e.state.selection.$from.nodeAfter?.attrs.latex??"")),n)]}),i&&(0,F.jsx)("div",{id:u,className:"rich-format-color-panel",role:"group","aria-label":r("format.colors"),children:["text","highlight"].map(b=>{let k=b==="text",C=k?c:d,S=r(k?"format.textColor":"format.highlightColor"),A=E=>k?e.chain().focus().setMark("textStyle",{color:E}).run():e.chain().focus().setMark("highlight",{color:E,mode:f}).run();return(0,F.jsxs)("div",{className:"rich-format-palette",children:[(0,F.jsx)("span",{className:"rich-format-panel-label",children:S}),(0,F.jsxs)("div",{className:"rich-format-swatches",children:[(k?iC:sC).map(E=>(0,F.jsx)("button",{type:"button",className:`rich-format-swatch${C===E?" is-active":""}`,style:{background:E},"aria-label":`${S} ${E}`,title:E,"aria-pressed":C===E,onMouseDown:M=>M.preventDefault(),onClick:()=>A(E)},E)),(0,F.jsx)("label",{className:"rich-format-custom-color",title:r("format.customColor"),children:(0,F.jsx)("input",{type:"color","aria-label":S,value:C,onChange:E=>A(E.target.value)})})]}),!k&&(0,F.jsx)("div",{className:"rich-format-highlight-modes",role:"group","aria-label":r("format.highlightMode"),children:["lower","full"].map(E=>(0,F.jsxs)("button",{type:"button","aria-pressed":f===E,onMouseDown:M=>M.preventDefault(),onClick:()=>e.chain().focus().setMark("highlight",{color:d,mode:E}).run(),children:[(0,F.jsx)("span",{className:`rich-format-highlight-preview is-${E}`,style:{"--highlight-preview":d},children:"Aa"}),r(E==="lower"?"format.highlightLower":"format.highlightFull")]},E))})]},b)})})]})}var Mh=new WeakSet,Ah=new WeakSet;function Qn(e){let t=e;return Mh.add(t),t}function Na(e){return Array.isArray(e)&&Mh.has(e)}function Th(e){return e.flatMap(t=>t==null?[]:Array.isArray(t)&&Ah.has(t)&&!Na(t)?Th(t):[t])}function lC(e,t){if(e==="slot")return 0;if(e instanceof Function){let o=e(t);return Array.isArray(o)&&!Na(o)&&!Ah.has(o)?Qn(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(Na(n))return Qn([e,r,n]);if(n.length===0)return Qn([e,r]);let o=Th(n);return o.length===0?Qn([e,r]):Qn([e,r,...o])}return n!=null?Qn([e,r,n]):Qn([e,r])}var Nr=(e,t)=>lC(e,t);var aC=(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(O.create(d.doc,c+p.size)),d.scrollIntoView(),f(d),!0})},cC=/^\s*>\s$/,Nh=ne.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return Nr("blockquote",{...K(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:()=>aC(this.editor,this.type)}},addInputRules(){return[fn({find:cC,type:this.type})]}});var uC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,dC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,fC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,pC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Rh=_e.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",{...K(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[it({find:uC,type:this.type}),it({find:fC,type:this.type})]},addPasteRules(){return[nt({find:dC,type:this.type}),nt({find:pC,type:this.type})]}});var hC=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},mC=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 gC(e){let t=new Set((e.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;t.has(n);)n+=1;return n}var Dh=_e.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",K(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(gC(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[it({find:hC,type:this.type})]},addPasteRules(){return[nt({find:mC,type:this.type})]}});var Ra=4,bC=/^```([a-z]+)?[\s\n]$/,yC=/^~~~([a-z]+)?[\s\n]$/,Ri=ne.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ra,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",K(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
|
-
\`\`\``,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:
|
|
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:Ra,{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,`
|
|
105
105
|
`,`
|
|
106
106
|
`).split(`
|
|
107
107
|
`).map(f=>l+f).join(`
|
|
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:
|
|
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:Ra,{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,
|
|
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(O.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(X.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[
|
|
118
|
-
`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(
|
|
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[ro({find:bC,type:this.type,getAttributes:e=>({language:e[1]})}),ro({find:yC,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new U({key:new te("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(O.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}});var Oh=ne.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
119
119
|
|
|
120
|
-
`):""});var
|
|
120
|
+
`):""});var Lh=ne.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",K(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 Oh=ne.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]}`,K(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=>no({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Dh=ne.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",K(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!tp(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,o=e();return fi(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(D.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(j.create(s.doc,a.pos)):s.setSelection(D.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(D.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var mC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,gC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,bC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,yC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Lh=_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",K(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[it({find:mC,type:this.type}),it({find:bC,type:this.type})]},addPasteRules(){return[nt({find:gC,type:this.type}),nt({find:yC,type:this.type})]}});var wC="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",kC="\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",$a="numeric",Ba="ascii",za="alpha",uo="asciinumeric",co="alphanumeric",Ha="domain",Hh="emoji",vC="scheme",CC="slashscheme",Ra="whitespace";function xC(e,t){return e in t||(t[e]=[]),t[e]}function Qn(e,t,n){t[$a]&&(t[uo]=!0,t[co]=!0),t[Ba]&&(t[uo]=!0,t[za]=!0),t[uo]&&(t[co]=!0),t[za]&&(t[co]=!0),t[co]&&(t[Ha]=!0),t[Hh]&&(t[Ha]=!0);for(let r in t){let o=xC(r,n);o.indexOf(e)<0&&o.push(e)}}function SC(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function st(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}st.groups={};st.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||st.groups;let o;return t&&t.j?o=t:(o=new st(t),n&&r&&Qn(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||st.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 st,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new st,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(SC(s.t,r),n);Qn(i,a,r)}else n&&Qn(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),Ee=(e,t,n,r,o)=>e.tr(t,n,r,o),Ih=(e,t,n,r,o)=>e.ts(t,n,r,o),N=(e,t,n,r,o)=>e.tt(t,n,r,o),Jt="WORD",_a="UWORD",_h="ASCIINUMERICAL",Vh="ALPHANUMERICAL",bo="LOCALHOST",Va="TLD",ja="UTLD",Li="SCHEME",Nr="SLASH_SCHEME",Wa="NUM",Fa="WS",Ka="NL",fo="OPENBRACE",po="CLOSEBRACE",Ii="OPENBRACKET",Pi="CLOSEBRACKET",$i="OPENPAREN",Bi="CLOSEPAREN",zi="OPENANGLEBRACKET",Hi="CLOSEANGLEBRACKET",_i="FULLWIDTHLEFTPAREN",Vi="FULLWIDTHRIGHTPAREN",ji="LEFTCORNERBRACKET",Fi="RIGHTCORNERBRACKET",Wi="LEFTWHITECORNERBRACKET",Ki="RIGHTWHITECORNERBRACKET",Ui="FULLWIDTHLESSTHAN",qi="FULLWIDTHGREATERTHAN",Gi="AMPERSAND",Ji="APOSTROPHE",Xi="ASTERISK",gn="AT",Yi="BACKSLASH",Qi="BACKTICK",Zi="CARET",Zn="COLON",Ua="COMMA",es="DOLLAR",Ot="DOT",ts="EQUALS",qa="EXCLAMATION",yt="HYPHEN",ho="PERCENT",ns="PIPE",rs="PLUS",is="POUND",mo="QUERY",Ga="QUOTE",jh="FULLWIDTHMIDDLEDOT",Ja="SEMI",Dt="SLASH",go="TILDE",ss="UNDERSCORE",Fh="EMOJI",ls="SYM",Wh=Object.freeze({__proto__:null,ALPHANUMERICAL:Vh,AMPERSAND:Gi,APOSTROPHE:Ji,ASCIINUMERICAL:_h,ASTERISK:Xi,AT:gn,BACKSLASH:Yi,BACKTICK:Qi,CARET:Zi,CLOSEANGLEBRACKET:Hi,CLOSEBRACE:po,CLOSEBRACKET:Pi,CLOSEPAREN:Bi,COLON:Zn,COMMA:Ua,DOLLAR:es,DOT:Ot,EMOJI:Fh,EQUALS:ts,EXCLAMATION:qa,FULLWIDTHGREATERTHAN:qi,FULLWIDTHLEFTPAREN:_i,FULLWIDTHLESSTHAN:Ui,FULLWIDTHMIDDLEDOT:jh,FULLWIDTHRIGHTPAREN:Vi,HYPHEN:yt,LEFTCORNERBRACKET:ji,LEFTWHITECORNERBRACKET:Wi,LOCALHOST:bo,NL:Ka,NUM:Wa,OPENANGLEBRACKET:zi,OPENBRACE:fo,OPENBRACKET:Ii,OPENPAREN:$i,PERCENT:ho,PIPE:ns,PLUS:rs,POUND:is,QUERY:mo,QUOTE:Ga,RIGHTCORNERBRACKET:Fi,RIGHTWHITECORNERBRACKET:Ki,SCHEME:Li,SEMI:Ja,SLASH:Dt,SLASH_SCHEME:Nr,SYM:ls,TILDE:go,TLD:Va,UNDERSCORE:ss,UTLD:ja,UWORD:_a,WORD:Jt,WS:Fa}),qt=/[a-z]/,ao=/\p{L}/u,Oa=/\p{Emoji}/u;var Gt=/\d/,Da=/\s/;var Ph="\r",La=`
|
|
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 Ih=ne.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]}`,K(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=>ro({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Ph=ne.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",K(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!op(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,o=e();return pi(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(O.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(j.create(s.doc,a.pos)):s.setSelection(O.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(O.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var wC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,kC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,vC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,CC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$h=_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",K(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[it({find:wC,type:this.type}),it({find:vC,type:this.type})]},addPasteRules(){return[nt({find:kC,type:this.type}),nt({find:CC,type:this.type})]}});var xC="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",SC="\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",Ba="numeric",za="ascii",Ha="alpha",fo="asciinumeric",uo="alphanumeric",_a="domain",jh="emoji",EC="scheme",MC="slashscheme",Da="whitespace";function AC(e,t){return e in t||(t[e]=[]),t[e]}function Zn(e,t,n){t[Ba]&&(t[fo]=!0,t[uo]=!0),t[za]&&(t[fo]=!0,t[Ha]=!0),t[fo]&&(t[uo]=!0),t[Ha]&&(t[uo]=!0),t[uo]&&(t[_a]=!0),t[jh]&&(t[_a]=!0);for(let r in t){let o=AC(r,n);o.indexOf(e)<0&&o.push(e)}}function TC(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function st(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}st.groups={};st.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||st.groups;let o;return t&&t.j?o=t:(o=new st(t),n&&r&&Zn(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||st.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 st,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new st,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(TC(s.t,r),n);Zn(i,a,r)}else n&&Zn(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),Ee=(e,t,n,r,o)=>e.tr(t,n,r,o),Bh=(e,t,n,r,o)=>e.ts(t,n,r,o),N=(e,t,n,r,o)=>e.tt(t,n,r,o),Jt="WORD",Va="UWORD",Fh="ASCIINUMERICAL",Wh="ALPHANUMERICAL",yo="LOCALHOST",ja="TLD",Fa="UTLD",Ii="SCHEME",Rr="SLASH_SCHEME",Ka="NUM",Wa="WS",Ua="NL",po="OPENBRACE",ho="CLOSEBRACE",Pi="OPENBRACKET",$i="CLOSEBRACKET",Bi="OPENPAREN",zi="CLOSEPAREN",Hi="OPENANGLEBRACKET",_i="CLOSEANGLEBRACKET",Vi="FULLWIDTHLEFTPAREN",ji="FULLWIDTHRIGHTPAREN",Fi="LEFTCORNERBRACKET",Wi="RIGHTCORNERBRACKET",Ki="LEFTWHITECORNERBRACKET",Ui="RIGHTWHITECORNERBRACKET",qi="FULLWIDTHLESSTHAN",Gi="FULLWIDTHGREATERTHAN",Ji="AMPERSAND",Xi="APOSTROPHE",Yi="ASTERISK",gn="AT",Qi="BACKSLASH",Zi="BACKTICK",es="CARET",er="COLON",qa="COMMA",ts="DOLLAR",Dt="DOT",ns="EQUALS",Ga="EXCLAMATION",yt="HYPHEN",mo="PERCENT",rs="PIPE",is="PLUS",ss="POUND",go="QUERY",Ja="QUOTE",Kh="FULLWIDTHMIDDLEDOT",Xa="SEMI",Ot="SLASH",bo="TILDE",ls="UNDERSCORE",Uh="EMOJI",as="SYM",qh=Object.freeze({__proto__:null,ALPHANUMERICAL:Wh,AMPERSAND:Ji,APOSTROPHE:Xi,ASCIINUMERICAL:Fh,ASTERISK:Yi,AT:gn,BACKSLASH:Qi,BACKTICK:Zi,CARET:es,CLOSEANGLEBRACKET:_i,CLOSEBRACE:ho,CLOSEBRACKET:$i,CLOSEPAREN:zi,COLON:er,COMMA:qa,DOLLAR:ts,DOT:Dt,EMOJI:Uh,EQUALS:ns,EXCLAMATION:Ga,FULLWIDTHGREATERTHAN:Gi,FULLWIDTHLEFTPAREN:Vi,FULLWIDTHLESSTHAN:qi,FULLWIDTHMIDDLEDOT:Kh,FULLWIDTHRIGHTPAREN:ji,HYPHEN:yt,LEFTCORNERBRACKET:Fi,LEFTWHITECORNERBRACKET:Ki,LOCALHOST:yo,NL:Ua,NUM:Ka,OPENANGLEBRACKET:Hi,OPENBRACE:po,OPENBRACKET:Pi,OPENPAREN:Bi,PERCENT:mo,PIPE:rs,PLUS:is,POUND:ss,QUERY:go,QUOTE:Ja,RIGHTCORNERBRACKET:Wi,RIGHTWHITECORNERBRACKET:Ui,SCHEME:Ii,SEMI:Xa,SLASH:Ot,SLASH_SCHEME:Rr,SYM:as,TILDE:bo,TLD:ja,UNDERSCORE:ls,UTLD:Fa,UWORD:Va,WORD:Jt,WS:Wa}),qt=/[a-z]/,co=/\p{L}/u,Oa=/\p{Emoji}/u;var Gt=/\d/,La=/\s/;var zh="\r",Ia=`
|
|
123
|
+
`,NC="\uFE0F",RC="\u200D",Pa="\uFFFC",Di=null,Oi=null;function DC(e=[]){let t={};st.groups=t;let n=new st;Di==null&&(Di=Hh(xC)),Oi==null&&(Oi=Hh(SC)),N(n,"'",Xi),N(n,"{",po),N(n,"}",ho),N(n,"[",Pi),N(n,"]",$i),N(n,"(",Bi),N(n,")",zi),N(n,"<",Hi),N(n,">",_i),N(n,"\uFF08",Vi),N(n,"\uFF09",ji),N(n,"\u300C",Fi),N(n,"\u300D",Wi),N(n,"\u300E",Ki),N(n,"\u300F",Ui),N(n,"\uFF1C",qi),N(n,"\uFF1E",Gi),N(n,"&",Ji),N(n,"*",Yi),N(n,"@",gn),N(n,"`",Zi),N(n,"^",es),N(n,":",er),N(n,",",qa),N(n,"$",ts),N(n,".",Dt),N(n,"=",ns),N(n,"!",Ga),N(n,"-",yt),N(n,"%",mo),N(n,"|",rs),N(n,"+",is),N(n,"#",ss),N(n,"?",go),N(n,'"',Ja),N(n,"/",Ot),N(n,";",Xa),N(n,"~",bo),N(n,"_",ls),N(n,"\\",Qi),N(n,"\u30FB",Kh);let r=Ee(n,Gt,Ka,{[Ba]:!0});Ee(r,Gt,r);let o=Ee(r,qt,Fh,{[fo]:!0}),i=Ee(r,co,Wh,{[uo]:!0}),s=Ee(n,qt,Jt,{[za]:!0});Ee(s,Gt,o),Ee(s,qt,s),Ee(o,Gt,o),Ee(o,qt,o);let l=Ee(n,co,Va,{[Ha]:!0});Ee(l,qt),Ee(l,Gt,i),Ee(l,co,l),Ee(i,Gt,i),Ee(i,qt),Ee(i,co,i);let a=N(n,Ia,Ua,{[Da]:!0}),u=N(n,zh,Wa,{[Da]:!0}),c=Ee(n,La,Wa,{[Da]:!0});N(n,Pa,c),N(u,Ia,a),N(u,Pa,c),Ee(u,La,c),N(c,zh),N(c,Ia),Ee(c,La,c),N(c,Pa,c);let d=Ee(n,Oa,Uh,{[jh]:!0});N(d,"#"),Ee(d,Oa,d),N(d,NC,d);let f=N(d,RC);N(f,"#"),Ee(f,Oa,d);let p=[[qt,s],[Gt,o]],h=[[qt,null],[co,l],[Gt,i]];for(let g=0;g<Di.length;g++)mn(n,Di[g],ja,Jt,p);for(let g=0;g<Oi.length;g++)mn(n,Oi[g],Fa,Va,h);Zn(ja,{tld:!0,ascii:!0},t),Zn(Fa,{utld:!0,alpha:!0},t),mn(n,"file",Ii,Jt,p),mn(n,"mailto",Ii,Jt,p),mn(n,"http",Rr,Jt,p),mn(n,"https",Rr,Jt,p),mn(n,"ftp",Rr,Jt,p),mn(n,"ftps",Rr,Jt,p),Zn(Ii,{scheme:!0,ascii:!0},t),Zn(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]?{[EC]:!0}:{[MC]:!0};m.indexOf("-")>=0?k[_a]=!0:qt.test(m)?Gt.test(m)?k[fo]=!0:k[za]=!0:k[Ba]=!0,Bh(n,m,m,k)}return Bh(n,"localhost",yo,{ascii:!0}),n.jd=new st(as),{start:n,tokens:Object.assign({groups:t},qh)}}function Gh(e,t){let n=OC(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 OC(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 mn(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 st(r),i.jr=o.slice(),e.j[a]=i),e=i}return i=new st(n),i.jr=o.slice(),e.j[t[s-1]]=i,i}function Hh(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 wo={defaultProtocol:"http",events:null,format:_h,formatHref:_h,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ya(e,t=null){let n=Object.assign({},wo);e&&(n=Object.assign(n,e instanceof Ya?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}Ya.prototype={o:wo,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]:wo[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 _h(e){return e}function Jh(e,t){this.t="token",this.v=e,this.tk=t}Jh.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=wo.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 cs(e,t){class n extends Jh{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 LC=cs("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Vh=cs("text"),IC=cs("nl"),Li=cs("url",{isLink:!0,toHref(e=wo.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==yo&&e[1].t===er}});var bt=e=>new st(e);function PC({groups:e}){let t=e.domain.concat([Ji,Yi,gn,Qi,Zi,es,ts,ns,yt,Ka,mo,rs,is,ss,Ot,as,bo,ls]),n=[Xi,er,qa,Dt,Ga,mo,go,Ja,Xa,Hi,_i,po,ho,$i,Pi,Bi,zi,Vi,ji,Fi,Wi,Ki,Ui,qi,Gi],r=[Ji,Xi,Yi,Qi,Zi,es,ts,ns,yt,po,ho,mo,rs,is,ss,go,Ot,as,bo,ls],o=bt(),i=N(o,bo);Y(i,r,i),Y(i,e.domain,i);let s=bt(),l=bt(),a=bt();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,gn);N(i,gn,u),N(l,gn,u),N(a,gn,u);let c=N(i,Dt);Y(c,r,i),Y(c,e.domain,i);let d=bt();Y(u,e.domain,d),Y(d,e.domain,d);let f=N(d,Dt);Y(f,e.domain,d);let p=bt(LC);Y(f,e.tld,p),Y(f,e.utld,p),N(u,yo,p);let h=N(d,yt);N(h,yt,h),Y(h,e.domain,d),Y(p,e.domain,d),N(p,Dt,f),N(p,yt,h);let g=N(s,yt),m=N(s,Dt);N(g,yt,g),Y(g,e.domain,s),Y(m,r,i),Y(m,e.domain,s);let b=bt(Li);Y(m,e.tld,b),Y(m,e.utld,b),Y(b,e.domain,s),Y(b,r,i),N(b,Dt,m),N(b,yt,g),N(b,gn,u);let k=N(b,er),C=bt(Li);Y(k,e.numeric,C);let S=bt(Li),A=bt();Y(S,t,S),Y(S,n,A),Y(A,t,S),Y(A,n,A),N(b,Ot,S),N(C,Ot,S);let E=N(l,er),M=N(a,er),L=N(M,Ot),oe=N(L,Ot);Y(l,e.domain,s),N(l,Dt,m),N(l,yt,g),Y(a,e.domain,s),N(a,Dt,m),N(a,yt,g),Y(E,e.domain,S),N(E,Ot,S),N(E,go,S),Y(oe,e.domain,S),Y(oe,t,S),N(oe,Ot,S);let he=[[po,ho],[Pi,$i],[Bi,zi],[Hi,_i],[Vi,ji],[Fi,Wi],[Ki,Ui],[qi,Gi]];for(let Ce=0;Ce<he.length;Ce++){let[Ae,Ve]=he[Ce],je=N(S,Ae);N(A,Ae,je);let $e=bt(Li);Y(je,t,$e);let T=bt();Y(je,n,T),N(je,Ve,S),Y($e,t,$e),Y($e,n,T),Y(T,t,$e),Y(T,n,T),N($e,Ve,S),N(T,Ve,S)}return N(o,yo,b),N(o,Ua,IC),{start:o,tokens:qh}}function $C(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($a(Vh,t,s)),s=[]),o-=f,c-=f;let p=d.t,h=n.slice(o-c,o);i.push($a(p,t,h))}}return s.length>0&&i.push($a(Vh,t,s)),i}function $a(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 BC=typeof console<"u"&&console&&console.warn||(()=>{}),zC="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",xe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Xh(){return st.groups={},xe.scanner=null,xe.parser=null,xe.tokenQueue=[],xe.pluginQueue=[],xe.customSchemes=[],xe.initialized=!1,xe}function Qa(e,t=!1){if(xe.initialized&&BC(`linkifyjs: already initialized - will not register custom scheme "${e}" ${zC}`),!/^[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`);xe.customSchemes.push([e,t])}function PC(){xe.scanner=AC(xe.customSchemes);for(let e=0;e<xe.tokenQueue.length;e++)xe.tokenQueue[e][1]({scanner:xe.scanner});xe.parser=OC(xe.scanner.tokens);for(let e=0;e<xe.pluginQueue.length;e++)xe.pluginQueue[e][1]({scanner:xe.scanner,parser:xe.parser});return xe.initialized=!0,xe}function cs(e){return xe.initialized||PC(),DC(xe.parser.start,e,Kh(xe.scanner.start,e))}cs.scan=Kh;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 Xa(n),o=cs(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 us="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",$C=new RegExp(us),BC=new RegExp(`${us}$`),zC=new RegExp(`${us}+$`),HC=new RegExp(us,"g");function _C(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(zC))===null||o===void 0?void 0:o[0];if(!s)return;let l=t.to-s.length,a=to(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 VC(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function jC(e){return new U({key:new te("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=ea(n.doc,[...t]);if(!t.some(df)){let a=[];l.steps.forEach((u,c)=>{if(!(u instanceof On)||!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=>_C(s,u,e.type))}if(vr(l).forEach(({newRange:a})=>{let u=Bf(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(!BC.test(f))return;c=u[0],d=r.doc.textBetween(c.pos,a.to,void 0," ")}if(c&&d){let f=d.split($C).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 b=cs(p).map(m=>m.toObject(e.defaultProtocol));if(!VC(b))return!1;b.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=>{to(m.from,m.to,r.doc).some(g=>g.mark.type===e.type)||s.addMark(m.from,m.to,e.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function FC(e){return new U({key:new te("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=ra(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 WC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,KC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Gh(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function UC(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Gh(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 Jh(e,t,n){var r,o;let[,i,s]=t;return(t.index?e[t.index-1]:void 0)==="!"||Gh(e,(r=t.index)!==null&&r!==void 0?r:0)||UC(e,(o=t.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Xh(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 qC(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function Yh(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 GC(e){let t=it({find:n=>{let r=WC.exec(n);return!r||!Jh(n,r,e.isAllowedHref)?null:Xh(r)},type:e.type,getAttributes:Yh});return new Sr({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 JC(e){let t=nt({find:n=>{var r,o;let i=[];for(let l of n.matchAll(KC))Jh(n,l,e.isAllowedHref)&&i.push(Xh(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=>qC(a,l)));return[...i,...s]},type:e.type,getAttributes:Yh});return new la({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 XC(e){return new U({key:new te("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 Xt(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(HC,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Qh=_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"){Ya(e);return}Ya(e.scheme,e.optionalSlashes)})},onDestroy(){qh()},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)=>!!Xt(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=>!!Xt(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=>!!Xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",K(this.options.HTMLAttributes,e),0]:["a",K(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=>!!Xt(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=>!!Xt(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?[GC({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!Xt(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=>!!Xt(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?[JC({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:n=>!!Xt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[nt({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(jC({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Xt(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(FC({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(XC({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}});var YC="listItem",Zh="textStyle",em=/^\s*([-+*])\s$/,Za=ne.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",K(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(YC,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:em,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=fn({find:em,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Zh),editor:this.editor})),[e]}}),QC=(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}},ZC=(e,t,n,r)=>{let o=QC(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,V.from(u)),c.setSelection(i.map(c.doc,c.mapping)),t&&t(c),!0},ex=(e,t,n)=>ZC(e.state,e.view.dispatch,t,n),am=(e,t)=>le.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>ex(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),cm=[[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"]],ds="abcdefghijklmnopqrstuvwxyz",um=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function hs(e){let t=e,n="";for(let[r,o]of cm)for(;t>=r;)n+=o,t-=r;return n}function ec(e){return hs(e).toUpperCase()}function dm(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let o=!1;for(let[i,s]of cm)if(t.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function tx(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=dm(e);return t<=0?!1:(e===e.toLowerCase()?hs(t):ec(t))===e}function nx(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 fs(e){if(e<=26)return ds[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?ds[n]:ds[t]+ds[n]}function ms(e){if(!(!e||/^\d+$/.test(e))){if(tx(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 tc(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=ms(e);if(t==="i"||t==="I")return dm(e);if(t==="a"||t==="A"){let r=nx(e);return r>0?r:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function rx(e,t){if(e==="numeric")return String(t);switch(e){case"a":return fs(t);case"A":return fs(t).toUpperCase();case"i":return hs(t);case"I":return ec(t);default:return String(t)}}function ox(e){var t;if(e.length===0)return!1;let n=(t=ms(e[0]))!==null&&t!==void 0?t:"numeric",r=tc(e[0]);if(r<1)return!1;for(let o=0;o<e.length;o++){let i=rx(n,r+o);if(e[o]!==i)return!1}return!0}function ix(e){return{type:ms(e),start:tc(e)}}function sx(e){let{type:t,start:n}=ix(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function lx(e,t,n=". "){let r=t+1;if(!e||e==="1")return`${r}${n}`;switch(e){case"a":return`${fs(r)}${n}`;case"A":return`${fs(r).toUpperCase()}${n}`;case"i":return`${hs(r)}${n}`;case"I":return`${ec(r)}${n}`;default:return`${r}${n}`}}function ax(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 cx(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var nc=ne.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",K(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(ax(e))return{type:"listItem",content:[{type:"paragraph",content:cx(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)=>ia(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 lx((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[am(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)}}}),rc=(e,t)=>{let{$from:n}=t.selection,r=Re(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}},fm=(e,t)=>{let n=rc(e,t);if(!n)return!1;let[,r]=jf(t,e,n.$pos.pos+4);return r},ux=(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))},tm=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Tt(e.state,t)&&ux(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(!Tt(e.state,t)||!Kf(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()},dx=(e,t)=>{let n=fm(e,t),r=rc(e,t);return!r||!n?!1:n>r.depth},fx=(e,t)=>{let n=fm(e,t),r=rc(e,t);return!r||!n?!1:n<r.depth},nm=(e,t)=>{if(!Tt(e.state,t)||!Wf(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:dx(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():fx(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},px=(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||Tt(r,t))return!1;let s=Ff(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,V.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,V.from(a)),f.setSelection(D.create(f.doc,d+1)),f.scrollIntoView()),!0))};var oc=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&&nm(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&&nm(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&&tm(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&&tm(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&&px(e,t,n))return!0;return!1}}}}),ps=new RegExp(`^(\\s*)(${um})([.)])\\s+(.*)$`),hx=/^\s/,Rr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function mx(e){return ps.test(e.trimStart())}function gx(e){let t=e.trimStart();return Rr.bulletItem.test(t)||mx(t)||Rr.heading.test(t)||Rr.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||Rr.codeFence.test(t)||Rr.blockMath.test(t)}function bx(e){return Object.values(Rr).some(t=>t.test(e))}function yx(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&&gx(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function rm(e){let t=[],n=0,r=0;for(;n<e.length;){let o=e[n],i=o.match(ps);if(!i)break;let[,s,l,a,u]=i,c=s.length,d=parseInt(l,10),f=isNaN(d)?ms(l):void 0,p=isNaN(d)?tc(l):d,h=[u],b=n+1,m=[o],g=!1;for(;b<e.length;){let k=e[b];if(k.match(ps))break;if(k.trim()==="")m.push(k),h.push(""),g=!0,b+=1;else if(k.match(hx)){let C=k.length-k.trimStart().length,S=c+l.length+1;m.push(k),h.push(k.slice(Math.min(C,S))),b+=1}else{if(g||bx(k))break;m.push(k),h.push(k),b+=1}}t.push({indent:c,number:p,type:f,content:h.join(`
|
|
126
|
+
3. "-" cannot repeat`);xe.customSchemes.push([e,t])}function HC(){xe.scanner=DC(xe.customSchemes);for(let e=0;e<xe.tokenQueue.length;e++)xe.tokenQueue[e][1]({scanner:xe.scanner});xe.parser=PC(xe.scanner.tokens);for(let e=0;e<xe.pluginQueue.length;e++)xe.pluginQueue[e][1]({scanner:xe.scanner,parser:xe.parser});return xe.initialized=!0,xe}function us(e){return xe.initialized||HC(),$C(xe.parser.start,e,Gh(xe.scanner.start,e))}us.scan=Gh;function Za(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 Ya(n),o=us(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 ds="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",_C=new RegExp(ds),VC=new RegExp(`${ds}$`),jC=new RegExp(`${ds}+$`),FC=new RegExp(ds,"g");function WC(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(jC))===null||o===void 0?void 0:o[0];if(!s)return;let l=t.to-s.length,a=no(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 KC(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function UC(e){return new U({key:new te("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=ta(n.doc,[...t]);if(!t.some(hf)){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=>WC(s,u,e.type))}if(Cr(l).forEach(({newRange:a})=>{let u=_f(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(_C).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=us(p).map(m=>m.toObject(e.defaultProtocol));if(!KC(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=>{no(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 qC(e){return new U({key:new te("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=oa(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 GC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,JC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Yh(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function XC(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Yh(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 Qh(e,t,n){var r,o;let[,i,s]=t;return(t.index?e[t.index-1]:void 0)==="!"||Yh(e,(r=t.index)!==null&&r!==void 0?r:0)||XC(e,(o=t.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Zh(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 YC(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function em(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 QC(e){let t=it({find:n=>{let r=GC.exec(n);return!r||!Qh(n,r,e.isAllowedHref)?null:Zh(r)},type:e.type,getAttributes:em});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=nt({find:n=>{var r,o;let i=[];for(let l of n.matchAll(JC))Qh(n,l,e.isAllowedHref)&&i.push(Zh(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=>YC(a,l)));return[...i,...s]},type:e.type,getAttributes:em});return new aa({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 ex(e){return new U({key:new te("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=Za(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 Xt(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(FC,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var tm=_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"){Qa(e);return}Qa(e.scheme,e.optionalSlashes)})},onDestroy(){Xh()},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)=>!!Xt(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=>!!Xt(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=>!!Xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",K(this.options.HTMLAttributes,e),0]:["a",K(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=>!!Xt(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=>!!Xt(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?[QC({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!Xt(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;Za(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Xt(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=>!!Xt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[nt({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(UC({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Xt(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(qC({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(ex({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}});var tx="listItem",nm="textStyle",rm=/^\s*([-+*])\s$/,ec=ne.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",K(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(tx,this.editor.getAttributes(nm)).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:rm,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=fn({find:rm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(nm),editor:this.editor})),[e]}}),nx=(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}},rx=(e,t,n,r)=>{let o=nx(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,V.from(u)),c.setSelection(i.map(c.doc,c.mapping)),t&&t(c),!0},ox=(e,t,n)=>rx(e.state,e.view.dispatch,t,n),dm=(e,t)=>le.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>ox(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),fm=[[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"]],fs="abcdefghijklmnopqrstuvwxyz",pm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function ms(e){let t=e,n="";for(let[r,o]of fm)for(;t>=r;)n+=o,t-=r;return n}function tc(e){return ms(e).toUpperCase()}function hm(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let o=!1;for(let[i,s]of fm)if(t.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function ix(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=hm(e);return t<=0?!1:(e===e.toLowerCase()?ms(t):tc(t))===e}function sx(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 ps(e){if(e<=26)return fs[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?fs[n]:fs[t]+fs[n]}function gs(e){if(!(!e||/^\d+$/.test(e))){if(ix(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 nc(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=gs(e);if(t==="i"||t==="I")return hm(e);if(t==="a"||t==="A"){let r=sx(e);return r>0?r:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function lx(e,t){if(e==="numeric")return String(t);switch(e){case"a":return ps(t);case"A":return ps(t).toUpperCase();case"i":return ms(t);case"I":return tc(t);default:return String(t)}}function ax(e){var t;if(e.length===0)return!1;let n=(t=gs(e[0]))!==null&&t!==void 0?t:"numeric",r=nc(e[0]);if(r<1)return!1;for(let o=0;o<e.length;o++){let i=lx(n,r+o);if(e[o]!==i)return!1}return!0}function cx(e){return{type:gs(e),start:nc(e)}}function ux(e){let{type:t,start:n}=cx(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function dx(e,t,n=". "){let r=t+1;if(!e||e==="1")return`${r}${n}`;switch(e){case"a":return`${ps(r)}${n}`;case"A":return`${ps(r).toUpperCase()}${n}`;case"i":return`${ms(r)}${n}`;case"I":return`${tc(r)}${n}`;default:return`${r}${n}`}}function fx(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 px(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var rc=ne.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",K(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(fx(e))return{type:"listItem",content:[{type:"paragraph",content:px(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)=>sa(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 dx((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[dm(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),oc=(e,t)=>{let{$from:n}=t.selection,r=Re(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}},mm=(e,t)=>{let n=oc(e,t);if(!n)return!1;let[,r]=Kf(t,e,n.$pos.pos+4);return r},hx=(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))},om=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Tt(e.state,t)&&hx(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(!Tt(e.state,t)||!Gf(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()},mx=(e,t)=>{let n=mm(e,t),r=oc(e,t);return!r||!n?!1:n>r.depth},gx=(e,t)=>{let n=mm(e,t),r=oc(e,t);return!r||!n?!1:n<r.depth},im=(e,t)=>{if(!Tt(e.state,t)||!qf(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:mx(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():gx(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},bx=(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||Tt(r,t))return!1;let s=Uf(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,V.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,V.from(a)),f.setSelection(O.create(f.doc,d+1)),f.scrollIntoView()),!0))};var ic=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&&im(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&&im(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&&om(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&&om(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&&bx(e,t,n))return!0;return!1}}}}),hs=new RegExp(`^(\\s*)(${pm})([.)])\\s+(.*)$`),yx=/^\s/,Dr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function wx(e){return hs.test(e.trimStart())}function kx(e){let t=e.trimStart();return Dr.bulletItem.test(t)||wx(t)||Dr.heading.test(t)||Dr.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||Dr.codeFence.test(t)||Dr.blockMath.test(t)}function vx(e){return Object.values(Dr).some(t=>t.test(e))}function Cx(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&&kx(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function sm(e){let t=[],n=0,r=0;for(;n<e.length;){let o=e[n],i=o.match(hs);if(!i)break;let[,s,l,a,u]=i,c=s.length,d=parseInt(l,10),f=isNaN(d)?gs(l):void 0,p=isNaN(d)?nc(l):d,h=[u],g=n+1,m=[o],b=!1;for(;g<e.length;){let k=e[g];if(k.match(hs))break;if(k.trim()==="")m.push(k),h.push(""),b=!0,g+=1;else if(k.match(yx)){let C=k.length-k.trimStart().length,S=c+l.length+1;m.push(k),h.push(k.slice(Math.min(C,S))),g+=1}else{if(b||vx(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=
|
|
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 xx=new RegExp(`^(${pm})([.)])\\s+(.+)$`);function Sx(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(xx);if(!o)return null;n.push({marker:o[1],content:o[3]})}return ax(n.map(r=>r.marker))?{type:"orderedList",attrs:ux(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function gm(e,t,n){let r=[],o=0;for(;o<e.length;){let i=e[o];if(i.indent===t){let{paragraphLines:s,blockLines:l}=Cx(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=oa(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=oa(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()}}}),oT=le.create({name:"listKit",addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Za.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(nc.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(oc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(ic.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(gs.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(bs.configure(this.options.taskList)),e}});var ys=" ",sc="\xA0",hm=ne.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",K(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===ys||n[0].text===ys||n[0].raw===sc||n[0].text===sc)&&r.length===1&&r[0].type==="text"&&(r[0].text===ys||r[0].text===sc)?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?ys:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Tx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Nx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,mm=_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",K(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[it({find:Tx,type:this.type})]},addPasteRules(){return[nt({find:Nx,type:this.type})]}});var gm=ne.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""});var bm=_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",K(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 ym(e={}){return new U({view(t){return new lc(t,e)}})}var lc=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(),b=d?h.bottom:h.top;d&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:b-m,bottom:b+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=Do(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 ET=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 U({key:new te("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)}})]}}),vm=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ym(this.options)]}}),MT=le.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new U({key:new te("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!n||!r)return de.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(Me.node(u,u+a.nodeSize,{class:this.options.className}))}),de.create(e,i)}}})]}}),Cm=le.create({name:"gapCursor",addProseMirrorPlugins(){return[Bp()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=fe(z(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),xm="placeholder",wm=new te("tiptap__placeholder");function Sm(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),Me.node(o,o+i.nodeSize,{class:c.join(" "),[r]:typeof n=="function"?n({editor:t,node:i,pos:o,hasAnchor:l}):n})}function Em(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&&Cr(c);return c.type.isTextblock&&(f||!t.showOnlyCurrent)&&p&&a.push(Sm({editor:e,isEmptyDoc:u,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Em(t.emptyNodeClass,{editor:e,node:c,pos:d,hasAnchor:f})},node:c,pos:d})),t.includeChildren}),a}function Am({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&&Cr(u)){let d=i>=c&&i<=c+u.nodeSize;s.push(Sm({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Em(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 de.create(r,s)}function wo(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 ko(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function Rx(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 Ox(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 Dx(e,t){let n=Rx(e,t.from,t.to);return n.push(ko(e,wo(e,t.from))),t.to>t.from?n.push(ko(e,wo(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(ko(e,wo(e,Math.min(t.from+1,e.content.size)))),n}function Lx(e,t,n){let r=[];if(e.docChanged){let o=vr(e);for(let i of o)r.push(...Dx(n.doc,i.newRange))}return e.selectionSet&&(r.push(ko(n.doc,wo(n.doc,e.mapping.map(t.selection.anchor)))),r.push(ko(n.doc,wo(n.doc,n.selection.anchor)))),Ox(r)}function Ix(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 Px({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}=Ix(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 $x({editor:e,options:t,dataAttribute:n}){return{init(r,o){let i=Am({editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection});return i??de.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Px({decorations:o.map(r.mapping,r.doc),ranges:Lx(r,i,s),editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Bx(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function zx({editor:e,options:t}){let n=t.dataAttribute?`data-${Bx(t.dataAttribute)}`:`data-${xm}`,r=t.showOnlyCurrent&&!t.includeChildren;return new U({key:wm,...r?{}:{state:$x({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>Am({editor:e,options:t,dataAttribute:n,doc:o,selection:i}):o=>{var i;return t.showOnlyWhenEditable&&!e.isEditable?de.empty:(i=wm.getState(o))!==null&&i!==void 0?i:de.empty}}})}var cc=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:xm,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[zx({editor:this.editor,options:this.options})]}});function ac(e,t){return!e.selection.empty&&!fi(e.selection)&&t.isEditable}function Hx(e,t){return ac(e,t)&&!t.isFocused&&!t.view.dragging}function _x(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function Vx(e){e.focus()}var AT=le.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new U({key:new te("selection"),props:{decorations(n){return Hx(n,e)?de.create(n.doc,[Me.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(n){return ac(n.state,e)&&_x(),!1},focus(n){return ac(n.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&n.hasFocus()&&Vx(n)}),!1}}}})]}});function km({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var Tm=le.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new te(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 U({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!km({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!km({node:s,types:r})}}})]}}),Nm=le.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Fl(e,t),redo:()=>({state:e,dispatch:t})=>Wl(e,t)}},addProseMirrorPlugins(){return[uf(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 jx=le.create({name:"starterKit",addExtensions(){let e=[];if(this.options.bold!==!1&&e.push(Ah.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Mh.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Za.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Th.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Ni.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Nh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(vm.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Cm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Rh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Oh.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Nm.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Dh.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Lh.configure(this.options.italic)),this.options.listItem!==!1&&e.push(nc.configure(this.options.listItem)),this.options.listKeymap!==!1){var t;e.push(oc.configure((t=this.options)===null||t===void 0?void 0:t.listKeymap))}if(this.options.link!==!1){var n;e.push(Qh.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&e.push(ic.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(hm.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(mm.configure(this.options.strike)),this.options.text!==!1&&e.push(gm.configure(this.options.text)),this.options.underline!==!1){var r;e.push(bm.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;e.push(Tm.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return e}}),Rm=jx;var Ym=ye(Xm(),1);var Qm=Ym.default;function tg(e,t=[]){return e.flatMap(n=>{let r=[...t,...n.properties?n.properties.className:[]];return n.children?tg(n.children,r):{text:n.value,classes:r}})}function Zm(e){return e.value||e.children||[]}function DS(e){return!!Qm.getLanguage(e)}function eg({doc:e,name:t,lowlight:n,defaultLanguage:r}){let o=[];return Kn(e,i=>i.type.name===t).forEach(i=>{var s;let l=i.pos+1,a=i.node.attrs.language||r,u=n.listLanguages();tg(a&&(u.includes(a)||DS(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=Me.inline(l,d,{class:c.classes.join(" ")});o.push(f)}l=d})}),de.create(e,o)}function LS(e){return typeof e=="function"}function IS({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(o=>LS(t[o])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new U({key:new te("lowlight"),state:{init:(o,{doc:i})=>eg({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=Kn(s.doc,f=>f.type.name===e),d=Kn(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)))?eg({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 PS=Ni.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))||[],IS({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),ng=PS;var rg=ng.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 U({...e.spec,state:{...t,apply(r,o,i,s){if(r.docChanged){let l=Kn(i.doc,u=>u.type.name===n),a=Kn(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:vu,HTMLAttributes:{class:"code-block"}});var og=cc;var $S=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,BS=ne.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",K(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=K(this.options.HTMLAttributes,l);Object.entries(c).forEach(([g,k])=>{if(k!=null)switch(g){case"src":case"width":case"height":break;default:u.setAttribute(g,k)}}),c.src!==null&&(u.src=c.src);let d={...l},f=g=>{if(typeof g=="string"&&g!==""){u.getAttribute("src")!==g&&(u.src=g);return}u.hasAttribute("src")&&u.removeAttribute("src"),u.src!==""&&(u.src="")};f(l.src);let p=g=>{if(g.type!==i.type)return!1;let k=a.extensionManager.attributes.filter(S=>S.type===g.type.name),C=Nt(g,k);return Object.keys(d).forEach(S=>{!o.has(S)&&!(S in C)&&u.removeAttribute(S)}),Object.entries(C).forEach(([S,A])=>{o.has(S)||(A!=null?u.setAttribute(S,A):u.removeAttribute(S))}),f(C.src),d=C,!0},h=new sp({element:u,editor:a,node:i,getPos:s,onResize:(g,k)=>{u.style.width=`${g}px`,u.style.height=`${k}px`},onCommit:(g,k)=>{let C=s();C!==void 0&&this.editor.chain().setNodeSelection(C).updateAttributes(this.name,{width:g,height:k}).run()},onUpdate:p,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),b=h.dom,m=()=>{b.style.visibility="",b.style.pointerEvents=""};return b.style.visibility="hidden",b.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[hi({find:$S,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),ig=BS;function xo(e){return e==="left"||e==="right"||e==="center"?e:null}function zS(e){let t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return xo(t||n)}function HS(e){return xo(e?.align)}function ug(){return{default:null,parseHTML:e=>zS(e),renderHTML:e=>{let t=xo(e.align);return xr(t)?{style:`text-align: ${t}`}:{}}}}function _S(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 dg(e){let t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):_S(e)}var VS=/[ \t\r\n\f]+/g;function fg(e){var t;return e.children.length>0?!1:((t=e.textContent)!==null&&t!==void 0?t:"").replace(VS,"")===""}function pg(e){let t=e.createAndFill();if(!t)throw new Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function Es(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 jS=ne.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:dg},align:ug()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:e=>fg(e)?{}:!1,getContent:(e,t)=>pg(t.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Es(t,e,"colspan"),Es(t,e,"rowspan"),["td",t,0]}}),FS=ne.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:dg},align:ug()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:e=>fg(e)?{}:!1,getContent:(e,t)=>pg(t.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Es(t,e,"colspan"),Es(t,e,"rowspan"),["th",t,0]}}),WS=ne.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",K(this.options.HTMLAttributes,e),0]}});function bc(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function sg(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:b}=u.child(f).attrs;for(let m=0;m<h;m+=1,p+=1){let g=o===p?i:b&&b[m],k=g?`${g}px`:"";if(s+=g||r,g||(l=!1),a){if(a.style.width!==k){let[C,S]=bc(r,g);a.style.setProperty(C,S)}a=a.nextSibling}else{let C=document.createElement("col"),[S,A]=bc(r,g);C.style.setProperty(S,A),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 yc=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")),sg(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,sg(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 KS(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 b=n===d?r:p&&p[h];o+=b||t,b||(i=!1);let[m,g]=bc(t,b);s.push(["col",{style:`${m}: ${g}`}])}}let a=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:u}}function lg(e,t){return t?e.createChecked(null,t):e.createAndFill()}function US(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 qS(e,t,n,r,o){let i=US(e),s=[],l=[];for(let u=0;u<n;u+=1){let c=lg(i.cell,o);if(c&&l.push(c),r){let d=lg(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 hg(e){return e instanceof re}var Ss=({editor:e})=>{let{selection:t}=e.state;if(!hg(t))return!1;let n=0,r=kr(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 ag(e,t){let n=e.mapping.map(t),r=kr(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(D.near(e.doc.resolve(i),-1))}function GS(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 JS(e){return e.split(`
|
|
139
|
-
`).map(t=>!t.includes("|")||!t.includes("`")?t:
|
|
140
|
-
`)}function
|
|
141
|
-
`):e}function
|
|
142
|
-
`):
|
|
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=gm(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 Ex(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 Mx=64;function lm(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 Ax(e){let t=e.indexOf(`
|
|
135
|
+
`),n=t===-1?e:e.slice(0,t);if(!hs.test(n))return[[],0,[]];let r=Mx,o=lm(e,r),i=sm(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=lm(e,r),i=sm(o);return[i[0],i[1],o]}var Tx="listItem",am="textStyle",cm=/^(\d+)\.\s$/;function um(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 sc=ne.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=um(n);if(o)return o}let r=e.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=um(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,o=K(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?Ex(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]=Ax(e);if(i.length===0)return;let a=gm(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(Tx,this.editor.getAttributes(am)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new U({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=Sx(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=fn({find:cm,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=fn({find:cm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(am)}),joinPredicate:e,editor:this.editor})),[t]}}),Nx=/^\s*(\[([( |x])?\])\s$/,Rx="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",Dx=(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"}`},bs=ne.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",K(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 sa(e,t,r)},addExtensions(){return this.options.nested?[dm(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=Rx;let u=d=>{let f=Dx(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=Nt(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[fn({find:Nx,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),ys=ne.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",K(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=ia(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=ia(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()}}}),cT=le.create({name:"listKit",addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(ec.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(rc.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ic.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(sc.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(bs.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(ys.configure(this.options.taskList)),e}});var ws=" ",lc="\xA0",bm=ne.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",K(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===ws||n[0].text===ws||n[0].raw===lc||n[0].text===lc)&&r.length===1&&r[0].type==="text"&&(r[0].text===ws||r[0].text===lc)?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?ws:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Ox=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Lx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ym=_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",K(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[it({find:Ox,type:this.type})]},addPasteRules(){return[nt({find:Lx,type:this.type})]}});var wm=ne.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""});var km=_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",K(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 vm(e={}){return new U({view(t){return new ac(t,e)}})}var ac=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=Lo(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 RT=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 U({key:new te("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=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[vm(this.options)]}}),DT=le.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new U({key:new te("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,i=[];if(!n||!r)return de.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(Me.node(u,u+a.nodeSize,{class:this.options.className}))}),de.create(e,i)}}})]}}),Em=le.create({name:"gapCursor",addProseMirrorPlugins(){return[_p()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=fe(z(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Mm="placeholder",Cm=new te("tiptap__placeholder");function Am(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),Me.node(o,o+i.nodeSize,{class:c.join(" "),[r]:typeof n=="function"?n({editor:t,node:i,pos:o,hasAnchor:l}):n})}function Tm(e,t){return typeof e=="function"?e(t):e}function Nm({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(Am({editor:e,isEmptyDoc:u,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Tm(t.emptyNodeClass,{editor:e,node:c,pos:d,hasAnchor:f})},node:c,pos:d})),t.includeChildren}),a}function Rm({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(Am({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Tm(t.emptyNodeClass,{editor:e,node:u,pos:c,hasAnchor:d})},node:u,pos:c}))}}else s.push(...Nm({editor:e,options:t,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return de.create(r,s)}function ko(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 vo(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function Ix(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 Px(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 $x(e,t){let n=Ix(e,t.from,t.to);return n.push(vo(e,ko(e,t.from))),t.to>t.from?n.push(vo(e,ko(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(vo(e,ko(e,Math.min(t.from+1,e.content.size)))),n}function Bx(e,t,n){let r=[];if(e.docChanged){let o=Cr(e);for(let i of o)r.push(...$x(n.doc,i.newRange))}return e.selectionSet&&(r.push(vo(n.doc,ko(n.doc,e.mapping.map(t.selection.anchor)))),r.push(vo(n.doc,ko(n.doc,n.selection.anchor)))),Px(r)}function zx(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 Hx({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}=zx(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=Nm({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:u,to:c});f.length&&(l=l.add(i,f))}return l}function _x({editor:e,options:t,dataAttribute:n}){return{init(r,o){let i=Rm({editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection});return i??de.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Hx({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 jx({editor:e,options:t}){let n=t.dataAttribute?`data-${Vx(t.dataAttribute)}`:`data-${Mm}`,r=t.showOnlyCurrent&&!t.includeChildren;return new U({key:Cm,...r?{}:{state:_x({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>Rm({editor:e,options:t,dataAttribute:n,doc:o,selection:i}):o=>{var i;return t.showOnlyWhenEditable&&!e.isEditable?de.empty:(i=Cm.getState(o))!==null&&i!==void 0?i:de.empty}}})}var uc=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Mm,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[jx({editor:this.editor,options:this.options})]}});function cc(e,t){return!e.selection.empty&&!pi(e.selection)&&t.isEditable}function Fx(e,t){return cc(e,t)&&!t.isFocused&&!t.view.dragging}function Wx(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function Kx(e){e.focus()}var OT=le.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new U({key:new te("selection"),props:{decorations(n){return Fx(n,e)?de.create(n.doc,[Me.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(n){return cc(n.state,e)&&Wx(),!1},focus(n){return cc(n.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&n.hasFocus()&&Kx(n)}),!1}}}})]}});function xm({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var Dm=le.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new te(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 U({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!xm({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!xm({node:s,types:r})}}})]}}),Om=le.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Wl(e,t),redo:()=>({state:e,dispatch:t})=>Kl(e,t)}},addProseMirrorPlugins(){return[pf(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 Ux=le.create({name:"starterKit",addExtensions(){let e=[];if(this.options.bold!==!1&&e.push(Rh.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Nh.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(ec.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Dh.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Ri.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Oh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Sm.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Em.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Lh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Ih.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Om.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Ph.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push($h.configure(this.options.italic)),this.options.listItem!==!1&&e.push(rc.configure(this.options.listItem)),this.options.listKeymap!==!1){var t;e.push(ic.configure((t=this.options)===null||t===void 0?void 0:t.listKeymap))}if(this.options.link!==!1){var n;e.push(tm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&e.push(sc.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(bm.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(ym.configure(this.options.strike)),this.options.text!==!1&&e.push(wm.configure(this.options.text)),this.options.underline!==!1){var r;e.push(km.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;e.push(Dm.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return e}}),Lm=Ux;var eg=we(Zm(),1);var tg=eg.default;function og(e,t=[]){return e.flatMap(n=>{let r=[...t,...n.properties?n.properties.className:[]];return n.children?og(n.children,r):{text:n.value,classes:r}})}function ng(e){return e.value||e.children||[]}function $S(e){return!!tg.getLanguage(e)}function rg({doc:e,name:t,lowlight:n,defaultLanguage:r}){let o=[];return Kn(e,i=>i.type.name===t).forEach(i=>{var s;let l=i.pos+1,a=i.node.attrs.language||r,u=n.listLanguages();og(a&&(u.includes(a)||$S(a)||!((s=n.registered)===null||s===void 0)&&s.call(n,a))?ng(n.highlight(a,i.node.textContent)):ng(n.highlightAuto(i.node.textContent))).forEach(c=>{let d=l+c.text.length;if(c.classes.length){let f=Me.inline(l,d,{class:c.classes.join(" ")});o.push(f)}l=d})}),de.create(e,o)}function BS(e){return typeof e=="function"}function zS({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 U({key:new te("lowlight"),state:{init:(o,{doc:i})=>rg({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=Kn(s.doc,f=>f.type.name===e),d=Kn(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)))?rg({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 HS=Ri.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))||[],zS({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),ig=HS;var sg=ig.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 U({...e.spec,state:{...t,apply(r,o,i,s){if(r.docChanged){let l=Kn(i.doc,u=>u.type.name===n),a=Kn(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:xu,HTMLAttributes:{class:"code-block"}});var lg=uc;var _S=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,VS=ne.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",K(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=K(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(S=>S.type===b.type.name),C=Nt(b,k);return Object.keys(d).forEach(S=>{!o.has(S)&&!(S in C)&&u.removeAttribute(S)}),Object.entries(C).forEach(([S,A])=>{o.has(S)||(A!=null?u.setAttribute(S,A):u.removeAttribute(S))}),f(C.src),d=C,!0},h=new cp({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[mi({find:_S,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),ag=VS;function So(e){return e==="left"||e==="right"||e==="center"?e:null}function jS(e){let t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return So(t||n)}function FS(e){return So(e?.align)}function pg(){return{default:null,parseHTML:e=>jS(e),renderHTML:e=>{let t=So(e.align);return Sr(t)?{style:`text-align: ${t}`}:{}}}}function WS(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 hg(e){let t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):WS(e)}var KS=/[ \t\r\n\f]+/g;function mg(e){var t;return e.children.length>0?!1:((t=e.textContent)!==null&&t!==void 0?t:"").replace(KS,"")===""}function gg(e){let t=e.createAndFill();if(!t)throw new Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function Ms(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 US=ne.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:hg},align:pg()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:e=>mg(e)?{}:!1,getContent:(e,t)=>gg(t.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Ms(t,e,"colspan"),Ms(t,e,"rowspan"),["td",t,0]}}),qS=ne.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:hg},align:pg()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:e=>mg(e)?{}:!1,getContent:(e,t)=>gg(t.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return Ms(t,e,"colspan"),Ms(t,e,"rowspan"),["th",t,0]}}),GS=ne.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",K(this.options.HTMLAttributes,e),0]}});function yc(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function cg(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,S]=yc(r,b);a.style.setProperty(C,S)}a=a.nextSibling}else{let C=document.createElement("col"),[S,A]=yc(r,b);C.style.setProperty(S,A),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 wc=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")),cg(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,cg(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 JS(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]=yc(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 ug(e,t){return t?e.createChecked(null,t):e.createAndFill()}function XS(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 YS(e,t,n,r,o){let i=XS(e),s=[],l=[];for(let u=0;u<n;u+=1){let c=ug(i.cell,o);if(c&&l.push(c),r){let d=ug(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 bg(e){return e instanceof re}var Es=({editor:e})=>{let{selection:t}=e.state;if(!bg(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 dg(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(O.near(e.doc.resolve(i),-1))}function QS(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:QS(t)).join(`
|
|
140
|
+
`)}function e1(e){return(e||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function fg(e,t){return t?e.split(t).join(`
|
|
141
|
+
`):e}function t1(e){return e.replace(/\\.|\|/g,t=>t==="|"?"\\|":t)}function n1(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=>fg(t.renderChildren(C),n.cellLineSeparator)).join(`
|
|
142
|
+
`):g=fg(h.content?t.renderChildren(h.content):"",n.cellLineSeparator);let m=t1(e1(g.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),b=h.type==="tableHeader",k=FS(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
|
-
`,c+=`| ${i.map((f,p)=>{let h=Math.max(3,f),
|
|
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 r1=new te("preserveCellSelectionOnContextMenu");function o1(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 i1(e,t){let n=!1;return e.forEachCell((r,o)=>{t>=o&&t<o+r.nodeSize&&(n=!0)}),n}function s1(){return new U({key:r1,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!bg(n)||n.ranges.length<2)return!1;let r=o1(e,t);return r==null||!i1(n,r)?!1:(t.preventDefault(),!0)}}}})}var l1=ne.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:wc,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}=JS(e,this.options.cellMinWidth),i=t.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",K(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=So((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=So((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)=>n1(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=qS(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(D.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Zp(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>eh(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=kr(e.selection.$from,r=>r.type.name==="table");return th(e,t&&(r=>{n&&ag(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>rh(e,t),addRowAfter:()=>({state:e,dispatch:t})=>oh(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=kr(e.selection.$from,r=>r.type.name==="table");return ih(e,t&&(r=>{n&&ag(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>ah(e,t),mergeCells:()=>({state:e,dispatch:t})=>Ca(e,t),splitCell:()=>({state:e,dispatch:t})=>xa(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})=>lh(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Ca(e,t)?!0:xa(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>sh(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Sa(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Sa(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&va(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:Ss,"Mod-Backspace":Ss,Delete:Ss,"Mod-Delete":Ss}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[uh({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],fh({allowTableNodeSelection:this.options.allowTableNodeSelection}),n1()]},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=K(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:fe(z(e,"tableRole",t))}}}),mg=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(r1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(jS.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(FS.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(WS.configure(this.options.tableRow)),e}});var gg=bs;var bg=gs;var o1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,i1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,s1=_e.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||np(e,"background-color")||e.style.backgroundColor,renderHTML:e=>xr(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",K(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[it({find:o1,type:this.type})]},addPasteRules(){return[nt({find:i1,type:this.type})]}}),yg=s1;var wg=yg.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 l1=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=>!xr(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")}}}),kg=l1;var vg=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new U({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 yn=ye(en(),1);var pe=ye(Ze(),1);function Cg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,yn.useContext)(Bo),s=io({editor:n,selector:({editor:l})=>l.isEditable});return(0,pe.jsx)(qn,{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(Fs(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(Fs(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:$o(l)})},readOnly:!s})})}var wc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],kc=["sage","sand","blue","rose"];function xg({node:e,updateAttributes:t,editor:n}){let r=Le(He),o=io({editor:n,selector:({editor:i})=>i.isEditable});return(0,pe.jsxs)(qn,{style:nn(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:wc[(wc.indexOf(e.attrs.icon)+1)%wc.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:kc[(kc.indexOf(e.attrs.tone)+1)%kc.length]})})]}),(0,pe.jsxs)("div",{children:[e.attrs.title&&(0,pe.jsx)("strong",{children:e.attrs.title}),(0,pe.jsx)(bi,{className:"callout-content"})]})]})}function Sg({node:e,updateAttributes:t,editor:n}){let r=Le(He),o=io({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,yn.useState)(!!e.attrs.open);return(0,yn.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]),(0,pe.jsxs)(qn,{style:nn(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)(So,{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)(bi,{})})]})}function Eg({node:e,editor:t,getPos:n}){let r=Le(He),o=io({editor:t,selector:({editor:g})=>g.isEditable}),[i,s]=(0,yn.useState)(0),l=e.childCount,a=Math.min(i,l-1),u=Array.from({length:l},(g,k)=>xu(e.child(k).attrs.title,k)),c=()=>{let g=n();if(typeof g!="number")throw new Error("The stepper is detached.");return g+1},d=g=>{let k=c();for(let C=0;C<g;C+=1)k+=e.child(C).nodeSize;return k};(0,yn.useEffect)(()=>{let g=()=>{let k=n(),C=typeof k=="number"?t.state.doc.nodeAt(k):null;if(!C||C.type.name!=="stepper")return;let{from:S}=t.state.selection;if(S<=k||S>=k+C.nodeSize)return;let A=k+1;for(let E=0;E<C.childCount;E+=1)if(A+=C.child(E).nodeSize,S<A)return s(E)};return t.on("selectionUpdate",g),()=>{t.off("selectionUpdate",g)}},[t,n]);let f=g=>{let{tr:k}=t.state,C=g(k);return t.view.dispatch(k),s(C),C},p=g=>f(k=>(k.setNodeMarkup(d(a),void 0,{...e.child(a).attrs,title:g}),a)),h=()=>{f(g=>{let{schema:k}=t.state,C=d(a)+e.child(a).nodeSize;return g.insert(C,k.nodes.step.create({title:""},k.nodes.paragraph.create())),g.setSelection(D.create(g.doc,C+2)),a+1}),t.view.focus()},b=()=>f(g=>{let k=d(a);return g.delete(k,k+e.child(a).nodeSize),Math.max(0,a-1)}),m=g=>f(k=>{let C=a+g,S=e.child(a),A=d(a),E=g<0?d(C):d(C)+e.child(C).nodeSize;return k.delete(A,A+S.nodeSize),k.insert(k.mapping.map(E),S),C});return(0,pe.jsxs)(qn,{style:nn(e.attrs.componentStyle),className:"document-stepper","data-block-id":e.attrs.id??void 0,children:[(0,pe.jsx)(Su,{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:g=>p(g.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>=fu,onClick:h,children:"+"}),(0,pe.jsx)("button",{type:"button",title:r("stepper.remove"),"aria-label":r("stepper.remove"),disabled:l<=1,onClick:b,children:"\xD7"})]}),(0,pe.jsx)(bi,{className:"stepper-steps","data-active":a})]})}function Mg({node:e,updateAttributes:t,editor:n,selected:r}){let o=Le(He),i=e.type.name==="mathBlock"||e.attrs.display;return Cu(),(0,pe.jsxs)(qn,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,pe.jsx)("span",{dangerouslySetInnerHTML:{__html:uu(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 Ag({node:e}){return(0,pe.jsx)(qn,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,pe.jsx)(wu,{attrs:e.attrs})})}var Cc=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","mathInline","mathBlock"],Ms=new te("showaiBlockIds");function a1(e){let t=new Set([...Cc,"region","richText","pageModule"]);return new U({key:Ms,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta(Ms)||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(Ms,!0).setMeta("addToHistory",!1):null}})}var c1=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...Cc,"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[a1(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(Ms,!0).setMeta("addToHistory",!1))}}),u1=ne.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",K(e,{"data-showai-widget":""})],addNodeView:()=>Gn(Cg)}),d1=ne.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",K(e,{"data-callout":""}),0],addNodeView:()=>Gn(xg)}),f1=ne.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",K(e,{"data-toggle":""}),0],addNodeView:()=>Gn(Sg)}),p1=ne.create({name:"stepper",group:"block",content:"step+",defining:!0,draggable:!0,isolating:!0,parseHTML:()=>[{tag:"section[data-stepper]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-stepper":""}),0],addNodeView:()=>Gn(Eg)}),h1=ne.create({name:"step",content:"block+",defining:!0,isolating:!0,addAttributes:()=>({title:{default:""}}),parseHTML:()=>[{tag:"section[data-step]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-step":""}),0]}),m1=ne.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",K(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]}),g1=_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",K(e),0]}),b1=_e.create({name:"annotation",inclusive:!1,addAttributes:()=>({note:{default:"",parseHTML:e=>e.getAttribute("data-showai-note")??"",renderHTML:e=>({"data-showai-note":e.note??""})}}),parseHTML:()=>[{tag:"span[data-showai-note]"}],renderHTML:({HTMLAttributes:e})=>["span",K({class:"showai-note"},e),0]}),Tg=e=>ne.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:()=>Gn(Mg)}),Ng=ir(He);function Rg(e={}){return[y1,m1,g1,b1,Tg(!0),Tg(!1),c1.configure({readOnly:e.readOnly??!1}),vg,Rm.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}),rg,og.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?Ng("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??Ng("placeholderDefault"),includeChildren:!1}),ig.extend({addNodeView:()=>Gn(Ag)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),mg.configure({table:{resizable:!0,View:vc}}),gh,gg,bg.configure({nested:!0}),wg.configure({multicolor:!0}),kg.configure({types:["heading","paragraph"]}),d1,f1,p1,h1,u1]}var y1=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({...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:Cc,attributes:{name:{...e("name"),default:"",parseHTML:t=>{let n=e("name").parseHTML(t);return typeof n=="string"?n:""}}}},{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")}}]}}),vc=class extends yc{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 v=ye(Ze(),1),Og=new WeakSet,Dg=ir(He);function Lt({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 w1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function Lg(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)}function Ig(e){return e.startsWith("page-tail-")}function Sc(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 k1({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=Le(He),d=Le(Ho),f=(0,$.useRef)(t),p=(0,$.useId)();f.current=t;let h=(0,$.useRef)(null),b=(0,$.useRef)(null),m=(0,$.useRef)(null),g=(0,$.useRef)(null),k=(0,$.useRef)(null),C=(0,$.useRef)([]),S=(0,$.useRef)(()=>{}),A=(0,$.useRef)(0),E=(0,$.useRef)(null),[M,L]=(0,$.useState)(null),{useCatalog:oe,registerComponent:he,assistant:ve}=(0,$.useContext)(Bo),Ae=oe(!!M),[Ve,je]=(0,$.useState)(!1),$e=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>{$e.current++},[]);let[T,H]=(0,$.useState)(0),[I,ae]=(0,$.useState)(null),[be,Ce]=(0,$.useState)(!1),Ye=(0,$.useRef)(null),wn=(0,$.useRef)(be);wn.current=be;let Be=(0,$.useRef)(0),lt=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>cancelAnimationFrame(Be.current),[]);let wt=(0,$.useCallback)(()=>{Ye.current!==null&&(clearTimeout(Ye.current),Ye.current=null)},[]),Lr=(0,$.useCallback)(()=>{Ye.current===null&&(Ye.current=setTimeout(()=>{Ye.current=null;let y=h.current?.querySelector(".block-handle");wn.current||E.current!==null||y?.contains(document.activeElement)||ae(null)},450))},[]);(0,$.useEffect)(()=>wt,[wt]);let[Yt,Qt]=(0,$.useState)(!1),[kn,pt]=(0,$.useState)(!1),[ee,Te]=(0,$.useState)(null),[Ir,Oe]=(0,$.useState)(""),[nr,xt]=(0,$.useState)(""),[q,at]=(0,$.useState)(null),Se=(0,$.useRef)(null),ie=(0,$.useRef)(!1),[,vn]=(0,$.useState)(0),Qe=(0,$.useRef)(null);g.current=M,A.current=T;let Pr=(0,$.useMemo)(()=>[...Rg({placeholder:({empty:y})=>Dg(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,$.useLayoutEffect)(()=>{if(!be)return;let y=h.current,x=y?.querySelector(".block-menu"),R=y?.querySelector(".block-handle");if(!x||!R)return;let P=()=>{let G=R.getBoundingClientRect(),ue=x.getBoundingClientRect();Object.assign(x.style,{position:"fixed",left:`${Math.max(12,Math.min(G.right,window.innerWidth-ue.width-12))}px`,top:`${Math.max(12,Math.min(G.top,window.innerHeight-ue.height-12))}px`})};P();let _=new ResizeObserver(P);return _.observe(x),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{_.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[be,I?.pos]);let w=Lp({retentionKey:u,extensions:Pr,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":Dg("documentContent"),spellcheck:"false"},handleKeyDown:(y,x)=>{if(x.isComposing)return!1;if(x.key==="Escape"&&!g.current&&!y.state.selection.empty)return Se.current=`${y.state.selection.from}:${y.state.selection.to}`,at(null),x.preventDefault(),!0;if(!g.current)return!1;if(x.key==="Escape")return J(),!0;if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let R=C.current.length;return H(P=>R?(P+(x.key==="ArrowDown"?1:-1)+R)%R:0),!0}return x.key==="Enter"&&C.current.length?(S.current(A.current),!0):!1},handleClick:(y,x,R)=>{let P=R.target.closest?.("a[href]");if(!P||!n&&!R.metaKey&&!R.ctrlKey)return!1;let _=P.getAttribute("href")??"";return Lg(_)&&(_.startsWith("#")?document.getElementById(_.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(_,"_blank","noopener,noreferrer")),!0},handlePaste:(y,x)=>{let R=[...x.clipboardData?.files??[]].filter(P=>P.type.startsWith("image/"));return R.length?(x.preventDefault(),ct(R),!0):!1}},onUpdate:({editor:y,transaction:x})=>f.current(fa(y.state.doc),{separateHistory:!!x.getMeta(Xn),historyGroup:x.getMeta(mu)})});(0,$.useEffect)(()=>w?gu(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))),vn(y=>y+1),n&&(L(null),ae(null),Ce(!1),Qt(!1),pt(!1),Te(null),at(null))},[w,n]);let O=(0,$.useRef)(e);O.current=e;let B=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!w)return;let y=()=>{B.current=!0},x=()=>{B.current=!1};return w.on("beforeTransaction",y),w.on("transaction",x),()=>{w.off("beforeTransaction",y),w.off("transaction",x)}},[w]),(0,$.useLayoutEffect)(()=>{if(!w)return;let y,x=()=>{if(w.isDestroyed)return;if(w.view.composing||B.current){y=setTimeout(x,B.current?0:25);return}let P=zp(w.state,O.current);if(!P)return;let _=w.state.selection instanceof j&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,G=w.state.selection instanceof re?w.state.selection:null;if(w.view.dispatch(P),G){let ue=hh(w.state.doc,G);ue&&w.view.dispatch(w.state.tr.setSelection(ue))}if(_){let ue;if(w.state.doc.descendants((ke,Q)=>{ke.type.name==="widget"&&ke.attrs.id===_&&(ue=Q)}),ue!==void 0)w.commands.setNodeSelection(ue);else{let ke=Mr(w.state);ke&&w.view.dispatch(ke)}}},R=()=>{y=setTimeout(x,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",R):x(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",R)}},[e,w]),(0,$.useEffect)(()=>{if(!ee)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),x=R=>{if(R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),Te(null),w?.commands.focus()),R.key!=="Tab")return;let P=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),_=P[0],G=P[P.length-1];R.shiftKey&&document.activeElement===_?(R.preventDefault(),G?.focus()):!R.shiftKey&&document.activeElement===G&&(R.preventDefault(),_?.focus())};return document.addEventListener("keydown",x,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",x,!0)}},[!!ee,w]),(0,$.useEffect)(()=>{if(!w||n)return;let y=()=>{let R=Mr(w.state);R&&w.view.dispatch(R)};!Og.has(w)&&!Dp(w)&&(Og.add(w),w.isInitialized?y():w.on("create",y));let x=R=>{if(R.button!==0||!(R.target instanceof Element))return;let P=R.target,_=P.closest(".document-widget");if(_&&w.view.dom.contains(_)||!_&&P.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let G=Mr(w.state);if(!G)return;let ue=document.activeElement;ue instanceof HTMLElement&&w.view.dom.contains(ue)&&ue.blur(),w.view.dispatch(G),w.view.dom.contains(P)&&!P.closest("[data-block-id]")&&R.preventDefault()};return document.addEventListener("pointerdown",x,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",x,!0)}},[w,n]),(0,$.useEffect)(()=>{if(!M?.manual)return;let y=requestAnimationFrame(()=>m.current?.focus());return()=>cancelAnimationFrame(y)},[M?.manual]),(0,$.useEffect)(()=>{if(!Yt&&!kn&&!be)return;let y=x=>{x.key==="Escape"&&(x.preventDefault(),Qt(!1),pt(!1),Ce(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[Yt,kn,be,w]),(0,$.useEffect)(()=>{if(!nr)return;let y=window.setTimeout(()=>xt(""),4500);return()=>window.clearTimeout(y)},[nr]),(0,$.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&vn(Sn=>Sn+1),!w.isEditable)return;let{selection:Q}=w.state,{$from:ze,from:Cn,to:Zt,empty:xn}=Q;if((xn||Se.current&&Se.current!==`${Cn}:${Zt}`)&&(Se.current=null),!g.current?.manual){let Sn=ze.parent.isTextblock?ze.parent.textBetween(0,ze.parentOffset,`
|
|
154
|
-
`):"",En=xn&&Sn.match(/^\/([^\n/]*)$/);if(En){let Rc=Cn-En[0].length;k.current!==`${Rc}:${Zt}:${En[1]}`&&(k.current=null,L({from:Rc,to:Zt,query:En[1],...Sc(w,Cn)}))}else L(null),k.current=null}if(!xn&&Se.current!==`${Cn}:${Zt}`&&(w.isFocused||ie.current)&&!w.isActive("codeBlock")&&!w.isActive("widget")&&!w.isActive("pageModule")){let Sn=w.view.coordsAtPos(Cn),En=w.view.coordsAtPos(Zt);at({left:(Sn.left+En.right)/2,top:Sn.top,bottom:Math.max(Sn.bottom,En.bottom)})}else at(null)},x=Q=>Q instanceof Element&&Q.closest(".editor-bubble")?.id===p,R=Q=>{x(Q.relatedTarget)&&(ie.current=!0)},P=()=>{ie.current=!1,at(null)},_=Q=>{ie.current=x(Q.target),!ie.current&&(!(Q.target instanceof Node)||!w.view.dom.contains(Q.target))&&P()},G=({event:Q})=>{!ie.current&&!x(Q.relatedTarget)&&P()},ue=Q=>{x(Q.target)||P()},ke=Q=>{!(Q.target instanceof Element)||!Q.target.contains(w.view.dom)||(at(null),L(null),Ce(!1),ae(null))};return w.on("transaction",y),w.on("focus",y),w.on("blur",G),w.view.dom.addEventListener("blur",R,!0),document.addEventListener("pointerdown",_,!0),document.addEventListener("focusin",_,!0),w.view.dom.addEventListener("contextmenu",P),window.addEventListener("scroll",ue,!0),window.addEventListener("resize",y),window.addEventListener("showai:viewport-change",ke),()=>{w.off("transaction",y),w.off("focus",y),w.off("blur",G),w.view.dom.removeEventListener("blur",R,!0),document.removeEventListener("pointerdown",_,!0),document.removeEventListener("focusin",_,!0),w.view.dom.removeEventListener("contextmenu",P),window.removeEventListener("scroll",ue,!0),window.removeEventListener("resize",y),window.removeEventListener("showai:viewport-change",ke)}},[w,p,r]),(0,$.useEffect)(()=>H(0),[M?.query]),(0,$.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[T]);function J(){let y=g.current;y&&!y.manual&&(k.current=`${y.from}:${y.to}:${y.query}`),g.current=null,L(null)}let se=(0,$.useCallback)(y=>{if(!w)return;let{selection:x}=w.state;Qe.current={from:x.from,to:x.to};let R=y==="note"&&x instanceof j&&["mathInline","mathBlock"].includes(x.node.type.name)?x.node:null,P=R?cu(String(R.attrs.latex??"")):null;Te({type:y,value:y==="link"?w.getAttributes("link").href??"":y==="note"?R?P?.note??"":w.getAttributes("annotation").note??"":"",alt:"",hadNote:y==="note"&&(R?!!P:w.isActive("annotation")),...R?{math:{pos:x.from,body:P?.body??String(R.attrs.latex??"")}}:{}}),Oe(""),pt(!1),at(null)},[w]);function De(y,x){if(!w)return!1;if(x.length>1e3)return Oe(d("dialog.noteTooLong",{max:1e3})),!1;if(y.math){let{pos:P,body:_}=y.math,G=w.state.doc.nodeAt(P);return!G||!["mathInline","mathBlock"].includes(G.type.name)?(Oe(d("dialog.noteTargetMissing")),!1):(w.chain().focus().command(({tr:ue})=>(ue.setNodeMarkup(P,void 0,{...G.attrs,latex:x?au(_,x):_}),!0)).run(),!0)}if(Qe.current&&w.commands.setTextSelection(Qe.current),w.state.selection.empty&&!w.isActive("annotation"))return Oe(d("dialog.noteNeedsSelection")),!1;let R=w.chain().focus();return w.state.selection.empty&&R.extendMarkRange("annotation"),x?R.setMark("annotation",{note:x}):R.unsetMark("annotation"),R.run(),!0}async function ct(y,x=!1){if(!w||!w.isEditable)return;x&&Qe.current&&w.commands.setTextSelection(Qe.current);let R=w.state.selection.getBookmark(),P=({transaction:_})=>{R=R.map(_.mapping)};w.on("transaction",P);for(let _ of y){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(_.type)){xt(c("notice.imageTypes"));continue}if(_.size>zs.resourceBytes){xt(c("notice.imageTooLarge",{name:_.name,size:Hs(_.size),limit:Hs(zs.resourceBytes)}));continue}let G;try{G=await new Promise((ke,Q)=>{let ze=new FileReader;ze.onload=()=>ke(String(ze.result)),ze.onerror=()=>Q(ze.error),ze.onabort=()=>Q(new Error(c("notice.readCancelled"))),ze.readAsDataURL(_)})}catch{xt(c("notice.imageUnreadable",{name:_.name}));continue}if(w.isDestroyed||!w.isEditable)break;let ue=R.resolve(w.state.doc);w.view.dispatch(w.state.tr.setSelection(ue)),w.chain().focus().setImage({src:G,alt:_.name}).run(),R=w.state.selection.getBookmark()}w.off("transaction",P),Te(null)}let $r=(0,$.useMemo)(()=>[{id:"text",title:c("block.text"),keywords:`text paragraph ${c("block.textKeywords")}`,icon:(0,v.jsx)(No,{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)(Wc,{size:20}):y===2?(0,v.jsx)(Kc,{size:20}):(0,v.jsx)(Uc,{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,v.jsx)(Rs,{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)(Ns,{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)(Ls,{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)(Os,{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)(Jc,{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)(So,{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)(Lc,{size:20}),group:c("group.basic"),run:y=>{let x={type:"step",content:[{type:"paragraph"}]},{from:R}=y.state.selection;y.chain().focus().insertContent({type:"stepper",content:[x,x]}).command(({tr:P})=>{let _=-1;return P.doc.nodesBetween(Math.max(0,R-1),P.doc.content.size,(G,ue)=>(_<0&&G.type.name==="stepper"&&(_=ue),_<0)),_>=0&&P.setSelection(D.create(P.doc,_+3)),!0}).run()}},{id:"divider",title:c("block.divider"),keywords:`divider hr ${c("block.dividerKeywords")}`,icon:(0,v.jsx)(Xc,{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)(Eo,{size:20}),group:c("group.rich"),run:()=>se("image")},{id:"code",title:c("block.code"),keywords:`code snippet ${c("block.codeKeywords")}`,icon:(0,v.jsx)(Bc,{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)(Is,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...Ae.items.filter(y=>("kind"in y||y.role!=="page-outline")&&!("kind"in y&&_s[y.kind])&&(!("kind"in y&&y.insertion)||!!i)).map(y=>({id:"catalog:"+("kind"in y?y.kind:`${y.id}@${y.version}#${y.integrity}`),title:Ae.displayName(y),keywords:`${"kind"in y?y.kind:y.id} ${y.name} ${y.description} ${Ae.displayDescription(y)}`,icon:(0,v.jsx)(Yc,{size:20}),group:c("group.components"),component:y,run:()=>{}}))],[se,i,Ae.items,Ae.displayName,Ae.displayDescription,c]),It=$r.filter(y=>`${y.title} ${y.keywords}`.toLowerCase().includes(M?.query.toLowerCase()??""));C.current=It;let As=async y=>{let x=g.current,R=C.current[y];if(!(!w||!x||!R||Ve)){if(R.component){let P=w.state.doc,_=++$e.current;je(!0);try{let G=await Ae.resolve(R.component);if(_!==$e.current||w.isDestroyed||g.current!==x||!w.state.doc.eq(P))return;if(L(null),g.current=null,G.component&&he(G.component),G.native&&i){let ue=w.state.tr.delete(x.from,x.to);i(G.kind,G.data,Nu(ue.doc,x.from))}else w.chain().focus().deleteRange({from:x.from,to:x.to}).insertContent({..._s[G.kind]?du(G.kind,G.data):{type:"widget",attrs:{kind:G.kind,data:G.data}}}).run()}catch(G){xt(G.message)}finally{_===$e.current&&je(!1)}return}L(null),g.current=null,x.from!==x.to?w.chain().focus().deleteRange({from:x.from,to:x.to}).run():w.commands.focus(),R.run(w)}};S.current=As;let Mc=()=>{if(!w)return;k.current=null;let{from:y,to:x}=w.state.selection;L({from:y,to:x,query:"",manual:!0,...Sc(w,y)}),H(0),pt(!1)},Pg=()=>{if(!w||!I)return;let y=I.pos+I.size;w.chain().focus().insertContentAt(y,{type:"paragraph"}).setTextSelection(y+1).run(),L({from:y+1,to:y+1,query:"",manual:!0,...Sc(w,y+1)}),Ce(!1)};function Ac(y,x){if(!w)return;let R=[];w.state.doc.forEach((Q,ze)=>R.push({pos:ze,size:Q.nodeSize}));let P=R.findIndex(Q=>Q.pos===y),_=R[P+x],G=w.state.doc.nodeAt(y);if(!_||!G)return;let ue=x===-1?_.pos:_.pos+_.size-G.nodeSize,ke=w.state.tr.delete(y,y+G.nodeSize).insert(ue,G);ke.setSelection(X.near(ke.doc.resolve(ue+1))),w.view.dispatch(ke),w.view.focus(),Ce(!1),ae(null)}function $g(y){if(!w||!w.isEditable)return;let x=E.current;if(x!==null){y.preventDefault(),y.stopPropagation(),E.current=null,ae(null);let P=w.state.doc.nodeAt(x);if(!P)return;let _=w.state.doc.content.size,G=!1;if(w.state.doc.forEach((ue,ke)=>{let Q=w.view.nodeDOM(ke);if(!(Q instanceof HTMLElement)||G)return;let ze=Q.getBoundingClientRect();y.clientY<ze.top+ze.height/2&&(_=ke,G=!0)}),_!==x&&_!==x+P.nodeSize){let ue=_>x?_-P.nodeSize:_,ke=w.state.tr.delete(x,x+P.nodeSize).insert(ue,P);ke.setSelection(X.near(ke.doc.resolve(ue+1))),w.view.dispatch(ke)}return}let R=[...y.dataTransfer.files].filter(P=>P.type.startsWith("image/"));if(R.length){y.preventDefault(),y.stopPropagation();let P=w.view.posAtCoords({left:y.clientX,top:y.clientY});P&&w.commands.setTextSelection(P.pos),ct(R)}}if(!w)return(0,v.jsx)("div",{className:"editor-loading","aria-label":c("openingDocument")});let Bg=w.isActive("heading")?c("block.heading",{level:w.getAttributes("heading").level}):c("block.text"),Tc=q&&ve?wi(w.state.doc,w.state.selection.from,w.state.selection.to).length:0,Nc=(!r||q)&&(0,v.jsx)(Ch,{editor:w,onLink:()=>se("link"),onNote:()=>se("note")});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:()=>{Qt(!Yt),pt(!1)},"aria-expanded":Yt,children:[Bg,(0,v.jsx)(Br,{size:13})]}),Yt&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Qt(!1)}),(0,v.jsx)("div",{className:"editor-small-menu style-menu",children:$r.slice(0,7).map(y=>(0,v.jsxs)("button",{onMouseDown:x=>x.preventDefault(),onClick:()=>{y.run(w),Qt(!1)},children:[y.icon,(0,v.jsx)("span",{children:y.title})]},y.id))})]})]}),(0,v.jsx)("span",{className:"toolbar-divider"}),Nc,(0,v.jsx)("span",{className:"toolbar-divider"}),(0,v.jsx)(Lt,{label:c("block.bullet"),active:w.isActive("bulletList"),onClick:()=>w.chain().focus().toggleBulletList().run(),children:(0,v.jsx)(Rs,{size:17})}),(0,v.jsx)(Lt,{label:c("block.todo"),active:w.isActive("taskList"),onClick:()=>w.chain().focus().toggleTaskList().run(),children:(0,v.jsx)(Ls,{size:16})}),(0,v.jsxs)("div",{className:"toolbar-insert",children:[(0,v.jsx)(Lt,{label:c("format.more"),active:kn,onClick:()=>{pt(!kn),Qt(!1)},children:(0,v.jsx)(tn,{size:17})}),kn&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>pt(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,v.jsxs)("button",{onClick:Mc,children:[(0,v.jsx)(tn,{size:16}),c("insert.content"),(0,v.jsx)("span",{className:"menu-key",children:"/"})]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleOrderedList().run(),pt(!1)},children:[(0,v.jsx)(Ns,{size:16}),c("block.ordered")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleBlockquote().run(),pt(!1)},children:[(0,v.jsx)(Os,{size:16}),c("block.quote")]}),(0,v.jsxs)("button",{onClick:()=>se("image"),children:[(0,v.jsx)(Eo,{size:16}),c("insert.image")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),pt(!1)},children:[(0,v.jsx)(Is,{size:16}),c("insert.table")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("div",{className:"align-tools",children:[(0,v.jsx)(Lt,{label:c("format.alignLeft"),active:w.isActive({textAlign:"left"}),onClick:()=>w.chain().focus().setTextAlign("left").run(),children:(0,v.jsx)(Tn,{size:17})}),(0,v.jsx)(Lt,{label:c("format.alignCenter"),active:w.isActive({textAlign:"center"}),onClick:()=>w.chain().focus().setTextAlign("center").run(),children:(0,v.jsx)(Mn,{size:17})}),(0,v.jsx)(Lt,{label:c("format.alignRight"),active:w.isActive({textAlign:"right"}),onClick:()=>w.chain().focus().setTextAlign("right").run(),children:(0,v.jsx)(An,{size:17})})]})]})]})]}),(0,v.jsx)("div",{className:"toolbar-spacer"}),(0,v.jsx)(Lt,{label:c("format.undo"),disabled:!w.can().undo(),onClick:()=>w.chain().focus().undo().run(),children:(0,v.jsx)(su,{size:16})}),(0,v.jsx)(Lt,{label:c("format.redo"),disabled:!w.can().redo(),onClick:()=>w.chain().focus().redo().run(),children:(0,v.jsx)(Qc,{size:16})})]}),(0,v.jsxs)("div",{className:"editor-canvas",ref:h,onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.shiftKey&&y.key.toLowerCase()==="k"&&!n&&(y.preventDefault(),y.stopPropagation(),se("link"))},onMouseEnter:wt,onMouseMove:y=>{if(n||be||E.current!==null)return;if(y.target.closest(".block-handle")){wt();return}let x=h.current;x&&y.target.closest(".document-editor")===x.closest(".document-editor")&&(lt.current=y.clientY,!Be.current&&(Be.current=requestAnimationFrame(()=>{Be.current=0;let R=h.current;if(!R||E.current!==null||w.isDestroyed)return;let P=lt.current,_=R.getBoundingClientRect(),G=_.width/R.offsetWidth||1,ue=null;w.state.doc.forEach((Q,ze,Cn)=>{let Zt=w.view.nodeDOM(ze);if(!(Zt instanceof HTMLElement))return;let xn=Zt.getBoundingClientRect();P>=xn.top-3&&P<=xn.bottom+3&&(ue={pos:ze,size:Q.nodeSize,index:Cn,top:(xn.top-_.top)/G})});let ke=ue;ke?(wt(),ae(Q=>Q&&Q.pos===ke.pos&&Q.size===ke.size&&Q.index===ke.index&&Math.abs(Q.top-ke.top)<.5?Q:ke)):Lr()})))},onMouseLeave:Lr,onDragOver:y=>{(E.current!==null||[...y.dataTransfer.types].includes("Files"))&&y.preventDefault()},onDropCapture:$g,children:[(0,v.jsx)(yi,{editor:w}),!n&&(0,v.jsx)(vh,{editor:w}),!n&&I&&(0,v.jsxs)("div",{className:"block-handle",style:{top:I.top},onMouseEnter:wt,onFocus:wt,children:[(0,v.jsx)("button",{"aria-label":c("insert.addBelow"),title:c("insert.addContent"),onMouseDown:y=>y.preventDefault(),onClick:Pg,children:(0,v.jsx)(tn,{size:15})}),(0,v.jsx)("button",{"aria-label":c("block.handle"),title:c("block.handleTitle"),draggable:!0,onDragStart:y=>{wt(),E.current=I.pos,y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("application/x-showai-block",String(I.pos));let x=w.view.nodeDOM(I.pos);x instanceof HTMLElement&&y.dataTransfer.setDragImage(x,0,0),Ce(!1)},onDragEnd:()=>{E.current=null},onClick:()=>Ce(!be),children:(0,v.jsx)(Fc,{size:15})}),be&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Ce(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(w.state.doc.nodeAt(I.pos)?.type.name??"")&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"align-tools",role:"group","aria-label":c("block.style"),children:$r.slice(0,7).map((y,x)=>(0,v.jsx)(Lt,{label:y.title,active:x===0?w.state.doc.nodeAt(I.pos)?.type.name==="paragraph":w.state.doc.nodeAt(I.pos)?.attrs.level===x,onClick:()=>{w.chain().focus().setTextSelection(I.pos+1).run(),y.run(w),Ce(!1)},children:y.icon},y.id))}),(0,v.jsx)("div",{className:"align-tools",children:[["left",c("format.alignLeft"),(0,v.jsx)(Tn,{size:16},"left")],["center",c("format.alignCenter"),(0,v.jsx)(Mn,{size:16},"center")],["right",c("format.alignRight"),(0,v.jsx)(An,{size:16},"right")]].map(([y,x,R])=>(0,v.jsx)(Lt,{label:x,active:w.state.doc.nodeAt(I.pos)?.attrs.textAlign===y,onClick:()=>{w.chain().focus().setTextSelection(I.pos+1).setTextAlign(y).run(),Ce(!1)},children:R},y))}),(0,v.jsx)("div",{className:"menu-rule"})]}),(0,v.jsx)(Tu,{editor:w,position:I.pos}),s&&(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(I.pos);y&&s(y.toJSON()),Ce(!1),ae(null)},children:[(0,v.jsx)(Vc,{size:15}),c("block.detach")]}),(0,v.jsxs)("button",{disabled:I.index===0,onClick:()=>Ac(I.pos,-1),children:[(0,v.jsx)(Ic,{size:15}),c("block.moveUp")]}),(0,v.jsxs)("button",{disabled:I.index===w.state.doc.childCount-1,onClick:()=>Ac(I.pos,1),children:[(0,v.jsx)(Dc,{size:15}),c("block.moveDown")]}),(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(I.pos);y&&w.chain().focus().insertContentAt(I.pos+y.nodeSize,y.toJSON()).run(),Ce(!1)},children:[(0,v.jsx)(Hc,{size:15}),c("block.duplicate")]}),ve&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(I.pos)?.attrs.id,R=y.currentTarget.closest(".block-handle").getBoundingClientRect();Ce(!1),typeof x=="string"&&!Ig(x)&&ve.open({kind:"blocks",blockIds:[x],anchor:{left:R.right+160,top:R.top,bottom:R.bottom}})},children:[(0,v.jsx)(Ds,{size:15}),c("assistant.askBlock")]}),ve&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(I.pos)?.attrs.id,R=y.currentTarget.closest(".block-handle").getBoundingClientRect();Ce(!1),typeof x=="string"&&!Ig(x)&&ve.reference({kind:"blocks",blockIds:[x],anchor:{left:R.right,top:R.top,bottom:R.bottom}})},children:[(0,v.jsx)(Ts,{size:15}),c("assistant.referenceBlock")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("button",{className:"danger",onClick:()=>{w.chain().focus().deleteRange({from:I.pos,to:I.pos+I.size}).run(),Ce(!1),ae(null)},children:[(0,v.jsx)(To,{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(),Mc()},children:[(0,v.jsx)(tn,{size:15}),(0,v.jsx)("span",{children:c("insert.addContent")}),(0,v.jsx)("kbd",{children:"/"})]}),(0,v.jsx)("input",{ref:b,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&&ct([x],!0),y.target.value=""}}),nr&&(0,v.jsxs)("div",{className:"editor-notice",role:"status",children:[nr,(0,v.jsx)("button",{"aria-label":c("dismissNotice"),onClick:()=>xt(""),children:(0,v.jsx)(zr,{size:14})})]}),q&&!n&&(0,v.jsxs)(Eu,{id:p,className:"rich-text-selection-toolbar",anchor:q,viewportTop:Math.max(0,...Array.from(h.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],y=>y.getBoundingClientRect().bottom))+8,onEscape:()=>{ie.current=!1,Se.current=`${w.state.selection.from}:${w.state.selection.to}`,w.state.selection instanceof re&&w.view.dispatch(w.state.tr.setSelection(D.near(w.state.selection.$from))),at(null),w.view.focus()},children:[Nc,(0,v.jsx)(Ai,{editor:w}),ve&&(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:x}=w.state.selection,R=q;ie.current=!1,at(null),ve.open({kind:"text",blockIds:wi(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
|
|
155
|
-
`),anchor:R})},children:[(0,v.jsx)(
|
|
156
|
-
`),anchor:R})},children:(0,v.jsx)(
|
|
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=YS(i.schema,e,t,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(O.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>nh(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>rh(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vr(e.selection.$from,r=>r.type.name==="table");return oh(e,t&&(r=>{n&&dg(r,n.pos),t(r)}))},addRowBefore:()=>({state:e,dispatch:t})=>sh(e,t),addRowAfter:()=>({state:e,dispatch:t})=>lh(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vr(e.selection.$from,r=>r.type.name==="table");return ah(e,t&&(r=>{n&&dg(r,n.pos),t(r)}))},deleteTable:()=>({state:e,dispatch:t})=>dh(e,t),mergeCells:()=>({state:e,dispatch:t})=>xa(e,t),splitCell:()=>({state:e,dispatch:t})=>Sa(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})=>uh(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>xa(e,t)?!0:Sa(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>ch(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ea(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ea(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Ca(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:Es,"Mod-Backspace":Es,Delete:Es,"Mod-Delete":Es}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ph({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],mh({allowTableNodeSelection:this.options.allowTableNodeSelection}),s1()]},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=K(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:fe(z(e,"tableRole",t))}}}),yg=le.create({name:"tableKit",addExtensions(){let e=[];return this.options.table!==!1&&e.push(l1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(US.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(qS.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(GS.configure(this.options.tableRow)),e}});var wg=ys;var kg=bs;var a1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,c1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,u1=_e.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||ip(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",K(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[it({find:a1,type:this.type})]},addPasteRules(){return[nt({find:c1,type:this.type})]}}),vg=u1;var Cg=vg.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 d1=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")}}}),xg=d1;var Sg=le.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new U({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 yn=we(en(),1);var pe=we(Ze(),1);function Eg({node:e,updateAttributes:t,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,yn.useContext)(zo),s=so({editor:n,selector:({editor:l})=>l.isEditable});return(0,pe.jsx)(qn,{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(Ws(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(Ws(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:Bo(l)})},readOnly:!s})})}var kc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],vc=["sage","sand","blue","rose"];function Mg({node:e,updateAttributes:t,editor:n}){let r=Le(He),o=so({editor:n,selector:({editor:i})=>i.isEditable});return(0,pe.jsxs)(qn,{style:nn(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:kc[(kc.indexOf(e.attrs.icon)+1)%kc.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:vc[(vc.indexOf(e.attrs.tone)+1)%vc.length]})})]}),(0,pe.jsxs)("div",{children:[e.attrs.title&&(0,pe.jsx)("strong",{children:e.attrs.title}),(0,pe.jsx)(yi,{className:"callout-content"})]})]})}function Ag({node:e,updateAttributes:t,editor:n}){let r=Le(He),o=so({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,yn.useState)(!!e.attrs.open);return(0,yn.useEffect)(()=>s(!!e.attrs.open),[e.attrs.open]),(0,pe.jsxs)(qn,{style:nn(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)(Eo,{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)(yi,{})})]})}function Tg({node:e,editor:t,getPos:n}){let r=Le(He),o=so({editor:t,selector:({editor:b})=>b.isEditable}),[i,s]=(0,yn.useState)(0),l=e.childCount,a=Math.min(i,l-1),u=Array.from({length:l},(b,k)=>Eu(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,yn.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:S}=t.state.selection;if(S<=k||S>=k+C.nodeSize)return;let A=k+1;for(let E=0;E<C.childCount;E+=1)if(A+=C.child(E).nodeSize,S<A)return s(E)};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(O.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,S=e.child(a),A=d(a),E=b<0?d(C):d(C)+e.child(C).nodeSize;return k.delete(A,A+S.nodeSize),k.insert(k.mapping.map(E),S),C});return(0,pe.jsxs)(qn,{style:nn(e.attrs.componentStyle),className:"document-stepper","data-block-id":e.attrs.id??void 0,children:[(0,pe.jsx)(Mu,{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>=hu,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)(yi,{className:"stepper-steps","data-active":a})]})}function Ng({node:e,updateAttributes:t,editor:n,selected:r}){let o=Le(He),i=e.type.name==="mathBlock"||e.attrs.display;return Su(),(0,pe.jsxs)(qn,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,pe.jsx)("span",{dangerouslySetInnerHTML:{__html:fu(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 Rg({node:e}){return(0,pe.jsx)(qn,{"data-block-id":e.attrs.id,"data-drag-handle":!0,contentEditable:!1,children:(0,pe.jsx)(vu,{attrs:e.attrs})})}var xc=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","stepper","step","widget","mathInline","mathBlock"],As=new te("showaiBlockIds");function f1(e){let t=new Set([...xc,"region","richText","pageModule"]);return new U({key:As,appendTransaction(n,r,o){if(!e()||!n.some(l=>l.docChanged||l.getMeta(As)||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(As,!0).setMeta("addToHistory",!1):null}})}var p1=le.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...xc,"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[f1(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(As,!0).setMeta("addToHistory",!1))}}),h1=ne.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",K(e,{"data-showai-widget":""})],addNodeView:()=>Gn(Eg)}),m1=ne.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",K(e,{"data-callout":""}),0],addNodeView:()=>Gn(Mg)}),g1=ne.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",K(e,{"data-toggle":""}),0],addNodeView:()=>Gn(Ag)}),b1=ne.create({name:"stepper",group:"block",content:"step+",defining:!0,draggable:!0,isolating:!0,parseHTML:()=>[{tag:"section[data-stepper]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-stepper":""}),0],addNodeView:()=>Gn(Tg)}),y1=ne.create({name:"step",content:"block+",defining:!0,isolating:!0,addAttributes:()=>({title:{default:""}}),parseHTML:()=>[{tag:"section[data-step]"}],renderHTML:({HTMLAttributes:e})=>["section",K(e,{"data-step":""}),0]}),w1=ne.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",K(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]}),k1=_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",K(e),0]}),v1=_e.create({name:"annotation",inclusive:!1,addAttributes:()=>({note:{default:"",parseHTML:e=>e.getAttribute("data-showai-note")??"",renderHTML:e=>({"data-showai-note":e.note??""})}}),parseHTML:()=>[{tag:"span[data-showai-note]"}],renderHTML:({HTMLAttributes:e})=>["span",K({class:"showai-note"},e),0]}),Dg=e=>ne.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:()=>Gn(Ng)}),Og=sr(He);function Lg(e={}){return[C1,w1,k1,v1,Dg(!0),Dg(!1),p1.configure({readOnly:e.readOnly??!1}),Sg,Lm.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}),sg,lg.configure({placeholder:({node:t,editor:n})=>t.type.name==="heading"?Og("placeholderHeading"):typeof e.placeholder=="function"?e.placeholder({empty:n.isEmpty}):e.placeholder??Og("placeholderDefault"),includeChildren:!1}),ag.extend({addNodeView:()=>Gn(Rg)}).configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),yg.configure({table:{resizable:!0,View:Cc}}),wh,wg,kg.configure({nested:!0}),Cg.configure({multicolor:!0}),xg.configure({types:["heading","paragraph"]}),m1,g1,b1,y1,h1]}var C1=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({...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:xc,attributes:{name:{...e("name"),default:"",parseHTML:t=>{let n=e("name").parseHTML(t);return typeof n=="string"?n:""}}}},{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")}}]}}),Cc=class extends wc{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 v=we(Ze(),1),Ig=new WeakSet,Pg=sr(He);function Lt({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 x1(e){return/^https?:\/\//i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(e)}function $g(e){return/^(https?:\/\/|mailto:|tel:|#)/i.test(e)}function Bg(e){return e.startsWith("page-tail-")}function Ec(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 S1({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=Le(He),d=Le(_o),f=(0,$.useRef)(t),p=(0,$.useId)();f.current=t;let h=(0,$.useRef)(null),g=(0,$.useRef)(null),m=(0,$.useRef)(null),b=(0,$.useRef)(null),k=(0,$.useRef)(null),C=(0,$.useRef)([]),S=(0,$.useRef)(()=>{}),A=(0,$.useRef)(0),E=(0,$.useRef)(null),[M,L]=(0,$.useState)(null),{useCatalog:oe,registerComponent:he,assistant:Ce}=(0,$.useContext)(zo),Ae=oe(!!M),[Ve,je]=(0,$.useState)(!1),$e=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>{$e.current++},[]);let[T,H]=(0,$.useState)(0),[I,ae]=(0,$.useState)(null),[ye,ke]=(0,$.useState)(!1),Ye=(0,$.useRef)(null),wn=(0,$.useRef)(ye);wn.current=ye;let Be=(0,$.useRef)(0),lt=(0,$.useRef)(0);(0,$.useEffect)(()=>()=>cancelAnimationFrame(Be.current),[]);let wt=(0,$.useCallback)(()=>{Ye.current!==null&&(clearTimeout(Ye.current),Ye.current=null)},[]),Ir=(0,$.useCallback)(()=>{Ye.current===null&&(Ye.current=setTimeout(()=>{Ye.current=null;let y=h.current?.querySelector(".block-handle");wn.current||E.current!==null||y?.contains(document.activeElement)||ae(null)},450))},[]);(0,$.useEffect)(()=>wt,[wt]);let[Yt,Qt]=(0,$.useState)(!1),[kn,pt]=(0,$.useState)(!1),[ee,Te]=(0,$.useState)(null),[Pr,De]=(0,$.useState)(""),[rr,xt]=(0,$.useState)(""),[q,at]=(0,$.useState)(null),Se=(0,$.useRef)(null),ie=(0,$.useRef)(!1),[,vn]=(0,$.useState)(0),Qe=(0,$.useRef)(null);b.current=M,A.current=T;let $r=(0,$.useMemo)(()=>[...Lg({placeholder:({empty:y})=>Pg(y&&!a?"placeholderPage":"placeholder"),trailingNode:a}),...l??[]],[l,a]);(0,$.useLayoutEffect)(()=>{if(!ye)return;let y=h.current,x=y?.querySelector(".block-menu"),R=y?.querySelector(".block-handle");if(!x||!R)return;let P=()=>{let G=R.getBoundingClientRect(),ue=x.getBoundingClientRect();Object.assign(x.style,{position:"fixed",left:`${Math.max(12,Math.min(G.right,window.innerWidth-ue.width-12))}px`,top:`${Math.max(12,Math.min(G.top,window.innerHeight-ue.height-12))}px`})};P();let _=new ResizeObserver(P);return _.observe(x),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{_.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[ye,I?.pos]);let w=$p({retentionKey:u,extensions:$r,content:e,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":Pg("documentContent"),spellcheck:"false"},handleKeyDown:(y,x)=>{if(x.isComposing)return!1;if(x.key==="Escape"&&!b.current&&!y.state.selection.empty)return Se.current=`${y.state.selection.from}:${y.state.selection.to}`,at(null),x.preventDefault(),!0;if(!b.current)return!1;if(x.key==="Escape")return J(),!0;if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let R=C.current.length;return H(P=>R?(P+(x.key==="ArrowDown"?1:-1)+R)%R:0),!0}return x.key==="Enter"&&C.current.length?(S.current(A.current),!0):!1},handleClick:(y,x,R)=>{let P=R.target.closest?.("a[href]");if(!P||!n&&!R.metaKey&&!R.ctrlKey)return!1;let _=P.getAttribute("href")??"";return $g(_)&&(_.startsWith("#")?document.getElementById(_.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(_,"_blank","noopener,noreferrer")),!0},handlePaste:(y,x)=>{let R=[...x.clipboardData?.files??[]].filter(P=>P.type.startsWith("image/"));return R.length?(x.preventDefault(),ct(R),!0):!1}},onUpdate:({editor:y,transaction:x})=>f.current(pa(y.state.doc),{separateHistory:!!x.getMeta(Yn),historyGroup:x.getMeta(bu)})});(0,$.useEffect)(()=>w?yu(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))),vn(y=>y+1),n&&(L(null),ae(null),ke(!1),Qt(!1),pt(!1),Te(null),at(null))},[w,n]);let D=(0,$.useRef)(e);D.current=e;let B=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!w)return;let y=()=>{B.current=!0},x=()=>{B.current=!1};return w.on("beforeTransaction",y),w.on("transaction",x),()=>{w.off("beforeTransaction",y),w.off("transaction",x)}},[w]),(0,$.useLayoutEffect)(()=>{if(!w)return;let y,x=()=>{if(w.isDestroyed)return;if(w.view.composing||B.current){y=setTimeout(x,B.current?0:25);return}let P=Vp(w.state,D.current);if(!P)return;let _=w.state.selection instanceof j&&w.state.selection.node.type.name==="widget"?w.state.selection.node.attrs.id:null,G=w.state.selection instanceof re?w.state.selection:null;if(w.view.dispatch(P),G){let ue=bh(w.state.doc,G);ue&&w.view.dispatch(w.state.tr.setSelection(ue))}if(_){let ue;if(w.state.doc.descendants((ve,Q)=>{ve.type.name==="widget"&&ve.attrs.id===_&&(ue=Q)}),ue!==void 0)w.commands.setNodeSelection(ue);else{let ve=Ar(w.state);ve&&w.view.dispatch(ve)}}},R=()=>{y=setTimeout(x,25)};return w.view.composing?w.view.dom.addEventListener("compositionend",R):x(),()=>{y&&clearTimeout(y),w.view.dom.removeEventListener("compositionend",R)}},[e,w]),(0,$.useEffect)(()=>{if(!ee)return;let y=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),x=R=>{if(R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),Te(null),w?.commands.focus()),R.key!=="Tab")return;let P=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),_=P[0],G=P[P.length-1];R.shiftKey&&document.activeElement===_?(R.preventDefault(),G?.focus()):!R.shiftKey&&document.activeElement===G&&(R.preventDefault(),_?.focus())};return document.addEventListener("keydown",x,!0),()=>{cancelAnimationFrame(y),document.removeEventListener("keydown",x,!0)}},[!!ee,w]),(0,$.useEffect)(()=>{if(!w||n)return;let y=()=>{let R=Ar(w.state);R&&w.view.dispatch(R)};!Ig.has(w)&&!Pp(w)&&(Ig.add(w),w.isInitialized?y():w.on("create",y));let x=R=>{if(R.button!==0||!(R.target instanceof Element))return;let P=R.target,_=P.closest(".document-widget");if(_&&w.view.dom.contains(_)||!_&&P.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let G=Ar(w.state);if(!G)return;let ue=document.activeElement;ue instanceof HTMLElement&&w.view.dom.contains(ue)&&ue.blur(),w.view.dispatch(G),w.view.dom.contains(P)&&!P.closest("[data-block-id]")&&R.preventDefault()};return document.addEventListener("pointerdown",x,!0),()=>{w.off("create",y),document.removeEventListener("pointerdown",x,!0)}},[w,n]),(0,$.useEffect)(()=>{if(!M?.manual)return;let y=requestAnimationFrame(()=>m.current?.focus());return()=>cancelAnimationFrame(y)},[M?.manual]),(0,$.useEffect)(()=>{if(!Yt&&!kn&&!ye)return;let y=x=>{x.key==="Escape"&&(x.preventDefault(),Qt(!1),pt(!1),ke(!1),w?.commands.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[Yt,kn,ye,w]),(0,$.useEffect)(()=>{if(!rr)return;let y=window.setTimeout(()=>xt(""),4500);return()=>window.clearTimeout(y)},[rr]),(0,$.useEffect)(()=>{if(!w)return;let y=()=>{if((!r||!w.state.selection.empty)&&vn(Sn=>Sn+1),!w.isEditable)return;let{selection:Q}=w.state,{$from:ze,from:Cn,to:Zt,empty:xn}=Q;if((xn||Se.current&&Se.current!==`${Cn}:${Zt}`)&&(Se.current=null),!b.current?.manual){let Sn=ze.parent.isTextblock?ze.parent.textBetween(0,ze.parentOffset,`
|
|
154
|
+
`):"",En=xn&&Sn.match(/^\/([^\n/]*)$/);if(En){let Dc=Cn-En[0].length;k.current!==`${Dc}:${Zt}:${En[1]}`&&(k.current=null,L({from:Dc,to:Zt,query:En[1],...Ec(w,Cn)}))}else L(null),k.current=null}if(!xn&&Se.current!==`${Cn}:${Zt}`&&(w.isFocused||ie.current)&&!w.isActive("codeBlock")&&!w.isActive("widget")&&!w.isActive("pageModule")){let Sn=w.view.coordsAtPos(Cn),En=w.view.coordsAtPos(Zt);at({left:(Sn.left+En.right)/2,top:Sn.top,bottom:Math.max(Sn.bottom,En.bottom)})}else at(null)},x=Q=>Q instanceof Element&&Q.closest(".editor-bubble")?.id===p,R=Q=>{x(Q.relatedTarget)&&(ie.current=!0)},P=()=>{ie.current=!1,at(null)},_=Q=>{ie.current=x(Q.target),!ie.current&&(!(Q.target instanceof Node)||!w.view.dom.contains(Q.target))&&P()},G=({event:Q})=>{!ie.current&&!x(Q.relatedTarget)&&P()},ue=Q=>{x(Q.target)||P()},ve=Q=>{!(Q.target instanceof Element)||!Q.target.contains(w.view.dom)||(at(null),L(null),ke(!1),ae(null))};return w.on("transaction",y),w.on("focus",y),w.on("blur",G),w.view.dom.addEventListener("blur",R,!0),document.addEventListener("pointerdown",_,!0),document.addEventListener("focusin",_,!0),w.view.dom.addEventListener("contextmenu",P),window.addEventListener("scroll",ue,!0),window.addEventListener("resize",y),window.addEventListener("showai:viewport-change",ve),()=>{w.off("transaction",y),w.off("focus",y),w.off("blur",G),w.view.dom.removeEventListener("blur",R,!0),document.removeEventListener("pointerdown",_,!0),document.removeEventListener("focusin",_,!0),w.view.dom.removeEventListener("contextmenu",P),window.removeEventListener("scroll",ue,!0),window.removeEventListener("resize",y),window.removeEventListener("showai:viewport-change",ve)}},[w,p,r]),(0,$.useEffect)(()=>H(0),[M?.query]),(0,$.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[T]);function J(){let y=b.current;y&&!y.manual&&(k.current=`${y.from}:${y.to}:${y.query}`),b.current=null,L(null)}let se=(0,$.useCallback)(y=>{if(!w)return;let{selection:x}=w.state;Qe.current={from:x.from,to:x.to};let R=y==="note"&&x instanceof j&&["mathInline","mathBlock"].includes(x.node.type.name)?x.node:null,P=R?du(String(R.attrs.latex??"")):null;Te({type:y,value:y==="link"?w.getAttributes("link").href??"":y==="note"?R?P?.note??"":w.getAttributes("annotation").note??"":"",alt:"",hadNote:y==="note"&&(R?!!P:w.isActive("annotation")),...R?{math:{pos:x.from,body:P?.body??String(R.attrs.latex??"")}}:{}}),De(""),pt(!1),at(null)},[w]);function Oe(y,x){if(!w)return!1;if(x.length>1e3)return De(d("dialog.noteTooLong",{max:1e3})),!1;if(y.math){let{pos:P,body:_}=y.math,G=w.state.doc.nodeAt(P);return!G||!["mathInline","mathBlock"].includes(G.type.name)?(De(d("dialog.noteTargetMissing")),!1):(w.chain().focus().command(({tr:ue})=>(ue.setNodeMarkup(P,void 0,{...G.attrs,latex:x?uu(_,x):_}),!0)).run(),!0)}if(Qe.current&&w.commands.setTextSelection(Qe.current),w.state.selection.empty&&!w.isActive("annotation"))return De(d("dialog.noteNeedsSelection")),!1;let R=w.chain().focus();return w.state.selection.empty&&R.extendMarkRange("annotation"),x?R.setMark("annotation",{note:x}):R.unsetMark("annotation"),R.run(),!0}async function ct(y,x=!1){if(!w||!w.isEditable)return;x&&Qe.current&&w.commands.setTextSelection(Qe.current);let R=w.state.selection.getBookmark(),P=({transaction:_})=>{R=R.map(_.mapping)};w.on("transaction",P);for(let _ of y){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(_.type)){xt(c("notice.imageTypes"));continue}if(_.size>Hs.resourceBytes){xt(c("notice.imageTooLarge",{name:_.name,size:_s(_.size),limit:_s(Hs.resourceBytes)}));continue}let G;try{G=await new Promise((ve,Q)=>{let ze=new FileReader;ze.onload=()=>ve(String(ze.result)),ze.onerror=()=>Q(ze.error),ze.onabort=()=>Q(new Error(c("notice.readCancelled"))),ze.readAsDataURL(_)})}catch{xt(c("notice.imageUnreadable",{name:_.name}));continue}if(w.isDestroyed||!w.isEditable)break;let ue=R.resolve(w.state.doc);w.view.dispatch(w.state.tr.setSelection(ue)),w.chain().focus().setImage({src:G,alt:_.name}).run(),R=w.state.selection.getBookmark()}w.off("transaction",P),Te(null)}let Br=(0,$.useMemo)(()=>[{id:"text",title:c("block.text"),keywords:`text paragraph ${c("block.textKeywords")}`,icon:(0,v.jsx)(Ro,{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)(Uc,{size:20}):y===2?(0,v.jsx)(qc,{size:20}):(0,v.jsx)(Gc,{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,v.jsx)(Ds,{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)(Rs,{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)(Is,{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)(Os,{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)(Yc,{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)(Eo,{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)(Ic,{size:20}),group:c("group.basic"),run:y=>{let x={type:"step",content:[{type:"paragraph"}]},{from:R}=y.state.selection;y.chain().focus().insertContent({type:"stepper",content:[x,x]}).command(({tr:P})=>{let _=-1;return P.doc.nodesBetween(Math.max(0,R-1),P.doc.content.size,(G,ue)=>(_<0&&G.type.name==="stepper"&&(_=ue),_<0)),_>=0&&P.setSelection(O.create(P.doc,_+3)),!0}).run()}},{id:"divider",title:c("block.divider"),keywords:`divider hr ${c("block.dividerKeywords")}`,icon:(0,v.jsx)(Qc,{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)(Mo,{size:20}),group:c("group.rich"),run:()=>se("image")},{id:"code",title:c("block.code"),keywords:`code snippet ${c("block.codeKeywords")}`,icon:(0,v.jsx)(zc,{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)(Ps,{size:20}),group:c("group.rich"),run:y=>{y.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...Ae.items.filter(y=>("kind"in y||y.role!=="page-outline")&&!("kind"in y&&Vs[y.kind])&&(!("kind"in y&&y.insertion)||!!i)).map(y=>({id:"catalog:"+("kind"in y?y.kind:`${y.id}@${y.version}#${y.integrity}`),title:Ae.displayName(y),keywords:`${"kind"in y?y.kind:y.id} ${y.name} ${y.description} ${Ae.displayDescription(y)}`,icon:(0,v.jsx)(Zc,{size:20}),group:c("group.components"),component:y,run:()=>{}}))],[se,i,Ae.items,Ae.displayName,Ae.displayDescription,c]),It=Br.filter(y=>`${y.title} ${y.keywords}`.toLowerCase().includes(M?.query.toLowerCase()??""));C.current=It;let Ts=async y=>{let x=b.current,R=C.current[y];if(!(!w||!x||!R||Ve)){if(R.component){let P=w.state.doc,_=++$e.current;je(!0);try{let G=await Ae.resolve(R.component);if(_!==$e.current||w.isDestroyed||b.current!==x||!w.state.doc.eq(P))return;if(L(null),b.current=null,G.component&&he(G.component),G.native&&i){let ue=w.state.tr.delete(x.from,x.to);i(G.kind,G.data,Ou(ue.doc,x.from))}else w.chain().focus().deleteRange({from:x.from,to:x.to}).insertContent({...Vs[G.kind]?pu(G.kind,G.data):{type:"widget",attrs:{kind:G.kind,data:G.data}}}).run()}catch(G){xt(G.message)}finally{_===$e.current&&je(!1)}return}L(null),b.current=null,x.from!==x.to?w.chain().focus().deleteRange({from:x.from,to:x.to}).run():w.commands.focus(),R.run(w)}};S.current=Ts;let Ac=()=>{if(!w)return;k.current=null;let{from:y,to:x}=w.state.selection;L({from:y,to:x,query:"",manual:!0,...Ec(w,y)}),H(0),pt(!1)},zg=()=>{if(!w||!I)return;let y=I.pos+I.size;w.chain().focus().insertContentAt(y,{type:"paragraph"}).setTextSelection(y+1).run(),L({from:y+1,to:y+1,query:"",manual:!0,...Ec(w,y+1)}),ke(!1)};function Tc(y,x){if(!w)return;let R=[];w.state.doc.forEach((Q,ze)=>R.push({pos:ze,size:Q.nodeSize}));let P=R.findIndex(Q=>Q.pos===y),_=R[P+x],G=w.state.doc.nodeAt(y);if(!_||!G)return;let ue=x===-1?_.pos:_.pos+_.size-G.nodeSize,ve=w.state.tr.delete(y,y+G.nodeSize).insert(ue,G);ve.setSelection(X.near(ve.doc.resolve(ue+1))),w.view.dispatch(ve),w.view.focus(),ke(!1),ae(null)}function Hg(y){if(!w||!w.isEditable)return;let x=E.current;if(x!==null){y.preventDefault(),y.stopPropagation(),E.current=null,ae(null);let P=w.state.doc.nodeAt(x);if(!P)return;let _=w.state.doc.content.size,G=!1;if(w.state.doc.forEach((ue,ve)=>{let Q=w.view.nodeDOM(ve);if(!(Q instanceof HTMLElement)||G)return;let ze=Q.getBoundingClientRect();y.clientY<ze.top+ze.height/2&&(_=ve,G=!0)}),_!==x&&_!==x+P.nodeSize){let ue=_>x?_-P.nodeSize:_,ve=w.state.tr.delete(x,x+P.nodeSize).insert(ue,P);ve.setSelection(X.near(ve.doc.resolve(ue+1))),w.view.dispatch(ve)}return}let R=[...y.dataTransfer.files].filter(P=>P.type.startsWith("image/"));if(R.length){y.preventDefault(),y.stopPropagation();let P=w.view.posAtCoords({left:y.clientX,top:y.clientY});P&&w.commands.setTextSelection(P.pos),ct(R)}}if(!w)return(0,v.jsx)("div",{className:"editor-loading","aria-label":c("openingDocument")});let _g=w.isActive("heading")?c("block.heading",{level:w.getAttributes("heading").level}):c("block.text"),Nc=q&&Ce?ki(w.state.doc,w.state.selection.from,w.state.selection.to).length:0,Rc=(!r||q)&&(0,v.jsx)(Eh,{editor:w,onLink:()=>se("link"),onNote:()=>se("note")});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:()=>{Qt(!Yt),pt(!1)},"aria-expanded":Yt,children:[_g,(0,v.jsx)(zr,{size:13})]}),Yt&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>Qt(!1)}),(0,v.jsx)("div",{className:"editor-small-menu style-menu",children:Br.slice(0,7).map(y=>(0,v.jsxs)("button",{onMouseDown:x=>x.preventDefault(),onClick:()=>{y.run(w),Qt(!1)},children:[y.icon,(0,v.jsx)("span",{children:y.title})]},y.id))})]})]}),(0,v.jsx)("span",{className:"toolbar-divider"}),Rc,(0,v.jsx)("span",{className:"toolbar-divider"}),(0,v.jsx)(Lt,{label:c("block.bullet"),active:w.isActive("bulletList"),onClick:()=>w.chain().focus().toggleBulletList().run(),children:(0,v.jsx)(Ds,{size:17})}),(0,v.jsx)(Lt,{label:c("block.todo"),active:w.isActive("taskList"),onClick:()=>w.chain().focus().toggleTaskList().run(),children:(0,v.jsx)(Is,{size:16})}),(0,v.jsxs)("div",{className:"toolbar-insert",children:[(0,v.jsx)(Lt,{label:c("format.more"),active:kn,onClick:()=>{pt(!kn),Qt(!1)},children:(0,v.jsx)(tn,{size:17})}),kn&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>pt(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,v.jsxs)("button",{onClick:Ac,children:[(0,v.jsx)(tn,{size:16}),c("insert.content"),(0,v.jsx)("span",{className:"menu-key",children:"/"})]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleOrderedList().run(),pt(!1)},children:[(0,v.jsx)(Rs,{size:16}),c("block.ordered")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().toggleBlockquote().run(),pt(!1)},children:[(0,v.jsx)(Os,{size:16}),c("block.quote")]}),(0,v.jsxs)("button",{onClick:()=>se("image"),children:[(0,v.jsx)(Mo,{size:16}),c("insert.image")]}),(0,v.jsxs)("button",{onClick:()=>{w.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),pt(!1)},children:[(0,v.jsx)(Ps,{size:16}),c("insert.table")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("div",{className:"align-tools",children:[(0,v.jsx)(Lt,{label:c("format.alignLeft"),active:w.isActive({textAlign:"left"}),onClick:()=>w.chain().focus().setTextAlign("left").run(),children:(0,v.jsx)(Tn,{size:17})}),(0,v.jsx)(Lt,{label:c("format.alignCenter"),active:w.isActive({textAlign:"center"}),onClick:()=>w.chain().focus().setTextAlign("center").run(),children:(0,v.jsx)(Mn,{size:17})}),(0,v.jsx)(Lt,{label:c("format.alignRight"),active:w.isActive({textAlign:"right"}),onClick:()=>w.chain().focus().setTextAlign("right").run(),children:(0,v.jsx)(An,{size:17})})]})]})]})]}),(0,v.jsx)("div",{className:"toolbar-spacer"}),(0,v.jsx)(Lt,{label:c("format.undo"),disabled:!w.can().undo(),onClick:()=>w.chain().focus().undo().run(),children:(0,v.jsx)(au,{size:16})}),(0,v.jsx)(Lt,{label:c("format.redo"),disabled:!w.can().redo(),onClick:()=>w.chain().focus().redo().run(),children:(0,v.jsx)(eu,{size:16})})]}),(0,v.jsxs)("div",{className:"editor-canvas",ref:h,onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.shiftKey&&y.key.toLowerCase()==="k"&&!n&&(y.preventDefault(),y.stopPropagation(),se("link"))},onMouseEnter:wt,onMouseMove:y=>{if(n||ye||E.current!==null)return;if(y.target.closest(".block-handle")){wt();return}let x=h.current;x&&y.target.closest(".document-editor")===x.closest(".document-editor")&&(lt.current=y.clientY,!Be.current&&(Be.current=requestAnimationFrame(()=>{Be.current=0;let R=h.current;if(!R||E.current!==null||w.isDestroyed)return;let P=lt.current,_=R.getBoundingClientRect(),G=_.width/R.offsetWidth||1,ue=null;w.state.doc.forEach((Q,ze,Cn)=>{let Zt=w.view.nodeDOM(ze);if(!(Zt instanceof HTMLElement))return;let xn=Zt.getBoundingClientRect();P>=xn.top-3&&P<=xn.bottom+3&&(ue={pos:ze,size:Q.nodeSize,index:Cn,top:(xn.top-_.top)/G})});let ve=ue;ve?(wt(),ae(Q=>Q&&Q.pos===ve.pos&&Q.size===ve.size&&Q.index===ve.index&&Math.abs(Q.top-ve.top)<.5?Q:ve)):Ir()})))},onMouseLeave:Ir,onDragOver:y=>{(E.current!==null||[...y.dataTransfer.types].includes("Files"))&&y.preventDefault()},onDropCapture:Hg,children:[(0,v.jsx)(wi,{editor:w}),!n&&(0,v.jsx)(Sh,{editor:w}),!n&&I&&(0,v.jsxs)("div",{className:"block-handle",style:{top:I.top},onMouseEnter:wt,onFocus:wt,children:[(0,v.jsx)("button",{"aria-label":c("insert.addBelow"),title:c("insert.addContent"),onMouseDown:y=>y.preventDefault(),onClick:zg,children:(0,v.jsx)(tn,{size:15})}),(0,v.jsx)("button",{"aria-label":c("block.handle"),title:c("block.handleTitle"),draggable:!0,onDragStart:y=>{wt(),E.current=I.pos,y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("application/x-showai-block",String(I.pos));let x=w.view.nodeDOM(I.pos);x instanceof HTMLElement&&y.dataTransfer.setDragImage(x,0,0),ke(!1)},onDragEnd:()=>{E.current=null},onClick:()=>ke(!ye),children:(0,v.jsx)(Kc,{size:15})}),ye&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>ke(!1)}),(0,v.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(w.state.doc.nodeAt(I.pos)?.type.name??"")&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"align-tools",role:"group","aria-label":c("block.style"),children:Br.slice(0,7).map((y,x)=>(0,v.jsx)(Lt,{label:y.title,active:x===0?w.state.doc.nodeAt(I.pos)?.type.name==="paragraph":w.state.doc.nodeAt(I.pos)?.attrs.level===x,onClick:()=>{w.chain().focus().setTextSelection(I.pos+1).run(),y.run(w),ke(!1)},children:y.icon},y.id))}),(0,v.jsx)("div",{className:"align-tools",children:[["left",c("format.alignLeft"),(0,v.jsx)(Tn,{size:16},"left")],["center",c("format.alignCenter"),(0,v.jsx)(Mn,{size:16},"center")],["right",c("format.alignRight"),(0,v.jsx)(An,{size:16},"right")]].map(([y,x,R])=>(0,v.jsx)(Lt,{label:x,active:w.state.doc.nodeAt(I.pos)?.attrs.textAlign===y,onClick:()=>{w.chain().focus().setTextSelection(I.pos+1).setTextAlign(y).run(),ke(!1)},children:R},y))}),(0,v.jsx)("div",{className:"menu-rule"})]}),(0,v.jsx)(Du,{editor:w,position:I.pos,onDone:()=>ke(!1)}),s&&(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(I.pos);y&&s(y.toJSON()),ke(!1),ae(null)},children:[(0,v.jsx)(Fc,{size:15}),c("block.detach")]}),(0,v.jsxs)("button",{disabled:I.index===0,onClick:()=>Tc(I.pos,-1),children:[(0,v.jsx)(Pc,{size:15}),c("block.moveUp")]}),(0,v.jsxs)("button",{disabled:I.index===w.state.doc.childCount-1,onClick:()=>Tc(I.pos,1),children:[(0,v.jsx)(Lc,{size:15}),c("block.moveDown")]}),(0,v.jsxs)("button",{onClick:()=>{let y=w.state.doc.nodeAt(I.pos);y&&w.chain().focus().insertContentAt(I.pos+y.nodeSize,y.toJSON()).run(),ke(!1)},children:[(0,v.jsx)(_c,{size:15}),c("block.duplicate")]}),Ce&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(I.pos)?.attrs.id,R=y.currentTarget.closest(".block-handle").getBoundingClientRect();ke(!1),typeof x=="string"&&!Bg(x)&&Ce.open({kind:"blocks",blockIds:[x],anchor:{left:R.right+160,top:R.top,bottom:R.bottom}})},children:[(0,v.jsx)(Ls,{size:15}),c("assistant.askBlock")]}),Ce&&(0,v.jsxs)("button",{onClick:y=>{let x=w.state.doc.nodeAt(I.pos)?.attrs.id,R=y.currentTarget.closest(".block-handle").getBoundingClientRect();ke(!1),typeof x=="string"&&!Bg(x)&&Ce.reference({kind:"blocks",blockIds:[x],anchor:{left:R.right,top:R.top,bottom:R.bottom}})},children:[(0,v.jsx)(Ns,{size:15}),c("assistant.referenceBlock")]}),(0,v.jsx)("div",{className:"menu-rule"}),(0,v.jsxs)("button",{className:"danger",onClick:()=>{w.chain().focus().deleteRange({from:I.pos,to:I.pos+I.size}).run(),ke(!1),ae(null)},children:[(0,v.jsx)(No,{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(),Ac()},children:[(0,v.jsx)(tn,{size:15}),(0,v.jsx)("span",{children:c("insert.addContent")}),(0,v.jsx)("kbd",{children:"/"})]}),(0,v.jsx)("input",{ref:g,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&&ct([x],!0),y.target.value=""}}),rr&&(0,v.jsxs)("div",{className:"editor-notice",role:"status",children:[rr,(0,v.jsx)("button",{"aria-label":c("dismissNotice"),onClick:()=>xt(""),children:(0,v.jsx)(Hr,{size:14})})]}),q&&!n&&(0,v.jsxs)(Au,{id:p,className:"rich-text-selection-toolbar",anchor:q,viewportTop:Math.max(0,...Array.from(h.current?.closest(".studio")?.querySelectorAll(".studio-window-topbar, .studio-topbar")??[],y=>y.getBoundingClientRect().bottom))+8,onEscape:()=>{ie.current=!1,Se.current=`${w.state.selection.from}:${w.state.selection.to}`,w.state.selection instanceof re&&w.view.dispatch(w.state.tr.setSelection(O.near(w.state.selection.$from))),at(null),w.view.focus()},children:[Rc,(0,v.jsx)(Ti,{editor:w}),Ce&&(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:x}=w.state.selection,R=q;ie.current=!1,at(null),Ce.open({kind:"text",blockIds:ki(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
|
|
155
|
+
`),anchor:R})},children:[(0,v.jsx)(Ls,{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:Nc}),title:c("assistant.referenceSelection",{count:Nc}),onClick:()=>{let{from:y,to:x}=w.state.selection,R=q;ie.current=!1,at(null),Ce.reference({kind:"text",blockIds:ki(w.state.doc,y,x),text:w.state.doc.textBetween(y,x,`
|
|
156
|
+
`),anchor:R})},children:(0,v.jsx)(Ns,{size:16})})]})]}),M&&!n&&(0,Mc.createPortal)((0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"slash-dismiss",onClick:()=>{J(),w.commands.focus()}}),(0,v.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":c("insert.content"),style:{left:M.left,top:M.top},children:[(0,v.jsxs)("div",{className:"slash-search",children:[M.manual?(0,v.jsx)(ku,{label:c("insert.search"),placeholder:c("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:m,value:M.query,onChange:y=>L({...M,query:y}),onKeyDown:y=>{y.key==="Escape"&&(J(),w.commands.focus()),y.key==="Enter"&&(y.preventDefault(),Ts(T)),(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),H(x=>It.length?(x+(y.key==="ArrowDown"?1:-1)+It.length)%It.length:0))}}):(0,v.jsx)("span",{children:M.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":Ve||Ae.loading,children:[Ae.error&&(0,v.jsx)("p",{role:"alert",className:"slash-empty",children:Ae.error}),It.length===0&&(0,v.jsx)("div",{className:"slash-empty",children:c("insert.noResults")}),It.map((y,x)=>(0,v.jsxs)("div",{children:[(x===0||It[x-1].group!==y.group)&&(0,v.jsx)("div",{className:"slash-group",children:y.group}),(0,v.jsxs)("button",{role:"option",disabled:Ve,"aria-selected":x===T,className:`slash-item${x===T?" is-selected":""}`,onMouseEnter:()=>H(x),onMouseDown:R=>R.preventDefault(),onClick:()=>Ts(x),children:[(0,v.jsx)("span",{className:"slash-item-icon",children:y.icon}),(0,v.jsx)("span",{children:(0,v.jsx)("strong",{children:y.title})}),x===T&&(0,v.jsx)("span",{className:"slash-enter",children:"\u21B5"})]})]},y.id))]})]})]}),document.body),ee&&(0,Mc.createPortal)((0,v.jsx)("div",{className:"editor-modal-backdrop",onMouseDown:y=>{y.target===y.currentTarget&&Te(null)},children:(0,v.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":"true","aria-labelledby":"editor-dialog-title",onKeyDown:y=>{y.key==="Escape"&&Te(null)},onSubmit:y=>{y.preventDefault();let x=ee.value.trim();if(ee.type==="image"&&!x1(x)){De(c("dialog.invalidImageUrl"));return}if(ee.type==="link"&&x&&!$g(x)){De(c("dialog.invalidLinkUrl"));return}if(ee.type==="note"){if(!Oe(ee,x))return;Te(null);return}Qe.current&&w.commands.setTextSelection(Qe.current),ee.type==="image"?w.chain().focus().setImage({src:x,alt:ee.alt}).run():x?w.state.selection.empty&&!w.isActive("link")?w.chain().focus().insertContent({type:"text",text:x,marks:[{type:"link",attrs:{href:x}}]}).run():w.chain().focus().extendMarkRange("link").setLink({href:x}).run():w.chain().focus().extendMarkRange("link").unsetLink().run(),Te(null)},children:[(0,v.jsxs)("div",{className:"editor-modal-heading",children:[(0,v.jsx)("div",{className:"editor-modal-symbol",children:ee.type==="image"?(0,v.jsx)(Mo,{size:21}):ee.type==="note"?(0,v.jsx)(To,{size:21}):(0,v.jsx)(Ao,{size:21})}),(0,v.jsx)("h3",{id:"editor-dialog-title",children:ee.type==="image"?c("insert.image"):ee.type==="note"?d(ee.hadNote?"dialog.editNote":"dialog.addNote"):c("dialog.addLink")}),(0,v.jsx)("button",{type:"button","aria-label":c("dialog.close"),onClick:()=>Te(null),children:(0,v.jsx)(Hr,{size:18})})]}),ee.type==="image"&&(0,v.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>g.current?.click(),children:[(0,v.jsx)(cu,{size:23}),(0,v.jsx)("strong",{children:c("dialog.chooseImage")}),(0,v.jsx)("span",{children:c("dialog.imageFormats")})]}),ee.type==="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:ee.math?d("dialog.noteFormula"):d("dialog.noteText")}),(0,v.jsx)("textarea",{autoFocus:!0,rows:4,maxLength:1e3,placeholder:d("dialog.notePlaceholder"),value:ee.value,onChange:y=>{Te({...ee,value:y.target.value}),De("")},onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),y.currentTarget.form?.requestSubmit())}}),(0,v.jsx)("small",{children:d("dialog.noteHint")})]}),ee.type!=="note"&&(0,v.jsxs)("label",{className:"editor-field",children:[(0,v.jsx)("span",{children:ee.type==="image"?c("dialog.imageUrl"):c("dialog.linkUrl")}),(0,v.jsx)("input",{autoFocus:!0,type:"text",placeholder:"https://",value:ee.value,onChange:y=>{Te({...ee,value:y.target.value}),De("")}})]}),ee.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:ee.alt,onChange:y=>Te({...ee,alt:y.target.value})})]}),Pr&&(0,v.jsx)("p",{className:"editor-field-error",role:"alert",children:Pr}),(0,v.jsxs)("div",{className:"editor-modal-actions",children:[ee.type==="link"&&w.isActive("link")&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{w.chain().focus().extendMarkRange("link").unsetLink().run(),Te(null)},children:c("dialog.removeLink")}),ee.type==="note"&&ee.hadNote&&(0,v.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{Oe(ee,"")&&Te(null)},children:d("dialog.removeNote")}),(0,v.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>Te(null),children:c("dialog.cancel")}),(0,v.jsxs)("button",{type:"submit",className:"editor-primary",disabled:(ee.type==="image"||ee.type==="note")&&!ee.value.trim(),children:[(0,v.jsx)(Bc,{size:15}),ee.type==="image"?c("insert.image"):c("dialog.confirm")]})]})]})}),document.body),n&&(0,v.jsxs)("span",{className:"editor-readonly-note",children:[(0,v.jsx)(Wc,{size:12}),c("readOnlyNote")]})]})}export{S1 as default};
|