tmux-ide 2.1.2 → 2.1.3

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.
Files changed (40) hide show
  1. package/dashboard/out/404/index.html +1 -1
  2. package/dashboard/out/404.html +1 -1
  3. package/dashboard/out/__next.__PAGE__.txt +1 -1
  4. package/dashboard/out/__next._full.txt +1 -1
  5. package/dashboard/out/__next._head.txt +1 -1
  6. package/dashboard/out/__next._index.txt +1 -1
  7. package/dashboard/out/__next._tree.txt +1 -1
  8. package/dashboard/out/_next/static/chunks/{422e1bb4d41ce5ba.js → aae0253c73fba984.js} +1 -1
  9. package/dashboard/out/_not-found/__next._full.txt +1 -1
  10. package/dashboard/out/_not-found/__next._head.txt +1 -1
  11. package/dashboard/out/_not-found/__next._index.txt +1 -1
  12. package/dashboard/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
  13. package/dashboard/out/_not-found/__next._not-found.txt +1 -1
  14. package/dashboard/out/_not-found/__next._tree.txt +1 -1
  15. package/dashboard/out/_not-found/index.html +1 -1
  16. package/dashboard/out/_not-found/index.txt +1 -1
  17. package/dashboard/out/index.html +1 -1
  18. package/dashboard/out/index.txt +1 -1
  19. package/dashboard/out/project/__fallback/__next._full.txt +2 -2
  20. package/dashboard/out/project/__fallback/__next._head.txt +1 -1
  21. package/dashboard/out/project/__fallback/__next._index.txt +1 -1
  22. package/dashboard/out/project/__fallback/__next._tree.txt +1 -1
  23. package/dashboard/out/project/__fallback/__next.project.$d$name.__PAGE__.txt +2 -2
  24. package/dashboard/out/project/__fallback/__next.project.$d$name.txt +1 -1
  25. package/dashboard/out/project/__fallback/__next.project.txt +1 -1
  26. package/dashboard/out/project/__fallback/index.html +1 -1
  27. package/dashboard/out/project/__fallback/index.txt +2 -2
  28. package/package.json +1 -1
  29. package/src/init.ts +78 -11
  30. package/src/launch.ts +121 -13
  31. package/src/lib/orchestrator.ts +3 -2
  32. package/src/stop.ts +9 -0
  33. package/templates/skills/backend.md +13 -0
  34. package/templates/skills/frontend.md +13 -0
  35. package/templates/skills/general-worker.md +13 -0
  36. package/templates/skills/researcher.md +9 -0
  37. package/templates/skills/reviewer.md +12 -0
  38. /package/dashboard/out/_next/static/{hKfaRIxA4e3yTmkv1VUnK → x34uErIsc3zyBFcltrEXS}/_buildManifest.js +0 -0
  39. /package/dashboard/out/_next/static/{hKfaRIxA4e3yTmkv1VUnK → x34uErIsc3zyBFcltrEXS}/_clientMiddlewareManifest.json +0 -0
  40. /package/dashboard/out/_next/static/{hKfaRIxA4e3yTmkv1VUnK → x34uErIsc3zyBFcltrEXS}/_ssgManifest.js +0 -0
@@ -190,4 +190,4 @@ XID_Continue XIDC
190
190
  XID_Start XIDS`.split(/\s/).map(e=>[s0(e),e])),aE=new Map([["s",af(383)],[af(383),"s"]]),aM=new Map([[af(223),af(7838)],[af(107),af(8490)],[af(229),af(8491)],[af(969),af(8486)]]),aT=new Map([aL(453),aL(456),aL(459),aL(498),...aO(8072,8079),...aO(8088,8095),...aO(8104,8111),aL(8124),aL(8140),aL(8188)]),aI=new Map([["alnum",am`[\p{Alpha}\p{Nd}]`],["alpha",am`\p{Alpha}`],["ascii",am`\p{ASCII}`],["blank",am`[\p{Zs}\t]`],["cntrl",am`\p{Cc}`],["digit",am`\p{Nd}`],["graph",am`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",am`\p{Lower}`],["print",am`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",am`[\p{P}\p{S}]`],["space",am`\p{space}`],["upper",am`\p{Upper}`],["word",am`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",am`\p{AHex}`]]);function aL(e){let t=af(e);return[t.toLowerCase(),t]}function aO(e,t){return(function(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n})(e,t).map(e=>aL(e))}var aD=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]),aR={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if("repeater"===i){let e=sV();e.body[0].body.push(sG({negate:!0,body:r}),sJ("Any"));let i=sV();i.body[0].body.push(sq("greedy",0,1/0,e)),n(aG(i,t),{traverse:!0})}else throw Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>"flags"===e.kind);for(let e=n+1;e<t.body.length;e++)ab(r,t.body[e],[]).push(...i)},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=a$(t.get(e));if(n){let t=sV({flags:n});t.body[0].body=e.body,e.body=[aG(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:o,replaceWith:s},a){let{kind:l,negate:c}=e,{asciiWordBoundaries:d,avoidSubclass:u,supportedGNodes:h,wordIsAscii:p}=a;if("text_segment_boundary"===l)throw Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if("line_end"===l)s(aG(sG({body:[sB({body:[sz("string_end")]}),sB({body:[sU(10)]})]}),t));else if("line_start"===l)s(aG(aH(am`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if("search_start"===l)if(h.has(e))i.flags.sticky=!0,o();else{var f;let e,i=r[n-1];if(i&&((e=["Character","CharacterClass","CharacterSet"]).includes((f=i).type)||"Quantifier"===f.type&&f.min&&e.includes(f.body.type)))s(aG(sG({negate:!0}),t));else if(u)throw Error(am`Uses "\G" in a way that requires a subclass`);else s(aV(sz("string_start"),t)),a.strategy="clip_search"}else if("string_end"===l||"string_start"===l);else if("string_end_newline"===l)s(aG(aH(am`(?=\n?\z)`),t));else if("word_boundary"===l){if(!p&&!d){let e=`(?:(?<=${aC})(?!${aC})|(?<!${aC})(?=${aC}))`,n=`(?:(?<=${aC})(?=${aC})|(?<!${aC})(?!${aC}))`;s(aG(aH(c?n:e),t))}}else throw Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||aU(n)||(e.ref=n=az(n,t))},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!aU(r)&&(e.name=r=az(r,t)),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){"intersection"===t.kind&&n(aG(sH({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:o,spaceIsAscii:s,wordIsAscii:a}){let{kind:l,negate:c,value:d}=e;if(o&&("digit"===l||"digit"===d))return void n(aV(sW("digit",{negate:c}),t));if(s&&("space"===l||"space"===d))return void n(aG(aW(aH("[ -\r ]"),c),t));if(a&&("word"===l||"word"===d))return void n(aV(sW("word",{negate:c}),t));if("any"===l)n(aV(sJ("Any"),t));else if("digit"===l)n(aV(sJ("Nd",{negate:c}),t));else if("dot"===l);else if("text_segment"===l){if("strict"===r)throw Error(am`Use of "\X" requires non-strict accuracy`);let e="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",o=am`\p{RI}{2}|${e}(?:\u200D${e})*`;n(aG(aH(am`(?>\r\n|${i?am`\p{RGI_Emoji}`:o}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if("hex"===l)n(aV(sJ("AHex",{negate:c}),t));else if("newline"===l)n(aG(aH(c?"[^\n]":"(?>\r\n?|[\n\v\f…\u2028\u2029])"),t));else if("posix"===l)if(i||"graph"!==d&&"print"!==d)n(aG(aW(aH(aI.get(d)),c),t));else{if("strict"===r)throw Error(`POSIX class "${d}" requires min target ES2024 or non-strict accuracy`);let e={graph:"!-~",print:" -~"}[d];c&&(e=`\0-${af(e.codePointAt(0)-1)}${af(e.codePointAt(2)+1)}-\u{10FFFF}`),n(aG(aH(`[${e}]`),t))}else if("property"===l)aA.has(s0(d))||(e.key="sc");else if("space"===l)n(aV(sJ("space",{negate:c}),t));else if("word"===l)n(aG(aW(aH(aC),c),t));else throw Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:o,removeAllNextSiblings:s}){let{kind:a,flags:l}=e;if("flags"===a)if(l.enable||l.disable){let e=sV({flags:l});e.body[0].body=s(),i(aG(e,t),{traverse:!0})}else r();else if("keep"===a){let e=n.body[0],r=1===n.body.length&&sP(e,{type:"Group"})&&1===e.body[0].body.length?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(am`Uses "\K" in a way that's unsupported`);let s=sG({behind:!0});s.body[0].body=o(),i(aG(s,t))}else throw Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error('Unsupported flag "P"');if("word"===e.textSegmentMode)throw Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,e.flags.enable||e.flags.disable||delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;"lookbehind"===n&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if("fail"===r)n(aG(sG({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if("Quantifier"===e.body.type){let t=sV();t.body[0].body.push(e.body),e.body=aG(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(1===t.body.length&&"search_start"===t.body[0].kind)t.body.pop();else{let e=function e(t){let n=t.find(e=>"search_start"===e.kind||function(e,t){let n={negate:null,...t};return"LookaroundAssertion"===e.type&&(null===n.negate||e.negate===n.negate)&&1===e.body.length&&sP(e.body[0],{type:"Assertion",kind:"search_start"})}(e,{negate:!1})||!function({type:e}){return"Assertion"===e||"Directive"===e||"LookaroundAssertion"===e}(e));if(!n)return null;if("search_start"===n.kind)return n;if("LookaroundAssertion"===n.type)return n.body[0].body[0];if("CapturingGroup"===n.type||"Group"===n.type){let t=[];for(let r of n.body){let n=e(r.body);if(!n)return null;Array.isArray(n)?t.push(...n):t.push(n)}return t}return null}(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if("strict"===t&&n&&r)throw Error(am`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||aU(n)||(e.ref=n=az(n,t))}},aP={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:o,multiplexCapturesToLeftByRef:s,openRefs:a,reffedNodesByReferencer:l}){let c=i.get(e);if(c&&a.has(e.number)){let r=aV(aB(e.number),t);l.set(r,a.get(e.number)),n(r);return}a.set(e.number,e),s.set(e.number,[]),e.name&&ab(s,e.name,[]);let d=s.get(e.name??e.number);for(let t=0;t<d.length;t++){let n=d[t];if(c===n.node||c&&c===n.origin||e===n.origin){d.splice(t,1);break}}if(s.get(e.number).push({node:e,origin:c}),e.name&&s.get(e.name).push({node:e,origin:c}),e.name){let t=ab(o,e.name,new Map),n=!1;if(c)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=av(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:o}=e;if(i){let n=t;for(;(n=n.parent)&&("CapturingGroup"!==n.type||n.name!==o&&n.number!==o););r.reffedNodesByReferencer.set(e,n);return}let s=r.subroutineRefMap.get(o),a=0===o,l=a?aB(0):function e(t,n,r,i){let o=Array.isArray(t)?[]:{};for(let[s,a]of Object.entries(t))"parent"===s?o.parent=Array.isArray(r)?i:r:a&&"object"==typeof a?o[s]=e(a,n,o,r):("type"===s&&"CapturingGroup"===a&&n.set(o,n.get(t)??t),o[s]=a);return o}(s,r.groupOriginByCopy,null),c=l;if(!a){var d,u;let e=a$(function(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}(s,e=>"Group"===e.type&&!!e.flags)),t=e?av(r.globalFlags,e):r.globalFlags;d=t,u=r.currentFlags,(d.dotAll!==u.dotAll||d.ignoreCase!==u.ignoreCase)&&(c=sV({flags:function({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),e&&t||(n.disable={},e||(n.disable.dotAll=!0),t||(n.disable.ignoreCase=!0)),n}(t)})).body[0].body.push(l)}n(aG(c,t),{traverse:!a})}},a_={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>(function(e,t){let n=t;do{if("Regex"===n.type)return!1;if("Alternative"===n.type)continue;if(n===e)return!1;for(let t of aF(n.parent)){if(t===n)break;if(t===e||function e(t,n){for(let r of aF(t)??[])if(r===n||e(r,n))return!0;return!1}(t,e))return!0}}while(n=n.parent)throw Error("Unexpected path")})(t,e));i.length?i.length>1?n(aG(sV({atomic:!0,body:i.reverse().map(e=>sB({body:[s$(e.number)]}))}),t)):e.ref=i[0].number:n(aG(sG({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=sF();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){e.isRecursive&&0!==e.ref&&(e.ref=t.reffedNodesByReferencer.get(e).number)}};function aj(e){s8(e,{"*"({node:e,parent:t}){e.parent=t}})}function aB(e){let t=sK(e);return t.isRecursive=!0,t}function az(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function a$(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return(e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable)?n:null}function aF(e){if(!e)throw Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function aU(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function aH(e,t){let n=sj(e,{...t,unicodePropertyMap:aA}).body;return n.length>1||n[0].body.length>1?sV({body:n}):n[0].body[0]}function aW(e,t){return e.negate=t,e}function aV(e,t){return e.parent=t,e}function aG(e,t){return aj(e),e.parent=t,e}var aq={"*":{enter({node:e},t){if(a8(e)){let n=t.getCurrentModI();t.pushModI(e.flags?av({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){a8(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){a0(af(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),a1(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){"property"===e.kind&&aD.has(e.value)&&t.setHasCasedChar()}},aK={Alternative:({body:e},t,n)=>e.map(n).join(""),Assertion({kind:e,negate:t}){if("string_end"===e)return"$";if("string_start"===e)return"^";if("word_boundary"===e)return t?am`\B`:am`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if("number"!=typeof e)throw Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&"strict"===t.accuracy&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:i,number:o}=e,s={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(s.hidden=!0,o>a.number&&(s.transferTo=a.number)),t.captureMap.set(o,s),`(${i?`?<${i}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=af(e),r=a2(e,{escDigit:"Backreference"===t.lastNode.type,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&a0(n)){let e=aN(n);return t.inCharClass?e.join(""):e.length>1?`[${e.join("")}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:o}=e,{body:s}=e;if("intersection"===r&&!t.useFlagV)throw Error("Use of character class intersection requires min target ES2024");ag.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&s.some(a5)&&(s=[sU(45),...s.filter(e=>!a5(e))]);let a=()=>`[${i?"^":""}${s.map(n).join("intersection"===r?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ag.bugNestedClassIgnoresNegation)&&!i){let t=s.filter(e=>"CharacterClass"===e.type&&"union"===e.kind&&e.negate);if(t.length){let r=sV(),i=r.body[0];return r.parent=o,i.parent=r,e.body=s=s.filter(e=>!t.includes(e)),s.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=sB({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=a();return t.inCharClass=!1,r}let l=s[0];if("union"===r&&!i&&l&&((!t.useFlagV||!t.verbose)&&"union"===o.kind&&!(ag.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&"intersection"===o.kind&&1===s.length&&"CharacterClassRange"!==l.type))return s.map(n).join("");if(!t.useFlagV&&"CharacterClass"===o.type)throw Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=a2(n,i),s=a2(r,i),a=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&(function(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:null===r?n.push(t[e]):(n.push([r,t[e]]),r=null);return n})(a1(e)).forEach(e=>{a.add(Array.isArray(e)?`${a2(e[0],i)}-${a2(e[1],i)}`:a2(e,i))}),`${o}-${s}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if("dot"===e)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":am`[^\n]`;if("digit"===e)return t?am`\D`:am`\d`;if("property"===e){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&aD.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?am`\P`:am`\p`}{${r?`${r}=`:""}${n}}`}if("word"===e)return t?am`\W`:am`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags:(e,t)=>(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":""),Group({atomic:e,body:t,flags:n,parent:r},i,o){let s=i.currentFlags;n&&(i.currentFlags=av(s,n));let a=t.map(o).join("|"),l=i.verbose||1!==t.length||"Quantifier"===r.type||e||i.useFlagMods&&n?`(?${function(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?"i":"")+(e?.dotAll?"s":"")+(n?"-":"")+(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")}return`${r}:`}(e,n,i.useFlagMods)}${a})`:a;return i.currentFlags=s,l},LookaroundAssertion({body:e,kind:t,negate:n},r,i){let o=`${"lookahead"===t?"":"<"}${n?"!":"="}`;return`(?${o}${e.map(i).join("|")})`},Quantifier:(e,t,n)=>n(e.body)+function({kind:e,max:t,min:n}){return(n||1!==t?n||t!==1/0?1===n&&t===1/0?"+":n===t?`{${n}}`:`{${n},${t===1/0?"":t}}`:"*":"?")+({greedy:"",lazy:"?",possessive:"+"})[e]}(e),Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return 0===t?`(?R=${r})`:am`\g<${t}&R=${r}>`}},aJ=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),aX=new Set(["-","\\","]","^","["]),aY=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),aQ=new Map([[9,am`\t`],[10,am`\n`],[11,am`\v`],[12,am`\f`],[13,am`\r`],[8232,am`\u2028`],[8233,am`\u2029`],[65279,am`\uFEFF`]]),aZ=/^\p{Cased}$/u;function a0(e){return aZ.test(e)}function a1(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,o=[];if(r<65&&(65535===i||i>=131071)||65536===r&&i>=131071)return o;for(let e=r;e<=i;e++){let t=af(e);if(!a0(t))continue;let s=aN(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(s.length&&(o.push(...s),n))break}return o}function a2(e,{escDigit:t,inCharClass:n,useFlagV:r}){var i;if(aQ.has(e))return aQ.get(e);if(e<32||e>126&&e<160||e>262143||t&&(i=e)>47&&i<58)return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=af(e);return((n?r?aY:aX:aJ).has(o)?"\\":"")+o}function a8({type:e}){return"CapturingGroup"===e||"Group"===e||"LookaroundAssertion"===e}function a5({type:e,value:t}){return"Character"===e&&45===t}var a6=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(t,n,r){const i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error("Cannot provide options when copying a regexp");super(t,n),this.#n=t.source,t instanceof e&&(this.#e=t.#e,this.#r=t.#r,this.#i=t.#i,this.rawOptions=t.rawOptions)}else{const e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?"":t,n),this.#n=t,this.#e=function(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)ab(n,t,{}).transferTo=e;return n}(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if("clip_search"===this.#i&&n&&r){this.lastIndex=0;let e=this.#o(t.slice(r));return e&&(function(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#o(t)}#o(e){let t;this.#t.lastIndex=this.lastIndex;let n=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!n||!this.#e.size)return n;let r=[...n];n.length=1,this.hasIndices&&(t=[...n.indices],n.indices.length=1);let i=[0];for(let e=1;e<r.length;e++){let{hidden:o,transferTo:s}=this.#e.get(e)??{};if(o?i.push(null):(i.push(n.length),n.push(r[e]),this.hasIndices&&n.indices.push(t[e])),s&&void 0!==r[e]){let o=i[s];if(!o)throw Error(`Invalid capture transfer to "${o}"`);if(n[o]=r[e],this.hasIndices&&(n.indices[o]=t[e]),n.groups){this.#r||(this.#r=function(e){let t,n=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,r=new Map,i=0,o=0;for(;t=n.exec(e);){let{0:e,groups:{capture:n,name:s}}=t;"["===e?i++:i?"]"===e&&i--:n&&(o++,s&&r.set(o,s))}return r}(this.source));let i=this.#r.get(s);i&&(n.groups[i]=r[e],this.hasIndices&&(n.indices.groups[i]=t[e]))}}}return n}};class a3{constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if("string"!=typeof e)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){let r="string"==typeof e?e:e.content,i=[];function o(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>null==e?{start:0xffffffff,end:0xffffffff,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let s=n.exec(r);if(!s)continue;if(s.index===t)return o(e,s,0);i.push([e,s,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return o(t,n,r)}return null}}async function a4({themes:t,langs:n,preferredHighlighter:i="shiki-js"}){let o=!function(e=r){return null!=e&&"then"in e}(r??=sp({themes:[],langs:["text"],engine:"shiki-wasm"===i?sh(e.A(62631)):function(e={}){let t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=e=>{let n;return(n=function(e,t){var n;let r,i,o,s,a=aw(t),l=(n=sj(e,{flags:a.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:a.rules.captureGroup,singleline:a.rules.singleline},skipBackrefValidation:a.rules.allowOrphanBackrefs,unicodePropertyMap:aA}),r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...{accuracy:a.accuracy,asciiWordBoundaries:a.rules.asciiWordBoundaries,avoidSubclass:a.avoidSubclass,bestEffortTarget:a.target}},aj(n),i={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ax[r.bestEffortTarget]>=ax.ES2024,passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:n.flags.digitIsAscii,spaceIsAscii:n.flags.spaceIsAscii,wordIsAscii:n.flags.wordIsAscii},s8(n,aR,i),s={currentFlags:o={dotAll:n.flags.dotAll,ignoreCase:n.flags.ignoreCase},prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:i.subroutineRefMap},s8(n,aP,s),s8(n,a_,{groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer}),n._originMap=s.groupOriginByCopy,n._strategy=i.strategy,n),c=function(e,t){let n=aw(t),r=ax[n.target]>=ax.ES2024,i=ax[n.target]>=ax.ES2025,o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw Error("Invalid recursionLimit; use 2-20");let s=null,a=null;if(!i){let t=[e.flags.ignoreCase];s8(e,aq,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?s=!0:a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||s)&&!a)},c=e,d={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!i&&s&&a),useFlagMods:i,useFlagV:r,verbose:n.verbose};function u(e){return d.lastNode=c,c=e,(function(e,t){if(null==e)throw Error(t??"Value expected");return e})(aK[e.type],`Unexpected node type "${e.type}"`)(e,d,u)}let h={pattern:e.body.map(u).join("|"),flags:u(e.flags),options:{...e.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],d.captureMap.forEach((e,t)=>{e.hidden&&h._hiddenCaptures.push(t),e.transferTo&&ab(h._captureTransfers,e.transferTo,[]).push(t)}),h}(l,a),d=function(e,t){let n,{hiddenCaptures:r,mode:i}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!RegExp(ao,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:r};if("plugin"===i&&s9(e,ar`\(\?\(DEFINE\)`,s4.DEFAULT))throw Error("DEFINE groups cannot be used with recursion");let s=[],a=s9(e,ar`\\[1-9]`,s4.DEFAULT),l=new Map,c=[],d=!1,u=0,h=0;for(al.lastIndex=0;n=al.exec(e);){let{0:t,groups:{captureName:p,rDepth:f,gRNameOrNum:m,gRDepth:g}}=n;if("["===t)u++;else if(u)"]"===t&&u--;else if(f){if(ad(f),d)throw Error(ac);if(a)throw Error(`${"external"===i?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let t=e.slice(0,n.index),l=e.slice(al.lastIndex);if(s9(l,ao,s4.DEFAULT))throw Error(ac);let c=f-1;e=au(t,l,c,!1,r,s,h),o=ap(o,t,c,s.length,0,h);break}else if(m){ad(g);let u=!1;for(let e of c)if(e.name===m||e.num===+m){if(u=!0,e.hasRecursedWithin)throw Error(ac);break}if(!u)throw Error(ar`Recursive \g cannot be used outside the referenced group "${"external"===i?m:ar`\g<${m}&R=${g}>`}"`);let p=l.get(m),f=function(e,t){let n,r=/\\?./gsu;r.lastIndex=t;let i=e.length,o=0,s=1;for(;n=r.exec(e);){let[e]=n;if("["===e)o++;else if(o)"]"===e&&o--;else if("("===e)s++;else if(")"===e&&!--s){i=n.index;break}}return e.slice(t,i)}(e,p);if(a&&s9(f,ar`${as}|\((?!\?)`,s4.DEFAULT))throw Error(`${"external"===i?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let y=e.slice(p,n.index),v=f.slice(y.length+t.length),b=s.length,x=g-1,k=au(y,v,x,!0,r,s,h);o=ap(o,y,x,s.length-b,b,h);let w=e.slice(0,p),S=e.slice(p+f.length);e=`${w}${k}${S}`,al.lastIndex+=k.length-t.length-y.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),d=!0}else if(p)h++,l.set(String(h),al.lastIndex),l.set(p,al.lastIndex),c.push({num:h,name:p});else if("("===t[0]){let e="("===t;e&&(h++,l.set(String(h),al.lastIndex)),c.push(e?{num:h}:{})}else")"===t&&c.pop()}return r.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:r}}(c.pattern,{captureTransfers:c._captureTransfers,hiddenCaptures:c._hiddenCaptures,mode:"external"}),u=function(e,t){let n,r=t?.hiddenCaptures??[],i=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:r};let o="(?:(?=(",s=[0],a=[],l=0,c=0,d=NaN;do{let t;n=!1;let u=0,h=0,p=!1;for(ae.lastIndex=Number.isNaN(d)?0:d+o.length;t=ae.exec(e);){let{0:f,index:m,groups:{capturingStart:g,noncapturingStart:y}}=t;if("["===f)u++;else if(u)"]"===f&&u--;else if("(?>"!==f||p){if(p&&y)h++;else if(g)p?h++:(l++,s.push(l+c));else if(")"===f&&p){if(!h){let t=l+ ++c;e=`${e.slice(0,d)}${o}${e.slice(d+3,m)}))<$$${t}>)${e.slice(m+1)}`,n=!0,a.push(t);for(let e=0;e<r.length;e++)r[e]>=t&&r[e]++;if(i.size){let e=new Map;i.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),i=e}break}h--}}else d=m,p=!0}}while(n)return r.push(...a),{pattern:e=s7(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>s.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${s[n]}`}return`\\${n}`},s4.DEFAULT),captureTransfers:i,hiddenCaptures:r}}(function(e){let t;if(!RegExp(`${at}\\+`).test(e))return{pattern:e};let n=[],r=null,i=null,o="",s=0;for(an.lastIndex=0;t=an.exec(e);){let{0:c,index:d,groups:{qBase:u,qMod:h,invalidQ:p}}=t;if("["===c)s||(i=d),s++;else if("]"===c)s?s--:i=null;else if(!s)if("+"===h&&o&&!o.startsWith("(")){if(p)throw Error(`Invalid quantifier "${c}"`);let t=-1;if(/^\{\d+\}$/.test(u)){var a,l;a=e,l=d+u.length,e=a.slice(0,l)+""+a.slice(l+h.length)}else{if(")"===o||"]"===o){let t=")"===o?r:i;if(null===t)throw Error(`Invalid unmatched "${o}"`);e=`${e.slice(0,t)}(?>${e.slice(t,d)}${u})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-o.length)}(?>${o}${u})${e.slice(d+c.length)}`;t+=4}an.lastIndex+=t}else"("===c[0]?n.push(d):")"===c&&(r=n.length?n.pop():null);o=c}return{pattern:e}}(d.pattern).pattern,{captureTransfers:d.captureTransfers,hiddenCaptures:d.hiddenCaptures}),h={pattern:u.pattern,flags:`${a.hasIndices?"d":""}${a.global?"g":""}${c.flags}${c.options.disable.v?"u":"v"}`};if(a.avoidSubclass){if(a.lazyCompileLength!==1/0)throw Error("Lazy compilation requires subclass")}else{let e=u.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(u.captureTransfers),n=l._strategy,r=h.pattern.length>=a.lazyCompileLength;(e.length||t.length||n||r)&&(h.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...n&&{strategy:n},...r&&{lazyCompile:r}})}return h}(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...{target:t.target}})).options?new a6(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)},{createScanner:e=>new a3(e,t),createString:e=>({content:e})}}()}))?r:await r;r=o;let s=[];for(let e of n){if("text"===e||"ansi"===e)continue;let t=il(e);"then"in t?s.push(t):ie(t,o)}let a=[];for(let e of t){let t=o7(e);"then"in t?a.push(t):ip(t,r)}return(s.length>0||a.length>0)&&await Promise.all([Promise.all(s).then(e=>{ie(e,o)}),Promise.all(a).then(e=>{ip(e,o)})]),o}function a7(e=nc){let t=[];return"string"==typeof e?t.push(e):(t.push(e.dark),t.push(e.light)),t}function a9(e){for(let t of a7(e))if(!ih.has(t))return!1;return!0}function le(e,t){return null==e||null==t||"string"==typeof e||"string"==typeof t?e===t:e.dark===t.dark&&e.light===t.light}o9("pierre-dark",async()=>{let t=await e.A(96109);return{...t.default??t,name:"pierre-dark"}}),o9("pierre-light",async()=>{let t=await e.A(87087);return{...t.default??t,name:"pierre-light"}});let lt=new Map,ln={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function lr(e){if(lt.has(e))return lt.get(e)??"text";if(null!=ln[e])return ln[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(null!=t){if(lt.has(t[1]))return lt.get(t[1])??"text";if(null!=ln[t[1]])return ln[t[1]]??"text"}let n=e.match(/\.([^.]+)$/)?.[1]??"";return lt.has(n)?lt.get(n)??"text":ln[n]??"text"}function li(e){return nC({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function lo(e){return nC({tagName:"div",children:[nC({tagName:"span",children:[nS("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function ls(e){return nC({tagName:"div",children:[nN({name:"both"===e?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{"data-expand-button":"","data-expand-both":"both"===e?"":void 0,"data-expand-up":"up"===e?"":void 0,"data-expand-down":"down"===e?"":void 0}})}function la({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:o,isLastHunk:s}){let a=[];if("metadata"===e&&null!=t&&a.push(nC({tagName:"div",children:[nS(t)],properties:{"data-separator-wrapper":""}})),("line-info"===e||"line-info-basic"===e)&&null!=t){let e=[];null!=n&&(r?(o||e.push(ls("up")),s||e.push(ls("down"))):e.push(ls(o||s?o?"down":"up":"both"))),e.push(nC({tagName:"div",children:[nC({tagName:"span",children:[nS(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),a.push(nC({tagName:"div",children:e,properties:{"data-separator-wrapper":"","data-separator-multi-button":e.length>2?"":void 0}}))}return"custom"===e&&null!=i&&a.push(nC({tagName:"slot",properties:{name:i}})),nC({tagName:"div",children:a,properties:{"data-separator":0===a.length?"simple":e,"data-expand-index":n,"data-separator-first":o?"":void 0,"data-separator-last":s?"":void 0}})}function ll({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:o=1,callback:s}){let a={finalHunk:e.hunks.at(-1),viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:0,unifiedCount:0,shouldBreak(){if(!a.isWindowedHighlight)return!1;let e=a.unifiedCount>=n+r,i=a.splitCount>=n+r;return"unified"===t?e:"split"===t?i:e&&i},shouldSkip(e,r){if(!a.isWindowedHighlight)return!1;let i=a.unifiedCount+e<n,o=a.splitCount+r<n;return"unified"===t?i:"split"===t?o:i&&o},incrementCounts(e,n){("unified"===t||"both"===t)&&(a.unifiedCount+=e),("split"===t||"both"===t)&&(a.splitCount+=n)},isInWindow(e,n){if(!a.isWindowedHighlight)return!0;let r=a.isInUnifiedWindow(e),i=a.isInSplitWindow(n);return"unified"===t?r:"split"===t?i:r||i},isInUnifiedWindow:e=>!a.isWindowedHighlight||a.unifiedCount>=n-e&&a.unifiedCount<n+r,isInSplitWindow:e=>!a.isWindowedHighlight||a.splitCount>=n-e&&a.splitCount<n+r,emit:(e,n=!1)=>(n||("unified"===t?a.incrementCounts(1,0):"split"===t?a.incrementCounts(0,1):a.incrementCounts(1,1)),s(e)??!1)};e:for(let[n,r]of e.hunks.entries()){if(a.shouldBreak())break;let s=lc(e.isPartial,r.collapsedBefore,i,n,o),d=(()=>{if(r!==a.finalHunk||!function(e){let t=e.hunks.at(-1);return null!=t&&!e.isPartial&&0!==e.additionLines.length&&0!==e.deletionLines.length&&(t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length)}(e))return;let t=e.additionLines.length-(r.additionLineIndex+r.additionCount),n=e.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(t!==n)throw Error(`iterateOverDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${e.name}`);let s=Math.min(t,n);return lc(e.isPartial,s,i,e.hunks.length,o)})(),u=s.fromStart+s.fromEnd;function l(e,n){return null==d||d.collapsedLines<=0||d.fromStart+d.fromEnd>0?0:"unified"===t?e===r.unifiedLineStart+r.unifiedLineCount-1?d.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?d.collapsedLines:0}function c(){if(0===s.collapsedLines)return 0;let e=s.collapsedLines;return s.collapsedLines=0,e}if(a.shouldSkip(u,u))a.incrementCounts(u,u),c();else{let e=r.unifiedLineStart-s.rangeSize,t=r.splitLineStart-s.rangeSize,i=r.deletionLineIndex-s.rangeSize,o=r.additionLineIndex-s.rangeSize,l=r.deletionStart-s.rangeSize,d=r.additionStart-s.rangeSize,u=0;for(;u<s.fromStart;){if(a.isInWindow(0,0)){if(a.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:l+u,lineIndex:i+u,noEOFCR:!1,unifiedLineIndex:e+u,splitLineIndex:t+u},additionLine:{unifiedLineIndex:e+u,splitLineIndex:t+u,lineIndex:o+u,lineNumber:d+u,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);u++}for(e=r.unifiedLineStart-s.fromEnd,t=r.splitLineStart-s.fromEnd,i=r.deletionLineIndex-s.fromEnd,o=r.additionLineIndex-s.fromEnd,l=r.deletionStart-s.fromEnd,d=r.additionStart-s.fromEnd,u=0;u<s.fromEnd;){if(a.isInWindow(0,0)){if(a.emit({hunkIndex:n,hunk:r,collapsedBefore:c(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:l+u,lineIndex:i+u,noEOFCR:!1,unifiedLineIndex:e+u,splitLineIndex:t+u},additionLine:{unifiedLineIndex:e+u,splitLineIndex:t+u,lineIndex:o+u,lineNumber:d+u,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);u++}}let h=r.unifiedLineStart,p=r.splitLineStart,f=r.deletionLineIndex,m=r.additionLineIndex,g=r.deletionStart,y=r.additionStart,v=r.hunkContent.at(-1);for(let e of r.hunkContent){if(a.shouldBreak())break e;let i=e===v;if("context"===e.type){if(a.shouldSkip(e.lines,e.lines))a.incrementCounts(e.lines,e.lines),c();else{let t=0;for(;t<e.lines;){if(a.isInWindow(0,0)){let o=i&&t===e.lines-1,s=h+t,d=p+t;if(a.emit({hunkIndex:n,hunk:r,collapsedBefore:c(),collapsedAfter:l(s,d),type:"context",deletionLine:{lineNumber:g+t,lineIndex:f+t,noEOFCR:o&&r.noEOFCRDeletions,unifiedLineIndex:s,splitLineIndex:d},additionLine:{unifiedLineIndex:s,splitLineIndex:d,lineIndex:m+t,lineNumber:y+t,noEOFCR:o&&r.noEOFCRAdditions}}))break e}else a.incrementCounts(1,1);t++}}h+=e.lines,p+=e.lines,f+=e.lines,m+=e.lines,g+=e.lines,y+=e.lines}else{let o=Math.max(e.deletions,e.additions),s=e.deletions+e.additions;if(!a.shouldSkip(s,o))for(let[d,u]of function(e,t,n){if(!e.isWindowedHighlight)return[[0,"unified"===n?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r="unified"===n?"unified":"split",i=[];function o(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function s(e,n){if(null==e)return;let[o,s]="split"===r?e:"additions"===n?[e[0]+t.deletions,e[1]+t.deletions]:e;s>o&&i.push([o,s])}if("split"!==n&&(s(o(e.unifiedCount,t.deletions),"deletions"),s(o(e.unifiedCount+t.deletions,t.additions),"additions")),"unified"!==n&&(s(o(e.splitCount,t.deletions),"deletions"),s(o(e.splitCount,t.additions),"additions")),0===i.length)return i;i.sort((e,t)=>e[0]-t[0]);let a=[i[0]];for(let[e,t]of i.slice(1)){let n=a[a.length-1];e<=n[1]?n[1]=Math.max(n[1],t):a.push([e,t])}return a}(a,e,t))for(let v=d;v<u;v++){let d=l(h+v,"unified"===t?p+(v<e.deletions?v:v-e.deletions):p+v);if(a.emit(function({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:o,unifiedLineIndex:s,splitLineIndex:a,additionLineIndex:l,deletionLineIndex:c,additionLineNumber:d,deletionLineNumber:u,content:h,isLastContent:p,unifiedCount:f,splitCount:m}){let g=o<h.deletions?s+o:void 0,y="unified"===i?o>=h.deletions?s+o:void 0:o<h.additions?s+h.deletions+o:void 0,v="unified"===i?a+(o<h.deletions?o:o-h.deletions):a+o,b=o<h.deletions?c+o:void 0,x=o<h.deletions?u+o:void 0,k="unified"===i?o>=h.deletions?l+(o-h.deletions):void 0:o<h.additions?l+o:void 0,w="unified"===i?o>=h.deletions?d+(o-h.deletions):void 0:o<h.additions?d+o:void 0,S="unified"===i?p&&o===h.deletions-1&&t.noEOFCRDeletions:p&&o===m-1&&t.noEOFCRDeletions,C="unified"===i?p&&o===f-1&&t.noEOFCRAdditions:p&&o===m-1&&t.noEOFCRAdditions,N=null!=b&&null!=x&&null!=g?{lineNumber:x,lineIndex:b,noEOFCR:S,unifiedLineIndex:g,splitLineIndex:v}:void 0,A=null!=k&&null!=w&&null!=y?{unifiedLineIndex:y,splitLineIndex:v,lineIndex:k,lineNumber:w,noEOFCR:C}:void 0;if(null==N&&null!=A)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:A};if(null!=N&&null==A)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:N,additionLine:void 0};if(null==N||null==A)throw Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:N,additionLine:A}}({hunkIndex:n,hunk:r,collapsedBefore:c(),collapsedAfter:d,diffStyle:t,index:v,unifiedLineIndex:h,splitLineIndex:p,additionLineIndex:m,deletionLineIndex:f,additionLineNumber:y,deletionLineNumber:g,content:e,isLastContent:i,unifiedCount:s,splitCount:o}),!0))break e}c(),a.incrementCounts(s,o),h+=s,p+=o,f+=e.deletions,m+=e.additions,g+=e.deletions,y+=e.additions}}if(null!=d){let{collapsedLines:t,fromStart:n,fromEnd:r}=d,i=n+r,o=0;for(;o<i;){if(a.shouldBreak())break e;if(a.isInWindow(0,0)){let n=o===i-1;if(a.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:n?t:0,type:"context-expanded",deletionLine:{lineNumber:g+o,lineIndex:f+o,noEOFCR:!1,unifiedLineIndex:h+o,splitLineIndex:p+o},additionLine:{unifiedLineIndex:h+o,splitLineIndex:p+o,lineIndex:m+o,lineNumber:y+o,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);o++}}}}function lc(e,t,n,r,i){if(0===(t=Math.max(t,0))||e)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:Math.max(t,0)};if(!0===n||t<=i)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),t),a=Math.min(Math.max(o?.fromEnd??0,0),t),l=s+a,c=l>=t;return{fromStart:c?t:s,fromEnd:c?0:a,rangeSize:t,collapsedLines:Math.max(t-l,0)}}let ld=function(e={}){let{classPrefix:t="__shiki_",classSuffix:n="",classReplacer:r=e=>e}=e,i=new Map;function o(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(";")}function s(e){let s=t+function(e,t=0){let n=0xdeadbeef^t,r=0x41c6ce57^t;for(let t=0,i;t<e.length;t++)n=Math.imul(n^(i=e.charCodeAt(t)),0x9e3779b1),r=Math.imul(r^i,0x5f356495);return n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35),(0x100000000*(2097151&(r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35)))+(n>>>0)).toString(36).slice(0,6)}("string"==typeof e?e:o(e))+n;return s=r(s),i.has(s)||i.set(s,"string"==typeof e?e:{...e}),s}return{name:"@shikijs/transformers:style-to-class",pre(e){if(!e.properties.style)return;let t=s(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=s(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry:()=>i,getCSS(){let e="";for(let[t,n]of i.entries())e+=`.${t}{${"string"==typeof n?n:o(n)}}`;return e},clearRegistry(){i.clear()}}}({classPrefix:"hl-"}),lu={name:"token-style-normalizer",tokens(e){for(let t of e)for(let e of t){if(null!=e.htmlStyle)continue;let t={};null!=e.color&&(t.color=e.color),null!=e.bgColor&&(t["background-color"]=e.bgColor),null!=e.fontStyle&&0!==e.fontStyle&&((1&e.fontStyle)!=0&&(t["font-style"]="italic"),(2&e.fontStyle)!=0&&(t["font-weight"]="bold"),(4&e.fontStyle)!=0&&(t["text-decoration"]="underline")),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function lh(e){return`--${"token"===e?"diffs-token":"diffs"}-`}function lp(e,t){t=null!=t?`${t}-`:"";let n="",r=e.colors?.["gitDecoration.addedResourceForeground"]??e.colors?.["terminal.ansiGreen"];null!=r&&(n+=`${lh("global")}${t}addition-color:${r};`);let i=e.colors?.["gitDecoration.deletedResourceForeground"]??e.colors?.["terminal.ansiRed"];null!=i&&(n+=`${lh("global")}${t}deletion-color:${i};`);let o=e.colors?.["gitDecoration.modifiedResourceForeground"]??e.colors?.["terminal.ansiBlue"];return null!=o&&(n+=`${lh("global")}${t}modified-color:${o};`),n}function lf(e){let t=e.children[0];for(;null!=t;){if("element"===t.type&&"code"===t.tagName)return t.children;t="children"in t?t.children[0]:null}throw console.error(e),Error("getLineNodes: Unable to find children")}function lm({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function lg({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let o=t[t.length-1];if(null==o||i||!n)return void t.push([+!r,e.value]);let s=0===o[0];if(r===s||r&&1===e.value.length&&!s){o[1]+=e.value;return}t.push([+!r,e.value])}class ly{diff(e,t,n={}){let r;"function"==typeof n?(r=n,n={}):"callback"in n&&(r=n.callback);let i=this.castInput(e,n),o=this.castInput(t,n),s=this.removeEmpty(this.tokenize(i,n)),a=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(s,a,n,r)}diffWithOptionsObj(e,t,n,r){var i;let o=e=>(e=this.postProcess(e,n),r)?void setTimeout(function(){r(e)},0):e,s=t.length,a=e.length,l=1,c=s+a;null!=n.maxEditLength&&(c=Math.min(c,n.maxEditLength));let d=null!=(i=n.timeout)?i:1/0,u=Date.now()+d,h=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(h[0],t,e,0,n);if(h[0].oldPos+1>=a&&p+1>=s)return o(this.buildValues(h[0].lastComponent,t,e));let f=-1/0,m=1/0,g=()=>{for(let r=Math.max(f,-l);r<=Math.min(m,l);r+=2){let i,l=h[r-1],c=h[r+1];l&&(h[r-1]=void 0);let d=!1;if(c){let e=c.oldPos-r;d=c&&0<=e&&e<s}let u=l&&l.oldPos+1<a;if(!d&&!u){h[r]=void 0;continue}if(i=!u||d&&l.oldPos<c.oldPos?this.addToPath(c,!0,!1,0,n):this.addToPath(l,!1,!0,1,n),p=this.extractCommon(i,t,e,r,n),i.oldPos+1>=a&&p+1>=s)return o(this.buildValues(i.lastComponent,t,e))||!0;h[r]=i,i.oldPos+1>=a&&(m=Math.min(m,r-1)),p+1>=s&&(f=Math.max(f,r+1))}l++};if(r)!function e(){setTimeout(function(){if(l>c||Date.now()>u)return r(void 0);g()||e()},0)}();else for(;l<=c&&Date.now()<=u;){let e=g();if(e)return e}}addToPath(e,t,n,r,i){let o=e.lastComponent;return o&&!i.oneChangePerToken&&o.added===t&&o.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:o.count+1,added:t,removed:n,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:o}}}extractCommon(e,t,n,r,i){let o=t.length,s=n.length,a=e.oldPos,l=a-r,c=0;for(;l+1<o&&a+1<s&&this.equals(n[a+1],t[l+1],i);)l++,a++,c++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return c&&!i.oneChangePerToken&&(e.lastComponent={count:c,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,l}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r,i=[];for(;e;)i.push(e),r=e.previousComponent,delete e.previousComponent,e=r;i.reverse();let o=i.length,s=0,a=0,l=0;for(;s<o;s++){let e=i[s];if(e.removed)e.value=this.join(n.slice(l,l+e.count)),l+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(a,a+e.count);r=r.map(function(e,t){let r=n[l+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(a,a+e.count));a+=e.count,e.added||(l+=e.count)}}return i}}let lv=new class extends ly{};function lb(e,t){let n;for(n=0;n<e.length&&n<t.length&&e[n]==t[n];n++);return e.slice(0,n)}function lx(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return"";for(n=0;n<e.length&&n<t.length&&e[e.length-(n+1)]==t[t.length-(n+1)];n++);return e.slice(-n)}function lk(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function lw(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function lS(e,t){return lk(e,t,"")}function lC(e,t){return t.slice(0,function(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),o=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[o]?i[e]=i[o]:i[e]=o;o>0&&t[e]!=t[o];)o=i[o];t[e]==t[o]&&o++}o=0;for(let r=n;r<e.length;r++){for(;o>0&&e[r]!=t[o];)o=i[o];e[r]==t[o]&&o++}return o}(e,t))}function lN(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function lA(e){let t=e.match(/^\s*/);return t?t[0]:""}let lE="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",lM=RegExp(`[${lE}]+|\\s+|[^${lE}]`,"ug");function lT(e,t,n,r){var i,o,s,a;if(t&&n){let s=lA(t.value),a=lN(t.value),l=lA(n.value),c=lN(n.value);if(e){let r=lb(s,l);e.value=lw(e.value,l,r),t.value=lS(t.value,r),n.value=lS(n.value,r)}if(r){let e=lx(a,c);r.value=lk(r.value,c,e),i=t.value,t.value=lw(i,e,""),o=n.value,n.value=lw(o,e,"")}}else if(n){if(e){let e=lA(n.value);n.value=n.value.substring(e.length)}if(r){let e=lA(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=lA(r.value),i=lA(t.value),o=lN(t.value),a=lb(n,i);t.value=lS(t.value,a);let l=lx(lS(n,a),o);s=t.value,t.value=lw(s,l,""),r.value=lk(r.value,n,l),e.value=lw(e.value,n,n.slice(0,n.length-l.length))}else if(r){let e=lA(r.value),n=lC(lN(t.value),e);a=t.value,t.value=lw(a,n,"")}else if(e){let n=lC(lN(e.value),lA(t.value));t.value=lS(t.value,n)}}new class extends ly{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if("word"!=r.resolvedOptions().granularity)throw Error('The segmenter passed must have a granularity of "word"');for(let t of(n=[],Array.from(r.segment(e)))){let e=t.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}}else n=e.match(lM)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?null==i?r.push(e):r.push(r.pop()+e):null!=i&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>0==t?e:e.replace(/^\s+/,"")).join("")}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&lT(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&lT(n,i,r,null),e}};let lI=new class extends ly{tokenize(e){let t=RegExp(`(\\r?\\n)|[${lE}]+|[^\\S\\n\\r]+|[^${lE}]`,"ug");return e.match(t)||[]}},lL={forcePlainText:!1},lO=-1;var lD=class{__id=`diff-hunks-renderer:${++lO}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang="text";renderCache;constructor(e={theme:nc},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=a9(e.theme??nc)?function(){if(null!=r&&!("then"in r))return r}():void 0)}cleanUp(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){this.getOptionsWithDefaults().themeType!==e&&this.mergeOptions({themeType:e})}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};("up"===t||"both"===t)&&(r.fromStart+=n),("down"===t||"both"===t)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&(this.renderCache=void 0),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??nh}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){for(let t of(this.additionAnnotations={},this.deletionAnnotations={},e)){let e=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e}}getSplitLineDecoration({side:e,type:t}){return"change"!==t?{gutterLineType:t}:{gutterLineType:"deletions"===e?"change-deletion":"change-addition"}}createAnnotationElement(e){return nC({tagName:"div",children:[nC({tagName:"div",children:e.annotations?.map(e=>nC({tagName:"slot",properties:{name:e}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}getOptionsWithDefaults(){let{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:o=!1,collapsed:s=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:c=100,hunkSeparators:d="line-info",lineDiffType:u="word-alt",maxLineDiffLength:h=1e3,overflow:p="scroll",theme:f=nc,themeType:m="system",tokenizeMaxLineLength:g=1e3,useCSSClasses:y=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:o,collapsed:s,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:c,hunkSeparators:d,lineDiffType:u,maxLineDiffLength:h,overflow:p,theme:this.workerManager?.getDiffRenderOptions().theme??f,themeType:m,tokenizeMaxLineLength:g,useCSSClasses:y}}async initializeHighlighter(){return this.highlighter=await a4(function(e,{theme:t,preferredHighlighter:n="shiki-js"}){return{langs:[e??"text"],themes:a7(t),preferredHighlighter:n}}(this.computedLang,this.options)),this.highlighter}hydrate(e){if(null==e)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=this.workerManager?.getDiffResultCache(e);null==n||lR(t,n.options)||(n=void 0),this.renderCache??={diff:e,highlighted:!0,options:t,result:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0&&null==this.renderCache.result?this.workerManager.highlightDiffAST(this,this.diff):this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}=this.getOptionsWithDefaults();return{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result!=null&&e===n.diff&&lR(t,n.options)?{options:t,forceRender:!1}:{options:t,forceRender:!0}}renderDiff(e=this.renderCache?.diff,t=np){if(null==e)return;let{expandUnchanged:n=!1,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),i=this.workerManager?.getDiffResultCache(e);null!=i&&null==this.renderCache&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...i});let{options:o,forceRender:s}=this.getRenderOptions(e);if(this.renderCache??={diff:e,highlighted:!1,options:o,result:void 0,renderRange:void 0},this.workerManager?.isWorkingPool()===!0){(null==this.renderCache.result||!this.renderCache.highlighted&&!rZ(this.renderCache.renderRange,t))&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,0===t.startingLine&&t.totalLines===1/0&&0===t.bufferBefore&&0===t.bufferAfter||!!n||this.expandedHunks,r),this.renderCache.renderRange=t);t.totalLines>0&&(!this.renderCache.highlighted||s)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??lr(e.name);let t=null!=this.highlighter&&a9(o.theme),n=null!=this.highlighter&&r9(this.computedLang);if(null!=this.highlighter&&t&&(s||!this.renderCache.highlighted&&n||null==this.renderCache.result)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,this.highlighter,!n);this.renderCache={diff:e,options:r,highlighted:n,result:t,renderRange:void 0}}t&&n||this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}return null!=this.renderCache.result?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=np){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n,r,i){var o;let{diffIndicators:s,disableBackground:a,disableLineNumbers:l,overflow:c,themeType:d}=this.getOptionsWithDefaults();return o={type:"diff",diffIndicators:s,disableBackground:a,disableLineNumbers:l,overflow:c,themeStyles:n,split:e,themeType:r??d,totalLines:t,customProperties:i},nC({tagName:"pre",properties:function({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,themeType:o,themeStyles:s,totalLines:a,type:l,customProperties:c}){let d={...c,"data-diff":"diff"===l?"":void 0,"data-file":"file"===l?"":void 0,"data-diff-type":"diff"===l?i?"split":"single":void 0,"data-overflow":r,"data-disable-line-numbers":n?"":void 0,"data-background":t?void 0:"","data-indicators":"bars"===e||"classic"===e?e:void 0,"data-theme-type":"system"!==o?o:void 0,style:s,tabIndex:0};return d.style+=`--diffs-min-number-column-width-default:${`${a}`.length}ch;`,d}(o)})}async asyncHighlight(e){this.computedLang=e.lang??lr(e.name);let t=null!=this.highlighter&&a9(this.options.theme??nc),n=null!=this.highlighter&&r9(this.computedLang);return null!=this.highlighter&&t&&n||(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:function(e,t,n,{forcePlainText:r,startingLine:i,totalLines:o,expandedHunks:s,collapsedContextThreshold:a=1}=lL){r?(i??=0,o??=1/0):(i=0,o=1/0);let l=i>0||o<1/0,c=(()=>{let e=n.theme??nc;if("string"==typeof e)return t.getTheme(e).type})(),d=function({theme:e=nc,highlighter:t,prefix:n}){let r="";if("string"==typeof e){let i=t.getTheme(e);r+=`color:${i.fg};`,r+=`background-color:${i.bg};`,r+=`${lh("global")}fg:${i.fg};`,r+=`${lh("global")}bg:${i.bg};`,r+=lp(i,n)}else{let n=t.getTheme(e.dark);r+=`${lh("global")}dark:${n.fg};`,r+=`${lh("global")}dark-bg:${n.bg};`,r+=lp(n,"dark"),n=t.getTheme(e.light),r+=`${lh("global")}light:${n.fg};`,r+=`${lh("global")}light-bg:${n.bg};`,r+=lp(n,"light")}return r}({theme:n.theme,highlighter:t}),u=r&&!l&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?"none":n.lineDiffType,h={deletionLines:[],additionLines:[]},p=!r&&!e.isPartial,f=new Map;function m(e,t,n,r){if(l){let e=n.at(-1);(null==e||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}for(let c of(ll({diff:e,diffStyle:"both",startingLine:i,totalLines:o,expandedHunks:!l||(r?s:void 0),collapsedContextThreshold:a,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let o,s,a=(o=p?0:t,s=f.get(o)??{deletionContent:{push(e){this.value+=e,this.length++},value:"",length:0},additionContent:{push(e){this.value+=e,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]},f.set(o,s),s),l=null!=n?n.splitLineIndex:r.splitLineIndex;"change"===i&&null!=n&&null!=r&&function({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:o,lineDiffType:s}){var a,l,c,d;if(null==e||null==t||"none"===s)return;e=nm(e),t=nm(t);let u="char"===s?(a=e,l=t,lv.diff(a,l,void 0)):(c=e,d=t,lI.diff(c,d,void 0)),h=[],p=[],f="word-alt"===s,m=u.at(-1);for(let e of u){let t=e===m;e.added||e.removed?e.removed?lg({item:e,arr:h,enableJoin:f,isLastItem:t}):lg({item:e,arr:p,enableJoin:f,isLastItem:t}):(lg({item:e,arr:h,enableJoin:f,isNeutral:!0,isLastItem:t}),lg({item:e,arr:p,enableJoin:f,isNeutral:!0,isLastItem:t}))}let g=0;for(let e of h)1===e[0]&&i.push(lm({line:n,spanStart:g,spanLength:e[1].length})),g+=e[1].length;for(let e of(g=0,p))1===e[0]&&o.push(lm({line:r,spanStart:g,spanLength:e[1].length})),g+=e[1].length}({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:u}),null!=r&&(m(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:"change"===i?"change-deletion":i,lineNumber:r.lineNumber,altLineNumber:"change"===i?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${l}`})),null!=n&&(m(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:"change"===i?"change-addition":i,lineNumber:n.lineNumber,altLineNumber:"change"===i?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${l}`}))}}),f.values())){if(0===c.deletionContent.length&&0===c.additionContent.length)continue;let i={name:e.prevName??e.name,contents:c.deletionContent.value},o={name:e.name,contents:c.additionContent.value},{deletionLines:s,additionLines:a}=function({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:o,additionDecorations:s,languageOverride:a,options:{theme:l=nc,...c}}){let d=a??lr(e.name),u=a??lr(t.name),{state:h,transformers:p}=function(e=!1){let t={lineInfo:[]},n=[{line:e=>(delete e.properties.class,e),pre(e){let n=function(e){let t=e.children[0];for(;null!=t;){if("element"===t.type&&"code"===t.tagName)return t;t="children"in t?t.children[0]:null}}(e),r=[];if(null!=n){let e=1;for(let i of n.children)"element"===i.type&&(r.push(function(e,t,n){let r="function"==typeof n.lineInfo?n.lineInfo(t):n.lineInfo[t-1];if(null==r){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName="div",e.properties["data-line"]=r.lineNumber,e.properties["data-alt-line"]=r.altLineNumber,e.properties["data-line-type"]=r.type,e.properties["data-line-index"]=r.lineIndex,0===e.children.length&&e.children.push(nS("\n")),e}(i,e,t)),e++);n.children=r}return e}}];return e&&n.push(lu,ld),{state:t,transformers:n,toClass:ld}}(),f="string"==typeof l?{...c,lang:"text",theme:l,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:lh("token")}:{...c,lang:"text",themes:l,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:lh("token")};return{deletionLines:""===e.contents?[]:(f.lang=d,h.lineInfo=n,f.decorations=o,lf(i.codeToHast(nm(e.contents),f))),additionLines:""===t.contents?[]:(f.lang=u,f.decorations=s,h.lineInfo=r,lf(i.codeToHast(nm(t.contents),f)))}}({deletionFile:i,deletionInfo:c.deletionInfo,deletionDecorations:c.deletionDecorations,additionFile:o,additionInfo:c.additionInfo,additionDecorations:c.additionDecorations,highlighter:t,options:n,languageOverride:r?"text":e.lang});if(p){h.deletionLines=s,h.additionLines=a;continue}if(c.deletionSegments.length>0)for(let e of c.deletionSegments)for(let t=0;t<e.count;t++)h.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else h.deletionLines.push(...s);if(c.additionSegments.length>0)for(let e of c.additionSegments)for(let t=0;t<e.count;t++)h.additionLines[e.targetIndex+t]=a[e.originalOffset+t];else h.additionLines.push(...a)}return{code:h,themeStyles:d,baseThemeType:c}}(e,t,r,{forcePlainText:n,expandedHunks:!!n||void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n){if(null==this.renderCache)return;let r=this.renderCache.diff!==e||!this.renderCache.highlighted||!lR(this.renderCache.options,n);this.renderCache={diff:e,options:n,highlighted:!0,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}onHighlightError(e){console.error(e)}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let o,{diffStyle:s,disableFileHeader:a,expandUnchanged:l,expansionLineCount:c,collapsedContextThreshold:d,hunkSeparators:u}=this.getOptionsWithDefaults();this.diff=e;let h="unified"===s,p=[],f=[],m=[],g=[],{additionLines:y,deletionLines:v}=n,b={rowCount:0,hunkSeparators:u,additionsContentAST:p,deletionsContentAST:f,unifiedContentAST:m,unifiedGutterAST:nA(),deletionsGutterAST:nA(),additionsGutterAST:nA(),expansionLineCount:c,hunkData:g,incrementRowCount(e=1){b.rowCount+=e},pushToGutter(e,t){switch(e){case"unified":b.unifiedGutterAST.children.push(t);break;case"deletions":b.deletionsGutterAST.children.push(t);break;case"additions":b.additionsGutterAST.children.push(t)}}},x=function(e){let t=e.hunks.at(-1);if(null==t||e.isPartial||0===e.additionLines.length||0===e.deletionLines.length)return 0;let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}(e),k={size:0,side:void 0,increment(){this.size+=1},flush(){if("unified"!==s){if(this.size<=0||null==this.side){this.side=void 0,this.size=0;return}"additions"===this.side?(b.pushToGutter("additions",nE(void 0,"buffer",this.size)),p?.push(li(this.size))):(b.pushToGutter("deletions",nE(void 0,"buffer",this.size)),f?.push(li(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{b.pushToGutter(e,function(e,t,n,r={}){return nC({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:null!=t?[nC({tagName:"span",properties:{"data-line-number-content":""},children:[nS(`${t}`)]})]:void 0})}(t,n,r,i))};function S(e){k.flush(),"unified"===s?lj("unified",e,b):(lj("deletions",e,b),lj("additions",e,b))}ll({diff:e,diffStyle:s,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:!!l||this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:a,type:l})=>{let c=null!=a?a.splitLineIndex:o.splitLineIndex,d=null!=o?o.unifiedLineIndex:a.unifiedLineIndex;"split"===s&&"change"!==l&&k.flush(),r>0&&S({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:0===t,isLastHunk:!1,isExpandable:!e.isPartial});let h="unified"===s?d:c,p={type:l,hunkIndex:t,lineIndex:h,unifiedLineIndex:d,splitLineIndex:c,deletionLine:a,additionLine:o};if("unified"===s){let n=null!=a?v[a.lineIndex]:void 0,r=null!=o?y[o.lineIndex]:void 0;if(null==n&&null==r){let t="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(t,{file:e.name}),Error(t)}let i="change"===l?null!=o?"change-addition":"change-deletion":l,s=this.getUnifiedLineDecoration({type:l,lineType:i,additionLineIndex:o?.lineIndex,deletionLineIndex:a?.lineIndex});w("unified",s.gutterLineType,null!=o?o.lineNumber:a.lineNumber,`${d},${c}`,s.gutterProperties),null!=r?r=lB(r,s.contentProperties):null!=n&&(n=lB(n,s.contentProperties)),l_({diffStyle:"unified",type:l,deletionLine:n,additionLine:r,unifiedSpan:this.getAnnotations("unified",a?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:b});let u=this.getUnifiedInlineRowsForLine?.(p);null!=u&&function(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}(u,b)}else{let n=null!=a?v[a.lineIndex]:void 0,r=null!=o?y[o.lineIndex]:void 0,i=this.getSplitLineDecoration({side:"deletions",type:l,lineIndex:a?.lineIndex}),s=this.getSplitLineDecoration({side:"additions",type:l,lineIndex:o?.lineIndex});if(null==n&&null==r){let t="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(t,{file:e.name}),Error(t)}let d=(()=>{if("change"===l){if(null==r)return"additions";else if(null==n)return"deletions"}})();if(null!=d){if(null!=k.side&&k.side!==d)throw Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");k.side=d,k.increment()}let u=this.getAnnotations("split",a?.lineNumber,o?.lineNumber,t,h);if(null!=u&&k.size>0&&k.flush(),null!=a){let e=lB(n,i.contentProperties);w("deletions",i.gutterLineType,a.lineNumber,`${a.unifiedLineIndex},${c}`,i.gutterProperties),null!=e&&(n=e)}if(null!=o){let e=lB(r,s.contentProperties);w("additions",s.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${c}`,s.gutterProperties),null!=e&&(r=e)}l_({diffStyle:"split",type:l,additionLine:r,deletionLine:n,...u,createAnnotationElement:e=>this.createAnnotationElement(e),context:b});let f=this.getSplitInlineRowsForLine?.(p);null!=f&&function(e,t,n){for(let{deletion:r,addition:i}of e){if(null==r&&null==i)continue;let e=null!=r&&null!=i?void 0:null==r?"deletions":"additions";(null==e||n.side!==e)&&n.flush(),null!=r&&(t.deletionsContentAST.push(r.content),t.pushToGutter("deletions",r.gutter)),null!=i&&(t.additionsContentAST.push(i.content),t.pushToGutter("additions",i.gutter)),null!=e&&(n.side=e,n.increment()),t.incrementRowCount(1)}}(f,b,k)}let f=a?.noEOFCR??!1,m=o?.noEOFCR??!1;if(m||f){if(f){let e="context"===l||"context-expanded"===l?l:"change-deletion";"unified"===s?(b.unifiedContentAST.push(lo(e)),b.pushToGutter("unified",nE(e,"metadata",1))):(b.deletionsContentAST.push(lo(e)),b.pushToGutter("deletions",nE(e,"metadata",1)),m||(b.pushToGutter("additions",nE(void 0,"buffer",1)),b.additionsContentAST.push(li(1))))}if(m){let e="context"===l||"context-expanded"===l?l:"change-addition";"unified"===s?(b.unifiedContentAST.push(lo(e)),b.pushToGutter("unified",nE(e,"metadata",1))):(b.additionsContentAST.push(lo(e)),b.pushToGutter("additions",nE(e,"metadata",1)),f||(b.pushToGutter("deletions",nE(void 0,"buffer",1)),b.deletionsContentAST.push(li(1))))}b.incrementRowCount(1)}i>0&&"simple"!==u&&S({hunkIndex:"context-expanded"===l?t:t+1,collapsedLines:i,rangeSize:x,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),b.incrementRowCount(1)}}),"split"===s&&k.flush();let C=Math.max(null==(o=e.hunks.at(-1))?0:Math.max(o.additionStart+o.additionCount,o.deletionStart+o.deletionCount),e.additionLines.length??0,e.deletionLines.length??0),N=t.bufferBefore>0||t.bufferAfter>0,A=!h&&"deleted"!==e.type,E=!h&&"new"!==e.type,M=b.rowCount>0||N;p=A&&M?p:void 0,f=E&&M?f:void 0,m=h&&M?m:void 0;let T=this.createPreElement(null!=f&&null!=p,C,r,i);return{unifiedGutterAST:h&&M?b.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:E&&M?b.deletionsGutterAST.children:void 0,deletionsContentAST:f,additionsGutterAST:A&&M?b.additionsGutterAST.children:void 0,additionsContentAST:p,hunkData:g,preNode:T,themeStyles:r,baseThemeType:i,headerElement:a?void 0:this.renderHeader(this.diff,r,i),totalLines:C,rowCount:b.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){var n;let r="unified"===e?t.unifiedGutterAST:"deletions"===e?t.deletionsGutterAST:t.additionsGutterAST,i="unified"===e?t.unifiedContentAST:"deletions"===e?t.deletionsContentAST:t.additionsContentAST;if(null==r||null==i)return;let o=nA(r);return o.properties.style=`grid-row: span ${t.rowCount}`,[o,(n=t.rowCount,nC({tagName:"div",children:i,properties:{"data-content":"",style:`grid-row: span ${n}`}}))]}renderFullAST(e,t=[]){let n="line-info"===this.getOptionsWithDefaults().hunkSeparators,r=this.renderCodeAST("unified",e);if(null!=r)return t.push(nC({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};let i=this.renderCodeAST("deletions",e);null!=i&&t.push(nC({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));let o=this.renderCodeAST("additions",e);return null!=o&&t.push(nC({tagName:"code",children:o,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return rU(this.renderFullAST(e,t))}renderPartialHTML(e,t){return null==t?rU(e):rU(nC({tagName:"code",children:e,properties:{"data-code":"","data-container-size":"line-info"===this.getOptionsWithDefaults().hunkSeparators?"":void 0,[`data-${t}`]:""}}))}getAnnotations(e,t,n,r,i){let o={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(null!=t)for(let e of this.deletionAnnotations[t]??[])o.annotations.push(nv(e));let s={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(null!=n)for(let t of this.additionAnnotations[n]??[])("unified"===e?o:s).annotations.push(nv(t));return"unified"===e?o.annotations.length>0?o:void 0:0!==s.annotations.length||0!==o.annotations.length?{deletionSpan:o,additionSpan:s}:void 0}renderHeader(e,t,n){let{themeType:r}=this.getOptionsWithDefaults();return function({fileOrDiff:e,themeStyles:t,themeType:n}){let r="type"in e?e:void 0,i={"data-diffs-header":"","data-change-type":r?.type,"data-theme-type":"system"!==n?n:void 0,style:t};return nC({tagName:"div",children:[function({name:e,prevName:t,iconType:n}){let r=[nC({tagName:"slot",properties:{name:na}}),nN({name:function(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}(n),properties:{"data-change-icon":n}})];return null!=t&&(r.push(nC({tagName:"div",children:[nS(t)],properties:{"data-prev-name":""}})),r.push(nN({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),r.push(nC({tagName:"div",children:[nS(e)],properties:{"data-title":""}})),nC({tagName:"div",children:r,properties:{"data-header-content":""}})}({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:r?.type??"file"}),function(e){let t=[];if(null!=e){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||0===n)&&t.push(nC({tagName:"span",children:[nS(`-${r}`)],properties:{"data-deletions-count":""}})),(n>0||0===r)&&t.push(nC({tagName:"span",children:[nS(`+${n}`)],properties:{"data-additions-count":""}}))}return t.push(nC({tagName:"slot",properties:{name:nl}})),nC({tagName:"div",children:t,properties:{"data-metadata":""}})}(r)],properties:i})}({fileOrDiff:e,themeStyles:t,themeType:n??r})}};function lR(e,t){return le(e.theme,t.theme)&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType}function lP(e){return`${e} unmodified line${e>1?"s":""}`}function l_({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:o,additionSpan:s,createAnnotationElement:a,context:l}){let c=!1;"unified"===e?(null!=r?l.unifiedContentAST.push(r):null!=n&&l.unifiedContentAST.push(n),null!=i&&(l.unifiedContentAST.push(a(i)),l.pushToGutter("unified",nE("change"===t?null!=n?"change-deletion":"change-addition":t,"annotation",1)),c=!0)):"split"===e&&(null!=n&&l.deletionsContentAST.push(n),null!=r&&l.additionsContentAST.push(r),null!=o&&(l.deletionsContentAST.push(a(o)),l.pushToGutter("deletions",nE("change"===t?null!=n?"change-deletion":"context":t,"annotation",1)),c=!0),null!=s&&(l.additionsContentAST.push(a(s)),l.pushToGutter("additions",nE("change"===t?null!=r?"change-addition":"context":t,"annotation",1)),c=!0)),c&&l.incrementRowCount(1)}function lj(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:o,isLastHunk:s,isExpandable:a},l){if(n<=0)return;let c="unified"===e?l.unifiedContentAST:"deletions"===e?l.deletionsContentAST:l.additionsContentAST;if("metadata"===l.hunkSeparators){null!=i&&(l.pushToGutter(e,la({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),c.push(la({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),"additions"!==e&&l.incrementRowCount(1));return}if("simple"===l.hunkSeparators){t>0&&(l.pushToGutter(e,la({type:"simple",isFirstHunk:o,isLastHunk:!1})),c.push(la({type:"simple",isFirstHunk:o,isLastHunk:!1})),"additions"!==e&&l.incrementRowCount(1));return}let d=`hunk-separator-${e}-${t}`,u=r>l.expansionLineCount,h=a?t:void 0;l.pushToGutter(e,la({type:l.hunkSeparators,content:lP(n),expandIndex:h,chunked:u,slotName:d,isFirstHunk:o,isLastHunk:s})),c.push(la({type:l.hunkSeparators,content:lP(n),expandIndex:h,chunked:u,slotName:d,isFirstHunk:o,isLastHunk:s})),"additions"!==e&&l.incrementRowCount(1),l.hunkData.push({slotName:d,hunkIndex:t,lines:n,type:e,expandable:a?{up:!o,down:!s,chunked:u}:void 0})}function lB(e,t){return null==e||"element"!==e.type||null==t?e:{...e,properties:{...e.properties,...t}}}let lz=new class extends ly{constructor(){super(...arguments),this.tokenize=l$}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes("\n")||(e=e.trim()),n.newlineIsToken&&t.includes("\n")||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith("\n")&&(e=e.slice(0,-1)),t.endsWith("\n")&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function l$(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,"\n"));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}let lF={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function lU(e,t,n,r,i,o,s){var a;let l;void 0===(l=s?"function"==typeof s?{callback:s}:s:{}).context&&(l.context=4);let c=l.context;if(l.newlineIsToken)throw Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!l.callback)return d(lz.diff(n,r,l));{let{callback:e}=l;a=Object.assign(Object.assign({},l),{callback:t=>{e(d(t))}}),lz.diff(n,r,a)}function d(n){if(!n)return;function r(e){return e.map(function(e){return" "+e})}n.push({value:"",lines:[]});let s=[],a=0,l=0,d=[],u=1,h=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||function(e){let t=e.endsWith("\n"),n=e.split("\n").map(e=>e+"\n");return t?n.pop():n.push(n.pop().slice(0,-1)),n}(t.value);if(t.lines=i,t.added||t.removed){if(!a){let t=n[e-1];a=u,l=h,t&&(a-=(d=c>0?r(t.lines.slice(-c)):[]).length,l-=d.length)}for(let e of i)d.push((t.added?"+":"-")+e);t.added?h+=i.length:u+=i.length}else{if(a)if(i.length<=2*c&&e<n.length-2)for(let e of r(i))d.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))d.push(t);let t={oldStart:a,oldLines:u-a+e,newStart:l,newLines:h-l+e,lines:d};s.push(t),a=0,l=0,d=[]}u+=i.length,h+=i.length}}for(let e of s)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith("\n")?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,"\"),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:o,hunks:s}}}function lH(e,t){if(t||(t=lF),Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders)throw Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return e.map(e=>lH(e,t)).join("\n")}let n=[];t.includeIndex&&e.oldFileName==e.newFileName&&n.push("Index: "+e.oldFileName),t.includeUnderline&&n.push("==================================================================="),t.includeFileHeaders&&(n.push("--- "+e.oldFileName+(void 0===e.oldHeader?"":" "+e.oldHeader)),n.push("+++ "+e.newFileName+(void 0===e.newHeader?"":" "+e.newHeader)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t];for(let e of(0===r.oldLines&&(r.oldStart-=1),0===r.newLines&&(r.newStart-=1),n.push("@@ -"+r.oldStart+","+r.oldLines+" +"+r.newStart+","+r.newLines+" @@"),r.lines))n.push(e)}return n.join("\n")+"\n"}function lW(e,t,n,r=!1){let i=ng(function(e,t,n,r,i,o,s){if("function"==typeof s&&(s={callback:s}),null==s?void 0:s.callback){let{callback:a}=s;lU(e,t,n,r,i,o,Object.assign(Object.assign({},s),{callback:e=>{e?a(lH(e,s.headerOptions)):a(void 0)}}))}else{let a=lU(e,t,n,r,i,o,s);if(!a)return;return lH(a,null==s?void 0:s.headerOptions)}}(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(null!=e.cacheKey&&null!=t.cacheKey)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(null==i)throw Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return i}let lV=-1;var lG=class{static LoadedCustomComponent=!0;__id=`file-diff:${++lV}`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;unsafeCSSStyle;gutterUtilityContent;headerElement;headerPrefix;headerMetadata;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;lastRowCount;enabled=!0;constructor(e={theme:nc},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new rQ,this.scrollSyncManager=new r5,this.interactionManager=new rV("diff",rG(e,"function"==typeof e.hunkSeparators||(e.hunkSeparators??"line-info")==="line-info"||"line-info-basic"===e.hunkSeparators?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return{...e,hunkSeparators:"function"==typeof e.hunkSeparators?"custom":e.hunkSeparators}}createHunksRenderer(e){return new lD(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>{let n,r;if(null==this.fileDiff)return;let i=this.fileDiff.hunks.at(-1);e:for(let o of this.fileDiff.hunks){let s="deletions"===t?o.deletionStart:o.additionStart,a="deletions"===t?o.deletionCount:o.additionCount,l=o.splitLineStart,c=o.unifiedLineStart;if(e<s){let t=s-e;n=Math.max(c-t,0),r=Math.max(l-t,0);break}if(e>=s+a){if(o===i){let t=e-(s+a);n=c+o.unifiedLineCount+t,r=l+o.splitLineCount+t;break}continue}for(let i of o.hunkContent)if("context"===i.type)if(e<s+i.lines){let t=e-s;r=l+t,n=c+t;break e}else s+=i.lines,l+=i.lines,c+=i.lines;else{let o="deletions"===t?i.deletions:i.additions;if(e<s+o){let o=e-s;n=c+("additions"===t?i.deletions:0)+o,r=l+o;break e}s+=o,l+=Math.max(i.deletions,i.additions),c+=i.deletions+i.additions}break}if(null!=n&&null!=r)return[n,r]};setOptions(e){null!=e&&(this.options=e,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.interactionManager.setOptions(rG(e,"function"==typeof e.hunkSeparators||(e.hunkSeparators??"line-info")==="line-info"||"line-info-basic"===e.hunkSeparators?this.handleExpandHunk:void 0,this.getLineIndex)))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.hunksRenderer.setThemeType(e),null!=this.headerElement&&("system"===e?delete this.headerElement.dataset.themeType:this.headerElement.dataset.themeType=e),null!=this.pre))switch(e){case"system":delete this.pre.dataset.themeType;break;case"light":case"dark":this.pre.dataset.themeType=e}}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!e&&!t&&!n&&"function"!=typeof this.options.hunkSeparators}setSelectedLines(e){this.interactionManager.setSelection(e)}cleanUp(e=!1){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer?.shadowRoot!=null&&(this.fileContainer.shadowRoot.innerHTML=""),this.fileContainer=void 0,null!=this.pre&&(this.pre.innerHTML="",this.pre=void 0),this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.lastRenderedHeaderHTML=void 0,this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{overflow:t="scroll",diffStyle:n="split"}=this.options,{fileContainer:r,prerenderedHTML:i,preventEmit:o=!1}=e;for(let e of(!function(e,t){if(null==t)return;let n=e.shadowRoot??e.attachShadow({mode:"open"});""===n.innerHTML&&(n.innerHTML=t)}(r,i),r.shadowRoot?.children??[])){if(e instanceof SVGElement){this.spriteSVG=e;continue}if(e instanceof HTMLElement){if(e instanceof HTMLPreElement){for(let t of(this.pre=e,e.children))t instanceof HTMLElement&&"code"===t.tagName.toLowerCase()&&("deletions"in t.dataset&&(this.codeDeletions=t),"additions"in t.dataset&&(this.codeAdditions=t),"unified"in t.dataset&&(this.codeUnified=t));continue}if("diffsHeader"in e.dataset){this.headerElement=e;continue}if(e instanceof HTMLStyleElement&&e.hasAttribute(nd)){this.unsafeCSSStyle=e;continue}}}if(null!=this.pre&&this.syncCodeNodesFromPre(this.pre),null==this.pre)this.render({...e,preventEmit:!0});else{let{lineAnnotations:i,oldFile:o,newFile:s,fileDiff:a}=e;this.fileContainer=r,delete this.pre.dataset.dehydrated,this.lineAnnotations=i??this.lineAnnotations,this.additionFile=s,this.deletionFile=o,this.fileDiff=a??(null!=o&&null!=s?lW(o,s):void 0),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,"wrap"===t),"scroll"===t&&"split"===n&&this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions)}o||this.emitPostRender()}rerender(){this.enabled&&(null!=this.fileDiff||null!=this.additionFile||null!=this.deletionFile)&&this.render({forceRender:!0,renderRange:this.renderRange})}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.rerender()};render({oldFile:e,newFile:t,fileDiff:n,forceRender:r=!1,preventEmit:i=!1,lineAnnotations:o,fileContainer:s,containerWrapper:a,renderRange:l}){if(!this.enabled)throw Error("FileDiff.render: attempting to call render after cleaned up");let{collapsed:c=!1}=this.options,d=c?void 0:l,u=null!=e&&null!=t&&(!r1(e,this.deletionFile)||!r1(t,this.additionFile)),h=null!=n&&n!==this.fileDiff,p=null!=o&&(o.length>0||this.lineAnnotations.length>0)&&o!==this.lineAnnotations;if(!c&&rZ(d,this.renderRange)&&!r&&!p&&(null!=n&&n===this.fileDiff||null==n&&!u))return!1;let{renderRange:f}=this;if(this.renderRange=d,this.deletionFile=e,this.additionFile=t,null!=n?this.fileDiff=n:null!=e&&null!=t&&u&&(h=!0,this.fileDiff=lW(e,t)),null!=o&&this.setLineAnnotations(o),null==this.fileDiff)return!1;this.hunksRenderer.setOptions({...this.options,hunkSeparators:"function"==typeof this.options.hunkSeparators?"custom":this.options.hunkSeparators}),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{diffStyle:m="split",disableErrorHandling:g=!1,disableFileHeader:y=!1,overflow:v="scroll"}=this.options;if(y&&(null!=this.headerElement&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),null!=this.headerPrefix&&(this.headerPrefix.remove(),this.headerPrefix=void 0),null!=this.headerMetadata&&(this.headerMetadata.remove(),this.headerMetadata=void 0)),s=this.getOrCreateFileContainer(s,a),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,nf);e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(g)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return i||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(r,p,u||h)&&this.applyPartialRender({previousRenderRange:f,renderRange:d}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,d);if(null==t)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;null!=t.headerElement&&this.applyHeaderToDOM(t.headerElement,s),null!=t.additionsContentAST||null!=t.deletionsContentAST||null!=t.unifiedContentAST?this.applyHunksToDOM(e,t):null!=this.pre&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.interactionManager.setup(e),this.resizeManager.setup(e,"wrap"===v),"scroll"===v&&"split"===m?this.scrollSyncManager.setup(e,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp()}catch(e){if(g)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return i||this.emitPostRender(),!0}emitPostRender(){null!=this.fileContainer&&this.options.onPostRender?.(this.fileContainer,this)}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();for(let{element:e}of(this.separatorCache.clear(),this.annotationCache.values()))e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(null==this.fileContainer)return!1;if(this.cleanChildNodes(),null==this.placeHolder){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.pre=void 0,this.spriteSVG=void 0,this.unsafeCSSStyle=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||null==this.fileContainer||"function"!=typeof t){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let i of e){var r;let e=i.slotName,o=this.separatorCache.get(e);if(null==o||(r=o.hunkData,i.slotName!==r.slotName||i.hunkIndex!==r.hunkIndex||i.lines!==r.lines||i.type!==r.type||i.expandable?.chunked!==r.expandable?.chunked||i.expandable?.up!==r.expandable?.up||i.expandable?.down!==r.expandable?.down)){o?.element.remove();let n=document.createElement("div");n.style.display="contents",n.slot=i.slotName;let r=t(i,this);null!=r&&n.appendChild(r),this.fileContainer.appendChild(n),o={element:n,hunkData:i},this.separatorCache.set(e,o)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||null==this.fileContainer){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(null!=t&&this.lineAnnotations.length>0)for(let[r,i]of this.lineAnnotations.entries()){var n;let o=`${r}-${nv(i)}`,s=this.annotationCache.get(o);if(null==s||(n=s.annotation,i.lineNumber!==n.lineNumber||i.side!==n.side||i.metadata!==n.metadata)){s?.element.remove();let e=t(i);if(null==e)continue;(s={element:function(e){let t=document.createElement("div");return t.dataset.annotationSlot="",t.slot=e,t.style.whiteSpace="normal",t}(nv(i)),annotation:i}).element.appendChild(e),this.fileContainer.appendChild(s.element),this.annotationCache.set(o,s)}e.delete(o)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let e,t=this.options.renderGutterUtility??this.options.renderHoverUtility;if(null==this.fileContainer||null==t){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=t(this.interactionManager.getHoveredLine);if(null!=n&&null!=this.gutterUtilityContent)return;if(null==n){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let r=((e=document.createElement("div")).slot="gutter-utility-slot",e.style.position="absolute",e.style.top="0",e.style.bottom="0",e.style.textAlign="center",e.style.whiteSpace="normal",e);r.appendChild(n),this.fileContainer.appendChild(r),this.gutterUtilityContent=r}getOrCreateFileContainer(e,t){let n=this.fileContainer;if(this.fileContainer=e??this.fileContainer??document.createElement(t3),null!=n&&n!==this.fileContainer&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),null!=t&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),null==this.spriteSVG){let e=document.createElement("div");e.innerHTML=r0;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t,this.fileContainer.shadowRoot?.appendChild(this.spriteSVG))}return this.fileContainer}getFileContainer(){return this.fileContainer}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});return null==this.pre?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){for(let t of(this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,Array.from(e.children)))t instanceof HTMLElement&&("unified"in t.dataset?this.codeUnified=t:"deletions"in t.dataset?this.codeDeletions=t:"additions"in t.dataset&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let n=rU(e);if(n!==this.lastRenderedHeaderHTML){let e=document.createElement("div");e.innerHTML=n;let r=e.firstElementChild;if(!(r instanceof HTMLElement))return;null!=this.headerElement?t.shadowRoot?.replaceChild(r,this.headerElement):t.shadowRoot?.prepend(r),this.headerElement=r,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged)return;let{renderHeaderPrefix:r,renderHeaderMetadata:i}=this.options;null!=this.headerPrefix&&this.headerPrefix.remove(),null!=this.headerMetadata&&this.headerMetadata.remove();let o=r?.({deletionFile:this.deletionFile,additionFile:this.additionFile,fileDiff:this.fileDiff})??void 0,s=i?.({deletionFile:this.deletionFile,additionFile:this.additionFile,fileDiff:this.fileDiff})??void 0;null!=o&&(this.headerPrefix=document.createElement("div"),this.headerPrefix.slot=na,o instanceof Element?this.headerPrefix.appendChild(o):this.headerPrefix.innerText=`${o}`,t.appendChild(this.headerPrefix)),null!=s&&(this.headerMetadata=document.createElement("div"),this.headerMetadata.slot=nl,s instanceof Element?this.headerMetadata.appendChild(s):this.headerMetadata.innerText=`${s}`,t.appendChild(this.headerMetadata))}injectUnsafeCSS(){if(this.fileContainer?.shadowRoot==null)return;let{unsafeCSS:e}=this.options;if(null!=e&&""!==e){if(null==this.unsafeCSSStyle){let e;this.unsafeCSSStyle=((e=document.createElement("style")).setAttribute(nd,""),e),this.fileContainer.shadowRoot.appendChild(this.unsafeCSSStyle)}this.unsafeCSSStyle.innerText=`@layer base, theme, unsafe;
191
191
  @layer unsafe {
192
192
  ${e}
193
- }`}}applyHunksToDOM(e,t){let{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i="wrap"===n?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let o=!1,s=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),c=this.hunksRenderer.renderCodeAST("additions",t);null!=a?(o=null==this.codeUnified||null!=this.codeAdditions||null!=this.codeDeletions,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=r8({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a),s.push(this.codeUnified)):null!=l||null!=c?(null!=l?(o=null==this.codeDeletions||null!=this.codeUnified,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=r8({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l),s.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),null!=c?(o=o||null==this.codeAdditions||null!=this.codeUnified,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=r8({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(c),s.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),0===s.length?e.textContent="":o&&e.replaceChildren(...s),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:o,options:{diffStyle:s="split"}}=this;if(null==n||null==e||null==t||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||null==this.lastRowCount)return!1;let a=this.getCodeColumns(s,r,o,i);if(null==a)return!1;let l=e.startingLine,c=t.startingLine,d=l+e.totalLines,u=c+t.totalLines,h=Math.max(l,c),p=Math.min(d,u);if(p<=h)return!1;let f=Math.max(0,h-l),m=Math.max(0,d-p),g=this.trimColumns({columns:a,trimStart:f,trimEnd:m,previousStart:l,overlapStart:h,overlapEnd:p,diffStyle:s});if(g<0)throw Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<g)throw Error("applyPartialRender: trimmed beyond DOM row count");let y=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0)&&null!=this.fileDiff)return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},b=v(c,Math.max(h-c,0));if(null==b&&c<h)return!1;let x=v(p,Math.max(u-p,0));if(null==x&&u>p)return!1;let k=(e,t)=>{if(null!=e){if("unified"!==s||Array.isArray(a))if("split"===s&&Array.isArray(a))this.insertPartialHTML(s,a,e,t);else throw Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");else this.insertPartialHTML(s,a,e,t);y+=e.rowCount}};return this.cleanupErrorWrapper(),k(b,"afterbegin"),k(x,"beforeend"),this.lastRowCount!==y&&(this.applyRowSpan(s,a,y),this.lastRowCount=y),!0}insertPartialHTML(e,t,n,r){if("unified"!==e||Array.isArray(t))if("split"===e&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST("deletions",n),i=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error("FileDiff.insertPartialHTML: Invalid argument composition");else{let e=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,e,r)}}renderPartialColumn(e,t,n){if(null==e||null==t)return;let r=lq(t[0]),i=lq(t[1]);if(null==r||null==i)throw Error("FileDiff.insertPartialHTML: Unexpected AST structure");let o=i.at(0);"beforeend"===n&&o?.type==="element"&&"number"==typeof o.properties["data-buffer-size"]&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let s=i.at(-1);"afterbegin"===n&&s?.type==="element"&&"number"==typeof s.properties["data-buffer-size"]&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,o){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let s=this.getBufferSize(t.dataset);null!=s&&(o?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,s+e),this.updateBufferSize(n,s+e))}applyRowSpan(e,t,n){let r=e=>{null!=e&&(e.gutter.style.setProperty("grid-row",`span ${n}`),e.content.style.setProperty("grid-row",`span ${n}`))};if("unified"!==e||Array.isArray(t))if("split"===e&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error("dun fuuuuked up");else r(t)}trimColumnRows(e,t,n){let r=0,i=0,o=0,s=!1,a=n>=0;if(null==e)return 0;let l=Array.from(e.content.children),c=Array.from(e.gutter.children);if(l.length!==c.length)throw Error("FileDiff.trimColumnRows: columns do not match");for(;o<l.length&&(!(t<=0)||a||s);){let e=c[o],d=l[o];if(o++,!(e instanceof HTMLElement)||!(d instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:d}),Error("FileDiff.trimColumnRows: invalid row elements");if(s&&(s=!1,"annotation"===e.dataset.gutterBuffer&&"lineAnnotation"in d.dataset||"metadata"===e.dataset.gutterBuffer&&"noNewline"in d.dataset)){e.remove(),d.remove(),i++;continue}if("lineIndex"in e.dataset&&"lineIndex"in d.dataset){(t>0||a&&r>=n)&&(e.remove(),d.remove(),t>0&&0==--t&&(s=!0),i++),r++;continue}if("separator"in e.dataset&&"separator"in d.dataset||"annotation"===e.dataset.gutterBuffer&&"lineAnnotation"in d.dataset||"metadata"===e.dataset.gutterBuffer&&"noNewline"in d.dataset){(t>0||a&&r>=n)&&(e.remove(),d.remove(),i++);continue}if("buffer"===e.dataset.gutterBuffer&&"contentBuffer"in d.dataset){let o=this.getBufferSize(d.dataset);if(null==o)throw Error("FileDiff.trimColumnRows: invalid element");if(t>0){let n=Math.min(t,o),r=o-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(d,r),i+=n):(e.remove(),d.remove(),i+=o),t-=n}else if(a){let t=r,s=r+o-1;if(n<=t)e.remove(),d.remove(),i+=o;else if(n<=s){let t=s-n+1,r=o-t;this.updateBufferSize(e,r),this.updateBufferSize(d,r),i+=t}}r+=o;continue}throw console.error({gutterElement:e,contentElement:d}),Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:o,trimStart:s}){let a=Math.max(0,r-i),l=n-i;if(l<0)throw Error("FileDiff.trimColumns: overlap ends before previous");let c=s>0,d=o>0;if(!c&&!d)return 0;let u=c?a:0,h=d?l:-1;if("unified"===t&&!Array.isArray(e))return this.trimColumnRows(e,u,h);if("split"===t&&Array.isArray(e)){let t=this.trimColumnRows(e[0],u,h),n=this.trimColumnRows(e[1],u,h);if(null!=e[0]&&null!=e[1]&&t!==n)throw Error("FileDiff.trimColumns: split columns out of sync");return null!=e[0]?t:n}throw console.error({diffStyle:t,columns:e}),Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(e){if(null==e)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&null!=t.dataset.gutter&&null!=n.dataset.content)return{gutter:t,content:n}}if("unified"===e)return i(t);{let e=i(n),t=i(r);return null!=e||null!=t?[e,t]:void 0}}applyBuffers(e,t){let{disableVirtualizationBuffers:n=!1}=this.options;if(n||null==t){null!=this.bufferBefore&&(this.bufferBefore.remove(),this.bufferBefore=void 0),null!=this.bufferAfter&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(null==this.bufferBefore&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):null!=this.bufferBefore&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(null==this.bufferAfter&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):null!=this.bufferAfter&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{themeStyles:t,baseThemeType:n,additionsContentAST:r,deletionsContentAST:i,totalLines:o},s){var a;let{diffIndicators:l="bars",disableBackground:c=!1,disableLineNumbers:d=!1,overflow:u="scroll",themeType:h="system",diffStyle:p="split"}=this.options,f={type:"diff",diffIndicators:l,disableBackground:c,disableLineNumbers:d,overflow:u,split:"unified"!==p&&null!=r&&null!=i,themeStyles:t,themeType:n??h,totalLines:o,customProperties:s};a=this.appliedPreAttributes,(null==f||null==a?f!==a:!function(e=r2,t=r2){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}(f.customProperties,a.customProperties)||f.type!==a.type||f.diffIndicators!==a.diffIndicators||f.disableBackground!==a.disableBackground||f.disableLineNumbers!==a.disableLineNumbers||f.overflow!==a.overflow||f.split!==a.split||f.themeStyles!==a.themeStyles||f.themeType!==a.themeType||f.totalLines!==a.totalLines)&&(!function(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:o,split:s,themeStyles:a,themeType:l,totalLines:c,customProperties:d}){if(null!=d)for(let t in d){let n=d[t];null!=n&&e.setAttribute(t,`${n}`)}switch("diff"===t?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),"system"===l?e.removeAttribute("data-theme-type"):e.setAttribute("data-theme-type",l),n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators")}i?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),r?e.removeAttribute("data-background"):e.setAttribute("data-background",""),"diff"===t?e.setAttribute("data-diff-type",s?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",o),e.tabIndex=0,e.style=a,e.style.setProperty("--diffs-min-number-column-width-default",`${`${c}`.length}ch`)}(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();let n=this.getOrCreatePreNode(t);n.innerHTML="",n.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let r=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.innerHTML="",r.appendChild(this.errorWrapper);let i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);let o=document.createElement("pre");o.dataset.errorStack="",o.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(o)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function lq(e){if(null!=e&&"element"===e.type)return e.children??[]}let lK=-1;var lJ=class extends lG{__id=`little-virtualized-file-diff:${++lK}`;top;height=0;metrics;heightCache=new Map;isVisible=!1;virtualizer;constructor(e,t,n,r,i=!1){super(e,r,i);const{hunkSeparators:o="line-info"}=this.options;this.virtualizer=t,this.metrics=function(e,t){let n={...nu,...t};return n.hunkSeparatorHeight=function(e,t){if(null!=t)return t;switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}(e,t?.hunkSeparatorHeight),n}("function"==typeof o?"custom":o,n)}getLineHeight(e,t=!1){let n=this.heightCache.get(e);return null!=n?n:this.metrics.lineHeight*(t?2:1)}setOptions(e){if(null==e)return;let t=this.options.diffStyle,n=this.options.overflow,r=this.options.collapsed;super.setOptions(e),(t!==this.options.diffStyle||n!==this.options.overflow||r!==this.options.collapsed)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){let{overflow:e="scroll"}=this.options;if(null!=this.fileContainer&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),null==this.fileContainer||null==this.fileDiff){this.height=0;return}if("scroll"===e&&0===this.lineAnnotations.length&&!this.virtualizer.config.resizeDebugging)return;let t=this.getDiffStyle(),n=!1;for(let e of"split"===t?[this.codeDeletions,this.codeAdditions]:[this.codeUnified]){if(null==e)continue;let r=e.children[1];if(r instanceof HTMLElement)for(let e of r.children){if(!(e instanceof HTMLElement))continue;let r=e.dataset.lineIndex;if(null==r)continue;let i=function(e,t){let[n,r]=e.split(",").map(Number);return"split"===t?r:n}(r,t),o=e.getBoundingClientRect().height,s=!1;e.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in e.nextElementSibling.dataset||"noNewline"in e.nextElementSibling.dataset)&&("noNewline"in e.nextElementSibling.dataset&&(s=!0),o+=e.nextElementSibling.getBoundingClientRect().height),o!==this.getLineHeight(i,s)&&(n=!0,o===this.metrics.lineHeight*(s?2:1)?this.heightCache.delete(i):this.heightCache.set(i,o))}}(n||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}onRender=e=>null!=this.fileContainer&&(e&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render());cleanUp(){null!=this.fileContainer&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)};setVisibility(e){null!=this.fileContainer&&(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){let e=0===this.height;if(this.height=0,null==this.fileDiff)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1,hunkSeparators:o="line-info"}=this.options,{diffHeaderHeight:s,fileGap:a,hunkSeparatorHeight:l}=this.metrics,c=this.getDiffStyle(),d="simple"!==o&&"metadata"!==o&&"line-info-basic"!==o?a:0;if(t?"simple"!==o&&"metadata"!==o&&(this.height+=a):this.height+=s,!r&&(ll({diff:this.fileDiff,diffStyle:c,expandedHunks:!!n||this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:n,deletionLine:r,additionLine:i})=>{let s=null!=i?i.splitLineIndex:r.splitLineIndex,a=null!=i?i.unifiedLineIndex:r.unifiedLineIndex,u=(i?.noEOFCR??!1)||(r?.noEOFCR??!1);t>0&&(e>0&&(this.height+=d),this.height+=l+d),this.height+=this.getLineHeight("split"===c?s:a,u),n>0&&"simple"!==o&&(this.height+=d+l)}}),this.fileDiff.hunks.length>0&&(this.height+=a),null!=this.fileContainer&&this.virtualizer.config.resizeDebugging&&!e)){let e=this.fileContainer.getBoundingClientRect();e.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,...i}={}){let o=null==this.fileContainer;if(this.fileDiff??=r??(null!=t&&null!=n?lW(t,n):void 0),e=this.getOrCreateFileContainer(e),null==this.fileDiff)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(o?(this.computeApproximateSize(),this.virtualizer.connect(e,this),this.top??=this.virtualizer.getOffsetInScrollContainer(e),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??=this.virtualizer.getOffsetInScrollContainer(e),!this.isVisible)return this.renderPlaceholder(this.height);let s=this.virtualizer.getWindowSpecs(),a=this.computeRenderRangeFromWindow(this.fileDiff,this.top,s);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:a,oldFile:t,newFile:n,...i})}getDiffStyle(){return this.options.diffStyle??"split"}getExpandedRegion(e,t,n){if(n<=0||e)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(n,0),renderAll:!1};let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;if(r||n<=i)return{fromStart:n,fromEnd:0,collapsedLines:0,renderAll:!0};let o=this.hunksRenderer.getExpandedHunk(t),s=Math.min(Math.max(o.fromStart,0),n),a=Math.min(Math.max(o.fromEnd,0),n),l=s+a;return{fromStart:s,fromEnd:a,collapsedLines:Math.max(n-l,0),renderAll:l>=n}}getExpandedLineCount(e,t){var n;let r,i=0;if(e.isPartial){for(let n of e.hunks)i+="split"===t?n.splitLineCount:n.unifiedLineCount;return i}for(let[n,r]of e.hunks.entries()){i+="split"===t?r.splitLineCount:r.unifiedLineCount;let o=Math.max(r.collapsedBefore,0),{fromStart:s,fromEnd:a,renderAll:l}=this.getExpandedRegion(e.isPartial,n,o);o>0&&(i+=l?o:s+a)}let o=e.hunks.at(-1);if(null!=o&&null!=(r=(n=e).hunks.at(-1))&&!n.isPartial&&0!==n.additionLines.length&&0!==n.deletionLines.length&&(r.additionLineIndex+r.additionCount<n.additionLines.length||r.deletionLineIndex+r.deletionCount<n.deletionLines.length)){let t=e.additionLines.length-(o.additionLineIndex+o.additionCount),n=e.deletionLines.length-(o.deletionLineIndex+o.deletionCount);if(null!=o&&t!==n)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${e.name}`);let r=Math.min(t,n);if(null!=o&&r>0){let{fromStart:t,renderAll:n}=this.getExpandedRegion(e.isPartial,e.hunks.length,r);i+=n?r:t}}return i}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let i,o,s,{disableFileHeader:a=!1,expandUnchanged:l=!1,collapsedContextThreshold:c=1,hunkSeparators:d="line-info"}=this.options,{diffHeaderHeight:u,fileGap:h,hunkLineCount:p,hunkSeparatorHeight:f,lineHeight:m}=this.metrics,g=this.getDiffStyle(),y=this.height,v=this.getExpandedLineCount(e,g),b=a?h:u;if(t<n-y||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:y-b-h};if(v<=p||0===e.hunks.length)return{startingLine:0,totalLines:p,bufferBefore:0,bufferAfter:0};let x=Math.ceil(Math.ceil(Math.max(r-n,0)/m)/p)*p+p,k=x/p,w=[],S=(n+r)/2,C="simple"===d||"metadata"===d||"line-info-basic"===d?0:h,N=t+b,A=0;if(ll({diff:e,diffStyle:g,expandedHunks:!!l||this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:c,callback:({hunkIndex:e,collapsedBefore:a,collapsedAfter:l,deletionLine:c,additionLine:u})=>{let h=null!=u?u.splitLineIndex:c.splitLineIndex,m=null!=u?u.unifiedLineIndex:c.unifiedLineIndex,y=(u?.noEOFCR??!1)||(c?.noEOFCR??!1),v=a>0?f+C+(e>0?C:0):0;0===e&&"simple"===d&&(v=0),N+=v;let x=A%p==0;if(x&&(w.push(N-(t+b+v)),null!=s)){if(s<=0)return!0;s--}let E=this.getLineHeight("split"===g?h:m,y),M=Math.floor(A/p);return N>n-E&&N<r&&(i??=M),null==o&&N+E>S&&(o=M),null==s&&N>=r&&x&&(s=k),A++,N+=E,l>0&&"simple"!==d&&(N+=f+C),!1}}),null==i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:y-b-h};let E=w.length,M=Math.round((o??=i)-k/2),T=Math.max(0,Math.min(M,Math.max(0,E-k))),I=M<0?x+M*p:x,L=w[T]??0,O=T+I/p;return{startingLine:T*p,totalLines:I,bufferBefore:L,bufferAfter:O<w.length?y-b-w[O]-h:y-(N-t)-h}}};let lX=new Set,lY=new Set,lQ=null,lZ=!1;function l0(e){lZ?lX.add(e):(lY.add(e),lQ??=requestAnimationFrame(l1))}function l1(e){for(let t of(lZ=!0,lY))try{t(e)}catch(e){console.error(e)}lY.clear(),lX.size>0?(lY=new Set(lX),lX.clear(),lQ=requestAnimationFrame(l1)):lQ=null,lZ=!1}function l2({scrollTop:e,scrollHeight:t,height:n,containerOffset:r=0,fitPerfectly:i,overscrollSize:o}){let s=n+2*o,a=i?n:s;if(s>=(t=Math.max(t,a))||i){let n=Math.max(e-r,0);return{top:n,bottom:Math.max(Math.min(e+a,t)-r,n)}}let l=e+n/2-s/2,c=l+s;return l<0&&(l=0),c>t&&(c=t),{top:l=Math.floor(Math.max(l-r,0)),bottom:Math.ceil(Math.max(Math.min(c,t)-r,l))}}let l8=[0,1e-6,.99999,1],l5={overscrollSize:1e3,intersectionObserverMargin:4e3,resizeDebugging:!1},l6=0,l3=-1;function l4(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}(class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++l3}`;config;type="basic";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...l5,...e}}setup(t,n){if(null==this.root){for(let[r,i]of(this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:l8,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),l0(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)},this.connectQueue.entries()))this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)}}instanceChanged(e){this.instancesChanged.add(e),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)}getWindowSpecs(){return 0===this.windowSpecs.top&&0===this.windowSpecs.bottom&&(this.windowSpecs=l2({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin;return!(e<n-i-t||e>n+r+i)}handleContainerResize=e=>{if(null==this.root)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:e-l6,newSize:e}),l6=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:e-l6,newSize:e}),l6=e))}t&&l0(this.computeRenderRangeAndEmit)};setupWindow(){if(null==this.root||!(this.root instanceof Document))throw Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(null==this.root||this.root instanceof Document)throw Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),(e??=this.root.firstElementChild??void 0)instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+l4(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error("Virtualizer.connect: instance is already connected...");return null==this.intersectionObserver?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),null!=t&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,l0(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{!e.__STOP&&null!=this.root&&this.root instanceof Document&&(this.scrollDirty=!0,l0(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||null==this.root||this.root instanceof Document||(this.scrollDirty=!0,l0(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&0===this.instancesChanged.size)return;if(0===this.instancesChanged.size){var n;let e=l2({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize});if(n=this.windowSpecs,(null==n||null==e?n===e:n.top===e.top&&n.bottom===e.bottom)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&0===this.instancesChanged.size)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let r=this.getScrollAnchor(this.height),i=new Set;for(let e of t?this.observers.values():this.visibleInstances.values())e.onRender(t)&&i.add(e);for(let e of this.instancesChanged)!i.has(e)&&e.onRender(t)&&i.add(e);for(let e of(this.scrollFix(r),this.instancesChanged.size>0&&this.markDOMDirty(),i))e.reconcileHeights();(this.instancesChanged.size>0||t)&&l0(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(null==e)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:o,fileTypeOffset:s}=e;if(null!=n&&null!=r){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=l4(e,t);n!==r&&this.applyScrollFix(n-r);return}}let a=l4(i,t);if("top"===s)a!==o&&this.applyScrollFix(a-o);else{let e=a+i.getBoundingClientRect().height;e!==o&&this.applyScrollFix(e-o)}}applyScrollFix(e){null==this.root||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){let t,n=this.getScrollContainerElement();for(let[r]of this.visibleInstances.entries()){let i,o,s,a,l=l4(r,n),c=l+r.offsetHeight;if(c<=0?(i=c,o="bottom"):(i=l,o="top"),c>0&&l<e)for(let e of r.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(e instanceof HTMLElement))continue;let t=e.dataset.lineIndex;if(null==t)continue;let r=l4(e,n);if(!(r<0)){s=t,a=r;break}}if(t?.lineOffset!=null&&null==a)continue;let d=!1;null==t||null!=a&&(null==t.lineOffset||a<t.lineOffset)?d=!0:null==a&&null==t.lineOffset&&(i>=0&&(t.fileOffset<0||i<t.fileOffset)?d=!0:i<0&&t.fileOffset<0&&i>t.fileOffset&&(d=!0)),d&&(t={fileElement:r,fileTypeOffset:o,fileOffset:i,lineIndex:s,lineOffset:a})}return t}handleIntersectionChange=e=>{for(let{target:t,isIntersecting:n}of(this.scrollDirty=!0,e)){if(!(t instanceof HTMLElement))throw Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");let e=this.observers.get(t);if(null==e)throw Error("Virtualizer.handleIntersectionChange: no instance for target");n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0)}this.visibleInstancesDirty&&l0(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=null==this.root?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty&&(this.scrollHeightDirty=!1,this.scrollHeight=null==this.root?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight),this.scrollHeight}getHeight(){return this.heightDirty&&(this.heightDirty=!1,this.height=null==this.root?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height),this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return null==this.root||this.root instanceof Document?void 0:this.root}});let l7=(0,et.createContext)(void 0);e.i(4135),Symbol("IGNORE_RESPONSE");let l9=(0,et.createContext)(void 0),ce="u"<typeof window?et.useEffect:et.useLayoutEffect;function ct(e,t){return t?{...e,renderGutterUtility:nk}:e}function cn({patch:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:o,style:s,prerenderedHTML:a,renderAnnotation:l,renderHeaderPrefix:c,renderHeaderMetadata:d,renderGutterUtility:u,renderHoverUtility:h}){var p,f;let m=(f=e,(0,et.useMemo)(()=>(function(e){let t=function(e,t,n=!1){let r=[];for(let t of e.split(t4))try{r.push(function(e,t,n=!1){let r,i=t7.test(e),o=e.split(i?t7:t9),s=[];for(let e of o){if(i&&!t7.test(e)||!i&&!t9.test(e)){if(null==r)r=e;else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",e);continue}let o=ng(e,{cacheKey:null!=t?`${t}-${s.length}`:void 0,isGitDiff:i,throwOnError:n});null!=o&&s.push(o)}return{patchMetadata:r,files:s}}(t,void 0,n))}catch(e){if(n)throw e;console.error(e)}return r}(e);if(1!==t.length)throw console.error(t),Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");let{files:n}=t[0];if(1!==n.length)throw console.error(n),Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]})(f),[f])),{ref:g,getHoveredLine:y}=function({oldFile:e,newFile:t,fileDiff:n,options:r,lineAnnotations:i,selectedLines:o,prerenderedHTML:s,metrics:a,hasGutterRenderUtility:l}){var c;let d,u=(0,et.useContext)(l7),h=(0,et.useContext)(l9),p=(0,et.useRef)(null),f=(c=o=>{if(null!=o){if(null!=p.current)throw Error("useFileDiffInstance: An instance should not already exist when a node is created");null!=u?p.current=new lJ(ct(r,l),u,a,h,!0):p.current=new lG(ct(r,l),h,!0),p.current.hydrate({fileDiff:n,oldFile:e,newFile:t,fileContainer:o,lineAnnotations:i,prerenderedHTML:s})}else{if(null==p.current)throw Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");p.current.cleanUp(),p.current=null}},d=(0,et.useRef)(c),(0,et.useInsertionEffect)(()=>void(d.current=c)),(0,et.useCallback)((...e)=>d.current(...e),[]));return ce(()=>{var s;let{current:a}=p;if(null==a)return;let c=ct(r,l),d=(s=a.options,!(le(s?.theme??nc,c?.theme??nc)&&function(e,t,n){if(e===t||null==e||null==t)return e===t;let r=new Set(n),i=Object.keys(e),o=new Set(Object.keys(t));for(let n of i)if(o.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(o))if(!r.has(e))return!1;return!0}(s,c,["theme"])));a.setOptions(c),a.render({forceRender:d,fileDiff:n,oldFile:e,newFile:t,lineAnnotations:i}),void 0!==o&&a.setSelectedLines(o)}),{ref:f,getHoveredLine:(0,et.useCallback)(()=>p.current?.getHoveredLine(),[])}}({fileDiff:m,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,hasGutterRenderUtility:null!=u||null!=h});return(0,ee.jsx)(t3,{ref:g,className:o,style:s,children:(p=function({fileDiff:e,actions:t,deletionFile:n,additionFile:r,renderHeaderPrefix:i,renderHeaderMetadata:o,renderAnnotation:s,renderGutterUtility:a,renderHoverUtility:l,renderMergeConflictUtility:c,lineAnnotations:d,getHoveredLine:u,getInstance:h}){let p=a??l,f=i?.({fileDiff:e,deletionFile:n,additionFile:r}),m=o?.({fileDiff:e,deletionFile:n,additionFile:r});return(0,ee.jsxs)(ee.Fragment,{children:[null!=f&&(0,ee.jsx)("div",{slot:na,children:f}),null!=m&&(0,ee.jsx)("div",{slot:nl,children:m}),null!=s&&d?.map((e,t)=>(0,ee.jsx)("div",{slot:nv(e),children:s(e)},t)),null!=t&&null!=c&&null!=h&&t.map(e=>{let t=function(e){let t=null!=e.incomingLineNumber?{side:"additions",lineNumber:e.incomingLineNumber}:null!=e.currentLineNumber?{side:"deletions",lineNumber:e.currentLineNumber}:void 0;return null!=t?function({side:e,lineNumber:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}({...t,conflictIndex:e.conflictIndex}):void 0}(e);return(0,ee.jsx)("div",{slot:t,style:nx,children:c(e,h)},t)}),null!=p&&(0,ee.jsx)("div",{slot:"gutter-utility-slot",style:nb,children:p(u)})]})}({fileDiff:m,renderHeaderPrefix:c,renderHeaderMetadata:d,renderAnnotation:l,lineAnnotations:r,renderGutterUtility:u,renderHoverUtility:h,getHoveredLine:y}),"u"<typeof window&&null!=a?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("template",{shadowrootmode:"open",dangerouslySetInnerHTML:{__html:a}}),p]}):(0,ee.jsx)(ee.Fragment,{children:p}))})}var cr=et,ci=e.i(21957);class co extends cr.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}function cs({patch:e,diffStyle:t="split",preloaded:n}){let[r,i]=(0,cr.useState)(!1),{theme:o}=(0,ci.useTheme)(),s="light"!==o;if(!e.trim())return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No changes"});let a=e.split("\n"),l=a.length>2e3&&!r,c=l?a.slice(0,2e3).join("\n"):e;return(0,ee.jsxs)("div",{className:"flex-1 overflow-auto",children:[l&&(0,ee.jsxs)("div",{className:"px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex items-center justify-between",children:[(0,ee.jsxs)("span",{className:"text-[var(--yellow)]",children:["showing first ",2e3," of ",a.length," lines"]}),(0,ee.jsx)("button",{onClick:()=>i(!0),className:"text-[var(--accent)] hover:underline",children:"show all"})]}),(0,ee.jsx)(co,{fallback:(0,ee.jsx)(ca,{patch:c}),children:(0,ee.jsx)(cr.Suspense,{fallback:(0,ee.jsx)(ca,{patch:c}),children:n?(0,ee.jsx)(cn,{patch:c,...n,className:"diff-container"}):(0,ee.jsx)(cn,{patch:c,options:{theme:s?"pierre-dark":"pierre-light",diffStyle:t,diffIndicators:"bars",overflow:"scroll",themeType:s?"dark":"light"},className:"diff-container"})})})]})}function ca({patch:e}){let t=e.split("\n").slice(0,500);return(0,ee.jsxs)("div",{className:"flex-1 overflow-auto p-4 font-mono text-xs leading-relaxed",children:[t.map((e,t)=>{let n="var(--fg)",r="var(--bg)";return e.startsWith("+")&&!e.startsWith("+++")?(n="var(--diff-add-text)",r="var(--diff-add-bg)"):e.startsWith("-")&&!e.startsWith("---")?(n="var(--diff-del-text)",r="var(--diff-del-bg)"):e.startsWith("@@")?n="var(--cyan)":(e.startsWith("diff ")||e.startsWith("index "))&&(n="var(--dim)"),(0,ee.jsx)("div",{style:{color:n,background:r,whiteSpace:"pre"},children:e||" "},t)}),t.length>=500&&(0,ee.jsx)("div",{style:{color:"var(--yellow)",padding:"8px 0"},children:"... truncated at 500 lines"})]})}function cl({files:e,selectedFile:t,onSelectFile:n}){return 0===e.length?(0,ee.jsx)("div",{className:"text-[var(--dim)] px-2 py-4",children:"No changed files"}):(0,ee.jsxs)("div",{children:[(0,ee.jsxs)("button",{onClick:()=>n(null),className:`w-full flex items-center h-6 px-2 text-left transition-colors ${null===t?"bg-[var(--surface-active)] text-[var(--accent)]":"text-[var(--dim)] hover:bg-[var(--surface-hover)] hover:text-[var(--fg)]"}`,children:[(0,ee.jsx)("span",{className:"flex-1 truncate",children:"All files"}),(0,ee.jsx)("span",{className:"shrink-0 text-[var(--dim)]",children:e.length})]}),e.map(e=>{let r=e.file.split("/").pop()??e.file,i=e.file.includes("/")?e.file.slice(0,e.file.lastIndexOf("/")+1):"",o=t===e.file;return(0,ee.jsxs)("button",{onClick:()=>n(e.file),className:`w-full flex items-center h-6 px-2 text-left transition-colors ${o?"bg-[var(--surface-active)]":"hover:bg-[var(--surface-hover)]"}`,children:[(0,ee.jsxs)("span",{className:"flex-1 min-w-0 truncate",children:[i&&(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:i}),(0,ee.jsx)("span",{className:o?"text-[var(--accent)]":"text-[var(--fg)]",children:r})]}),(0,ee.jsxs)("span",{className:"shrink-0 flex gap-1.5 ml-2",children:[e.additions>0&&(0,ee.jsxs)("span",{className:"text-[var(--green)]",children:["+",e.additions]}),e.deletions>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["-",e.deletions]})]})]},e.file)})]})}function cc({sessionName:e}){let{data:t,loading:n}=ei((0,et.useCallback)(()=>(0,er.fetchDiff)(e),[e]),5e3),[r,i]=(0,et.useState)(null),[o,s]=(0,et.useState)(""),[a,l]=(0,et.useState)("split"),[c,d]=(0,et.useState)(!1);(0,et.useEffect)(()=>{r?(d(!0),(0,er.fetchFileDiff)(e,r).then(e=>s(e)).catch(()=>s("")).finally(()=>d(!1))):s("")},[r,e]);let u=r?o:"";if(n&&!t)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Loading diffs…"});if(!t||!t.diff.trim())return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No uncommitted changes"});let h=t.files.reduce((e,t)=>e+t.additions,0),p=t.files.reduce((e,t)=>e+t.deletions,0);return(0,ee.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,ee.jsxs)("div",{className:"flex items-center h-7 px-3 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[t.files.length," file",1!==t.files.length?"s":""," changed"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--green)]",children:["+",h]}),(0,ee.jsx)("span",{className:"mx-1 text-[var(--dim)] opacity-30",children:"/"}),(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["-",p]}),(0,ee.jsx)("span",{className:"flex-1"}),(0,ee.jsxs)("div",{className:"flex border border-[var(--border)] rounded overflow-hidden",children:[(0,ee.jsx)("button",{onClick:()=>l("split"),className:`px-2 h-5 text-[11px] transition-colors ${"split"===a?"bg-[var(--surface-active)] text-[var(--fg)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"split"}),(0,ee.jsx)("button",{onClick:()=>l("unified"),className:`px-2 h-5 text-[11px] transition-colors ${"unified"===a?"bg-[var(--surface-active)] text-[var(--fg)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"unified"})]})]}),(0,ee.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,ee.jsx)("div",{className:"w-[260px] shrink-0 border-r border-[var(--border)] overflow-y-auto",children:(0,ee.jsx)(cl,{files:t.files,selectedFile:r,onSelectFile:i})}),r&&u?(0,ee.jsx)(cs,{patch:u,diffStyle:a}):c?(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"loading diff..."}):(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"select a file to view diff"})]})]})}let cd={dispatch:{icon:">",color:"var(--accent)"},completion:{icon:"✓",color:"var(--green)"},stall:{icon:"!",color:"var(--yellow)"},retry:{icon:"~",color:"var(--yellow)"},reconcile:{icon:"×",color:"var(--red)"},error:{icon:"✗",color:"var(--red)"},task_created:{icon:"+",color:"var(--dim)"},status_change:{icon:"—",color:"var(--dim)"}},cu={icon:"·",color:"var(--dim)"};function ch({events:e,maxEvents:t=50}){let n=(0,et.useRef)(null),r=(0,et.useRef)(0);if((0,et.useEffect)(()=>{e.length>r.current&&n.current&&(n.current.scrollTop=0),r.current=e.length},[e.length]),0===e.length)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No activity yet"});let i=e.slice(0,t);return(0,ee.jsx)("div",{ref:n,className:"flex-1 overflow-y-auto py-1",children:i.map((e,t)=>{let{icon:n,color:r}=cd[e.type]??cu;return(0,ee.jsxs)("div",{className:"flex items-start h-6 px-3 hover:bg-[var(--surface-hover)]",children:[(0,ee.jsx)("span",{className:"w-[8ch] shrink-0 text-right text-[var(--dim)] pr-2",children:e.relative??""}),(0,ee.jsx)("span",{className:"w-3 shrink-0 text-center",style:{color:r},children:n}),(0,ee.jsx)("span",{className:"flex-1 truncate pl-1 text-[var(--fg)]",children:function(e){if(e.message)return e.message;let t=[];return e.agent&&t.push(e.agent),"dispatch"===e.type&&t.push("dispatched"),"completion"===e.type&&t.push("completed"),"stall"===e.type&&t.push("stalled on"),"retry"===e.type&&t.push("retrying"),"reconcile"===e.type&&t.push("released"),e.taskId&&t.push(`task ${e.taskId}`),t.join(" ")}(e)})]},`${e.timestamp}-${t}`)})})}function cp(){}function cf(){}let cm=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cg=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cy={};function cv(e,t){return((t||cy).jsx?cg:cm).test(e)}let cb={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var cx=e.i(63185);let ck=cS("end"),cw=cS("start");function cS(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function cC(e){return e&&"object"==typeof e?"position"in e||"type"in e?cA(e.position):"start"in e||"end"in e?cA(e):"line"in e||"column"in e?cN(e):"":""}function cN(e){return cE(e&&e.line)+":"+cE(e&&e.column)}function cA(e){return cN(e&&e.start)+"-"+cN(e&&e.end)}function cE(e){return e&&"number"==typeof e?e:1}class cM extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=s?s.line:void 0,this.name=cC(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}cM.prototype.file="",cM.prototype.name="",cM.prototype.reason="",cM.prototype.message="",cM.prototype.stack="",cM.prototype.column=void 0,cM.prototype.line=void 0,cM.prototype.ancestors=void 0,cM.prototype.cause=void 0,cM.prototype.fatal=void 0,cM.prototype.place=void 0,cM.prototype.ruleId=void 0,cM.prototype.source=void 0;let cT={}.hasOwnProperty,cI=new Map,cL=/[A-Z]/g,cO=new Set(["table","tbody","thead","tfoot","tr"]),cD=new Set(["td","th"]),cR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cP(e,t,n){var r,i,o,s,a,l,c,d,u;let h,p,f,m,g,y,v,b,x,k,w;return"element"===t.type?(r=e,i=t,o=n,p=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=n1),r.ancestors.push(i),f=cz(r,i.tagName,!1),m=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&cT.call(t.properties,r)){let o=function(e,t,n){let r=ry(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?rp(n):rx(n)),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,cx.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new cM("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=cR+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)cT.call(e,t)&&(n[function(e){let t=e.replace(cL,cF);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?cb[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(o){let[r,s]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof s&&cD.has(t.tagName)?n=s:i[r]=s}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),g=cB(r,i),cO.has(i.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!rw(e)})),c_(r,m,f,i),cj(m,g),r.ancestors.pop(),r.schema=h,r.create(i,f,m,o)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return cp("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}c$(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(s=e,a=t,l=n,v=y=s.schema,"svg"===a.name&&"html"===y.space&&(s.schema=n1),s.ancestors.push(a),b=null===a.name?s.Fragment:cz(s,a.name,!0),x=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];cp("ExpressionStatement"===t.type);let i=t.expression;cp("ObjectExpression"===i.type);let o=i.properties[0];cp("SpreadElement"===o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else c$(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];cp("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else c$(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}(s,a),k=cB(s,a),c_(s,x,b,a),cj(x,k),s.ancestors.pop(),s.schema=y,s.create(a,b,x,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);c$(e,t.position)}(e,t):"root"===t.type?(c=e,d=t,u=n,cj(w={},cB(c,d)),c.create(d,c.Fragment,w,u)):"text"===t.type?t.value:void 0}function c_(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function cj(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function cB(e,t){let n=[],r=-1,i=e.passKeys?new Map:cI;for(;++r<t.children.length;){let o,s=t.children[r];if(e.passKeys){let e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let a=cP(e,s,o);void 0!==a&&n.push(a)}return n}function cz(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=cv(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}cp(e,"always a result"),r=e}else r=cv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return cT.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);c$(e)}function c$(e,t){let n=new cM("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=cR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function cF(e){return"-"+e.toLowerCase()}let cU={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},cH={};function cW(e,t){let n=t||cH;return cV(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function cV(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return cG(e.children,t,n)}return Array.isArray(e)?cG(e,t,n):""}function cG(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=cV(e[i],t,n);return r.join("")}function cq(e,t,n,r){let i,o=e.length,s=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s<r.length;)(i=r.slice(s,s+1e4)).unshift(t,0),e.splice(...i),s+=1e4,t+=1e4}function cK(e,t){return e.length>0?(cq(e,e.length,0,t),e):t}let cJ={}.hasOwnProperty,cX=c7(/[A-Za-z]/),cY=c7(/[\dA-Za-z]/),cQ=c7(/[#-'*+\--9=?A-Z^-~]/);function cZ(e){return null!==e&&(e<32||127===e)}let c0=c7(/\d/),c1=c7(/[\dA-Fa-f]/),c2=c7(/[!-/:-@[-`{-~]/);function c8(e){return null!==e&&e<-2}function c5(e){return null!==e&&(e<0||32===e)}function c6(e){return -2===e||-1===e||32===e}let c3=c7(/\p{P}|\p{S}/u),c4=c7(/\s/);function c7(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function c9(e,t,n,r){let i=r?r-1:1/0,o=0;return function(r){return c6(r)?(e.enter(n),function r(s){return c6(s)&&o++<i?(e.consume(s),r):(e.exit(n),t(s))}(r)):t(r)}}let de={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return c8(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},dt={tokenize:function(e){let t,n,r,i=this,o=[],s=0;return a;function a(t){if(s<o.length){let n=o[s];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(s++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&y();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}g(s);let a=r;for(;a<i.events.length;)i.events[a][1].end={...n},a++;return cq(i.events,o+1,0,i.events.slice(r)),i.events.length=a,c(e)}return a(e)}function c(n){if(s===o.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return f(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(dn,d,u)(n)}function d(e){return t&&y(),g(s),h(e)}function u(e){return i.parser.lazy[i.now().line]=s!==o.length,r=i.now().offset,f(e)}function h(t){return i.containerState={},e.attempt(dn,p,f)(t)}function p(e){return s++,o.push([i.currentConstruct,i.containerState]),h(e)}function f(r){if(null===r){t&&y(),g(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){m(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return c8(n)?(e.consume(n),m(e.exit("chunkFlow")),s=0,i.interrupt=void 0,a):(e.consume(n),t)}(r)}function m(e,o){let a=i.sliceStream(e);if(o&&a.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(a),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let a=i.events.length,l=a;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(g(s),o=a;o<i.events.length;)i.events[o][1].end={...n},o++;cq(i.events,l+1,0,i.events.slice(a)),i.events.length=o}}function g(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function y(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},dn={tokenize:function(e,t,n){return c9(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},dr={partial:!0,tokenize:function(e,t,n){return function(t){return c6(t)?c9(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||c8(e)?t(e):n(e)}}};class di{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&ds(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ds(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ds(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);ds(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);ds(this.left,t.reverse())}}}function ds(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function da(e){let t,n,r,i,o,s,a,l={},c=-1,d=new di(e);for(;++c<d.length;){for(;c in l;)c=l[c];if(t=d.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((r=0)<(s=t[1]._tokenizer.events).length&&"lineEndingBlank"===s[r][1].type&&(r+=2),r<s.length&&"content"===s[r][1].type))for(;++r<s.length&&"content"!==s[r][1].type;)"chunkText"===s[r][1].type&&(s[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],s=t-1,a=[],l=i._tokenizer;!l&&(l=o.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,d=[],u={},h=-1,p=i,f=0,m=0,g=[0];for(;p;){for(;e.get(++s)[1]!==p;);a.push(s),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&l.defineSkip(p.start),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(m=h+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(l.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),h=g.length;h--;){let t=c.slice(g[h],g[h+1]),n=a.pop();d.push([n,n+t.length-1]),e.splice(n,2,t)}for(d.reverse(),h=-1;++h<d.length;)u[f+d[h][0]]=f+d[h][1],f+=d[h][1]-d[h][0]-1;return u}(d,c)),c=l[c],a=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=d.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...d.get(n)[1].start},(o=d.slice(n,c)).unshift(t),d.splice(n,c-n+1,o))}}return cq(e,0,1/0,d.slice(0)),!a}let dl={resolve:function(e){return da(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):c8(t)?e.check(dc,o,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},dc={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,i,"linePrefix")};function i(i){if(null===i||c8(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},dd={tokenize:function(e){let t=this,n=e.attempt(dr,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,c9(e,e.attempt(this.parser.constructs.flow,r,e.attempt(dl,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},du={resolveAll:dm()},dh=df("string"),dp=df("text");function df(e){return{resolveAll:dm("text"===e?dg:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,s);return o;function o(e){return l(e)?i(e):s(e)}function s(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),a)}function a(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function dm(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function dg(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),s=o.length,a=-1,l=0;for(;s--;){let e=o[s];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)l++,a--;if(a)break;a=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let o={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:i.start._bufferIndex+a,_index:i.start._index+s,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}function dy(e){return null===e||c5(e)||c4(e)?1:c3(e)?2:void 0}function dv(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let db={name:"attention",resolveAll:function(e,t){let n,r,i,o,s,a,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},h={...e[d][1].start};dx(u,-a),dx(h,a),o={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},s={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},i={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:a>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[n][1].end={...o.start},e[d][1].start={...s.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=cK(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=cK(l,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),l=cK(l,dv(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=cK(l,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=cK(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,cq(e,n-1,d-n+3,l),d=n+l.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=dy(i);return function(s){return n=s,e.enter("attentionSequence"),function s(a){if(a===n)return e.consume(a),s;let l=e.exit("attentionSequence"),c=dy(a),d=!c||2===c&&o||r.includes(a),u=!o||2===o&&c||r.includes(i);return l._open=!!(42===n?d:d&&(o||!u)),l._close=!!(42===n?u:u&&(c||!d)),t(a)}(s)}}};function dx(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let dk={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return c6(t)?c9(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(dk,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return c6(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},dw={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return c2(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},dS=document.createElement("i");function dC(e){let t="&"+e+";";dS.innerHTML=t;let n=dS.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let dN={name:"characterReference",tokenize:function(e,t,n){let r,i,o=this,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=cY,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=c1,c):(e.enter("characterReferenceValue"),r=7,i=c0,c(t))}function c(a){if(59===a&&s){let r=e.exit("characterReferenceValue");return i!==cY||dC(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return i(a)&&s++<r?(e.consume(a),c):n(a)}}},dA={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},dE={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s};function s(t){return e.enter("codeFencedFence"),c6(t)?c9(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(o++,e.consume(i),t):o>=a?(e.exit("codeFencedFenceSequence"),c6(i)?c9(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||c8(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},s=0,a=0;return function(t){var o;let c;return o=t,s=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a<3?n(i):(e.exit("codeFencedFenceSequence"),c6(i)?c9(e,l,"whitespace")(i):l(i))}(o)};function l(o){return null===o||c8(o)?(e.exit("codeFencedFence"),i.interrupt?t(o):e.check(dA,d,f)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||c8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):c6(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c9(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(o))}function c(t){return null===t||c8(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||c8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function d(t){return e.attempt(o,f,u)(t)}function u(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return s>0&&c6(t)?c9(e,p,"linePrefix",s+1)(t):p(t)}function p(t){return null===t||c8(t)?e.check(dA,d,f)(t):(e.enter("codeFlowValue"),function t(n){return null===n||c8(n)?(e.exit("codeFlowValue"),p(n)):(e.consume(n),t)}(t))}function f(n){return e.exit("codeFenced"),t(n)}}},dM={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),c9(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?o(n):c8(n)?e.attempt(dT,t,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||c8(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function o(n){return e.exit("codeIndented"),t(n)}}},dT={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):c9(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):c8(e)?i(e):n(e)}}};function dI(e,t,n,r,i,o,s,a,l){let c=l||1/0,d=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),u):null===t||32===t||41===t||cZ(t)?n(t):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),f(t))};function u(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),u(t)):null===t||60===t||c8(t)?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(i){return!d&&(null===i||41===i||c5(i))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(i)):d<c&&40===i?(e.consume(i),d++,f):41===i?(e.consume(i),d--,f):null===i||32===i||40===i||cZ(i)?n(i):(e.consume(i),92===i?m:f)}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function dL(e,t,n,r,i,o){let s,a=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),c};function c(u){return l>999||null===u||91===u||93===u&&!s||94===u&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):93===u?(e.exit(o),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):c8(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||c8(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),s||(s=!c6(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function dO(e,t,n,r,i,o){let s;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),s=40===t?41:t,a):n(t)};function a(n){return n===s?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),l(n))}function l(t){return t===s?(e.exit(o),a(s)):null===t?n(t):c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||c8(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===s||92===t?(e.consume(t),c):c(t)}}function dD(e,t){let n;return function r(i){return c8(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):c6(i)?c9(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function dR(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let dP={partial:!0,tokenize:function(e,t,n){return function(t){return c5(t)?dD(e,r)(t):n(t)};function r(t){return dO(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return c6(t)?c9(e,o,"whitespace")(t):o(t)}function o(e){return null===e||c8(e)?t(e):n(e)}}},d_=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],dj=["pre","script","style","textarea"],dB={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(dr,t,n)}}},dz={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},d$={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&cq(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,o,s=e.length,a=0;for(;s--;)if(n=e[s][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[s][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[s][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=s,"labelLink"!==n.type)){a=2;break}}else"labelEnd"===n.type&&(i=s);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[r+a+2][1].end},end:{...e[i-2][1].start}};return o=cK(o=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+a+3)),o=cK(o,[["enter",d,t]]),o=cK(o,dv(t.parser.constructs.insideSpan.null,e.slice(r+a+4,i-3),t)),o=cK(o,[["exit",d,t],e[i-2],e[i-1],["exit",c,t]]),o=cK(o,e.slice(i+1)),o=cK(o,[["exit",l,t]]),cq(e,r,e.length,o),e},tokenize:function(e,t,n){let r,i,o=this,s=o.events.length;for(;s--;)if(("labelImage"===o.events[s][1].type||"labelLink"===o.events[s][1].type)&&!o.events[s][1]._balanced){r=o.events[s][1];break}return function(t){return r?r._inactive?d(t):(i=o.parser.defined.includes(dR(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),a):n(t)};function a(t){return 40===t?e.attempt(dF,c,i?c:d)(t):91===t?e.attempt(dU,c,i?l:d)(t):i?c(t):d(t)}function l(t){return e.attempt(dH,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},dF={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return c5(t)?dD(e,i)(t):i(t)}function i(t){return 41===t?c(t):dI(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return c5(t)?dD(e,a)(t):c(t)}function s(e){return n(e)}function a(t){return 34===t||39===t||40===t?dO(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return c5(t)?dD(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},dU={tokenize:function(e,t,n){let r=this;return function(t){return dL.call(r,e,i,o,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(dR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},dH={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},dW={name:"labelStartImage",resolveAll:d$.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},dV={name:"labelStartLink",resolveAll:d$.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},dG={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),c9(e,t,"linePrefix")}}},dq={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(o){var s;return e.enter("thematicBreak"),r=s=o,function o(s){return s===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),c6(n)?c9(e,o,"whitespace")(n):o(n))}(s)):i>=3&&(null===s||c8(s))?(e.exit("thematicBreak"),t(s)):n(s)}(s)}}},dK={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(dr,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,c9(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!c6(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(dX,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,c9(e,e.attempt(dK,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,s=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:c0(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(dq,n,a)(t):a(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return c0(i)&&++s<10?(e.consume(i),t):(!r.interrupt||s<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),a(i)):n(i)}(t)}return n(t)};function a(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(dr,r.interrupt?n:l,e.attempt(dJ,d,c))}function l(e){return r.containerState.initialBlankLine=!0,o++,d(e)}function c(t){return c6(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},dJ={partial:!0,tokenize:function(e,t,n){let r=this;return c9(e,function(e){let i=r.events[r.events.length-1];return!c6(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},dX={partial:!0,tokenize:function(e,t,n){let r=this;return c9(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},dY={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let s={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",s,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=s,e.push(["exit",s,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var s;let a,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){a="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||a)?(e.enter("setextHeadingLine"),r=t,s=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),c6(n)?c9(e,o,"lineSuffix")(n):o(n))}(s)):n(t)};function o(r){return null===r||c8(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,dL.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(t){return(r=dR(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return c5(t)?dD(e,a)(t):a(t)}function a(t){return dI(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(dP,c,c)(t)}function c(t){return c6(t)?c9(e,d,"whitespace")(t):d(t)}function d(o){return null===o||c8(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}}},"disable",0,{null:[]},"document",0,{42:dK,43:dK,45:dK,48:dK,49:dK,50:dK,51:dK,52:dK,53:dK,54:dK,55:dK,56:dK,57:dK,62:dk},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},cq(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var o;return e.enter("atxHeading"),o=i,e.enter("atxHeadingSequence"),function i(o){return 35===o&&r++<6?(e.consume(o),i):null===o||c5(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||c8(r)?(e.exit("atxHeading"),t(r)):c6(r)?c9(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||c5(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(o)):n(o)}(o)}}},42:dq,45:[dY,dq],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,o,s,a,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(s){return 33===s?(e.consume(s),d):47===s?(e.consume(s),i=!0,p):63===s?(e.consume(s),r=3,l.interrupt?t:O):cX(s)?(e.consume(s),o=String.fromCharCode(s),f):n(s)}function d(i){return 45===i?(e.consume(i),r=2,u):91===i?(e.consume(i),r=5,s=0,h):cX(i)?(e.consume(i),r=4,l.interrupt?t:O):n(i)}function u(r){return 45===r?(e.consume(r),l.interrupt?t:O):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(s++)?(e.consume(r),s===i.length)?l.interrupt?t:C:h:n(r)}function p(t){return cX(t)?(e.consume(t),o=String.fromCharCode(t),f):n(t)}function f(s){if(null===s||47===s||62===s||c5(s)){let a=47===s,c=o.toLowerCase();return!a&&!i&&dj.includes(c)?(r=1,l.interrupt?t(s):C(s)):d_.includes(o.toLowerCase())?(r=6,a)?(e.consume(s),m):l.interrupt?t(s):C(s):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(s):i?function t(n){return c6(n)?(e.consume(n),t):w(n)}(s):g(s))}return 45===s||cY(s)?(e.consume(s),o+=String.fromCharCode(s),f):n(s)}function m(r){return 62===r?(e.consume(r),l.interrupt?t:C):n(r)}function g(t){return 47===t?(e.consume(t),w):58===t||95===t||cX(t)?(e.consume(t),y):c6(t)?(e.consume(t),g):w(t)}function y(t){return 45===t||46===t||58===t||95===t||cY(t)?(e.consume(t),y):v(t)}function v(t){return 61===t?(e.consume(t),b):c6(t)?(e.consume(t),v):g(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,x):c6(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||c5(n)?v(n):(e.consume(n),t)}(t)}function x(t){return t===a?(e.consume(t),a=null,k):null===t||c8(t)?n(t):(e.consume(t),x)}function k(e){return 47===e||62===e||c6(e)?g(e):n(e)}function w(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||c8(t)?C(t):c6(t)?(e.consume(t),S):n(t)}function C(t){return 45===t&&2===r?(e.consume(t),M):60===t&&1===r?(e.consume(t),T):62===t&&4===r?(e.consume(t),D):63===t&&3===r?(e.consume(t),O):93===t&&5===r?(e.consume(t),L):c8(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(dB,R,N)(t)):null===t||c8(t)?(e.exit("htmlFlowData"),N(t)):(e.consume(t),C)}function N(t){return e.check(dz,A,R)(t)}function A(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||c8(t)?N(t):(e.enter("htmlFlowData"),C(t))}function M(t){return 45===t?(e.consume(t),O):C(t)}function T(t){return 47===t?(e.consume(t),o="",I):C(t)}function I(t){if(62===t){let n=o.toLowerCase();return dj.includes(n)?(e.consume(t),D):C(t)}return cX(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),I):C(t)}function L(t){return 93===t?(e.consume(t),O):C(t)}function O(t){return 62===t?(e.consume(t),D):45===t&&2===r?(e.consume(t),O):C(t)}function D(t){return null===t||c8(t)?(e.exit("htmlFlowData"),R(t)):(e.consume(t),D)}function R(n){return e.exit("htmlFlow"),t(n)}}},61:dY,95:dq,96:dE,126:dE},"flowInitial",0,{[-2]:dM,[-1]:dM,32:dM},"insideSpan",0,{null:[db,du]},"string",0,{38:dN,92:dw},"text",0,{[-5]:dG,[-4]:dG,[-3]:dG,33:dW,38:dN,42:db,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return cX(t)?(e.consume(t),o):64===t?n(t):a(t)}function o(t){return 43===t||45===t||46===t||cY(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,s):(43===n||45===n||46===n||cY(n))&&r++<32?(e.consume(n),t):(r=0,a(n))}(t)):a(t)}function s(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||cZ(r)?n(r):(e.consume(r),s)}function a(t){return 64===t?(e.consume(t),l):cQ(t)?(e.consume(t),a):n(t)}function l(i){return cY(i)?function i(o){return 46===o?(e.consume(o),r=0,l):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(o){if((45===o||cY(o))&&r++<63){let n=45===o?t:i;return e.consume(o),n}return n(o)}(o)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,o,s=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),x):63===t?(e.consume(t),v):cX(t)?(e.consume(t),w):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,p):cX(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):c8(t)?(o=d,I(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),h):d(t)}function h(e){return 62===e?T(e):45===e?u(e):d(e)}function p(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):c8(t)?(o=f,I(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),g):f(t)}function g(t){return 62===t?T(t):93===t?(e.consume(t),g):f(t)}function y(t){return null===t||62===t?T(t):c8(t)?(o=y,I(t)):(e.consume(t),y)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):c8(t)?(o=v,I(t)):(e.consume(t),v)}function b(e){return 62===e?T(e):v(e)}function x(t){return cX(t)?(e.consume(t),k):n(t)}function k(t){return 45===t||cY(t)?(e.consume(t),k):function t(n){return c8(n)?(o=t,I(n)):c6(n)?(e.consume(n),t):T(n)}(t)}function w(t){return 45===t||cY(t)?(e.consume(t),w):47===t||62===t||c5(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),T):58===t||95===t||cX(t)?(e.consume(t),C):c8(t)?(o=S,I(t)):c6(t)?(e.consume(t),S):T(t)}function C(t){return 45===t||46===t||58===t||95===t||cY(t)?(e.consume(t),C):function t(n){return 61===n?(e.consume(n),N):c8(n)?(o=t,I(n)):c6(n)?(e.consume(n),t):S(n)}(t)}function N(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,A):c8(t)?(o=N,I(t)):c6(t)?(e.consume(t),N):(e.consume(t),E)}function A(t){return t===r?(e.consume(t),r=void 0,M):null===t?n(t):c8(t)?(o=A,I(t)):(e.consume(t),A)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||c5(t)?S(t):(e.consume(t),E)}function M(e){return 47===e||62===e||c5(e)?S(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function I(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),L}function L(t){return c6(t)?c9(e,O,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),o(t)}}}],91:dV,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return c8(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},dw],93:d$,95:db,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),o++,t):(e.exit("codeTextSequence"),s(n))}(t)};function s(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),s):96===l?(i=e.enter("codeTextSequence"),r=0,function n(s){return 96===s?(e.consume(s),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(s)):(i.type="codeTextData",a(s))}(l)):c8(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):(e.enter("codeTextData"),a(l))}function a(t){return null===t||32===t||96===t||c8(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),a)}}}}],19210);var dQ=e.i(19210);let dZ=/[\0\t\n\r]/g;function d0(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let d1=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function d2(e){return e.replace(d1,d8)}function d8(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return d0(n.slice(t?2:1),t?16:10)}return dC(n)||e}let d5={}.hasOwnProperty;function d6(e){return{line:e.line,column:e.column,offset:e.offset}}function d3(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+cC({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cC({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+cC({start:t.start,end:t.end})+") is still open")}function d4(e){let t=this;t.parser=function(n){var r,i;let o,s,a,l;return"object"==typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(y),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(f),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(p),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(p,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(m),hardBreakTrailing:r(m),htmlFlow:r(g,i),htmlFlowData:c,htmlText:r(g,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(y),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(v),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(f),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:s(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:s(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:s(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=d0(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=dC(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=d6(e.end)},codeFenced:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:s(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dR(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:s(),hardBreakEscape:s(u),hardBreakTrailing:s(u),htmlFlow:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=d2(t),n.identifier=dR(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=d6(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),d.call(this,e))},link:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dR(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:s(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:s(),thematicBreak:s()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(d5.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},s={stack:[r],tokenStack:[],config:t,enter:o,exit:a,buffer:i,resume:l,data:n},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,t,n){let r,i,o,s,a=t-1,l=-1,c=!1;for(;++a<=n;){let t=e[a];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||s||l||o||(o=a),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let s=a;for(i=void 0;s--;){let t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=s}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||a,0,["exit",r,t[2]]),a++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(a,0,["enter",i,t[2]]),a++,n++,o=void 0,s=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];d5.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},s),e[d][1])}if(s.tokenStack.length>0){let e=s.tokenStack[s.tokenStack.length-1];(e[1]||d3).call(s,void 0,e[0])}for(r.position={start:d6(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:d6(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r};function r(e,t){return function(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:d6(t.start),end:void 0}}function s(e){return function(t){e&&e.call(this,t),a.call(this,t)}}function a(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||d3).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+cC({start:e.start,end:e.end})+"): it’s not open");n.position.end=d6(e.end)}function l(){return cW(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:d6(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=d6(e.end)}function u(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function f(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function g(){return{type:"html",value:""}}function y(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!da(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(cJ.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){cJ.call(i,r)||(i[r]=[]);let e=o[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);cq(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([dQ,...(e||{}).extensions||[]]),content:n(de),defined:[],document:n(dt),flow:n(dd),lazy:{},string:n(dh),text:n(dp)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],s=[],a=[],l={attempt:f(function(e,t){m(e,t.from)}),check:f(p),consume:function(e){c8(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,g()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),a.push(n),n},exit:function(e){let t=a.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:f(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,g()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,s=e[r];if("string"==typeof s)o=s;else switch(s){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(s)}n=-2===s,i.push(o)}return i.join("")}(u(e),t)},sliceStream:u,write:function(e){return(s=cK(s,e),function(){let e;for(;r._index<s.length;){let n=s[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),d=d(t)}else d=d(n)}}(),null!==s[s.length-1])?[]:(m(t,0),c.events=dv(o,c.events,c),c.events)}},d=t.tokenize.call(c,l);return t.resolveAll&&o.push(t),c;function u(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,s=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,s)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}s>0&&n.push(e[o].slice(0,s))}return n}(s,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function p(e,t){t.restore()}function f(e,t){return function(n,i,o){var s;let d,u,p,f;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):(s=n,function(e){let t=null!==e&&s[e],n=null!==e&&s.null;return m([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function m(e){return(d=e,u=0,0===e.length)?o:y(e[u])}function y(e){return function(n){let i,o,s,d,u;return(i=h(),o=c.previous,s=c.currentConstruct,d=c.events.length,u=Array.from(a),f={from:d,restore:function(){r=i,c.previous=o,c.currentConstruct=s,c.events.length=d,a=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,v,b)(n)}}function v(t){return e(p,f),i}function b(e){return(f.restore(),++u<d.length)?y(d[u]):o}}}function m(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&cq(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((s=1,a="",l=!0,function(e,t,n){let r,i,c,d,u,h=[];for(e=a+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,a="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(dZ.lastIndex=c,d=(r=dZ.exec(e))&&void 0!==r.index?r.index:e.length,u=e.charCodeAt(d),!r){a=e.slice(c);break}if(10===u&&c===d&&o)h.push(-3),o=void 0;else switch(o&&(h.push(-5),o=void 0),c<d&&(h.push(e.slice(c,d)),s+=d-c),u){case 0:h.push(65533),s++;break;case 9:for(i=4*Math.ceil(s/4),h.push(-2);s++<i;)h.push(-1);break;case 10:h.push(-4),s=1;break;default:o=!0,s=1}c=d+1}return n&&(o&&h.push(-5),a&&h.push(a),h.push(null)),h})(n,r,!0))))}}let d7="object"==typeof self?self:globalThis,d9=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[o,s]=e[i];switch(o){case 0:case -1:return n(s,i);case 1:{let e=n([],i);for(let t of s)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of s)e[r(t)]=r(n);return e}case 3:return n(new Date(s),i);case 4:{let{source:e,flags:t}=s;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of s)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of s)e.add(r(t));return e}case 7:{let{name:e,message:t}=s;return n(new d7[e](t),i)}case 8:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:e}=new Uint8Array(s);return n(new DataView(e),s)}}return n(new d7[o](s),i)})(0)},{toString:ue}={},{keys:ut}=Object,un=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=ue.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},ur=([e,t])=>0===e&&("function"===t||"symbol"===t),ui=(e,{json:t,lossy:n}={})=>{var r,i,o;let s,a,l=[];return(r=!(t||n),i=!!t,o=new Map,s=(e,t)=>{let n=l.push(e)-1;return o.set(t,n),n},a=e=>{if(o.has(e))return o.get(e);let[t,n]=un(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return s([-1],e)}return s([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),s([n,[...t]],e)}let r=[],i=s([t,r],e);for(let t of e)r.push(a(t));return i}case 2:{if(n)switch(n){case"BigInt":return s([n,e.toString()],e);case"Boolean":case"Number":case"String":return s([n,e.valueOf()],e)}if(i&&"toJSON"in e)return a(e.toJSON());let o=[],l=s([t,o],e);for(let t of ut(e))(r||!ur(un(e[t])))&&o.push([a(t),a(e[t])]);return l}case 3:return s([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return s([t,{source:n,flags:r}],e)}case 5:{let n=[],i=s([t,n],e);for(let[t,i]of e)(r||!(ur(un(t))||ur(un(i))))&&n.push([a(t),a(i)]);return i}case 6:{let n=[],i=s([t,n],e);for(let t of e)(r||!ur(un(t)))&&n.push(a(t));return i}}let{message:l}=e;return s([t,{name:n,message:l}],e)})(e),l},uo="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?d9(ui(e,t)):structuredClone(e):(e,t)=>d9(ui(e,t));function us(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),s="";if(37===o&&cY(e.charCodeAt(n+1))&&cY(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(s=String.fromCharCode(o,t),i=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ua(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function ul(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let uc=function(e){var t,n;if(null==e)return uu;if("function"==typeof e)return ud(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=uc(e[n]);return ud(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,ud(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,ud(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function ud(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function uu(){return!0}let uh=[],up="skip";function uf(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let o=uc(i),s=r?-1:1;(function e(i,a,l){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return d;function d(){var c;let d,u,h,p=uh;if((!t||o(i,a,l[l.length-1]||void 0))&&!1===(p=Array.isArray(c=n(i,l))?c:"number"==typeof c?[!0,c]:null==c?uh:[c])[0])return p;if("children"in i&&i.children&&i.children&&p[0]!==up)for(u=(r?i.children.length:-1)+s,h=l.concat(i);u>-1&&u<i.children.length;){if(!1===(d=e(i.children[u],u,h)())[0])return d;u="number"==typeof d[1]?d[1]:u+s}return p}})(e,void 0,[])()}function um(e,t,n,r){let i,o,s;"function"==typeof t&&"function"!=typeof n?(o=void 0,s=t,i=n):(o=t,s=n,i=r),uf(e,o,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return s(e,r,n)},i)}function ug(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let s=i[i.length-1];return s&&"text"===s.type?s.value+=r:i.push({type:"text",value:r}),i}function uy(e){let t=e.spread;return null==t?e.children.length>1:t}function uv(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let ub={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=us(i.toLowerCase()),s=e.footnoteOrder.indexOf(i),a=e.footnoteCounts.get(i);void 0===a?(a=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=s+1,a+=1,e.footnoteCounts.set(i,a);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ug(e,t);let i={src:us(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:us(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ug(e,t);let i={href:us(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:us(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=uy(n[r])}return t}(n):uy(t),o={},s=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let e=r[a];(i||0!==a||"element"!==e.type||"p"!==e.tagName)&&s.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?s.push(e):s.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&s.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=cw(t.children[1]),s=ck(t.children[t.children.length-1]);o&&s&&(r.position={start:o,end:s}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,s=o?o.length:t.children.length,a=-1,l=[];for(;++a<s;){let n=t.children[a],r={},s=o?o[a]:void 0;s&&(r.align=s);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(uv(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(uv(t.slice(i),i>0,!1)),o.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:ux,yaml:ux,definition:ux,footnoteDefinition:ux};function ux(){}let uk={}.hasOwnProperty,uw={};function uS(e,t){e.position&&(t.position=function(e){let t=cw(e),n=ck(e);if(t&&n)return{start:t,end:n}}(e))}function uC(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,uo(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function uN(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function uA(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function uE(e,t){let n,r,i,o,s=(n=t||uw,r=new Map,i=new Map,o={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=uA(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=uA(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:uC,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ub,...n.handlers},one:function(e,t){let n=e.type,r=o.handlers[n];if(uk.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=uo(n);return r.children=o.all(e),r}return uo(e)}return(o.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(uk.call(n,"hProperties")||uk.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(o,e,t)},options:n,patch:uS,wrap:uN},um(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o),a=s.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ua,r=e.options.footnoteBackLabel||ul,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let o=e.all(i),s=String(i.identifier).toUpperCase(),c=us(s.toLowerCase()),d=0,u=[],h=e.footnoteCounts.get(s);for(;void 0!==h&&++d<=h;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let f={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(o,!0)};e.patch(i,f),a.push(f)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...uo(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(s),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return l&&(cp("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function uM(e,t){return e&&"run"in e?async function(n,r){let i=uE(n,{file:r,...t});await e.run(i,r)}:function(n,r){return uE(n,{file:r,...e||t})}}function uT(e){if(e)throw e}var uI=e.i(75609);function uL(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let uO=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');u_(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else s<0&&(n=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(i=o):(a=-1,i=s));return r===i?i=s:i<0&&(i=e.length),e.slice(r,i)},uD=function(e){let t;if(u_(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},uR=function(e){let t;u_(e);let n=e.length,r=-1,i=0,o=-1,s=0;for(;n--;){let a=e.codePointAt(n);if(47===a){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===a?o<0?o=n:1!==s&&(s=1):o>-1&&(s=-1)}return o<0||r<0||0===s||1===s&&o===r-1&&o===i+1?"":e.slice(o,r)},uP=function(...e){var t;let n,r,i,o=-1;for(;++o<e.length;)u_(e[o]),e[o]&&(i=void 0===i?e[o]:i+"/"+e[o]);return void 0===i?".":(u_(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",o=0,s=-1,a=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(s===l-1||1===a);else if(s!==l-1&&2===a){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),s=l,a=0;continue}}else if(i.length>0){i="",o=0,s=l,a=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(s+1,l):i=e.slice(s+1,l),o=l-s-1;s=l,a=0}else 46===n&&a>-1?a++:a=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function u_(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function uj(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let uB=["history","path","basename","stem","extname","dirname"];class uz{constructor(e){let t,n;t=e?uj(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<uB.length;){const e=uB[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)uB.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?uO(this.path):void 0}set basename(e){uF(e,"basename"),u$(e,"basename"),this.path=uP(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?uD(this.path):void 0}set dirname(e){uU(this.basename,"dirname"),this.path=uP(e||"",this.basename)}get extname(){return"string"==typeof this.path?uR(this.path):void 0}set extname(e){if(u$(e,"extname"),uU(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=uP(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){uj(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!uj(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),uF(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?uO(this.path,this.extname):void 0}set stem(e){uF(e,"stem"),u$(e,"stem"),this.path=uP(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new cM(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function u$(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function uF(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function uU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let uH=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},uW={}.hasOwnProperty;class uV extends uH{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(o,...s){let a=e[++n],l=-1;if(o)return void r(o);for(;++l<t.length;)(null===s[l]||void 0===s[l])&&(s[l]=t[l]);t=s,a?(function(e,t){let n;return function(...t){let o,s=e.length>t.length;s&&t.push(r);try{o=e.apply(this,t)}catch(e){if(s&&n)throw e;return r(e)}s||(o&&o.then&&"function"==typeof o.then?o.then(i,r):o instanceof Error?r(o):i(o))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(a,i)(...s):r(null,...s)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new uV,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,uI.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(uJ("data",this.frozen),this.namespace[e]=t,this):uW.call(this.namespace,e)&&this.namespace[e]||void 0:e?(uJ("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=uQ(e),n=this.parser||this.Parser;return uq("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),uq("process",this.parser||this.Parser),uK("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=uQ(e),s=n.parse(o);function a(e,n){e||!n?i(e):r?r(n):(cp(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(s,o,function(e,t,r){var i,o;if(e||!t||!r)return a(e);let s=n.stringify(t,r);"string"==typeof(i=s)||(o=i)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?r.value=s:r.result=s,a(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),uq("processSync",this.parser||this.Parser),uK("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,uT(e),t=r}),uY("processSync","process",n),cp(t,"we either bailed on an error or have a tree"),t}run(e,t,n){uX(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){cp("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let s=uQ(t);r.run(e,s,function(t,r,s){let a=r||e;t?o(t):i?i(a):(cp(n,"`done` is defined if `resolve` is not"),n(void 0,a,s))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){uT(e),n=t,r=!0}),uY("runSync","run",r),cp(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=uQ(t),r=this.compiler||this.Compiler;return uK("stringify",r),uX(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(uJ("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else if("object"==typeof e)Array.isArray(e)?o(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,uI.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)s(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,s=n[i][1];uL(s)&&uL(r)&&(r=(0,uI.default)(!0,s,r)),n[i]=[e,r,...o]}}}}let uG=new uV().freeze();function uq(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function uK(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function uJ(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function uX(e){if(!uL(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function uY(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function uQ(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new uz(e)}let uZ=[],u0={allowDangerousHtml:!0},u1=/^(https?|ircs?|mailto|xmpp)$/i,u2=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function u8(e){var t;let n,r,i,o,s,a=(n=(t=e).rehypePlugins||uZ,r=t.remarkPlugins||uZ,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...u0}:u0,uG().use(d4).use(r).use(uM,i).use(n)),l=(o=e.children||"",s=new uz,"string"==typeof o?s.value=o:cf("Unexpected value `"+o+"` for `children` prop, expected `string`"),s);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||u5;for(let e of u2)Object.hasOwn(t,e.from)&&cf("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&o&&cf("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),um(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return s?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in cU)if(Object.hasOwn(cU,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=cU[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let s=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!s&&r&&"number"==typeof t&&(s=!r(e,t,i)),s&&i&&"number"==typeof t)return a&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,o;let s;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let a=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=a,r=t.jsxDEV,s=function(e,t,i,o){let s=Array.isArray(i.children),a=cw(e);return r(t,i,o,s,{columnNumber:a?a.column-1:void 0,fileName:n,lineNumber:a?a.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,o=t.jsxs,s=function(e,t,n,r){let s=Array.isArray(n.children)?o:i;return r?s(t,n,r):s(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?n1:n0,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=cP(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:ee.Fragment,components:i,ignoreInvalidStyle:!0,jsx:ee.jsx,jsxs:ee.jsxs,passKeys:!0,passNode:!0})}(a.runSync(a.parse(l),l),e)}function u5(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||u1.test(e.slice(0,t))?e:""}function u6({authorship:e}){if(!e)return(0,ee.jsx)("div",{className:"text-[10px] text-[var(--dim)] px-1 py-1",children:"No authorship data"});let{aiPercent:t,humanPercent:n,totalChars:r}=e.stats;return(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-1 py-1.5",children:[(0,ee.jsxs)("div",{className:"flex h-1.5 flex-1 overflow-hidden rounded-sm",children:[t>0&&(0,ee.jsx)("div",{className:"h-full transition-all duration-300",style:{width:`${t}%`,backgroundColor:"var(--ai-color)",opacity:.6}}),n>0&&(0,ee.jsx)("div",{className:"h-full transition-all duration-300",style:{width:`${n}%`,backgroundColor:"var(--human-color)",opacity:.6}})]}),(0,ee.jsxs)("span",{className:"text-[10px] shrink-0 flex gap-2",children:[(0,ee.jsxs)("span",{style:{color:"var(--ai-color)"},children:[t,"% AI"]}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"/"}),(0,ee.jsxs)("span",{style:{color:"var(--human-color)"},children:[n,"% human"]}),(0,ee.jsxs)("span",{className:"text-[var(--dimmer)]",children:["(",Math.round(r/1e3),"k chars)"]})]})]})}var u3=((x=u3||{}).docTypeError="docTypeError",x.contextNotFound="contextNotFound",x.timerNotFound="timerNotFound",x.ctxCallOutOfScope="ctxCallOutOfScope",x.createNodeInParserFail="createNodeInParserFail",x.stackOverFlow="stackOverFlow",x.parserMatchError="parserMatchError",x.serializerMatchError="serializerMatchError",x.getAtomFromSchemaFail="getAtomFromSchemaFail",x.expectDomTypeError="expectDomTypeError",x.callCommandBeforeEditorView="callCommandBeforeEditorView",x.missingRootElement="missingRootElement",x.missingNodeInSchema="missingNodeInSchema",x.missingMarkInSchema="missingMarkInSchema",x.ctxNotBind="ctxNotBind",x.missingYjsDoc="missingYjsDoc",x);class u4 extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}let u7=(e,t)=>"function"==typeof t?"[Function]":t;function u9(){return new u4(u3.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function he(){return new u4(u3.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function ht(e){return new u4(u3.expectDomTypeError,`Expect to be a dom, but get: ${JSON.stringify(e,u7)}.`)}function hn(){return new u4(u3.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}class hr{constructor(){this.sliceMap=new Map,this.get=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t){var n;throw n="string"==typeof e?e:e.name,new u4(u3.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}return t},this.remove=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}}class hi{constructor(e,t,n){this.#s=[],this.#a=()=>{this.#s.forEach(e=>e(this.#l))},this.set=e=>{this.#l=e,this.#a()},this.get=()=>this.#l,this.update=e=>{this.#l=e(this.#l),this.#a()},this.type=n,this.#l=t,e.set(n.id,this)}#s;#l;#a;on(e){return this.#s.push(e),()=>{this.#s=this.#s.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#s=this.#s.filter(t=>t!==e)}offAll(){this.#s=[]}}class ho{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw u9()}}create(e,t=this._defaultValue){return new hi(e,t,this)}}let hs=(e,t)=>new ho(e,t);class ha{constructor(e,t,n){this.#c=new Set,this.#d=new Set,this.#u=new Map,this.#h=new Map,this.read=()=>({metadata:this.#p,injectedSlices:[...this.#c].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),consumedSlices:[...this.#d].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),recordedTimers:[...this.#u].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)})),waitTimers:[...this.#h].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)}))}),this.onRecord=e=>{this.#u.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#u.delete(e)},this.onDone=e=>{let t=this.#u.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#h.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#c.add(e)},this.onRemove=e=>{this.#c.delete(e)},this.onUse=e=>{this.#d.add(e)},this.#f=e=>this.#g.get(e).get(),this.#m=e=>this.#y.get(e).status,this.#g=e,this.#y=t,this.#p=n}#p;#g;#y;#c;#d;#u;#h;#f;#m}class hl{constructor(e,t,n){this.produce=e=>e&&Object.keys(e).length?new hl(this.#g,this.#y,{...e}):this,this.inject=(e,t)=>{let n=e.create(this.#g.sliceMap);return null!=t&&n.set(t),this.#v?.onInject(e),this},this.remove=e=>(this.#g.remove(e),this.#v?.onRemove(e),this),this.record=e=>(e.create(this.#y.store),this.#v?.onRecord(e),this),this.clearTimer=e=>(this.#y.remove(e),this.#v?.onClear(e),this),this.isInjected=e=>this.#g.has(e),this.isRecorded=e=>this.#y.has(e),this.use=e=>(this.#v?.onUse(e),this.#g.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#y.get(e),this.done=e=>{this.timer(e).done(),this.#v?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#v?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#g=e,this.#y=t,this.#p=n,n&&(this.#v=new ha(e,t,n))}#g;#y;#p;#v;get meta(){return this.#p}get inspector(){return this.#v}}class hc{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t){var n;throw n=e.name,new u4(u3.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}class hd{constructor(e,t){this.#b=null,this.#x=null,this.#k="pending",this.start=()=>(this.#b??=new Promise((e,t)=>{this.#x=t=>{t instanceof CustomEvent&&t.detail.id===this.#w&&(this.#k="resolved",this.#S(),t.stopImmediatePropagation(),e())},this.#C(()=>{"pending"===this.#k&&(this.#k="rejected"),this.#S(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#k="pending",addEventListener(this.type.name,this.#x)}),this.#b),this.done=()=>{dispatchEvent(new CustomEvent(this.type.name,{detail:{id:this.#w}}))},this.#S=()=>{this.#x&&removeEventListener(this.type.name,this.#x)},this.#C=e=>{setTimeout(()=>{e()},this.type.timeout)},this.#w=Symbol(t.name),this.type=t,e.set(t.id,this)}#b;#x;#w;#k;get status(){return this.#k}#S;#C}class hu{constructor(e,t=3e3){this.create=e=>new hd(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}let hh=(e,t=3e3)=>new hu(e,t);function hp(e){this.content=e}hp.prototype={constructor:hp,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return -1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new hp(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new hp(n)},addToStart:function(e,t){return new hp([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new hp(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new hp(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=hp.from(e)).size?new hp(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=hp.from(e)).size?new hp(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hp.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},hp.from=function(e){if(e instanceof hp)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new hp(t)};class hf{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,i||null,o)&&a.content.size){let i=s+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",o=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(o?o=!1:i+=n),i+=l},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new hf(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,o=0;o<t;i++){let s=this.content[i],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),r+=s.nodeSize),o=a}return new hf(n,r)}cutByIndex(e,t){return e==t?hf.empty:0==e&&t==this.content.length?this:new hf(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new hf(r,i)}addToStart(e){return new hf([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new hf(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let i=0;;i++){if(i==t.childCount||i==n.childCount)return t.childCount==n.childCount?null:r;let o=t.child(i),s=n.child(i);if(o==s){r+=o.nodeSize;continue}if(!o.sameMarkup(s))return r;if(o.isText&&o.text!=s.text){for(let e=0;o.text[e]==s.text[e];e++)r++;return r}if(o.content.size||s.content.size){let t=e(o.content,s.content,r+1);if(null!=t)return t}r+=o.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,i){for(let o=t.childCount,s=n.childCount;;){if(0==o||0==s)return o==s?null:{a:r,b:i};let a=t.child(--o),l=n.child(--s),c=a.nodeSize;if(a==l){r-=c,i-=c;continue}if(!a.sameMarkup(l))return{a:r,b:i};if(a.isText&&a.text!=l.text){let e=0,t=Math.min(a.text.length,l.text.length);for(;e<t&&a.text[a.text.length-e-1]==l.text[l.text.length-e-1];)e++,r--,i--;return{a:r,b:i}}if(a.content.size||l.content.size){let t=e(a.content,l.content,r-1,i-1);if(t)return t}r-=c,i-=c}}(this,e,t,n)}findIndex(e){if(0==e)return hg(0,e);if(e==this.size)return hg(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e){if(r==e)return hg(t+1,r);return hg(t,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return hf.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return new hf(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return hf.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new hf(t||e,n)}static from(e){if(!e)return hf.empty;if(e instanceof hf)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new hf([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}hf.empty=new hf([],0);let hm={index:0,offset:0};function hg(e,t){return hm.index=e,hm.offset=t,hm}function hy(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!hy(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!hy(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class hv{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hy(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return hv.none;if(e instanceof hv)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}hv.none=[];class hb extends Error{}class hx{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,r,i){let{index:o,offset:s}=t.findIndex(n),a=t.maybeChild(o);if(s==n||a.isText)return i&&!i.canReplace(o,o,r)?null:t.cut(0,n).append(r).append(t.cut(n));let l=e(a.content,n-s-1,r,a);return l&&t.replaceChild(o,a.copy(l))}(this.content,e+this.openStart,t);return n&&new hx(n,this.openStart,this.openEnd)}removeBetween(e,t){return new hx(function e(t,n,r){let{index:i,offset:o}=t.findIndex(n),s=t.maybeChild(i),{index:a,offset:l}=t.findIndex(r);if(o==n||s.isText){if(l!=r&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=a)throw RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(e(s.content,n-o-1,r-o-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return hx.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new hx(hf.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new hx(e,n,r)}}function hk(e,t){if(!t.type.compatibleContent(e.type))throw new hb("Cannot join "+t.type.name+" onto "+e.type.name)}function hw(e,t,n){let r=e.node(n);return hk(r,t.node(n)),r}function hS(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function hC(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(hS(e.nodeAfter,r),o++));for(let e=o;e<s;e++)hS(i.child(e),r);t&&t.depth==n&&t.textOffset&&hS(t.nodeBefore,r)}function hN(e,t){return e.type.checkContent(t),e.copy(t)}function hA(e,t,n){let r=[];return hC(null,e,n,r),e.depth>n&&hS(hN(hw(e,t,n+1),hA(e,t,n+1)),r),hC(t,null,n,r),new hf(r)}hx.empty=new hx(hf.empty,0,0);class hE{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return hv.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||r&&i[o].isInSet(r.marks)||(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new hL(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(i),s=i-o;if(n.push(t,e,r+o),!s||(t=t.child(e)).isText)break;i=s-1,r+=o+1}return new hE(t,n,i)}static resolveCached(e,t){let n=hI.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else hI.set(e,n=new hM);let r=n.elts[n.i]=hE.resolve(e,t);return n.i=(n.i+1)%hT,r}}class hM{constructor(){this.elts=[],this.i=0}}let hT=12,hI=new WeakMap;class hL{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let hO=Object.create(null);class hD{constructor(e,t,n,r=hv.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||hf.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&hy(this.attrs,t||e.defaultAttrs||hO)&&hv.sameSet(this.marks,n||hv.none)}copy(e=null){return e==this.content?this:new hD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new hD(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return hx.empty;let r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),s=r.start(o);return new hx(r.node(o).content.cut(r.pos-s,i.pos-s),r.depth-o,i.depth-o)}replace(e,t,n){var r=this.resolve(e),i=this.resolve(t);if(n.openStart>r.depth)throw new hb("Inserted content deeper than insertion position");if(r.depth-n.openStart!=i.depth-n.openEnd)throw new hb("Inconsistent open depths");return function e(t,n,r,i){let o=t.index(i),s=t.node(i);if(o==n.index(i)&&i<t.depth-r.openStart){let a=e(t,n,r,i+1);return s.copy(s.content.replaceChild(o,a))}if(!r.content.size)return hN(s,hA(t,n,i));if(r.openStart||r.openEnd||t.depth!=i||n.depth!=i){let{start:e,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(hf.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return hN(s,function e(t,n,r,i,o){let s=t.depth>o&&hw(t,n,o+1),a=i.depth>o&&hw(r,i,o+1),l=[];return hC(null,t,o,l),s&&a&&n.index(o)==r.index(o)?(hk(s,a),hS(hN(s,e(t,n,r,i,o+1)),l)):(s&&hS(hN(s,hA(t,n,o+1)),l),hC(n,r,o,l),a&&hS(hN(a,hA(r,i,o+1)),l)),hC(i,null,o,l),new hf(l)}(t,e,o,n,i))}{let e=t.parent,i=e.content;return hN(e,i.cut(0,t.parentOffset).append(r.content).append(i.cut(n.parentOffset)))}}(r,i,n,0)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return hE.resolveCached(this,e)}resolveNoCache(e){return hE.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),hP(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=hf.empty,r=0,i=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,i),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=hv.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!hv.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=hf.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}hD.prototype.text=void 0;class hR extends hD{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):hP(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new hR(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hR(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function hP(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class h_{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){var n;let r,i=new hj(e,t);if(null==i.next)return h_.empty;let o=function e(t){let n=[];do n.push(function(t){let n=[];do n.push(function(t){let n=function(t){if(t.eat("(")){let n=e(t);return t.eat(")")||t.err("Missing closing paren"),n}if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=(function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i})(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(t);for(;;)if(t.eat("+"))n={type:"plus",expr:n};else if(t.eat("*"))n={type:"star",expr:n};else if(t.eat("?"))n={type:"opt",expr:n};else if(t.eat("{"))n=function(e,t){let n=hB(e),r=n;return e.eat(",")&&(r="}"!=e.next?hB(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}(t,n);else break;return n}(t));while(t.next&&")"!=t.next&&"|"!=t.next)return 1==n.length?n[0]:{type:"seq",exprs:n}}(t));while(t.eat("|"))return 1==n.length?n[0]:{type:"choice",exprs:n}}(i);i.next&&i.err("Unexpected trailing text");let s=(n=function(e){let t=[[]];return i(function e(t,o){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,o)),[]);if("seq"==t.type)for(let r=0;;r++){let s=e(t.exprs[r],o);if(r==t.exprs.length-1)return s;i(s,o=n())}else if("star"==t.type){let s=n();return r(o,s),i(e(t.expr,s),s),[r(s)]}else if("plus"==t.type){let s=n();return i(e(t.expr,o),s),i(e(t.expr,s),s),[r(s)]}else if("opt"==t.type)return[r(o)].concat(e(t.expr,o));else if("range"==t.type){let s=o;for(let r=0;r<t.min;r++){let r=n();i(e(t.expr,s),r),s=r}if(-1==t.max)i(e(t.expr,s),s);else for(let o=t.min;o<t.max;o++){let o=n();r(s,o),i(e(t.expr,s),o),s=o}return[r(s)]}else if("name"==t.type)return[r(o,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}}(o),r=Object.create(null),function e(t){let i=[];t.forEach(e=>{n[e].forEach(({term:e,to:t})=>{let r;if(e){for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);h$(n,t).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})}})});let o=r[t.join(",")]=new h_(t.indexOf(n.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(hz);o.next.push({type:i[t][0],next:r[n.join(",")]||e(n)})}return o}(h$(n,0)));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),-1==r.indexOf(s)&&r.push(s)}i&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(o,s){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return hf.from(s.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=i(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:o,next:s}=i.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}h_.empty=new h_(!0);class hj{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function hB(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function hz(e,t){return t-e}function h$(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:o}=i[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(hz)}function hF(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function hU(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function hH(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function hW(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new hG(e,r,t[r]);return n}class hV{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=hW(e,n.attrs),this.defaultAttrs=hF(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==h_.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:hU(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new hD(this,this.computeAttrs(e),hf.from(t),hv.setFrom(n))}createChecked(e=null,t,n){return t=hf.from(t),this.checkContent(t),new hD(this,this.computeAttrs(e),t,hv.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=hf.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(hf.empty,!0);return i?new hD(this,e,t.append(i),hv.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){hH(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:hv.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new hV(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class hG{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(0>r.indexOf(i))throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class hq{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=hW(e,r.attrs),this.excluded=null;let i=hF(this.attrs);this.instance=i?new hv(this,i):null}create(e=null){return!e&&this.instance?this.instance:new hv(this,hU(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new hq(e,r++,t,i)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){hH(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class hK{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=hp.from(e.nodes),t.marks=hp.from(e.marks||{}),this.nodes=hV.compile(this.spec.nodes,this),this.marks=hq.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=h_.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==i?null:i?hJ(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:hJ(this,n.split(" "))}this.nodeFromJSON=e=>hD.fromJSON(this,e),this.markFromJSON=e=>hv.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof hV){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new hR(n,n.defaultAttrs,e,hv.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function hJ(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=r)}if(!s)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class hX{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new h2(this,t,!1);return n.addAll(e,hv.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new h2(this,t,!0);return n.addAll(e,hv.none,t.from,t.to),hx.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){var r,i;let n=this.tags[o];if(r=e,i=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,i)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],o=r.style;if(0==o.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(o.length>e.length)||61==o.charCodeAt(e.length)&&o.slice(e.length+1)==t)){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=h8(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=h8(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new hX(e,hX.schemaRules(e)))}}let hY={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},hQ={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hZ={ol:!0,ul:!0};function h0(e,t,n){return null!=t?!!t|2*("full"===t):e&&"pre"==e.whitespace?3:-5&n}class h1{constructor(e,t,n,r,i,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=hv.none,this.match=i||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(hf.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=hf.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(hf.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!hY.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class h2{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,o=h0(null,t.preserveWhitespace,0)|4*!!n;i=r?new h1(r.type,r.attrs,hv.none,!0,t.topMatch||r.type.contentMatch,o):n?new h1(null,null,hv.none,!0,null,o):new h1(e.schema.topNodeType,null,hv.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),s;hZ.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&hZ.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,n));t:if(a?a.ignore:hQ.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(hY.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break t}let s=a&&a.skip?t:this.readStyles(e,t);s&&this.addAll(e,s),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?s:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,o=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+o)&&(r=a,i=s,!a.length))break;if(s.solid){if(n)break;o+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=hv.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):h5(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let s=h0(e,i,o.options);4&o.options&&0==o.content.length&&(s|=4);let a=hv.none;return n=n.filter(t=>(o.type?!o.type.allowsMarkType(t.type):!h5(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new h1(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=i;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=i?n.node(s-i).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function h8(e){let t={};for(let n in e)t[n]=e[n];return t}function h5(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||0>o.indexOf(i)&&s(i))return!0}};if(s(i.contentMatch))return!0}}class h6{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=h4(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,o=0;for(;n<i.length&&o<e.marks.length;){let t=e.marks[o];if(!this.marks[t.type.name]){o++;continue}if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,o++}for(;n<i.length;)r=i.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(i.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=h9(h4(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&h9(h4(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return h9(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new h6(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=h3(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return h3(e.marks)}}function h3(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function h4(e){return e.document||window.document}let h7=new WeakMap;function h9(e,t,n,r){let i,o,s;if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(o=h7.get(r))&&h7.set(r,(s=null,!function e(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])s||(s=[]),s.push(t);else for(let n=0;n<t.length;n++)e(t[n]);else for(let n in t)e(t[n])}(r),o=s)),l=o)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let c=a.indexOf(" ");c>0&&(n=a.slice(0,c),a=a.slice(c+1));let d=n?e.createElementNS(n,a):e.createElement(a),u=t[1],h=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){for(let e in h=2,u)if(null!=u[e]){let t=e.indexOf(" ");t>0?d.setAttributeNS(e.slice(0,t),e.slice(t+1),u[e]):"style"==e&&d.style?d.style.cssText=u[e]:d.setAttribute(e,u[e])}}for(let o=h;o<t.length;o++){let s=t[o];if(0===s){if(o<t.length-1||o>h)throw RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}{let{dom:t,contentDOM:o}=h9(e,s,n,r);if(d.appendChild(t),o){if(i)throw RangeError("Multiple content holes");i=o}}}return{dom:d,contentDOM:i}}class pe{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class pt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&pt.empty)return pt.empty}recover(e){let t=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+(e-(65535&e))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+i],c=this.ranges[s+o],d=a+l;if(e<=d){let i=l?e==a?-1:e==d?1:t:t,o=a+r+(i<0?0:c);if(n)return o;let u=e==(t<0?a:d)?null:s/3+(e-a)*65536,h=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(h|=8),new pe(o,h,u)}r+=c-l}return n?e+r:new pe(e+r,0,null)}touches(e,t){let n=0,r=65535&t,i=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+i];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let o=this.ranges[r],s=o-(this.inverted?i:0),a=o+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),i+=c-l}}invert(){return new pt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?pt.empty:new pt(e<0?[0,-e,0]:[0,0,e])}}pt.empty=new pt([]);class pn{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new pn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new pn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new pe(e,r,null)}}let pr=Object.create(null);class pi{getMap(){return pt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=pr[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pr)throw RangeError("Duplicate use of step JSON ID "+e);return pr[e]=t,t.prototype.jsonID=e,t}}class po{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new po(e,null)}static fail(e){return new po(null,e)}static fromReplace(e,t,n,r){try{return po.ok(e.replace(t,n,r))}catch(e){if(e instanceof hb)return po.fail(e.message);throw e}}}function ps(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(ps(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return hf.fromArray(r)}class pa extends pi{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new hx(ps(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return po.fromReplace(e,this.from,this.to,i)}invert(){return new pl(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new pa(t.pos,n.pos,this.mark)}merge(e){return e instanceof pa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pa(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new pa(t.from,t.to,e.markFromJSON(t.mark))}}pi.jsonID("addMark",pa);class pl extends pi{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new hx(ps(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return po.fromReplace(e,this.from,this.to,n)}invert(){return new pa(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new pl(t.pos,n.pos,this.mark)}merge(e){return e instanceof pl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pl(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pl(t.from,t.to,e.markFromJSON(t.mark))}}pi.jsonID("removeMark",pl);class pc extends pi{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new pc(this.pos,t.marks[n]);return new pc(this.pos,this.mark)}}return new pd(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pc(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new pc(t.pos,e.markFromJSON(t.mark))}}pi.jsonID("addNodeMark",pc);class pd extends pi{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new pc(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pd(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pd(t.pos,e.markFromJSON(t.mark))}}pi.jsonID("removeNodeMark",pd);class pu extends pi{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&pp(e,this.from,this.to)?po.fail("Structure replace would overwrite content"):po.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pt([this.from,this.to-this.from,this.slice.size])}invert(e){return new pu(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new pu(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof pu)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?hx.empty:new hx(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new pu(e.from,this.to,t,this.structure)}{let t=this.slice.size+e.slice.size==0?hx.empty:new hx(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new pu(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new pu(t.from,t.to,hx.fromJSON(e,t.slice),!!t.structure)}}pi.jsonID("replace",pu);class ph extends pi{constructor(e,t,n,r,i,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=o,this.structure=s}apply(e){if(this.structure&&(pp(e,this.from,this.gapFrom)||pp(e,this.gapTo,this.to)))return po.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return po.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?po.fromReplace(e,this.from,this.to,n):po.fail("Content does not fit in gap")}getMap(){return new pt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ph(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new ph(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ph(t.from,t.to,t.gapFrom,t.gapTo,hx.fromJSON(e,t.slice),t.insert,!!t.structure)}}function pp(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function pf(e,t,n,r=n.contentMatch,i=!0){let o=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<o.childCount;t++){let l=o.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new pl(a,c,l.marks[t]));if(i&&l.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(l.text);)r||(r=new hx(hf.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new pu(a+e.index,a+e.index+e[0].length,r))}}else s.push(new pu(a,c,hx.empty));a=c}if(!r.validEnd){let t=r.fillBefore(hf.empty,!0);e.replace(a,a,new hx(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function pm(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,a,t))return n;if(0==n||o.type.spec.isolating||!((0==s||o.canReplace(s,o.childCount))&&(a==o.childCount||o.canReplace(0,a))))break;s&&(r=1),a<o.childCount&&(i=1)}return null}function pg(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}(e,t),o=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return o?i.map(py).concat({type:t,attrs:n}).concat(o.map(py)):null}function py(e){return{type:e,attrs:null}}function pv(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let i=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function pb(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function px(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>o;e--,t--){let n=i.node(e),o=i.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(o+1,n.childCount)||!l.type.validContent(s))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function pk(e,t){var n,r;let i=e.resolve(t),o=i.index();return n=i.nodeBefore,r=i.nodeAfter,!!(n&&r&&!n.isLeaf&&function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(s))||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(n,r))&&i.parent.canReplace(o,o+1)}function pw(e,t,n=t,r=hx.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return pS(i,o,r)?new pu(t,n,r):new pC(i,o,r).fit()}function pS(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}pi.jsonID("replaceAround",ph);class pC{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=hf.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=hf.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,o=n.depth,s=r.depth;for(;o&&s&&1==i.childCount;)i=i.firstChild.content,o--,s--;let a=new hx(i,o,s);return e>-1?new ph(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new pu(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e=null,r=(n?(e=pE(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let i=this.depth;i>=0;i--){let{type:o,match:s}=this.frontier[i],a,l=null;if(1==t&&(r?s.matchType(r.type)||(l=s.fillBefore(hf.from(r),!1)):e&&o.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:i,parent:e,inject:l};if(2==t&&r&&(a=s.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:i,parent:e,wrap:a};if(e&&s.matchType(e.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=pE(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new hx(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=pE(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new hx(pN(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new hx(pN(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let o=this.unplaced,s=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=s.size+e-(o.content.size-o.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;(++l>1||0==a||e.content.size)&&(d=t,c.push(function e(t,n,r){if(n<=0)return t;let i=t.content;return n>1&&(i=i.replaceChild(0,e(i.firstChild,n-1,1==i.childCount?r-1:0))),n>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(hf.empty,!0)))),t.copy(i)}(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=pA(this.placed,t,hf.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?hx.empty:new hx(pN(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new hx(pN(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!pM(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){n:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=pM(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=pM(e,n,r,t,!0);if(!i||i.childCount)continue n}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=pA(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=pA(this.placed,this.depth,hf.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(hf.empty,!0);e.childCount&&(this.placed=pA(this.placed,this.frontier.length,e))}}function pN(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(pN(e.firstChild.content,t-1,n)))}function pA(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(pA(e.lastChild.content,t-1,n)))}function pE(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function pM(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?a:null}function pT(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class pI extends pi{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(r),0,+!t.isLeaf))}getMap(){return pt.empty}invert(e){return new pI(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pI(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new pI(t.pos,t.attr,t.value)}}pi.jsonID("attr",pI);class pL extends pi{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return po.ok(n)}getMap(){return pt.empty}invert(e){return new pL(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new pL(t.attr,t.value)}}pi.jsonID("docAttr",pL);let pO=class extends Error{};(pO=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),pO.prototype.constructor=pO,pO.prototype.name="TransformError";class pD{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new pO(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,o)=>{e=Math.min(e,i),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=hx.empty){let r=pw(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new hx(hf.from(n),0,0))}delete(e,t){return this.replace(e,t,hx.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(pS(i,o,r))return e.step(new pu(t,n,r));let s=pT(i,o);0==s[s.length-1]&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:i.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){var u;let t=c[e],n=(u=t.type).spec.defining||u.spec.definingForContent;if(n&&!t.sameMarkup(i.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let h=i.node(c-1),p=i.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(i.before(c),d?o.after(c):n,new hx(function e(t,n,r,i,o){if(n<r){let o=t.firstChild;t=t.replaceChild(0,o.copy(e(o.content,n+1,r,i,o)))}if(n>i){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(hf.empty,!0))}return t}(r.content,0,r.openStart,a),a,r.openEnd))}}let h=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>h));a--){let e=s[a];e<0||(t=i.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){var r=e,i=t;if(!n.isInline&&r==i&&this.doc.resolve(r).parent.content.size){let e=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)break}return null}(this.doc,r,n.type);null!=e&&(r=i=e)}return this.replaceRange(r,i,new hx(hf.from(n),0,0)),this}deleteRange(e,t){return!function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),o=pT(r,i);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(t-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return e.delete(r.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:i,depth:o}=t,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=hf.empty,u=0;for(let e=o,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=hf.from(r.node(e).copy(d)),u++):l--;let h=hf.empty,p=0;for(let e=o,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,h=hf.from(i.node(e).copy(h)),p++):c++;e.step(new ph(l,c,s,a,new hx(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),s=o.node().type;if(i&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);pb(e,r.node(),r.before(),a)}s.inlineContent&&pf(e,t+n-1,s,o.node().contentMatchAt(o.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new pu(c,l.map(t+n,-1),hx.empty,!0)),!0===r){let t=e.doc.resolve(c);pv(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return!function(e,t,n){let r=hf.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=hf.from(n[e].type.create(n[e].attrs,r))}let i=t.start,o=t.end;e.step(new ph(i,o,i,o,new hx(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){var i=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let o=i.steps.length;return i.doc.nodesBetween(e,t,(e,t)=>{var s,a,l;let c,d,u="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(n,u)&&(s=i.doc,a=i.mapping.slice(o).map(t),l=n,d=(c=s.resolve(a)).index(),c.parent.canReplaceWith(d,d+1,l))){let r=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&pb(i,e,t,o),pf(i,i.mapping.slice(o).map(t,1),n,void 0,null===r);let s=i.mapping.slice(o),a=s.map(t,1),l=s.map(t+e.nodeSize,1);return i.step(new ph(a,l,a+1,l-1,new hx(hf.from(n.create(u,null,e.marks)),0,0),1,!0)),!0===r&&pv(i,e,t,o),!1}}),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw RangeError("Invalid content for node type "+n.name);e.step(new ph(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new hx(hf.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new pI(e,t,n)),this}setDocAttribute(e,t){return this.step(new pL(e,t)),this}addNodeMark(e,t){return this.step(new pc(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof hv)t.isInSet(n.marks)&&this.step(new pd(e,t));else{let r=n.marks,i,o=[];for(;i=t.isInSet(r);)o.push(new pd(e,i)),r=i.removeFromSet(r);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let i=e.doc.resolve(t),o=hf.empty,s=hf.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){o=hf.from(i.node(e).copy(o));let t=r&&r[a];s=hf.from(t?t.type.create(t.attrs,s):i.node(e).copy(s))}e.step(new pu(t,t,new hx(o.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var r;let i,o,s,a;return r=this,s=[],a=[],r.doc.nodesBetween(e,t,(r,l,c)=>{if(!r.isInline)return;let d=r.marks;if(!n.isInSet(d)&&c.type.allowsMarkType(n.type)){let c=Math.max(l,e),u=Math.min(l+r.nodeSize,t),h=n.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(i&&i.to==c&&i.mark.eq(d[e])?i.to=u:s.push(i=new pl(c,u,d[e])));o&&o.to==c?o.to=u:a.push(o=new pa(c,u,n))}}),s.forEach(e=>r.step(e)),a.forEach(e=>r.step(e)),this}removeMark(e,t,n){var r;let i,o;return r=this,i=[],o=0,r.doc.nodesBetween(e,t,(r,s)=>{if(!r.isInline)return;o++;let a=null;if(n instanceof hq){let e=r.marks,t;for(;t=n.isInSet(e);)(a||(a=[])).push(t),e=t.removeFromSet(e)}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length){let n=Math.min(s+r.nodeSize,t);for(let t=0;t<a.length;t++){let r=a[t],l;for(let e=0;e<i.length;e++){let t=i[e];t.step==o-1&&r.eq(i[e].style)&&(l=t)}l?(l.to=n,l.step=o):i.push({style:r,from:Math.max(s,e),to:n,step:o})}}}),i.forEach(e=>r.step(new pl(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return pf(this,e,t,n),this}}let pR=Object.create(null);class pP{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new p_(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=hx.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:a,$to:l}=o[s],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),s?hx.empty:t),0==s&&pG(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(s.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),pG(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new pz(e):pV(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?pV(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):pV(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new pH(e.node(0))}static atStart(e){return pV(e,e,0,0,1)||new pH(e)}static atEnd(e){return pV(e,e,e.content.size,e.childCount,-1)||new pH(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=pR[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pR)throw RangeError("Duplicate use of selection JSON ID "+e);return pR[e]=t,t.prototype.jsonID=e,t}getBookmark(){return pz.between(this.$anchor,this.$head).getBookmark()}}pP.prototype.visible=!0;class p_{constructor(e,t){this.$from=e,this.$to=t}}let pj=!1;function pB(e){pj||e.parent.inlineContent||(pj=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class pz extends pP{constructor(e,t=e){pB(e),pB(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return pP.near(n);let r=e.resolve(t.map(this.anchor));return new pz(r.parent.inlineContent?r:n,n)}replace(e,t=hx.empty){if(super.replace(e,t),t==hx.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof pz&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new p$(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new pz(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let e=pP.findFrom(t,n,!0)||pP.findFrom(t,-n,!0);if(!e)return pP.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r?e=t:(e=(pP.findFrom(e,-n,!0)||pP.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0&&(e=t)),new pz(e,t)}}pP.jsonID("text",pz);class p${constructor(e,t){this.anchor=e,this.head=t}map(e){return new p$(e.map(this.anchor),e.map(this.head))}resolve(e){return pz.between(e.resolve(this.anchor),e.resolve(this.head))}}class pF extends pP{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?pP.near(i):new pF(i)}content(){return new hx(hf.from(this.node),0,0)}eq(e){return e instanceof pF&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new pU(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new pF(e.resolve(t.anchor))}static create(e,t){return new pF(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}pF.prototype.visible=!1,pP.jsonID("node",pF);class pU{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new p$(n,n):new pU(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&pF.isSelectable(n)?new pF(t):pP.near(t)}}class pH extends pP{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=hx.empty){if(t==hx.empty){e.delete(0,e.doc.content.size);let t=pP.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new pH(e)}map(e){return new pH(e)}eq(e){return e instanceof pH}getBookmark(){return pW}}pP.jsonID("all",pH);let pW={map(){return this},resolve:e=>new pH(e)};function pV(e,t,n,r,i,o=!1){if(t.inlineContent)return pz.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let r=t.child(s);if(r.isAtom){if(!o&&pF.isSelectable(r))return pF.create(e,n-(i<0?r.nodeSize:0))}else{let t=pV(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function pG(e,t,n){let r,i=e.steps.length-1;if(i<t)return;let o=e.steps[i];(o instanceof pu||o instanceof ph)&&(e.mapping.maps[i].forEach((e,t,n,i)=>{null==r&&(r=i)}),e.setSelection(pP.near(e.doc.resolve(r),n)))}class pq extends pD{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return hv.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||hv.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(pP.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function pK(e,t){return t&&e?e.bind(t):e}class pJ{constructor(e,t,n){this.name=e,this.init=pK(t.init,n),this.apply=pK(t.apply,n)}}let pX=[new pJ("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new pJ("selection",{init:(e,t)=>e.selection||pP.atStart(t.doc),apply:e=>e.selection}),new pJ("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new pJ("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class pY{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pX.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new pJ(e.key,e.spec.state,e))})}}class pQ{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new pQ(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new pq(this)}static create(e){let t=new pY(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new pQ(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new pY(this.schema,e.plugins),n=t.fields,r=new pQ(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new pY(e.schema,e.plugins),i=new pQ(r);return r.fields.forEach(r=>{if("doc"==r.name)i.doc=hD.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=pP.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let s=n[o],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o)){i[r.name]=a.fromJSON.call(s,e,t[o],i);return}}i[r.name]=r.init(e,i)}}),i}}class pZ{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let i in t){let o=t[i];o instanceof Function?o=o.bind(n):"handleDOMEvents"==i&&(o=e(o,n,{})),r[i]=o}return r}(e.props,this,this.props),this.key=e.key?e.key.key:p1("plugin")}getState(e){return e[this.key]}}let p0=Object.create(null);function p1(e){return e in p0?e+"$"+ ++p0[e]:(p0[e]=0,e+"$")}class p2{constructor(e="key"){this.key=p1(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let p8=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function p5(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let p6=(e,t,n)=>{let r=p5(e,n);if(!r)return!1;let i=p9(r);if(!i){let n=r.blockRange(),i=n&&pm(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let o=i.nodeBefore;if(fn(e,i,t,-1))return!0;if(0==r.parent.content.size&&(p4(o,"end")||pF.isSelectable(o)))for(let n=r.depth;;n--){let s=pw(e.doc,r.before(n),r.after(n),hx.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(p4(o,"end")?pP.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):pF.create(n.doc,i.pos-o.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!!o.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0)},p3=(e,t,n)=>{let r=p5(e,n);if(!r)return!1;let i=p9(r);return!!i&&function(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let o=t.nodeAfter,s=t.pos+1;for(;!o.isTextblock;s++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let a=pw(e.doc,i,s,hx.empty);if(!a||a.from!=i||a instanceof pu&&a.slice.size>=s-i)return!1;if(n){let t=e.tr.step(a);t.setSelection(pz.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,i,t)};function p4(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let p7=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=p9(r)}let s=o&&o.nodeBefore;return!!s&&!!pF.isSelectable(s)&&(t&&t(e.tr.setSelection(pF.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function p9(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 fe(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}function ft(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function fn(e,t,n,r){let i,o,s,a=t.nodeBefore,l=t.nodeAfter,c,d,u=a.type.spec.isolating||l.type.spec.isolating;if(!u&&(i=t.nodeBefore,o=t.nodeAfter,s=t.index(),i&&o&&i.type.compatibleContent(o.type)&&(!i.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),!0):!!t.parent.canReplace(s,s+1)&&!!(o.isTextblock||pk(e.doc,t.pos))&&(n&&n(e.tr.join(t.pos).scrollIntoView()),!0))))return!0;let h=!u&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(c=(d=a.contentMatchAt(a.childCount)).findWrapping(l.type))&&d.matchType(c[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=hf.empty;for(let e=c.length-1;e>=0;e--)i=hf.from(c[e].create(null,i));i=hf.from(a.copy(i));let o=e.tr.step(new ph(t.pos-1,r,t.pos,r,new hx(i,1,0),c.length,!0)),s=o.doc.resolve(r+2*c.length);s.nodeAfter&&s.nodeAfter.type==a.type&&pk(o.doc,s.pos)&&o.join(s.pos),n(o.scrollIntoView())}return!0}let p=l.type.spec.isolating||r>0&&u?null:pP.findFrom(t,1),f=p&&p.$from.blockRange(p.$to),m=f&&pm(f);if(null!=m&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(h&&p4(l,"start",!0)&&p4(a,"end")){let r=a,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let o=l,s=1;for(;!o.isTextblock;o=o.firstChild)s++;if(r.canReplace(r.childCount,r.childCount,o.content)){if(n){let r=hf.empty;for(let e=i.length-1;e>=0;e--)r=hf.from(i[e].copy(r));n(e.tr.step(new ph(t.pos-i.length,t.pos+l.nodeSize,t.pos+s,t.pos+l.nodeSize-s,new hx(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(pz.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}let fi=fr(-1),fo=fr(1);function fs(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&pg(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function fa(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(o,s,(r,o)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(o),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];i.setBlockType(o,s,e,t)}r(i.scrollIntoView())}return!0}}function fl(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),i=!1!==(n&&n.enterInlineAtoms),o=!(n&&n.includeWhitespace);return function(n,s){let{empty:a,$cursor:l,ranges:c}=n.selection;if(a&&!l||!function(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:o,$to:s}=t[i],a=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.pos,s.pos,(e,t)=>{if(a||!r&&e.isAtom&&e.isInline&&t>=o.pos&&t+e.nodeSize<=s.pos)return!1;a=e.inlineContent&&e.type.allowsMarkType(n)}),a)return!0}return!1}(n.doc,c,e,i))return!1;if(s)if(l)s(e.isInSet(n.storedMarks||l.marks())?n.tr.removeStoredMark(e):n.tr.addStoredMark(e.create(t)));else{let a,l=n.tr;i||(c=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new p_(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new p_(r,i))}return t}(c)),a=r?!c.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!c.every(t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,o)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!o&&o.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<c.length;n++){let{$from:r,$to:i}=c[n];if(a){let n=r.pos,s=i.pos,a=r.nodeAfter,c=i.nodeBefore,d=o&&a&&a.isText?/^\s*/.exec(a.text)[0].length:0,u=o&&c&&c.isText?/\s*$/.exec(c.text)[0].length:0;n+d<s&&(n+=d,s-=u),l.addMark(n,s,e.create(t))}else l.removeMark(r.pos,i.pos,e)}s(l.scrollIntoView())}return!0}}function fc(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}let fd=fc(p8,p6,p7),fu=fc(p8,(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}(e,n);if(!r)return!1;let i=fe(r);if(!i)return!1;let o=i.nodeAfter;if(fn(e,i,t,1))return!0;if(0==r.parent.content.size&&(p4(o,"start")||pF.isSelectable(o))){let n=pw(e.doc,r.before(),r.after(),hx.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(p4(o,"start")?pP.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):pF.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!!o.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=fe(r)}let s=o&&o.nodeAfter;return!!s&&!!pF.isSelectable(s)&&(t&&t(e.tr.setSelection(pF.create(e.doc,o.pos)).scrollIntoView()),!0)}),fh={Enter:fc((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof pH||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ft(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(pz.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(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 r=n.before();if(px(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&pm(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof pF&&e.selection.node.isBlock)return!!n.parentOffset&&!!px(e.doc,n.pos)&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let i=[],o,s,a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){let t;a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),s=ft(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));i.unshift(t||(a&&s?{type:s}:null)),o=e;break}if(1==e)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof pz||e.selection instanceof pH)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=px(c.doc,d,i.length,i);if(u||(i[0]=s?{type:s}:null,u=px(c.doc,d,i.length,i)),!u)return!1;if(c.split(d,i.length,i),!a&&l&&n.node(o).type!=s){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);s&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&c.setNodeMarkup(c.mapping.map(n.before(o)),s)}return t&&t(c.scrollIntoView()),!0}),"Mod-Enter":(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=ft(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,s.createAndFill());i.setSelection(pP.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Backspace:fd,"Mod-Backspace":fd,"Shift-Backspace":fd,Delete:fu,"Mod-Delete":fu,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new pH(e.doc))),!0)},fp={"Ctrl-h":fh.Backspace,"Alt-Backspace":fh["Mod-Backspace"],"Ctrl-d":fh.Delete,"Ctrl-Alt-Backspace":fh["Mod-Delete"],"Alt-Delete":fh["Mod-Delete"],"Alt-d":fh["Mod-Delete"],"Ctrl-a":fi,"Ctrl-e":fo};for(let e in fh)fp[e]=fh[e];let ff=("u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&!!os.platform&&"darwin"==os.platform())?fp:fh,fm={}.hasOwnProperty;function fg(e,t,n){return">"+(n?"":" ")+e}function fy(e,t){return fv(e,t.inConstruct,!0)&&!fv(e,t.notInConstruct,!1)}function fv(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function fb(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if("\n"===n.unsafe[i].character&&fy(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function fx(e,t){return!!(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fk(e,t,n){return(n?"":" ")+e}function fw(e){let t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function fS(e){return"&#x"+e.toString(16).toUpperCase()+";"}function fC(e,t,n){let r=dy(e),i=dy(t);return void 0===r?void 0===i?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===i?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===i?{inside:!1,outside:!1}:1===i?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===i?{inside:!1,outside:!1}:1===i?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function fN(e,t,n,r){let i=function(e){let t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i),l=s.move(n.containerPhrasing(e,{after:i,before:a,...s.current()})),c=l.charCodeAt(0),d=fC(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=fS(c)+l.slice(1));let u=l.charCodeAt(l.length-1),h=fC(r.after.charCodeAt(0),u,i);h.inside&&(l=l.slice(0,-1)+fS(u));let p=s.move(i);return o(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+l+p}function fA(e,t){let n=!1;return um(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,!1}),!!((!e.depth||e.depth<3)&&cW(e)&&(t.options.setext||n))}function fE(e){return e.value||""}function fM(e,t,n,r){let i=fw(n),o='"'===i?"Quote":"Apostrophe",s=n.enter("image"),a=n.enter("label"),l=n.createTracker(r),c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),s(),c}function fT(e,t,n,r){let i=e.referenceType,o=n.enter("imageReference"),s=n.enter("label"),a=n.createTracker(r),l=a.move("!["),c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),s();let d=n.stack;n.stack=[],s=n.enter("reference");let u=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return s(),n.stack=d,o(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(u+"]"),l}function fI(e,t,n){let r=e.value||"",i="`",o=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){let e,t=n.unsafe[o],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}function fL(e,t){let n=cW(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function fO(e,t,n,r){let i,o,s=fw(n),a='"'===s?"Quote":"Apostrophe",l=n.createTracker(r);if(fL(e,n)){let t=n.stack;n.stack=[],i=n.enter("autolink");let r=l.move("<");return r+=l.move(n.containerPhrasing(e,{before:r,after:">",...l.current()})),r+=l.move(">"),i(),n.stack=t,r}i=n.enter("link"),o=n.enter("label");let c=l.move("[");return c+=l.move(n.containerPhrasing(e,{before:c,after:"](",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${a}`),c+=l.move(" "+s),c+=l.move(n.safe(e.title,{before:c,after:s,...l.current()})),c+=l.move(s),o()),c+=l.move(")"),i(),c}function fD(e,t,n,r){let i=e.referenceType,o=n.enter("linkReference"),s=n.enter("label"),a=n.createTracker(r),l=a.move("["),c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),s();let d=n.stack;n.stack=[],s=n.enter("reference");let u=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return s(),n.stack=d,o(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(u+"]"),l}function fR(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function fP(e){let t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}fN.peek=function(e,t,n){return n.options.emphasis||"*"},fE.peek=function(){return"<"},fM.peek=function(){return"!"},fT.peek=function(){return"!"},fI.peek=function(){return"`"},fO.peek=function(e,t,n){return fL(e,n)?"<":"["},fD.peek=function(){return"["};let f_=uc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function fj(e,t,n,r){let i=function(e){let t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i),l=s.move(n.containerPhrasing(e,{after:i,before:a,...s.current()})),c=l.charCodeAt(0),d=fC(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=fS(c)+l.slice(1));let u=l.charCodeAt(l.length-1),h=fC(r.after.charCodeAt(0),u,i);h.inside&&(l=l.slice(0,-1)+fS(u));let p=s.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+l+p}fj.peek=function(e,t,n){return n.options.strong||"*"};let fB={blockquote:function(e,t,n,r){let i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);let s=n.indentLines(n.containerFlow(e,o.current()),fg);return i(),s},break:fb,code:function(e,t,n,r){let i=function(e){let t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),o=e.value||"",s="`"===i?"GraveAccent":"Tilde";if(fx(e,n)){let e=n.enter("codeIndented"),t=n.indentLines(o,fk);return e(),t}let a=n.createTracker(r),l=i.repeat(Math.max(function(e,t){let n=String(e),r=n.indexOf(t),i=r,o=0,s=0;if("string"!=typeof t)throw TypeError("Expected substring");for(;-1!==r;)r===i?++o>s&&(s=o):o=1,i=r+t.length,r=n.indexOf(t,i);return s}(o,i)+1,3)),c=n.enter("codeFenced"),d=a.move(l);if(e.lang){let t=n.enter(`codeFencedLang${s}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${s}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:"\n",encode:["`"],...a.current()})),t()}return d+=a.move("\n"),o&&(d+=a.move(o+"\n")),d+=a.move(l),c(),d},definition:function(e,t,n,r){let i=fw(n),o='"'===i?"Quote":"Apostrophe",s=n.enter("definition"),a=n.enter("label"),l=n.createTracker(r),c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),a(),e.title&&(a=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),s(),c},emphasis:fN,hardBreak:fb,heading:function(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(fA(e,n)){let t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...o.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===i?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}let s="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");o.move(s+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...o.current()});return/^[\t ]/.test(c)&&(c=fS(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),l(),a(),c},html:fE,image:fM,imageReference:fT,inlineCode:fI,link:fO,linkReference:fD,list:function(e,t,n,r){let i=n.enter("list"),o=n.bulletCurrent,s=e.ordered?function(e){let t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):fR(n),a=e.ordered?"."===s?")":".":function(e){let t=fR(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n),l=!!t&&!!n.bulletLastUsed&&s===n.bulletLastUsed;if(!e.ordered){let t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),fP(n)===s&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(s=a),n.bulletCurrent=s;let c=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=o,i(),c},listItem:function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),o=n.bulletCurrent||fR(n);t&&"list"===t.type&&t.ordered&&(o=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+o);let s=o.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));let a=n.createTracker(r);a.move(o+" ".repeat(s-o.length)),a.shift(s);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),function(e,t,n){return t?(n?"":" ".repeat(s))+e:(n?o:o+" ".repeat(s-o.length))+e});return l(),c},paragraph:function(e,t,n,r){let i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,r);return o(),i(),s},root:function(e,t,n,r){return(e.children.some(function(e){return f_(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:fj,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){let r=(fP(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}},fz=[function(e,t,n,r){if("code"===t.type&&fx(t,r)&&("list"===e.type||e.type===t.type&&fx(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&fA(t,r)))return;return+!!n.spread}}],f$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],fF=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:f$},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"+",after:"(?:[ \r\n])"},{atBreak:!0,character:"-",after:"(?:[ \r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:f$},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:f$},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"~"}];function fU(e){return e.label||!e.identifier?e.label||"":d2(e.identifier)}function fH(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}let fW=/\r?\n|\r/g;function fV(e,t){let n,r=[],i=0,o=0;for(;n=fW.exec(e);)s(e.slice(i,n.index)),r.push(n[0]),i=n.index+n[0].length,o++;return s(e.slice(i)),r.join("");function s(e){r.push(t(e,o,!e))}}function fG(e,t){return e-t}function fq(e,t){let n,r=/\\(?=[!-/:-@[-`{-~])/g,i=[],o=[],s=e+t,a=-1,l=0;for(;n=r.exec(s);)i.push(n.index);for(;++a<i.length;)l!==i[a]&&o.push(e.slice(l,i[a])),o.push("\\"),l=i[a];return o.push(e.slice(l)),o.join("")}function fK(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,o=n.column||1;return{move:function(e){let t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return i+=n.length-1,o=1===n.length?o+s.length:1+s.length+r,t},current:function(){return{now:{line:i,column:o},lineShift:r}},shift:function(e){r+=e}}}function fJ(e){throw Error("Cannot handle value `"+e+"`, expected node")}function fX(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function fY(e,t){if("definition"===e.type&&e.type===t.type)return 0}function fQ(e,t){return function(e,t,n){let r,i=t.indexStack,o=e.children||[],s=[],a=-1,l=n.before;i.push(-1);let c=t.createTracker(n);for(;++a<o.length;){let d,u=o[a];if(i[i.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),d=n?n(o[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else d=n.after;s.length>0&&("\r"===l||"\n"===l)&&"html"===u.type&&(s[s.length-1]=s[s.length-1].replace(/(\r?\n|\r)$/," "),l=" ",(c=t.createTracker(n)).move(s.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:l});r&&r===h.slice(0,1)&&(h=fS(r.charCodeAt(0))+h.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,r=void 0,p&&(s.length>0&&p.before&&l===s[s.length-1].slice(-1)&&(s[s.length-1]=s[s.length-1].slice(0,-1)+fS(l.charCodeAt(0))),p.after&&(r=d)),c.move(h),s.push(h),l=h.slice(-1)}return i.pop(),s.join("")}(e,this,t)}function fZ(e,t){return function(e,t,n){let r=t.indexStack,i=e.children||[],o=t.createTracker(n),s=[],a=-1;for(r.push(-1);++a<i.length;){let n=i[a];r[r.length-1]=a,s.push(o.move(t.handle(n,e,t,{before:"\n",after:"\n",...o.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<i.length-1&&s.push(o.move(function(e,t,n,r){let i=r.join.length;for(;i--;){let o=r.join[i](e,t,n,r);if(!0===o||1===o)break;if("number"==typeof o)return"\n".repeat(1+o);if(!1===o)return"\n\n<!---->\n\n"}return"\n\n"}(n,i[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function f0(e,t){return function(e,t,n){let r=(n.before||"")+(t||"")+(n.after||""),i=[],o=[],s={},a=-1;for(;++a<e.unsafe.length;){let t,n=e.unsafe[a];if(!fy(e.stack,n))continue;let o=e.compilePattern(n);for(;t=o.exec(r);){let e="before"in n||!!n.atBreak,r="after"in n,o=t.index+(e?t[1].length:0);i.includes(o)?(s[o].before&&!e&&(s[o].before=!1),s[o].after&&!r&&(s[o].after=!1)):(i.push(o),s[o]={before:e,after:r})}}i.sort(fG);let l=n.before?n.before.length:0,c=r.length-(n.after?n.after.length:0);for(a=-1;++a<i.length;){let e=i[a];!(e<l)&&!(e>=c)&&(!(e+1<c)||i[a+1]!==e+1||!s[e].after||s[e+1].before||s[e+1].after)&&(i[a-1]!==e-1||!s[e].before||s[e-1].before||s[e-1].after)&&(l!==e&&o.push(fq(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(o.push(fS(r.charCodeAt(e))),l++):o.push("\\"))}return o.push(fq(r.slice(l,c),n.after)),o.join("")}(this,e,t)}function f1(e){let t=this;t.compiler=function(n){var r;let i,o;return r={...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]},!function e(t,n){var r,i,o,s;let a,l=-1;if(n.extensions)for(;++l<n.extensions.length;)e(t,n.extensions[l]);for(a in n)if(fm.call(n,a))switch(a){case"extensions":break;case"unsafe":case"join":r=t[a],(i=n[a])&&r.push(...i);break;case"handlers":o=t[a],(s=n[a])&&Object.assign(o,s);break;default:t.options[a]=n[a]}return t}(i={associationId:fU,containerPhrasing:fQ,containerFlow:fZ,createTracker:fK,compilePattern:fH,enter:function(e){return i.stack.push(e),function(){i.stack.pop()}},handlers:{...fB},handle:void 0,indentLines:fV,indexStack:[],join:[...fz],options:{},safe:f0,stack:[],unsafe:[...fF]},r||{}),i.options.tightDefinitions&&i.join.push(fY),i.handle=n8("type",{invalid:fJ,unknown:fX,handlers:i.handlers}),(o=i.handle(n,void 0,i,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0}))&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}}var f2=e=>{throw TypeError(e)},f8=(e,t,n)=>t.has(e)||f2("Cannot "+n),f5=(e,t,n)=>(f8(e,t,"read from private field"),n?n.call(e):t.get(e)),f6=(e,t,n)=>t.has(e)?f2("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),f3=(e,t,n,r)=>(f8(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class f4{}class f7{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw he();return e}}}class f9 extends f4{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new f9(e,t,n)}}let me=class extends f7{constructor(e){super(),f6(this,R),f6(this,P),f6(this,_),f6(this,j),f6(this,B),f6(this,z),f6(this,$),f3(this,R,hv.none),f3(this,P,e=>e.isText),f3(this,_,(e,t)=>{if(f5(this,P).call(this,e)&&f5(this,P).call(this,t)&&hv.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)}),f3(this,j,e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t){var n;throw n=e,new u4(u3.parserMatchError,`Cannot match target parser for node: ${JSON.stringify(n,u7)}.`)}return t}),f3(this,B,e=>{let t=f5(this,j).call(this,e);t.spec.parseMarkdown.runner(this,e,t)}),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(f9.create(e,[],t)),this),f3(this,z,()=>{f3(this,R,hv.none);let e=this.close();return f5(this,$).call(this,e.type,e.attrs,e.content)}),this.closeNode=()=>{try{f5(this,z).call(this)}catch(e){console.error(e)}return this},f3(this,$,(e,t,n)=>{let r=e.createAndFill(t,n,f5(this,R));if(!r){let r,i,o,s;throw r="name"in e?e.name:e,i=`Cannot create node for ${r}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},s=[["[Description]",i],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{let r=`${t}: ${o(n)}.`;return e.concat(r)},[]),new u4(u3.createNodeInParserFail,s.join("\n"))}return this.push(r),r}),this.addNode=(e,t,n)=>{try{f5(this,$).call(this,e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{let n=e.create(t);return f3(this,R,n.addToSet(f5(this,R))),this},this.closeMark=e=>(f3(this,R,e.removeFromSet(f5(this,R))),this),this.addText=e=>{try{let t=this.top();if(!t)throw he();let n=t.pop(),r=this.schema.text(e,f5(this,R));if(!n)return t.push(r),this;let i=f5(this,_).call(this,n,r);if(i)return t.push(i),this;return t.push(n,r),this}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=f5(this,z).call(this);while(this.size())return e},this.next=(e=[])=>([e].flat().forEach(e=>f5(this,B).call(this,e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}};R=new WeakMap,P=new WeakMap,_=new WeakMap,j=new WeakMap,B=new WeakMap,z=new WeakMap,$=new WeakMap,me.create=(e,t)=>{let n=new me(e);return e=>(n.run(t,e),n.toDoc())};let mt=class extends f4{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}};mt.create=(e,t,n,r={})=>new mt(e,t,n,r);let mn=class extends f7{constructor(e){super(),f6(this,F),f6(this,U),f6(this,H),f6(this,W),f6(this,V),f6(this,G),f6(this,q),f6(this,K),f6(this,J),f6(this,X),f6(this,Y),f6(this,Q),f6(this,Z),f3(this,F,hv.none),f3(this,U,e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t){var n;throw n=e.type,new u4(u3.serializerMatchError,`Cannot match target serializer for node: ${JSON.stringify(n,u7)}.`)}return t}),f3(this,H,e=>f5(this,U).call(this,e).spec.toMarkdown.runner(this,e)),f3(this,W,(e,t)=>f5(this,U).call(this,e).spec.toMarkdown.runner(this,e,t)),f3(this,V,e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!f5(this,W).call(this,t,e))&&f5(this,H).call(this,e),t.forEach(e=>f5(this,Z).call(this,e))}),f3(this,G,(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,o={...e,children:i};return o.children=i,r.children=[o],r}),f3(this,q,e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){let{children:n,...i}=t=f5(this,G).call(this,t,r.type),{children:o,...s}=r;if(t.type===r.type&&n&&o&&JSON.stringify(i)===JSON.stringify(s)){let t={...s,children:[...o,...n]};return e.slice(0,-1).concat(f5(this,q).call(this,t))}}return e.concat(t)},[])),e}),f3(this,K,e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t}),this.openNode=(e,t,n)=>(this.open(mt.create(e,void 0,t,n)),this),f3(this,J,(e,t)=>{let n="",r="",i=e.children,o=-1,s=-1;if(i){i&&i.forEach((e,t)=>{"text"===e.type&&e.value&&(o<0&&(o=t),s=t)});let e=i?.[s],t=i?.[o];if(e&&e.value.endsWith(" ")){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&f5(this,Y).call(this,"text",void 0,n);let a=t();return r.length&&f5(this,Y).call(this,"text",void 0,r),a}),f3(this,X,(e=!1)=>{let t=this.close(),n=()=>f5(this,Y).call(this,t.type,t.children,t.value,t.props);return e?f5(this,J).call(this,t,n):n()}),this.closeNode=()=>(f5(this,X).call(this),this),f3(this,Y,(e,t,n,r)=>{let i=mt.create(e,t,n,r),o=f5(this,q).call(this,f5(this,K).call(this,i));return this.push(o),o}),this.addNode=(e,t,n,r)=>(f5(this,Y).call(this,e,t,n,r),this),f3(this,Q,(e,t,n,r)=>e.isInSet(f5(this,F))?this:(f3(this,F,e.addToSet(f5(this,F))),this.openNode(t,n,{...r,isMark:!0}))),f3(this,Z,e=>{e.isInSet(f5(this,F))&&(f3(this,F,e.type.removeFromSet(f5(this,F))),f5(this,X).call(this,!0))}),this.withMark=(e,t,n,r)=>(f5(this,Q).call(this,e,t,n,r),this),this.closeMark=e=>(f5(this,Z).call(this,e),this),this.build=()=>{let e=null;do e=f5(this,X).call(this);while(this.size())return e},this.next=e=>(Object.prototype.hasOwnProperty.call(e,"size")?e.forEach(e=>{f5(this,V).call(this,e)}):f5(this,V).call(this,e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}};F=new WeakMap,U=new WeakMap,H=new WeakMap,W=new WeakMap,V=new WeakMap,G=new WeakMap,q=new WeakMap,K=new WeakMap,J=new WeakMap,X=new WeakMap,Y=new WeakMap,Q=new WeakMap,Z=new WeakMap,mn.create=(e,t)=>{let n=new mn(e);return e=>(n.run(e),n.toString(t))};class mr{constructor(e,t,n={}){this.match=e,this.match=e,this.handler="string"==typeof t?function(e){return function(t,n,r,i){let o=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);o+=n[0].slice(e+n[1].length);let t=(r+=e)-i;t>0&&(o=n[0].slice(e-t,e)+o,r=i)}return t.tr.insertText(o,r,i)}}(t):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}let mi=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function mo(e,t,n=null,r){return new mr(e,(e,i,o,s)=>{let a=n instanceof Function?n(i):n,l=e.tr.delete(o,s),c=l.doc.resolve(o).blockRange(),d=c&&pg(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(o-1).nodeBefore;return u&&u.type==t&&pk(l.doc,o-1)&&(!r||r(i,u))&&l.join(o-1),l})}function ms(e,t,n=null){return new mr(e,(e,r,i,o)=>{let s=e.doc.resolve(i),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(i,o).setBlockType(i,i,t,a):null})}new mr(/--$/,"—",{inCodeMark:!1}),new mr(/\.\.\.$/,"…",{inCodeMark:!1}),new mr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new mr(/"$/,"”",{inCodeMark:!1}),new mr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new mr(/'$/,"’",{inCodeMark:!1});let ma="u">typeof navigator?navigator:null,ml="u">typeof document?document:null,mc=ma&&ma.userAgent||"",md=/Edge\/(\d+)/.exec(mc),mu=/MSIE \d/.exec(mc),mh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mc),mp=!!(mu||mh||md);mu?document.documentMode:mh?mh[1]:md&&md[1],!mp&&/gecko\/(\d+)/i.test(mc)&&(/Firefox\/(\d+)/.exec(mc)||[0,0])[1];let mf=!mp&&/Chrome\/(\d+)/.exec(mc);function mm(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of i){let i=a.match.exec(l),c=i&&i[0]&&a.handler(s,i,t-(i[0].length-r.length),n);if(c)return!1!==a.undoable&&c.setMeta(o,{transform:c,from:t,to:n,text:r}),e.dispatch(c),!0}return!1}mf&&mf[1],!mp&&ma&&/Apple Computer/.test(ma.vendor)&&(/Mobile\/\w+/.test(mc)||ma&&ma.maxTouchPoints>2)||ma&&/Mac/.test(ma.platform),/Android \d/.test(mc),ml&&"webkitFontSmoothing"in ml.documentElement.style&&(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];let mg=new p2("MILKDOWN_CUSTOM_INPUTRULES");function my(e,t,n={}){return new mr(e,(e,r,i,o)=>{var s,a,l,c;let{tr:d}=e,u=r.length,h=r[u-1],p=r[0],f=[],m=o,g={group:h,fullMatch:p,start:i,end:o},y=null==(s=n.updateCaptured)?void 0:s.call(n,g);if(Object.assign(g,y),{group:h,fullMatch:p,start:i,end:o}=g,null===p||(null==h?void 0:h.trim())==="")return null;if(h){let e=p.search(/\S/),s=i+p.indexOf(h),u=s+h.length;f=null!=(a=d.storedMarks)?a:[],u<o&&d.delete(u,o),s>i&&d.delete(i+e,s),m=i+e+h.length;let g=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(i,m,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:i,end:o,tr:d})}return d})}Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;for(var mv={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:"'"},mb={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mx="u">typeof navigator&&/Mac/.test(navigator.platform),mk="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),mw=0;mw<10;mw++)mv[48+mw]=mv[96+mw]=String(mw);for(var mw=1;mw<=24;mw++)mv[mw+111]="F"+mw;for(var mw=65;mw<=90;mw++)mv[mw]=String.fromCharCode(mw+32),mb[mw]=String.fromCharCode(mw);for(var mS in mv)mb.hasOwnProperty(mS)||(mb[mS]=mv[mS]);let mC="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),mN="u">typeof navigator&&/Win/.test(navigator.platform);function mA(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 mE(e){let t;return new pZ({props:{handleKeyDown:(t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else if(/^mod$/i.test(s))mC?i=!0:n=!0;else throw Error("Unrecognized modifier name: "+s)}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}(n)]=e[n];return t}(e),function(e,n){var r;let i=("Esc"==(r=!(mx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||mk&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?mb:mv)[n.keyCode]||n.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o,s=t[mA(i,n)];if(s&&s(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[mA(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(mN&&n.ctrlKey&&n.altKey)&&(o=mv[n.keyCode])&&o!=i){let r=t[mA(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1})}})}let mM=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},mT=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},mI=null,mL=function(e,t,n){let r=mI||(mI=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},mO=function(){mI=null},mD=function(e,t,n,r){return n&&(mP(e,t,n,r,-1)||mP(e,t,n,r,1))},mR=/^(img|br|input|textarea|hr)$/i;function mP(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:m_(e))){let n=e.parentNode;if(!n||1!=n.nodeType||mj(e)||mR.test(e.nodeName)||"false"==e.contentEditable)return!1;t=mM(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable)if(null==(o=n.pmViewDesc)||!o.ignoreForSelection)return!1;else t+=i;else e=n,t=i<0?m_(e):0}}}function m_(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function mj(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)}let mB=function(e){return e.focusNode&&mD(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function mz(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let m$="u">typeof navigator?navigator:null,mF="u">typeof document?document:null,mU=m$&&m$.userAgent||"",mH=/Edge\/(\d+)/.exec(mU),mW=/MSIE \d/.exec(mU),mV=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mU),mG=!!(mW||mV||mH),mq=mW?document.documentMode:mV?+mV[1]:mH?+mH[1]:0,mK=!mG&&/gecko\/(\d+)/i.test(mU);mK&&(/Firefox\/(\d+)/.exec(mU)||[0,0])[1];let mJ=!mG&&/Chrome\/(\d+)/.exec(mU),mX=!!mJ,mY=mJ?+mJ[1]:0,mQ=!mG&&!!m$&&/Apple Computer/.test(m$.vendor),mZ=mQ&&(/Mobile\/\w+/.test(mU)||!!m$&&m$.maxTouchPoints>2),m0=mZ||!!m$&&/Mac/.test(m$.platform),m1=!!m$&&/Win/.test(m$.platform),m2=/Android \d/.test(mU),m8=!!mF&&"webkitFontSmoothing"in mF.documentElement.style,m5=m8?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function m6(e,t){return"number"==typeof e?e:e[t]}function m3(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=mT(s);continue}let e=s,n=e==o.body,a=n?function(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}}(o):function(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}}(e),l=0,c=0;if(t.top<a.top+m6(r,"top")?c=-(a.top-t.top+m6(i,"top")):t.bottom>a.bottom-m6(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+m6(i,"top")-a.top:t.bottom-a.bottom+m6(i,"bottom")),t.left<a.left+m6(r,"left")?l=-(a.left-t.left+m6(i,"left")):t.right>a.right-m6(r,"right")&&(l=t.right-a.right+m6(i,"right")),l||c)if(n)o.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,o=e.scrollTop-r;t={left:t.left-i,top:t.top-o,right:t.right-i,bottom:t.bottom-o}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:mT(s)}}function m4(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=mT(r));return t}function m7(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:o}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let m9=null;function ge(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function gt(e){return e.top<e.bottom||e.left<e.right}function gn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(gt(e))return e}return Array.prototype.find.call(n,gt)||e.getBoundingClientRect()}let gr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gi(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=m8||mK;if(3==r.nodeType)if(s&&(gr.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=gn(mL(r,i,i),n);if(mK&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=gn(mL(r,i-1,i-1),-1);if(t.top==e.top){let n=gn(mL(r,i,i+1),-1);if(n.top!=e.top)return go(n,n.left<t.left)}}return e}else{let e=i,t=i,o=n<0?1:-1;return n<0&&!i?(t++,o=-1):n>=0&&i==r.nodeValue.length?(e--,o=1):n<0?e--:t++,go(gn(mL(r,e,t),o),o<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&i&&(n<0||i==m_(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return gs(e.getBoundingClientRect(),!1)}if(null==o&&i<m_(r)){let e=r.childNodes[i];if(1==e.nodeType)return gs(e.getBoundingClientRect(),!0)}return gs(r.getBoundingClientRect(),n>=0)}if(null==o&&i&&(n<0||i==m_(r))){let e=r.childNodes[i-1],t=3==e.nodeType?mL(e,m_(e)-!s):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return go(gn(t,1),!1)}if(null==o&&i<m_(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?mL(e,0,+!s):1==e.nodeType?e:null:null;if(t)return go(gn(t,-1),!0)}return go(gn(3==r.nodeType?mL(r):r,-n),n>=0)}function go(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function gs(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function ga(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}let gl=/[\u0590-\u08ac]/,gc=null,gd=null,gu=!1;class gh{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){let r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}if(e==this.dom&&this.contentDOM)r=t>mM(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),o;if(i&&(!t||i.node))if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;else n=!1}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],o=t+i.size;if(o>e||i instanceof gb){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof gp&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?mM(e.dom)+1:0}}{let e,r=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?mM(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let o=n,s=0;;s++){let n=this.children[s],a=o+n.size;if(-1==r&&e<=a){let i=o+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=mM(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=mM(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(i>a&&o<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((mK||mQ)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if((d=!!(t&&"\n"==e.nodeValue[t-1]))&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){"BR"==n.nodeName&&(s=a={node:n.parentNode,offset:mM(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(mK&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&mQ)&&mD(s.node,s.offset,c.anchorNode,c.anchorOffset)&&mD(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&!(d&&mK)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let r=n+i.border,s=o-i.border;if(e>=r&&t<=s){this.dirty=e==n||t==o?2:1,e==r&&t==s&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=3:i.markDirty(e-r,t-r);return}i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class gp extends gh{constructor(e,t,n,r){let i,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class gf extends gh{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class gm extends gh{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(e,t,n,r){let i=r.nodeViews[t.type.name],o=i&&i(t,r,n);return o&&o.dom||(o=h6.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new gm(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=gm.create(this.parent,this.mark,!0,n),i=this.children,o=this.size;t<o&&(i=gI(i,t,o,n)),e>0&&(i=gI(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gg extends gh{constructor(e,t,n,r,i,o,s,a,l){super(e,[],i,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,o){let s=i.nodeViews[t.type.name],a,l=s&&s(t,i,()=>a?a.parent?a.parent.posBeforeChild(a):void 0:o,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=h6.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return(c=gN(c,n,t),l)?a=new gx(e,t,n,r,c,d||null,u,l,i,o+1):t.isText?new gv(e,t,n,r,c,u,i):new gg(e,t,n,r,c,d||null,u,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>hf.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&gA(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,s=i&&i.pos<0,a=new gM(this,o&&o.node,e);(function(e,t,n,r){let i=t.locals(e),o=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,i,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<i.length&&i[s].to==o;){let e=i[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(gT);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else if(c<e.childCount)p=c,h=e.child(c++);else break;for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let f=o+h.nodeSize;if(h.isText){let e=f;s<i.length&&i[s].from<e&&(e=i[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-o),h=h.cut(0,e-o),f=e,p=-1)}else for(;s<i.length&&i[s].to<f;)s++;let m=h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice();r(h,m,t.forChild(o,h),p),o=f}})(this.node,this.innerDeco,(t,i,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!o&&a.syncToMarks(i==this.node.childCount?hv.none:this.node.child(i).marks,n,e,i),a.placeWidget(t,e,r)},(t,o,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,o,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,l,d,e)||a.updateNextNode(t,o,l,e,c,r)||a.addNode(t,o,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),function e(t,n,r){let i=t.firstChild,o=!1;for(let s=0;s<n.length;s++){let a=n[s],l=a.dom;if(l.parentNode==t){for(;l!=i;)i=gE(i),o=!0;i=i.nextSibling}else o=!0,t.insertBefore(l,i);if(a instanceof gm){let n=i?i.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),i=n?n.nextSibling:t.firstChild}}for(;i;)i=gE(i),o=!0;o&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),mZ&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof pz)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(!this.node.inlineContent)return{node:i,pos:-1,text:""};{let e=i.nodeValue,o=function(e,t,n,r){for(let i=0,o=0;i<e.childCount&&o<=r;){let s=e.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<e.childCount;){let t=e.child(i++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}if(o>=n){if(o>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return -1}(this.node.content,e,n-t,r-t);return o<0?null:{node:i,pos:o,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new gf(this,i,t,r);e.input.compositionNodes.push(o),this.children=gI(this.children,n,n+r.length,e,o)}update(e,t,n,r){return 3!=this.dirty&&!!e.sameMarkup(this.node)&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(gA(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=gC(this.dom,this.nodeDOM,gS(this.outerDeco,this.node,t),gS(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function gy(e,t,n,r,i){gN(r,t,e);let o=new gg(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class gv extends gg{constructor(e,t,n,r,i,o,s){super(e,t,n,r,i,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!e.sameMarkup(this.node)&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new gv(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class gb extends gh{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gx extends gg{constructor(e,t,n,r,i,o,s,a,l,c){super(e,t,n,r,i,o,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return(!!this.contentDOM||!!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let gk=function(e){e&&(this.nodeName=e)};gk.prototype=Object.create(null);let gw=[new gk];function gS(e,t,n){if(0==e.length)return gw;let r=n?gw[0]:new gk,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s)for(let e in s.nodeName&&i.push(r=new gk(s.nodeName)),s){let o=s[e];null!=o&&(n&&1==i.length&&i.push(r=new gk(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}return i}function gC(e,t,n,r){if(n==gw&&r==gw)return t;let i=t;for(let t=0;t<r.length;t++){let o=r[t],s=n[t];if(t){let t;s&&s.nodeName==o.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==o.nodeName||((t=document.createElement(o.nodeName)).pmIsDeco=!0,t.appendChild(i),s=gw[0]),i=t}!function(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}(i,s||gw[0],o)}return i}function gN(e,t,n){return gC(e,e,gw,gS(t,n,1!=e.nodeType))}function gA(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 gE(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class gM{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];r:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(e instanceof gm)n=e,r=e.children.length;else{a=e,r--;break}}else if(n==t)break r;else r=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(l){if(l!=e.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let i=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=gm.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let i=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return -1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return -1}e=t}}updateNextNode(e,t,n,r,i,o){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof gg){let l=this.preMatch.matched.get(a);if(null!=l&&l!=i)return!1;let c=a.dom,d,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&gA(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(a,e,t,n,r,o)))return this.destroyBetween(this.index,s),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=2,d.updateChildren(r,o+1),d.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!gA(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=gg.create(this.top,t,n,r,i,o);if(s.contentDOM)for(let t of(s.children=e.children,e.children=[],s.children))t.parent=s;return e.destroy(),s}addNode(e,t,n,r,i){let o=gg.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new gp(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof gm;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof gv)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((mQ||mX)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new gb(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function gT(e,t){return e.type.side-t.type.side}function gI(e,t,n,r,i){let o=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?o.push(l):(c<t&&o.push(l.slice(0,t-c,r)),i&&(o.push(i),i=void 0),d>n&&o.push(l.slice(n-c,l.size,r)))}return o}function gL(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(mB(n)){for(l=s;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&pF.isSelectable(e)&&i.parent&&!(e.isInline&&function(e,t,n){for(let r=0==t,i=t==m_(e);r||i;){if(e==n)return!0;let t=mM(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==m_(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;c=new pF(s==e?a:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,i=s;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(t<0)return null;[l,s]=i==e.state.selection.anchor?[i,t]:[t,i],a=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let n="pointer"==t||e.state.selection.head<a.pos&&!o?1:-1;c=g$(e,d,a,n)}return c}function gO(e){return e.editable?e.hasFocus():gU(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gD(e,t=!1){let n=e.state.selection;if(gB(e,n),gO(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&mX){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&mD(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,mM(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&mG&&mq<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var r;let i,o,s,a,{anchor:l,head:c}=n,d,u;gR&&!(n instanceof pz)&&(n.$from.parent.inlineContent||(d=gP(e,n.from)),n.empty||n.$from.parent.inlineContent||(u=gP(e,n.to))),e.docView.setSelection(l,c,e,t),gR&&(d&&gj(d),u&&gj(u)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((i=(r=e).dom.ownerDocument).removeEventListener("selectionchange",r.input.hideSelectionGuard),s=(o=r.domSelectionRange()).anchorNode,a=o.anchorOffset,i.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(o.anchorNode!=s||o.anchorOffset!=a)&&(i.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!gO(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let gR=mQ||mX&&mY<63;function gP(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(mQ&&i&&"false"==i.contentEditable)return g_(i);if((!i||"false"==i.contentEditable)&&(!o||"false"==o.contentEditable)){if(i)return g_(i);else if(o)return g_(o)}}function g_(e){return e.contentEditable="true",mQ&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function gj(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function gB(e,t){if(t instanceof pF){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(gz(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else gz(e)}function gz(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function g$(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||pz.between(t,n,r)}function gF(e){return(!e.editable||!!e.hasFocus())&&gU(e)}function gU(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function gH(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return o&&pP.findFrom(o,t)}function gW(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function gV(e,t,n){let r=e.state.selection;if(r instanceof pz){if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return gW(e,new pz(r.$anchor,o))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=gH(e.state,t);return!!n&&n instanceof pF&&gW(e,n)}else if(!(m0&&n.indexOf("m")>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,o;if(!i||i.isText)return!1;let s=t<0?n.pos-i.nodeSize:n.pos;return!!(i.isAtom||(o=e.docView.descAt(s))&&!o.contentDOM)&&(pF.isSelectable(i)?gW(e,new pF(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):!!m8&&gW(e,new pz(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}else{if(r instanceof pF&&r.node.isInline)return gW(e,new pz(t>0?r.$to:r.$from));let n=gH(e.state,t);return!!n&&gW(e,n)}}function gG(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function gq(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function gK(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=!1;for(mK&&1==n.nodeType&&r<gG(n)&&gq(n.childNodes[r],-1)&&(s=!0);;)if(r>0)if(1!=n.nodeType)break;else{let e=n.childNodes[r-1];if(gq(e,-1))i=n,o=--r;else if(3==e.nodeType)r=(n=e).nodeValue.length;else break}else if(gJ(n))break;else{let t=n.previousSibling;for(;t&&gq(t,-1);)i=n.parentNode,o=mM(t),t=t.previousSibling;if(t)r=gG(n=t);else{if((n=n.parentNode)==e.dom)break;r=0}}s?gX(e,n,r):i&&gX(e,i,o)}(e):function(e){let t,n,r=e.domSelectionRange(),i=r.focusNode,o=r.focusOffset;if(!i)return;let s=gG(i);for(;;)if(o<s){if(1!=i.nodeType)break;if(gq(i.childNodes[o],1))t=i,n=++o;else break}else if(gJ(i))break;else{let r=i.nextSibling;for(;r&&gq(r,1);)t=r.parentNode,n=mM(r)+1,r=r.nextSibling;if(r)o=0,s=gG(i=r);else{if((i=i.parentNode)==e.dom)break;o=s=0}}t&&gX(e,t,n)}(e)}function gJ(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function gX(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!mj(e);)t=mM(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!mj(e);)t=mM(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(mB(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&gD(e)},50)}function gY(e,t){let n=e.state.doc.resolve(t);if(!(mX||m1)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function gQ(e,t,n){let r=e.state.selection;if(r instanceof pz&&!r.empty||n.indexOf("s")>-1||m0&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=gH(e.state,t);if(n&&n instanceof pF)return gW(e,n)}if(!i.parent.inlineContent){let n=t<0?i:o,s=r instanceof pH?pP.near(n,t):pP.findFrom(n,t);return!!s&&gW(e,s)}return!1}function gZ(e,t){if(!(e.state.selection instanceof pz))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return t<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function g0(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function g1(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:o}=t;for(;i>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||h6.fromSchema(e.state.schema),a=g9(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&1==c.nodeType&&(d=g4[c.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function g2(e,t,n,r,i){let o,s,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new hx(hf.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,s=h6.fromSchema(r);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),o=function(e){var t;let n,r=/^(\s*<meta [^>]*>)*/.exec(e);r&&(e=e.slice(r[0].length));let i=g9().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),s;if((s=o&&g4[o[1].toLowerCase()])&&(e=s.map(e=>"<"+e+">").join("")+e+s.map(e=>"</"+e+">").reverse().join("")),i.innerHTML=(t=e,(n=window.trustedTypes)?(ye||(ye=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),ye.createHTML(t)):t),s)for(let e=0;e<s.length;e++)i=i.querySelector(s[e])||i;return i}(n),m8&&function(e){let t=e.querySelectorAll(mX?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(s||(s=(e.someProp("clipboardParser")||e.someProp("domParser")||hX.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||g8.test(e.parentNode.nodeName)?null:{ignore:!0}})),d)s=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch(t){return e}let{content:i,openStart:o,openEnd:s}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=hf.from(t.create(r[e+1],i)),o++,s++}return new hx(i,o,s)}(g3(s,+d[1],+d[2]),d[4]);else if((s=hx.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,o=[];if(e.forEach(e=>{if(!o)return;let t=r.findWrapping(e.type),n;if(!t)return o=null;if(n=o.length&&i.length&&function e(t,n,r,i,o){if(o<t.length&&o<n.length&&t[o]==n[o]){let s=e(t,n,r,i.lastChild,o+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(o==t.length-1?r.type:t[o+1]))return i.copy(i.content.append(hf.from(g5(r,t,o+1))))}}(t,i,e,o[o.length-1],0))o[o.length-1]=n;else{o.length&&(o[o.length-1]=function e(t,n){if(0==n)return t;let r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(hf.empty,!0);return t.copy(r.append(i))}(o[o.length-1],i.length));let n=g5(e,t);o.push(n),r=r.matchType(n.type),i=t}}),o)return hf.from(o)}return e}(s.content,i),!0)).openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=g3(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}let g8=/^(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 g5(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,hf.from(e));return e}function g6(e,t,n,r,i,o){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(o=0),i<r-1&&(a=g6(a,t,n,r,i+1,o)),i>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(hf.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function g3(e,t,n){return t<e.openStart&&(e=new hx(g6(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new hx(g6(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let g4={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},g7=null;function g9(){return g7||(g7=document.implementation.createHTMLDocument("title"))}let ye=null,yt={},yn={},yr={touchstart:!0,touchmove:!0};class yi{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 yo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ys(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ya(e,t))})}function ya(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function yl(e){return{left:e.clientX,top:e.clientY}}function yc(e,t,n,r,i){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let r=o.depth+1;r>0;r--)if(e.someProp(t,t=>r>o.depth?t(e,n,o.nodeAfter,o.before(r),i,!0):t(e,n,o.node(r),o.before(r),i,!1)))return!0;return!1}function yd(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}yn.keydown=(e,t)=>{if((e.input.shiftKey=16==t.keyCode||t.shiftKey,!yp(e,t))&&(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!m2||!mX||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!mZ||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){let n,r=t.keyCode,i=(n="",t.ctrlKey&&(n+="c"),t.metaKey&&(n+="m"),t.altKey&&(n+="a"),t.shiftKey&&(n+="s"),n);if(8==r||m0&&72==r&&"c"==i)return gZ(e,-1)||gK(e,-1);if(46==r&&!t.shiftKey||m0&&68==r&&"c"==i)return gZ(e,1)||gK(e,1);if(13==r||27==r)return!0;if(37==r||m0&&66==r&&"c"==i){let t=37==r?"ltr"==gY(e,e.state.selection.from)?-1:1:-1;return gV(e,t,i)||gK(e,t)}if(39==r||m0&&70==r&&"c"==i){let t=39==r?"ltr"==gY(e,e.state.selection.from)?1:-1:1;return gV(e,t,i)||gK(e,t)}else if(38==r||m0&&80==r&&"c"==i)return gQ(e,-1,i)||gK(e,-1);else if(40==r||m0&&78==r&&"c"==i)return function(e){if(!mQ||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;g0(e,n,"true"),setTimeout(()=>g0(e,n,"false"),20)}return!1}(e)||gQ(e,1,i)||gK(e,1);else if(i==(m0?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():yo(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},yn.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},yn.keypress=(e,t)=>{if(yp(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||m0&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t)))return void t.preventDefault();let n=e.state.selection;if(!(n instanceof pz)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),i=()=>e.state.tr.insertText(r).scrollIntoView();/[\r\n]/.test(r)||e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,r,i))||e.dispatch(i()),t.preventDefault()}};let yu=m0?"metaKey":"ctrlKey";yt.mousedown=(e,t)=>{var n;let r,i;e.input.shiftKey=t.shiftKey;let o=yy(e),s=Date.now(),a="singleClick";s-e.input.lastClick.time<500&&(r=(n=e.input.lastClick).x-t.clientX)*r+(i=n.y-t.clientY)*i<100&&!t[yu]&&e.input.lastClick.button==t.button&&("singleClick"==e.input.lastClick.type?a="doubleClick":"doubleClick"==e.input.lastClick.type&&(a="tripleClick")),e.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:a,button:t.button};let l=e.posAtCoords(yl(t));l&&("singleClick"==a?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new yh(e,l,t,!!o)):("doubleClick"==a?function(e,t,n,r){return yc(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}:function(e,t,n,r){return yc(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(yd(e,pz.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),o=i.before(t);if(n.inlineContent)yd(e,pz.create(r,o+1,o+1+n.content.size),"pointer");else{if(!pF.isSelectable(n))continue;yd(e,pF.create(r,o),"pointer")}return!0}}(e,n,r)})(e,l.pos,l.inside,t)?t.preventDefault():yo(e,"pointer"))};class yh{constructor(e,t,n,r){let i,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[yu],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,o=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof pF&&l.from<=o&&l.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&mK&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),yo(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>gD(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yl(e))),this.updateAllowDefault(e),this.allowDefault||!t)yo(this.view,"pointer");else{var n,r,i,o;(n=this.view,r=t.pos,i=t.inside,o=this.selectNode,yc(n,"handleClickOn",r,i,e)||n.someProp("handleClick",t=>t(n,r,e))||(o?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,i;n instanceof pF&&(r=n.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if(pF.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?o.before(n.$from.depth):o.before(e);break}}return null!=i&&(yd(e,pF.create(e.state.doc,i),"pointer"),!0)}(n,i):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&pF.isSelectable(r))&&(yd(e,new pF(n),"pointer"),!0)}(n,i)))?e.preventDefault():0==e.button&&(this.flushed||mQ&&this.mightDrag&&!this.mightDrag.node.isAtom||mX&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(yd(this.view,pP.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):yo(this.view,"pointer")}}move(e){this.updateAllowDefault(e),yo(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function yp(e,t){return!!e.composing||!!(mQ&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}yt.touchstart=e=>{e.input.lastTouch=Date.now(),yy(e),yo(e,"pointer")},yt.touchmove=e=>{e.input.lastTouch=Date.now(),yo(e,"pointer")},yt.contextmenu=e=>yy(e);let yf=m2?5e3:-1;function ym(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>yy(e),t))}function yg(e){let t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function yy(e,t=!1){if(!m2||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),yg(e),t||e.docView&&e.docView.dirty){let n=gL(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}}yn.compositionstart=yn.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof pz&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||mX&&m1&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),yy(e,!0),e.markCursor=null;else if(yy(e,!t.selection.empty),mK&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}ym(e,yf)},yn.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,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++,ym(e,20))};let yv=mG&&mq<15||mZ&&m5<604;function yb(e,t,n,r,i){let o=g2(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,o||hx.empty)))return!0;if(!o)return!1;let s=0==o.openStart&&0==o.openEnd&&1==o.content.childCount?o.content.firstChild:null,a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function yx(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," "):""}yt.copy=yn.cut=(e,t)=>{let n=e.state.selection,r="cut"==t.type;if(n.empty)return;let i=yv?null:t.clipboardData,{dom:o,text:s}=g1(e,n.content());i?(t.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",s)):function(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(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,o),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},yn.paste=(e,t)=>{if(e.composing&&!m2)return;let n=yv?null:t.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&yb(e,yx(n),n.getData("text/html"),r,t)?t.preventDefault():function(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 i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?yb(e,r.value,null,i,t):yb(e,r.textContent,r.innerHTML,i,t)},50)}(e,t)};class yk{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let yw=m0?"altKey":"ctrlKey";function yS(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[yw]}for(let e in yt.dragstart=(e,t)=>{let n,r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=e.state.selection,o=i.empty?null:e.posAtCoords(yl(t));if(o&&o.pos>=i.from&&o.pos<=(i instanceof pF?i.to-1:i.to));else if(r&&r.mightDrag)n=pF.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=pF.create(e.state.doc,r.posBefore))}let s=(n||e.state.selection).content(),{dom:a,text:l,slice:c}=g1(e,s);t.dataTransfer.files.length&&mX&&!(mY>120)||t.dataTransfer.clearData(),t.dataTransfer.setData(yv?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",yv||t.dataTransfer.setData("text/plain",l),e.dragging=new yk(c,yS(e,t),n)},yt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},yn.dragover=yn.dragenter=(e,t)=>t.preventDefault(),yn.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(yl(t));if(!r)return;let i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=g2(e,yx(t.dataTransfer),yv?null:t.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&yS(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||hx.empty,s)))return t.preventDefault();if(!o)return;t.preventDefault();let a=o?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,o=r.index(t)+ +(n>0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(o,o,i);else{let e=s.contentMatchAt(o).findWrapping(i.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,i.pos,o):i.pos;null==a&&(a=i.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&pF.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new pF(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),l.setSelection(g$(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},yt.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())&&gD(e)},20))},yt.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},yt.beforeinput=(e,t)=>{if(mX&&m2&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,mz(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},yn)yt[e]=yn[e];function yC(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}class yN{constructor(e,t){this.toDOM=e,this.spec=t||yI,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new yM(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof yN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yC(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class yA{constructor(e,t){this.attrs=e,this.spec=t||yI}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new yM(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof yA&&yC(this.attrs,e.attrs)&&yC(this.spec,e.spec)}static is(e){return e.type instanceof yA}destroy(){}}class yE{constructor(e,t){this.attrs=e,this.spec=t||yI}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new yM(i.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(e){return this==e||e instanceof yE&&yC(this.attrs,e.attrs)&&yC(this.spec,e.spec)}destroy(){}}class yM{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new yM(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new yM(e,e,new yN(t,n))}static inline(e,t,n,r){return new yM(e,t,new yA(n,r))}static node(e,t,n,r){return new yM(e,t,new yE(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof yA}get widget(){return this.type instanceof yN}}let yT=[],yI={};class yL{constructor(e,t){this.local=e.length?e:yT,this.children=t.length?t:yT}static create(e,t){return t.length?yj(t,e,0,yI):yO}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,r+s,i)}}map(e,t,n){return this==yO||0==e.maps.length?this:this.mapInner(e,t,0,0,n||yI)}mapInner(e,t,n,r,i){let o;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,i,o,s){let a=e.slice();for(let e=0,t=o;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,o)=>{let s=o-i-(n-e);for(let i=0;i<a.length;i+=3){let o=a[i+1];if(o<0||e>o+t-r)continue;let l=a[i]+t-r;n>=l?a[i+1]=e<=l?-2:-1:e>=t&&s&&(a[i]+=s,a[i+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+o),d=c-i;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+o,-1)-i,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+o+1,s);r!=yO?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=yj(function(e,t,n,r,i,o,s){for(let a=0;a<e.length;a+=3)-1==e[a+1]&&function e(t,o){for(let e=0;e<t.local.length;e++){let a=t.local[e].map(r,i,o);a?n.push(a):s.onRemove&&s.onRemove(t.local[e].spec)}for(let n=0;n<t.children.length;n+=3)e(t.children[n+2],t.children[n]+o+1)}(e[a+2],t[a]+o+1);return n}(a,e,t,n,i,o,s),r,0,s);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new yL(t.sort(yB),a)}(this.children,o||[],e,t,n,r,i):o?new yL(o.sort(yB),yT):yO}add(e,t){return t.length?this==yO?yL.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach((e,o)=>{let s=o+n,a;if(a=yP(t,e,s)){for(r||(r=this.children.slice());i<r.length&&r[i]<o;)i+=3;r[i]==o?r[i+2]=r[i+2].addInner(e,a,s+1):r.splice(i,0,o,o+e.nodeSize,yj(a,e,s+1,yI)),i+=3}});let o=yR(i?y_(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new yL(o.length?this.local.concat(o).sort(yB):this.local,r||this.children)}remove(e){return 0==e.length||this==yO?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,o=n[r]+t,s=n[r+1]+t;for(let t=0,n;t<e.length;t++)(n=e[t])&&n.from>o&&n.to<s&&(e[t]=null,(i||(i=[])).push(n));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,o+1);a!=yO?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length){for(let n=0,i;n<e.length;n++)if(i=e[n])for(let e=0;e<r.length;e++)r[e].eq(i,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new yL(r,n):yO}forChild(e,t){let n,r;if(this==yO)return this;if(t.isLeaf)return yL.empty;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,o=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>i&&t.type instanceof yA){let e=Math.max(i,t.from)-i,n=Math.min(o,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new yL(r.sort(yB),yT);return n?new yD([e,n]):e}return n||yO}eq(e){if(this==e)return!0;if(!(e instanceof yL)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return yz(this.localsInner(e))}localsInner(e){if(this==yO)return yT;if(e.inlineContent||!this.local.some(yA.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof yA||t.push(this.local[e]);return t}forEachSet(e){e(this)}}yL.empty=new yL([],[]),yL.removeOverlap=yz;let yO=yL.empty;class yD{constructor(e){this.members=e}map(e,t){let n=this.members.map(n=>n.map(e,t,yI));return yD.from(n)}forChild(e,t){if(t.isLeaf)return yL.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=yO&&(i instanceof yD?n=n.concat(i.members):n.push(i))}return yD.from(n)}eq(e){if(!(e instanceof yD)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?yz(n?t:t.sort(yB)):yT}static from(e){switch(e.length){case 0:return yO;case 1:return e[0];default:return new yD(e.every(e=>e instanceof yL)?e:e.reduce((e,t)=>e.concat(t instanceof yL?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function yR(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new yM(i.from+t,i.to+t,i.type))}return n}function yP(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,o;t<e.length;t++)(o=e[t])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),e[t]=null);return i}function y_(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function yj(e,t,n,r){let i=[],o=!1;t.forEach((t,s)=>{let a=yP(e,t,s+n);if(a){o=!0;let e=yj(a,t,n+s+1,r);e!=yO&&i.push(s,s+t.nodeSize,e)}});let s=yR(o?y_(e):e,-n).sort(yB);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||i.length?new yL(s,i):yO}function yB(e,t){return e.from-t.from||e.to-t.to}function yz(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let o=t[i];if(o.from==r.from){o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),y$(t,i+1,o.copy(r.to,o.to)));continue}o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),y$(t,i,r.copy(o.from,r.to)));break}}return t}function y$(e,t,n){for(;t<e.length&&yB(n,e[t])>0;)t++;e.splice(t,0,n)}function yF(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=yO&&t.push(r)}),e.cursorWrapper&&t.push(yL.create(e.state.doc,[e.cursorWrapper.deco])),yD.from(t)}let yU={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yH=mG&&mq<=11;class yW{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class yV{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yW,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);mG&&mq<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():mQ&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),yH&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,yU)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);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(gF(this.view)){if(this.suppressingSelectionUpdates)return gD(this.view);if(mG&&mq<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&mD(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=mT(n))t.add(n);for(let r=e.anchorNode;r;r=mT(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){var e;let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&gF(t)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],l);t&&(o=o<0?t.from:Math.min(t.from,o),s=s<0?t.to:Math.max(t.to,s),t.typeOver&&(a=!0))}if(l.some(e=>"BR"==e.nodeName)&&(8==t.input.lastKeyCode||46==t.input.lastKeyCode)){for(let e of l)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(mK&&l.length){let e=l.filter(e=>"BR"==e.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(t,n)!=e)&&r.remove()}}}let c=null;o<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&mB(r)&&(c=gL(t))&&c.eq(pP.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,gD(t),this.currentSelection.set(r),t.scrollToSelection()):(o>-1||i)&&(o>-1&&(t.docView.markDirty(o,s),e=t,!yG.has(e)&&(yG.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))&&(e.requiresGeckoHackNode=mK,yq||(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."),yq=!0))),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let o of t)if((null==(n=o.parentNode)?void 0:n.nodeName)=="TR"){let t=o.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}(t,l)),this.handleDOMChange(o,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||gD(t),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(mG&&mq<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(r=n),(!o||0>Array.prototype.indexOf.call(e.addedNodes,o))&&(i=o)}let o=r&&r.parentNode==e.target?mM(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?mM(i):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let yG=new WeakMap,yq=!1;function yK(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return mD(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function yJ(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(mQ&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(e.parentNode.lastChild==e||mQ&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let yX=/^(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){return Math.max(n.anchor,n.head)>t.content.size?null:g$(e,t.resolve(n.anchor),t.resolve(n.head))}function yQ(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function yZ(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class y0{constructor(e,t){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 yi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(y6),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=y8(this),y2(this),this.nodeViews=y5(this),this.docView=gy(this.state.doc,y1(this),yF(this),this.dom,this),this.domObserver=new yV(this,(e,t,n,r)=>(function(e,t,n,r,i){let o,s,a,l=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=gL(e,t);if(n&&!e.state.selection.eq(n)){if(mX&&m2&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let c=e.state.doc.resolve(t),d=c.sharedDepth(n);t=c.before(d+1),n=e.state.doc.resolve(n).after(d+1);let u=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:o,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],mB(c)||r.push({node:c.focusNode,offset:c.focusOffset})),mX&&8===e.input.lastKeyCode)for(let e=s;e>o;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,h=e.someProp("domParser")||hX.fromSchema(e.state.schema),p=u.resolve(a),f=null,m=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:yJ,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,f=p.slice(h.from,h.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(o=e.state.selection.to,s="end"):(o=e.state.selection.from,s="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,i){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){let e=Math.max(0,o-Math.min(s,a));r-=s+e-o}if(s<o&&e.size<t.size){let e=r<=o&&r>=s?o-r:0;(o-=e)&&o<t.size&&yZ(t.textBetween(o-1,o+1))&&(o+=e?1:-1),a=o+(a-s),s=o}else if(a<o){let t=r<=o&&r>=a?o-r:0;(o-=t)&&o<e.size&&yZ(e.textBetween(o-1,o+1))&&(o+=t?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}(f.content,h.doc.content,h.from,o,s);if(m&&e.input.domChangeCount++,(mZ&&e.input.lastIOSEnter>Date.now()-225||m2)&&i.some(e=>1==e.nodeType&&!yX.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&u instanceof pz&&!u.empty&&u.$head.sameParent(u.$anchor)&&!e.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))m={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let t=yY(e,e.state.doc,h.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof pz&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),mG&&mq<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>h.from&&"  "==h.doc.textBetween(m.start-h.from-1,m.start-h.from+1)&&(m.start--,m.endA--,m.endB--);let g=h.doc.resolveNoCache(m.start-h.from),y=h.doc.resolveNoCache(m.endB-h.from),v=p.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&v.end()>=m.endA;if((mZ&&e.input.lastIOSEnter>Date.now()-225&&(!b||i.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&g.pos<h.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(h.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||yQ(r,!0,!1)<i.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==t+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(yQ(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||yQ(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",t=>t(e,mz(8,"Backspace")))){m2&&mX&&e.domObserver.suppressSelectionUpdates();return}mX&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),m2&&!b&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==m.endA&&(m.endB-=2,y=h.doc.resolveNoCache(m.endB-h.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,mz(13,"Enter"))})},20));let x=m.start,k=m.endA,w=t=>{let n=t||e.state.tr.replace(x,k,h.doc.slice(m.start-h.from,m.endB-h.from));if(h.sel){let t=yY(e,n.doc,h.sel);t&&!(mX&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==x||t.head==n.mapping.map(k)-1)||mG&&t.empty&&t.head==x)&&n.setSelection(t)}return l&&n.setMeta("composition",l),n.scrollIntoView()};if(b)if(g.pos==y.pos){mG&&mq<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gD(e),20));let t=w(e.state.tr.delete(x,k)),n=p.resolve(m.start).marksAcross(p.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(a=function(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,o=r,s,a,l;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)o=n[e].removeFromSet(o);if(1==i.length&&0==o.length)a=i[0],s="add",l=e=>e.mark(a.addToSet(e.marks));else{if(0!=i.length||1!=o.length)return null;a=o[0],s="remove",l=e=>e.mark(a.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(l(t.child(e)));if(hf.from(c).eq(e))return{mark:a,type:s}}(g.parent.content.cut(g.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start())))){let t=w(e.state.tr);"add"==a.type?t.addMark(x,k,a.mark):t.removeMark(x,k,a.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-!y.textOffset){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>w(e.state.tr.insertText(t,x,k));e.someProp("handleTextInput",r=>r(e,x,k,t,n))||e.dispatch(n())}else e.dispatch(w());else e.dispatch(w())})(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in yt){let n=yt[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!function(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||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||ya(e,t)||!e.editable&&t.type in yn||n(e,t)},yr[t]?{passive:!0}:void 0)}mQ&&e.dom.addEventListener("input",()=>null),ys(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ys(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(y6),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,r,i;let o=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(yg(this),a=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=y5(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ys(this),this.editable=y8(this),y2(this);let c=yF(this),d=y1(this),u=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",h=s||!this.docView.matchesNode(e.doc,d,c);(h||!e.selection.eq(o.selection))&&(a=!0);let p="preserve"==u&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let o=(r.left+r.right)/2,s=i+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(o,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:m4(e.dom)}}(this);if(a){let t,n,a;this.domObserver.stop();let l=h&&(mG||mX)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&(r=o.selection,i=e.selection,a=Math.min(r.$anchor.sharedDepth(r.head),i.$anchor.sharedDepth(i.head)),r.$anchor.start(a)!=i.$anchor.start(a));if(h){let t=mX?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=m_(e=e.childNodes[t-1])}else{if(!e.parentNode||mj(e))return null;t=mM(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||mj(e))return null;t=mM(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}(this)),(s||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=gy(e.doc,d,c,this.dom,this)),!t||this.trackWrites&&this.dom.contains(this.trackWrites)||(l=!0)}l||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(t=this.docView.domFromPos(this.state.selection.anchor,0),n=this.domSelectionRange(),mD(t.node,t.offset,n.anchorNode,n.anchorOffset)))?gD(this,l):(gB(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null==(n=this.dragging)?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():p&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;m7(n,0==r?0:r-t)}(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof pF){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&m3(this,t.getBoundingClientRect(),e)}else m3(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new yk(e.slice,e.move,r<0?void 0:pF.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(null!=n&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(null!=i&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let o=i[n].props[e];if(null!=o&&(r=t?t(o):o))return r}}hasFocus(){if(mG){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(m9)return e.focus(m9);let t=m4(e);e.focus(null==m9?{get preventScroll(){return m9={preventScroll:!0},!0}}:void 0),m9||(m9=!1,m7(t,0))}(this.dom),gD(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n;let r,i,o=e.dom.ownerDocument,s,a=0,l=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(m_(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(m_(r.startContainer),r.startOffset)}}}(o,t.left,t.top);l&&({node:s,offset:a}=l);let c=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!c||!e.dom.contains(1!=c.nodeType?c.parentNode:c)){let n=e.dom.getBoundingClientRect();if(!ge(t,n)||!(c=function e(t,n,r){let i=t.childNodes.length;if(i&&r.top<r.bottom)for(let o=Math.max(0,Math.min(i-1,Math.floor(i*(n.top-r.top)/(r.bottom-r.top))-2)),s=o;;){let r=t.childNodes[s];if(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let o=t[i];if(ge(n,o))return e(r,n,o)}}if((s=(s+1)%i)==o)break}return t}(e.dom,t,n)))return null}if(mQ)for(let e=c;s&&e;e=mT(e))e.draggable&&(s=void 0);if(c=(r=(n=c).parentNode)&&/^li$/i.test(r.nodeName)&&t.left<n.getBoundingClientRect().left?r:n,s){let n;if(mK&&1==s.nodeType&&(a=Math.min(a,s.childNodes.length))<s.childNodes.length){let e=s.childNodes[a],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&a++}m8&&a&&1==s.nodeType&&1==(n=s.childNodes[a-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&a--,s==e.dom&&a==s.childNodes.length-1&&1==s.lastChild.nodeType&&t.top>s.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:(0==a||1!=s.nodeType||"BR"!=s.childNodes[a-1].nodeName)&&(i=function(e,t,n,r){let i=-1;for(let n=t,o=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),s;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((s=t.dom.getBoundingClientRect()).width||s.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!o&&s.left>r.left||s.top>r.top?i=t.posBefore:(!o&&s.right<r.left||s.bottom<r.top)&&(i=t.posAfter),o=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(s.top+s.bottom)/2:r.left<(s.left+s.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,s,a,t))}null==i&&(i=function(e,t,n){let{node:r,offset:i}=function e(t,n){let r,i,o,s=2e8,a,l=0,c=n.top,d=n.top;for(let e=t.firstChild,u=0;e;e=e.nextSibling,u++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=mL(e).getClientRects()}for(let h=0;h<t.length;h++){let p=t[h];if(p.top<=c&&p.bottom>=d){c=Math.max(p.bottom,c),d=Math.min(p.top,d);let t=p.left>n.left?p.left-n.left:p.right<n.left?n.left-p.right:0;if(t<s){o=e,s=t,a=t&&3==o.nodeType?{left:p.right<n.left?p.right:p.left,top:n.top}:n,1==e.nodeType&&t&&(l=u+ +(n.left>=(p.left+p.right)/2));continue}}else p.top>n.top&&!r&&p.left<=n.left&&p.right>=n.left&&(r=e,i={left:Math.max(p.left,Math.min(p.right,n.left)),top:p.top});!o&&(n.left>=p.right&&n.top>=p.top||n.left>=p.left&&n.top>=p.bottom)&&(l=u+1)}}return(!o&&r&&(o=r,a=i,s=0),o&&3==o.nodeType)?function(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=gn(r,1);if(n.top!=n.bottom&&ge(t,n)){i={node:e,offset:o+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}(o,a):!o||s&&1==o.nodeType?{node:t,offset:l}:e(o,a)}(t,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,o)}(e,c,t));let d=e.docView.nearestDesc(c,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}(this,e)}coordsAtPos(e,t=1){return gi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){let r,i;return gc==t&&gd==n?gu:(gc=t,gd=n,gu="up"==n||"down"==n?(r=t.selection,i="up"==n?r.$from:r.$to,ga(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=gi(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=mL(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=i==r.parent.content.size,s=e.domSelection();return s?gl.test(r.parent.textContent)&&s.modify?ga(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:o,anchorOffset:a}=e.domSelectionRange(),l=s.caretBidiLevel;s.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&i==u;try{s.collapse(o,a),t&&(t!=o||i!=a)&&s.extend&&s.extend(t,i)}catch(e){}return null!=l&&(s.caretBidiLevel=l),h}):"left"==n||"backward"==n?!i:o:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return yb(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return yb(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return g1(this,e)}destroy(){if(this.docView){for(let e in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(e,this.input.eventHandlers[e]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],yF(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,mO()}}get isDestroyed(){return null==this.docView}dispatchEvent(e){!ya(this,e)&&yt[e.type]&&(this.editable||!(e.type in yn))&&yt[e.type](this,e)}domSelectionRange(){let e=this.domSelection();return e?mQ&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return yK(e,n)}function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?yK(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function y1(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[yM.node(0,e.state.doc.content.size,t)]}function y2(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:yM.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function y8(e){return!e.someProp("editable",t=>!1===t(e.state))}function y5(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function y6(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}function y3(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}y0.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};let y4={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},y7=hs({},"editorView"),y9=hs({},"editorState"),ve=hs([],"initTimer"),vt=hs({},"editor"),vn=hs([],"inputRules"),vr=hs([],"prosePlugins"),vi=hs([],"remarkPlugins"),vo=hs([],"nodeView"),vs=hs([],"markView"),va=hs(uG().use(d4).use(f1),"remark"),vl=hs({handlers:y4,encode:[]},"remarkStringifyOptions"),vc=hh("ConfigReady"),vd=hh("InitReady"),vu=hh("SchemaReady"),vh=hs([],"schemaTimer"),vp=hs({},"schema"),vf=hs([],"nodes"),vm=hs([],"marks");function vg(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}let vy=e=>(e.inject(vp,{}).inject(vf,[]).inject(vm,[]).inject(vh,[vd]).record(vu),async()=>{await e.waitTimers(vh);let t=e.get(va),n=e.get(vi).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(va,n);let r=new hK({nodes:Object.fromEntries(e.get(vf).map(([e,t])=>[e,vg(t)])),marks:Object.fromEntries(e.get(vm).map(([e,t])=>[e,vg(t)]))});return e.set(vp,r),e.done(vu),()=>{e.remove(vp).remove(vf).remove(vm).remove(vh).clearTimer(vu)}});y3(vy,{displayName:"Schema"});class vv{constructor(){this.#g=new hr,this.#N=null,this.setCtx=e=>{this.#N=e},this.chain=()=>{if(null==this.#N)throw hn();let e=this.#N,t=[],n=this.get.bind(this),r={run:()=>{let n=fc(...t),r=e.get(y7);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:(function(e,i){let o=n(e);return t.push(o(i)),r}).bind(this)};return r}}#g;#N;get ctx(){return this.#N}create(e,t){let n=e.create(this.#g.sliceMap);return n.set(t),n}get(e){return this.#g.get(e).get()}remove(e){return this.#g.remove(e)}call(e,t){if(null==this.#N)throw hn();let n=this.get(e)(t),r=this.#N.get(y7);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#N)throw hn();let t=this.#N.get(y7);return e(t.state,t.dispatch,t)}}let vb=hs(new vv,"commands"),vx=hs([vu],"commandsTimer"),vk=hh("CommandsReady"),vw=e=>{let t=new vv;return t.setCtx(e),e.inject(vb,t).inject(vx,[vu]).record(vk),async()=>(await e.waitTimers(vx),e.done(vk),()=>{e.remove(vb).remove(vx).clearTimer(vk)})};y3(vw,{displayName:"Commands"});class vS{constructor(){this.#N=null,this.#A=[],this.setCtx=e=>{this.#N=e},this.add=e=>(this.#A.push(e),()=>{this.#A=this.#A.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){let r={key:e,onRun:()=>n};this.#A.push(r),t.push(()=>{this.#A=this.#A.filter(e=>e!==r)})}else this.#A.push(n),t.push(()=>{this.#A=this.#A.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=(ff.Backspace=fc(mi,p8,p3,p7),ff);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#A.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#N;if(null==i)throw u9();return fc(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#N;#A;get ctx(){return this.#N}}let vC=hs(new vS,"keymap"),vN=hs([vu],"keymapTimer"),vA=hh("KeymapReady"),vE=e=>{let t=new vS;return t.setCtx(e),e.inject(vC,t).inject(vN,[vu]).record(vA),async()=>(await e.waitTimers(vN),e.done(vA),()=>{e.remove(vC).remove(vN).clearTimer(vA)})},vM=hh("ParserReady"),vT=()=>{throw u9()},vI=hs(vT,"parser"),vL=hs([],"parserTimer"),vO=e=>(e.inject(vI,vT).inject(vL,[vu]).record(vM),async()=>{await e.waitTimers(vL);let t=e.get(va),n=e.get(vp);return e.set(vI,me.create(n,t)),e.done(vM),()=>{e.remove(vI).remove(vL).clearTimer(vM)}});y3(vO,{displayName:"Parser"});let vD=hh("SerializerReady"),vR=hs([],"serializerTimer"),vP=()=>{throw u9()},v_=hs(vP,"serializer"),vj=e=>(e.inject(v_,vP).inject(vR,[vu]).record(vD),async()=>{await e.waitTimers(vR);let t=e.get(va),n=e.get(vp);return e.set(v_,mn.create(n,t)),e.done(vD),()=>{e.remove(v_).remove(vR).clearTimer(vD)}});y3(vj,{displayName:"Serializer"});let vB=hs("","defaultValue"),vz=hs(e=>e,"stateOptions"),v$=hs([],"editorStateTimer"),vF=hh("EditorStateReady"),vU=new p2("MILKDOWN_STATE_TRACKER"),vH=e=>(e.inject(vB,"").inject(y9,{}).inject(vz,e=>e).inject(v$,[vM,vD,vk,vA]).record(vF),async()=>{await e.waitTimers(v$);let t=e.get(vp),n=e.get(vI),r=e.get(vn),i=e.get(vz),o=e.get(vr),s=function(e,t,n){var r;if("string"==typeof e)return t(e);if("html"===e.type)return hX.fromSchema(n).parse(e.dom);if("json"===e.type)return hD.fromJSON(n,e.value);throw r=e,new u4(u3.docTypeError,`Doc type error, unsupported type: ${JSON.stringify(r,u7)}`)}(e.get(vB),n,t),a=e.get(vC),l=a.addBaseKeymap(),c=[...o,new pZ({key:vU,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(y9,i)}}}),function({rules:e}){let t=new pZ({key:mg,isInputRules:!0,state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,i,o)=>mm(n,r,i,o,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&mm(n,r.pos,r.pos,"",e,t)}),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;let{$cursor:i}=n.state.selection;return!!i&&mm(n,i.pos,i.pos,"\n",e,t)}}});return t}({rules:r}),mE(a.build())];e.set(vr,c);let d=i({schema:t,doc:s,plugins:c}),u=pQ.create(d);return e.set(y9,u),e.done(vF),()=>{l(),e.remove(vB).remove(y9).remove(vz).remove(v$).clearTimer(vF)}});y3(vH,{displayName:"EditorState"});let vW=hs([],"pasteRule"),vV=hs([vu],"pasteRuleTimer"),vG=hh("PasteRuleReady"),vq=e=>(e.inject(vW,[]).inject(vV,[vu]).record(vG),async()=>(await e.waitTimers(vV),e.done(vG),()=>{e.remove(vW).remove(vV).clearTimer(vG)}));y3(vq,{displayName:"PasteRule"});let vK=hh("EditorViewReady"),vJ=hs([],"editorViewTimer"),vX=hs({},"editorViewOptions"),vY=hs(null,"root"),vQ=hs(null,"rootDOM"),vZ=hs({},"rootAttrs"),v0=new p2("MILKDOWN_VIEW_CLEAR"),v1=e=>(e.inject(vY,document.body).inject(y7,{}).inject(vX,{}).inject(vQ,null).inject(vZ,{}).inject(vJ,[vF,vG]).record(vK),async()=>{var t;await e.wait(vd);let n=e.get(vY)||document.body,r="string"==typeof n?document.querySelector(n):n;e.update(vr,t=>[new pZ({key:v0,view:t=>{let n,i=r?((n=document.createElement("div")).className="milkdown",r.appendChild(n),e.set(vQ,n),Object.entries(e.get(vZ)).forEach(([e,t])=>n.setAttribute(e,t)),n):void 0;if(i&&r){let e=t.dom;r.replaceChild(i,e),i.appendChild(e)}return{destroy:()=>{i?.parentNode&&i?.parentNode.replaceChild(t.dom,i),i?.remove()}}}}),...t]),await e.waitTimers(vJ);let i=e.get(y9),o=e.get(vX),s=new y0(r,{state:i,nodeViews:Object.fromEntries(e.get(vo)),markViews:Object.fromEntries(e.get(vs)),transformPasted:(t,n,r)=>(e.get(vW).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});return(t=s.dom).classList.add("editor"),t.setAttribute("role","textbox"),e.set(y7,s),e.done(vK),()=>{s?.destroy(),e.remove(vY).remove(y7).remove(vX).remove(vQ).remove(vZ).remove(vJ).clearTimer(vK)}});y3(v1,{displayName:"EditorView"});var v2=((k=v2||{}).Idle="Idle",k.OnCreate="OnCreate",k.Created="Created",k.OnDestroy="OnDestroy",k.Destroyed="Destroyed",k);class v8{constructor(){this.#E=!1,this.#k="Idle",this.#M=[],this.#T=()=>void 0,this.#g=new hr,this.#y=new hc,this.#I=new Map,this.#L=new Map,this.#N=new hl(this.#g,this.#y),this.#O=()=>{var e,t;let n,r,i=(e=async e=>{await Promise.all(this.#M.map(t=>Promise.resolve(t(e))))},y3(n=t=>(t.record(vc),async()=>(await e(t),t.done(vc),()=>{t.clearTimer(vc)})),{displayName:"Config"}),n),o=[vy,vO,vj,vw,vE,vq,vH,v1,(t=this,y3(r=e=>(e.inject(vt,t).inject(vr,[]).inject(vi,[]).inject(vn,[]).inject(vo,[]).inject(vs,[]).inject(vl,{handlers:y4,encode:[]}).inject(va,uG().use(d4).use(f1)).inject(ve,[vc]).record(vd),async()=>{await e.waitTimers(ve);let t=e.get(vl);return e.set(va,uG().use(d4).use(f1,t)),e.done(vd),()=>{e.remove(vt).remove(vr).remove(vi).remove(vn).remove(vo).remove(vs).remove(vl).remove(va).remove(ve).clearTimer(vd)}}),{displayName:"Init"}),r),i];this.#D(o,this.#L)},this.#D=(e,t)=>{e.forEach(e=>{let n=this.#N.produce(this.#E?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#R=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#I.get(e),r=n?.cleanup;return(t?this.#I.delete(e):this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof r)?r():r})),this.#P=async()=>{await Promise.all([...this.#L.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#L.clear()},this.#_=e=>{this.#k=e,this.#T(e)},this.#j=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let o=await i();e.set(t,{ctx:r,handler:i,cleanup:o})}),this.enableInspector=(e=!0)=>(this.#E=e,this),this.onStatusChange=e=>(this.#T=e,this),this.config=e=>(this.#M.push(e),this),this.removeConfig=e=>(this.#M=this.#M.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),"Created"===this.#k&&this.#D(t,this.#I),this},this.remove=async e=>"OnCreate"===this.#k?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#R([e].flat(),!0),this),this.create=async()=>("OnCreate"===this.#k||("Created"===this.#k&&await this.destroy(),this.#_("OnCreate"),this.#O(),this.#D([...this.#I.keys()],this.#I),await Promise.all([this.#j(this.#L),this.#j(this.#I)].flat()),this.#_("Created")),this),this.destroy=async(e=!1)=>"Destroyed"===this.#k||"OnDestroy"===this.#k?this:"OnCreate"===this.#k?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#M=[]),this.#_("OnDestroy"),await this.#R([...this.#I.keys()],e),await this.#P(),this.#_("Destroyed"),this),this.action=e=>e(this.#N),this.inspect=()=>this.#E?[...this.#L.values(),...this.#I.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new v8}#E;#k;#M;#T;#g;#y;#I;#L;#N;#O;#D;#R;#P;#_;#j;get ctx(){return this.#N}get status(){return this.#k}}let v5=e=>crypto.getRandomValues(new Uint8Array(e)),v6=(e,t=21)=>{var n;let r,i;return n=0|t,i=-~(1.6*(r=(2<<Math.log2(e.length-1))-1)*n/e.length),(t=n)=>{let o="";for(;;){let n=v5(i),s=0|i;for(;s--;)if((o+=e[n[s]&r]||"").length>=t)return o}}};function v3(e,t){let n=function(e="cmdKey"){return hs(()=>()=>!1,e)}(e),r=i=>async()=>{r.key=n,await i.wait(vk);let o=t(i);return i.get(vb).create(n,o),r.run=t=>i.get(vb).call(e,t),()=>{i.get(vb).remove(n)}};return r}function v4(e){let t=n=>async()=>{await n.wait(vu);let r=e(n);return n.update(vn,e=>[...e,r]),t.inputRule=r,()=>{n.update(vn,e=>e.filter(e=>e!==r))}};return t}function v7(e,t){let n=r=>async()=>{let i=t(r);return r.update(vf,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(vf,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(vp).nodes[e];if(!n)throw new u4(u3.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`);return n},n}function v9(e){let t,n=n=>async()=>(await n.wait(vu),t=e(n),n.update(vr,e=>[...e,t]),()=>{n.update(vr,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function be(e,t){let n=hs(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function bt(e,t){let n=be(t,e),r=v7(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>bt(e,n(t)),i}function bn(e,t){var n;let r,i=be(t,e),o=(n=e=>e.get(i.key)(e),(r=t=>async()=>{let i=n(t);return t.update(vm,t=>[...t.filter(t=>t[0]!==e),[e,i]]),r.id=e,r.schema=i,()=>{t.update(vm,t=>t.filter(([t])=>t!==e))}}).type=t=>{let n=t.get(vp).marks[e];if(!n)throw new u4(u3.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`);return n},r),s=[i,o];return s.id=o.id,s.mark=o,s.type=e=>o.type(e),s.ctx=i,s.key=i.key,s.extendSchema=n=>bn(e,n(t)),s}function br(e,t){var n;let r,i=be(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),o=(n=e=>{let n=e.get(i.key);return Object.fromEntries(Object.entries(t).flatMap(([e,{command:t}])=>{let r=n[e],i=[r.shortcuts].flat(),o=r.priority;return i.map(e=>[e,{key:e,onRun:t,priority:o}])}))},r=e=>async()=>{await e.wait(vA);let t=e.get(vC),i=n(e),o=t.addObjectKeymap(i);return r.keymap=i,()=>{o()}}),s=[i,o];return s.ctx=i,s.shortcuts=o,s.key=i.key,s.keymap=o.keymap,s}v6("abcedfghicklmn",10);let bi=(e,t=()=>({}))=>be(t,`${e}Attr`),bo=(e,t=()=>({}))=>be(t,`${e}Attr`);function bs(e,t,n){let r=be(n??{},e),i=e=>async()=>{await e.wait(vd);let n={plugin:t(e),options:e.get(r.key)};return e.update(vi,e=>[...e,n]),()=>{e.update(vi,e=>e.filter(e=>e!==n))}},o=[r,i];return o.id=e,o.plugin=i,o.options=r,o}function ba(e){return String(e||"").toUpperCase()}function bl(){return function(e){let t=function(e){let t=new Map;if(!e||!e.type)throw Error("mdast-util-definitions expected node");return um(e,"definition",function(e){let n=ba(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){let n=ba(e);return t.get(n)}}(e);um(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[up,n];if("imageReference"===e.type||"linkReference"===e.type){let i=t(e.identifier);if(i&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:i.url,title:i.title,alt:e.alt}:{type:"link",url:i.url,title:i.title,children:e.children},[up,n]}})}}function bc(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name==="hardbreak"))return void e.next(t.content);let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(hf.fromArray(n))}function bd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}let bu=bo("emphasis");bd(bu,{displayName:"Attr<emphasis>",group:"Emphasis"});let bh=bn("emphasis",e=>({attrs:{marker:{default:e.get(vl).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(bu.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));bd(bh.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),bd(bh.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});let bp=v3("ToggleEmphasis",e=>()=>fl(bh.type(e)));bd(bp,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});let bf=v4(e=>my(/(?:^|[^*])\*([^*]+)\*$/,bh.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));bd(bf,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});let bm=v4(e=>my(/\b_(?![_\s])(.*?[^_\s])_\b/,bh.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));bd(bm,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});let bg=br("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{let t=e.get(vb);return()=>t.call(bp.key)}}});bd(bg.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),bd(bg.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});let by=bo("strong");bd(by,{displayName:"Attr<strong>",group:"Strong"});let bv=bn("strong",e=>({attrs:{marker:{default:e.get(vl).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(by.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));bd(bv.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),bd(bv.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});let bb=v3("ToggleStrong",e=>()=>fl(bv.type(e)));bd(bb,{displayName:"Command<toggleStrongCommand>",group:"Strong"});let bx=v4(e=>my(RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),bv.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));bd(bx,{displayName:"InputRule<strong>",group:"Strong"});let bk=br("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{let t=e.get(vb);return()=>t.call(bb.key)}}});bd(bk.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),bd(bk.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});let bw=bo("inlineCode");bd(bw,{displayName:"Attr<inlineCode>",group:"InlineCode"});let bS=bn("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(bw.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>{e.withMark(t,"inlineCode",n.text||"")}}}));bd(bS.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),bd(bS.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});let bC=v3("ToggleInlineCode",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:o,to:s}=r;return t.doc.rangeHasMark(o,s,bS.type(e))?n?.(i.removeMark(o,s,bS.type(e))):(Object.keys(t.schema.marks).filter(e=>e!==bS.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(o,s,e)}),n?.(i.addMark(o,s,bS.type(e).create()))),!0});bd(bC,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});let bN=v4(e=>my(/(?:`)([^`]+)(?:`)$/,bS.type(e)));bd(bN,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});let bA=br("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{let t=e.get(vb);return()=>t.call(bC.key)}}});bd(bA.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),bd(bA.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});let bE=bo("link");bd(bE,{displayName:"Attr<link>",group:"Link"});let bM=bn("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(bE.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));bd(bM.mark,{displayName:"MarkSchema<link>",group:"Link"});let bT=v3("ToggleLink",e=>(t={})=>fl(bM.type(e),t));bd(bT,{displayName:"Command<toggleLinkCommand>",group:"Link"});let bI=v3("UpdateLink",e=>(t={})=>(n,r)=>{let i;if(!r)return!1;let o=-1,{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(bM.type(e).isInSet(t.marks))return i=t,o=n,!1}),!i)return!1;let c=i.marks.find(({type:t})=>t===bM.type(e));if(!c)return!1;let d=o,u=o+i.nodeSize,{tr:h}=n,p=bM.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new pz(h.selection.$anchor)).scrollIntoView()),!0)});bd(bI,{displayName:"Command<updateLinkCommand>",group:"Link"});let bL=v7("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function bO(e){return uf(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);-1!==r&&n.children.splice(r,1)},!0)}bd(bL,{displayName:"NodeSchema<doc>",group:"Doc"});let bD=bs("remark-preserve-empty-line",()=>()=>bO);bd(bD.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),bd(bD.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});let bR=bi("paragraph");bd(bR,{displayName:"Attr<paragraph>",group:"Paragraph"});let bP=bt("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(bR.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{let r=e.get(y7),i=r.state?.doc.lastChild;t.openNode("paragraph"),(!n.content||0===n.content.size)&&n!==i&&function(e){let t=!1;try{e.get(bD.id),t=!0}catch{t=!1}return t}(e)?t.addNode("html",void 0,"<br />"):bc(t,n),t.closeNode()}}}));bd(bP.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),bd(bP.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});let b_=v3("TurnIntoText",e=>()=>fa(bP.type(e)));bd(b_,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});let bj=br("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{let t=e.get(vb);return()=>t.call(b_.key)}}});bd(bj.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),bd(bj.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});let bB=Array(6).fill(0).map((e,t)=>t+1),bz=be(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");bd(bz,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});let b$=bi("heading");bd(b$,{displayName:"Attr<heading>",group:"Heading"});let bF=bt("heading",e=>{let t=e.get(bz.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:bB.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw ht(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(b$.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),bc(e,t),e.closeNode()}}}});bd(bF.node,{displayName:"NodeSchema<heading>",group:"Heading"}),bd(bF.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});let bU=v4(e=>ms(/^(?<hashes>#+)\s$/,bF.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(y7).state.selection,i=r.node();if("heading"===i.type.name){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));bd(bU,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});let bH=v3("WrapInHeading",e=>t=>(t??=1)<1?fa(bP.type(e)):fa(bF.type(e),{level:t}));bd(bH,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});let bW=v3("DowngradeHeading",e=>()=>(t,n,r)=>{let{$from:i}=t.selection,o=i.node();if(o.type!==bF.type(e)||!t.selection.empty||0!==i.parentOffset)return!1;let s=o.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):fa(bP.type(e))(t,n,r)});bd(bW,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});let bV=br("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{let t=e.get(vb);return()=>t.call(bW.key)}}});bd(bV.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),bd(bV.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});let bG=bi("blockquote");bd(bG,{displayName:"Attr<blockquote>",group:"Blockquote"});let bq=bt("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(bG.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));bd(bq.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),bd(bq.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});let bK=v4(e=>mo(/^\s*>\s$/,bq.type(e)));bd(bK,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});let bJ=v3("WrapInBlockquote",e=>()=>fs(bq.type(e)));bd(bJ,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});let bX=br("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{let t=e.get(vb);return()=>t.call(bJ.key)}}});bd(bX.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),bd(bX.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});let bY=bi("codeBlock",()=>({pre:{},code:{}}));bd(bY,{displayName:"Attr<codeBlock>",group:"CodeBlock"});let bQ=bt("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(bY.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...i},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{let r=t.lang??"",i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));bd(bQ.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),bd(bQ.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});let bZ=v4(e=>ms(/^```(?<language>[a-z]*)?[\s\n]$/,bQ.type(e),e=>({language:e.groups?.language??""})));bd(bZ,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});let b0=v3("CreateCodeBlock",e=>(t="")=>fa(bQ.type(e),{language:t}));bd(b0,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),bd(v3("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});let b1=br("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{let t=e.get(vb);return()=>t.call(b0.key)}}});bd(b1.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),bd(b1.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});let b2=bi("image");bd(b2,{displayName:"Attr<image>",group:"Image"});let b8=bt("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(b2.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{let r=t.url,i=t.alt,o=t.title;e.addNode(n,{src:r,alt:i,title:o})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));bd(b8.node,{displayName:"NodeSchema<image>",group:"Image"}),bd(b8.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});let b5=v3("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=t,a=b8.type(e).create({src:i,alt:o,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});bd(b5,{displayName:"Command<insertImageCommand>",group:"Image"});let b6=v3("UpdateImage",e=>(t={})=>(n,r)=>{let i=function(e,t){if(!(e instanceof pF))return;let{node:n,$from:r}=e;if(Array.isArray(t)&&t.includes(n.type)||n.type===t)return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}(n.selection,b8.type(e));if(!i)return!1;let{node:o,pos:s}=i,a={...o.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});bd(b6,{displayName:"Command<updateImageCommand>",group:"Image"}),bd(v4(e=>new mr(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[o,s,a="",l]=n;return o?t.tr.replaceWith(r,i,b8.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});let b3=bi("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));bd(b3,{displayName:"Attr<hardbreak>",group:"Hardbreak"});let b4=bt("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(b3.key)(t)," "]:["br",e.get(b3.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));bd(b4.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),bd(b4.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});let b7=v3("InsertHardbreak",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof pz))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name==="hardbreak")return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(pP.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta("hardbreak",!0).replaceSelectionWith(b4.type(e).create()).scrollIntoView()),!0});bd(b7,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});let b9=br("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{let t=e.get(vb);return()=>t.call(b7.key)}}});bd(b9.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),bd(b9.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});let xe=bi("hr");bd(xe,{displayName:"Attr<hr>",group:"Hr"});let xt=bt("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(xe.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));bd(xt.node,{displayName:"NodeSchema<hr>",group:"Hr"}),bd(xt.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});let xn=v4(e=>new mr(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:o}=t;return n[0]&&o.replaceWith(r-1,i,xt.type(e).create()),o}));bd(xn,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});let xr=v3("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;let r=bP.node.type(e).create(),{tr:i,selection:o}=t,{from:s}=o,a=xt.type(e).create();if(!a)return!0;let l=i.replaceSelectionWith(a).insert(s,r),c=pP.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});bd(xr,{displayName:"Command<insertHrCommand>",group:"Hr"});let xi=bi("bulletList");bd(xi,{displayName:"Attr<bulletList>",group:"BulletList"});let xo=bt("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(xi.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{let r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));bd(xo.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),bd(xo.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});let xs=v4(e=>mo(/^\s*([-+*])\s$/,xo.type(e)));bd(xs,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});let xa=v3("WrapInBulletList",e=>()=>fs(xo.type(e)));bd(xa,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});let xl=br("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{let t=e.get(vb);return()=>t.call(xa.key)}}});bd(xl.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),bd(xl.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});let xc=bi("orderedList");bd(xc,{displayName:"Attr<orderedList>",group:"OrderedList"});let xd=bt("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(xc.key)(t),...1===t.attrs.order?{}:t.attrs.order,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{let r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));bd(xd.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),bd(xd.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});let xu=v4(e=>mo(/^\s*(\d+)\.\s$/,xd.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));bd(xu,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});let xh=v3("WrapInOrderedList",e=>()=>fs(xd.type(e)));bd(xh,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});let xp=br("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{let t=e.get(vb);return()=>t.call(xh.key)}}});bd(xp.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),bd(xp.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});let xf=bi("listItem");bd(xf,{displayName:"Attr<listItem>",group:"ListItem"});let xm=bt("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(xf.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{let r=null!=t.label?`${t.label}.`:"•",i=null!=t.label?"ordered":"bullet",o=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:i,spread:o}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));bd(xm.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),bd(xm.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});let xg=v3("SinkListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,e=>e.childCount>0&&e.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,i=hf.from(r?t.create():null),s=new hx(hf.from(t.create(null,hf.from(a.type.create(null,i)))),r?3:1,0),c=o.start,d=o.end;n(e.tr.step(new ph(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0}});bd(xg,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});let xy=v3("LiftListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,e=>e.childCount>0&&e.firstChild.type==t);return!!o&&(!n||(r.node(o.depth-1).type==t?function(e,t,n,r){let i=e.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new ph(o-1,s,o,s,new hx(hf.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new hL(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let a=pm(r);if(null==a)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return pk(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),t(i.scrollIntoView()),!0}(e,n,t,o):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,o=n.startIndex;t>o;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+ +!a,d+1,s.content.append(l?hf.empty:hf.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new ph(u-!!a,h+ +!!l,u+1,h-1,new hx((a?hf.empty:hf.from(i.copy(hf.empty))).append(l?hf.empty:hf.from(i.copy(hf.empty))),+!a,+!l),+!a)),t(r.scrollIntoView()),!0}(e,n,o)))}});bd(xy,{displayName:"Command<liftListItemCommand>",group:"ListItem"});let xv=v3("SplitListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i,node:o}=e.selection;if(o&&o.isBlock||r.depth<2||!r.sameParent(i))return!1;let s=r.node(-1);if(s.type!=t)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=t||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let i=hf.empty,o=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-o;e>=r.depth-3;e--)i=hf.from(r.node(e).copy(i));let s=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;i=i.append(hf.from(t.createAndFill()));let a=r.before(r.depth-(o-1)),l=e.tr.replace(a,r.after(-s),new hx(i,4-o,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(pP.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=i.pos==r.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(r.pos,i.pos),c=a?[null,{type:a}]:void 0;return!!px(l.doc,r.pos,2,c)&&(n&&n(l.split(r.pos,2,c).scrollIntoView()),!0)}});bd(xv,{displayName:"Command<splitListItemCommand>",group:"ListItem"});let xb=v3("LiftFirstListItem",e=>()=>(t,n,r)=>{let{selection:i}=t;if(!(i instanceof pz))return!1;let{empty:o,$from:s}=i;return!!o&&0===s.parentOffset&&s.node(-1).type===xm.type(e)&&p6(t,n,r)});bd(xb,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});let xx=br("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{let t=e.get(vb);return()=>t.call(xv.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{let t=e.get(vb);return()=>t.call(xg.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{let t=e.get(vb);return()=>t.call(xy.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{let t=e.get(vb);return()=>t.call(xb.key)}}});bd(xx.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),bd(xx.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});let xk=v7("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));bd(xk,{displayName:"NodeSchema<text>",group:"Text"});let xw=bi("html");bd(xw,{displayName:"Attr<html>",group:"Html"});let xS=bt("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{let n=document.createElement("span"),r={...e.get(xw.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>"html"===e,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));bd(xS.node,{displayName:"NodeSchema<html>",group:"Html"}),bd(xS.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});let xC=[bL,bR,bP,bz,b$,bF,b3,b4,bG,bq,bY,bQ,xe,xt,b2,b8,xi,xo,xc,xd,xf,xm,bu,bh,by,bv,bw,bS,bE,bM,xw,xS,xk].flat(),xN=[bK,xs,xu,bZ,xn,bU].flat(),xA=[bf,bm,bN,bx],xE=[b_,bJ,bH,bW,b0,b7,xr,b5,b6,xh,xa,xg,xv,xy,xb,bp,bC,bb,bT,bI,v3("IsMarkSelected",()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),v3("IsNoteSelected",()=>e=>t=>!!e&&((e,t)=>{let{selection:n,doc:r}=e;if(n instanceof pF)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:o}=n,s=!1,a=-1,l=null;return r.nodesBetween(i,o,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}})(t,e).hasNode),v3("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:o}=r,{pos:s}=i,a=o-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),v3("SetBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr,{from:s,to:a}=o.selection;try{o.setBlockType(s,a,r,i)}catch{return!1}return n?.(o),!0}),v3("WrapInBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let{$from:e,$to:t}=o.selection,n=e.blockRange(t),s=n&&pg(n,r,i);if(!s)return!1;o=o.wrap(n,s)}catch{return!1}return n?.(o),!0}),v3("AddBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let e=r instanceof hD?r:r.createAndFill(i);if(!e)return!1;o.replaceSelectionWith(e)}catch{return!1}return n?.(o),!0}),v3("SelectTextNearPos",()=>e=>(t,n)=>{let{pos:r}=e??{};if(null==r)return!1;let i=t.tr;try{let e,n=t.doc.resolve((e=t.doc.content.size,Math.min(Math.max(r,0),e)));i.setSelection(pz.near(n))}catch{return!1}return n?.(i.scrollIntoView()),!0})],xM=[bX,b1,b9,bV,xx,xp,xl,bj,bg,bA,bk].flat(),xT=bs("remarkAddOrderInList",()=>()=>e=>{um(e,"list",e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});bd(xT.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),bd(xT.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});let xI=bs("remarkLineBreak",()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;um(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;let i=[],o=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){let n=s.index;o!==n&&i.push({type:"text",value:e.value.slice(o,n)}),i.push({type:"break",data:{isInline:!0}}),o=n+s[0].length,s=t.exec(e.value)}if(i.length>0&&r&&"number"==typeof n)return o<e.value.length&&i.push({type:"text",value:e.value.slice(o)}),r.children.splice(n,1,...i),n+i.length})});bd(xI.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),bd(xI.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});let xL=bs("remarkInlineLink",()=>bl);bd(xL.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),bd(xL.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});let xO=["root","blockquote","listItem"],xD=bs("remarkHTMLTransformer",()=>()=>e=>{(function e(t,n,r){if(t.children){let n=[];for(let r=0,i=t.children.length;r<i;r++){let i=t.children[r];if(i){let o=e(i,r,t);if(o)for(let e=0,t=o.length;e<t;e++){let t=o[e];t&&n.push(t)}}}t.children=n}return((e,t,n)=>("html"!==e.type||n&&xO.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]))(t,n,r)})(e,0,null)[0]});bd(xD.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),bd(xD.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});let xR=bs("remarkMarker",()=>()=>(e,t)=>{um(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=t.value.charAt(e.position.start.offset)})});bd(xR.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),bd(xR.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});let xP=v9(()=>{let e=!1,t=new pZ({key:new p2("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!n&&!!r&&!!n.isInline&&!n.isText&&!!r.isInline&&!r.isText}},props:{handleDOMEvents:{compositionend:(n,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement("span"),r=yM.widget(t,n,{side:-1}),i=document.createElement("span"),o=yM.widget(t,i);return setTimeout(()=>{n.contentEditable="true",i.contentEditable="true"}),yL.create(e.doc,[r,o])}return yL.empty}}});return t});bd(xP,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});let x_=v9(e=>new pZ({key:new p2("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof pu))return;let{from:t}=o;return r.tr.setNodeMarkup(t,b4.type(e),void 0,[])}if(o instanceof pa){let t=r.tr,{from:n,to:i}=o;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===b4.type(e)&&(t=t.setNodeMarkup(r,b4.type(e),void 0,[]))}),t}}}));bd(x_,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});let xj=be(["table","code_block"],"hardbreakFilterNodes");bd(xj,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});let xB=v9(e=>{let t=e.get(xj.key);return new pZ({key:new p2("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{let r=e.getMeta("hardbreak"),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),o=r.depth,s=!0;for(;o>0;)t.includes(r.node(o).type.name)&&(s=!1),o--;return s}return!0}})});bd(xB,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});let xz=v9(e=>{let t=new p2("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;let r=e.get(bz.key),i=n.state.tr.setMeta("addToHistory",!1),o=!1,s={};n.state.doc.descendants((n,a)=>{if(n.type===bF.type(e)){if(0===n.textContent.trim().length)return;let e=n.attrs,l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(o=!0,i.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),o&&n.dispatch(i)};return new pZ({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});bd(xz,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});let x$=v9(e=>new pZ({key:new p2("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;let i=xd.type(e),o=xo.type(e),s=xm.type(e),a=(e,t)=>{let n=!1,r=`${t+1}.`;return e.label!==r&&(e.label=r,n=!0),n},l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===o){let n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,i,{spread:"true"}),e.descendants((e,t,n,r)=>{if(e.type===s){let n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===i){let i={...e.attrs},o=!1;"ordered"!==i.listType&&(i.listType="ordered",o=!0),n?.maybeChild(0)&&(o=a(i,r)),o&&(l=l.setNodeMarkup(t,void 0,i),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));bd(x$,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});let xF=[xC,xN,xA,xE,xM,[x_,xj,xB,xP,xT,xL,xI,xD,xR,bD,xz,x$].flat()].flat(),xU=function(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=function e(t){var n,r,i="";if("string"==typeof t||"number"==typeof t)i+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(r=e(t[n]))&&(i&&(i+=" "),i+=r)}else for(r in t)t[r]&&(i&&(i+=" "),i+=r);return i}(e))&&(r&&(r+=" "),r+=t);return r};function xH(e){e.update(vX,e=>{let t=e.attributes;return{...e,attributes:e=>{let n="function"==typeof t?t(e):t;return{...n,class:xU("prose dark:prose-invert",n?.class||"","milkdown-theme-nord")}}}})}let xW=(0,et.createContext)({}),xV=()=>{let e=function(){let{dom:e,editor:t,setLoading:n,editorFactory:r}=(0,et.useContext)(xW),i=(0,et.useRef)(null);return(0,et.useEffect)(()=>{let o=i.current;if(!r||!o)return;e.current=o;let s=r(o);if(s)return n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}},[e,t,r,n]),i}();return et.default.createElement("div",{"data-milkdown-root":!0,ref:e})},xG=({children:e})=>{let t=(0,et.useRef)(void 0),[n,r]=(0,et.useState)(void 0),i=(0,et.useRef)(void 0),[o,s]=(0,et.useState)(!0),a=(0,et.useMemo)(()=>({loading:o,dom:t,editor:i,setLoading:s,editorFactory:n,setEditorFactory:r}),[o,n]);return et.default.createElement(xW.Provider,{value:a},e)};var xq=((w={}).docTypeError="docTypeError",w.contextNotFound="contextNotFound",w.timerNotFound="timerNotFound",w.ctxCallOutOfScope="ctxCallOutOfScope",w.createNodeInParserFail="createNodeInParserFail",w.stackOverFlow="stackOverFlow",w.parserMatchError="parserMatchError",w.serializerMatchError="serializerMatchError",w.getAtomFromSchemaFail="getAtomFromSchemaFail",w.expectDomTypeError="expectDomTypeError",w.callCommandBeforeEditorView="callCommandBeforeEditorView",w.missingRootElement="missingRootElement",w.missingNodeInSchema="missingNodeInSchema",w.missingMarkInSchema="missingMarkInSchema",w.ctxNotBind="ctxNotBind",w.missingYjsDoc="missingYjsDoc",w),xK=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},xJ=(e,t)=>"function"==typeof t?"[Function]":t;function xX(){return new xK(xq.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function xY(){return new xK(xq.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function xQ(){return new xK(xq.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}var xZ=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t){var n;throw n="string"==typeof e?e:e.name,new xK(xq.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}return t},this.remove=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},x0=class{#s=[];#l;#a=()=>{this.#s.forEach(e=>e(this.#l))};constructor(e,t,n){this.set=e=>{this.#l=e,this.#a()},this.get=()=>this.#l,this.update=e=>{this.#l=e(this.#l),this.#a()},this.type=n,this.#l=t,e.set(n.id,this)}on(e){return this.#s.push(e),()=>{this.#s=this.#s.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#s=this.#s.filter(t=>t!==e)}offAll(){this.#s=[]}},x1=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw xX()}}create(e,t=this._defaultValue){return new x0(e,t,this)}},x2=(e,t)=>new x1(e,t),x8=class{#p;#g;#y;#c=new Set;#d=new Set;#u=new Map;#h=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#p,injectedSlices:[...this.#c].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),consumedSlices:[...this.#d].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),recordedTimers:[...this.#u].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)})),waitTimers:[...this.#h].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)}))}),this.onRecord=e=>{this.#u.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#u.delete(e)},this.onDone=e=>{let t=this.#u.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#h.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#c.add(e)},this.onRemove=e=>{this.#c.delete(e)},this.onUse=e=>{this.#d.add(e)},this.#g=e,this.#y=t,this.#p=n}#f=e=>this.#g.get(e).get();#m=e=>this.#y.get(e).status},x5=class e{#g;#y;#p;#v;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#g,this.#y,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#g.sliceMap);return null!=t&&n.set(t),this.#v?.onInject(e),this},this.remove=e=>(this.#g.remove(e),this.#v?.onRemove(e),this),this.record=e=>(e.create(this.#y.store),this.#v?.onRecord(e),this),this.clearTimer=e=>(this.#y.remove(e),this.#v?.onClear(e),this),this.isInjected=e=>this.#g.has(e),this.isRecorded=e=>this.#y.has(e),this.use=e=>(this.#v?.onUse(e),this.#g.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#y.get(e),this.done=e=>{this.timer(e).done(),this.#v?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#v?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#g=t,this.#y=n,this.#p=r,r&&(this.#v=new x8(t,n,r))}get meta(){return this.#p}get inspector(){return this.#v}},x6=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t){var n;throw n=e.name,new xK(xq.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},x3=class{#b=null;#x=null;#w;#k="pending";constructor(e,t){this.start=()=>(this.#b??=new Promise((e,t)=>{this.#x=t=>{t instanceof CustomEvent&&t.detail.id===this.#w&&(this.#k="resolved",this.#S(),t.stopImmediatePropagation(),e())},this.#C(()=>{"pending"===this.#k&&(this.#k="rejected"),this.#S(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#k="pending",addEventListener(this.type.name,this.#x)}),this.#b),this.done=()=>{dispatchEvent(new CustomEvent(this.type.name,{detail:{id:this.#w}}))},this.#w=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#k}#S=()=>{this.#x&&removeEventListener(this.type.name,this.#x)};#C=e=>{setTimeout(()=>{e()},this.type.timeout)}},x4=class{constructor(e,t=3e3){this.create=e=>new x3(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},x7=(e,t=3e3)=>new x4(e,t);let x9="u">typeof navigator?navigator:null,ke="u">typeof document?document:null,kt=x9&&x9.userAgent||"",kn=/Edge\/(\d+)/.exec(kt),kr=/MSIE \d/.exec(kt),ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kt),ko=!!(kr||ki||kn);kr?document.documentMode:ki?ki[1]:kn&&kn[1],!ko&&/gecko\/(\d+)/i.test(kt)&&(/Firefox\/(\d+)/.exec(kt)||[0,0])[1];let ks=!ko&&/Chrome\/(\d+)/.exec(kt);function ka(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of i){let i=a.match.exec(l),c=i&&i[0]&&a.handler(s,i,t-(i[0].length-r.length),n);if(c)return!1!==a.undoable&&c.setMeta(o,{transform:c,from:t,to:n,text:r}),e.dispatch(c),!0}return!1}ks&&ks[1],!ko&&x9&&/Apple Computer/.test(x9.vendor)&&(/Mobile\/\w+/.test(kt)||x9&&x9.maxTouchPoints>2)||x9&&/Mac/.test(x9.platform),/Android \d/.test(kt),ke&&"webkitFontSmoothing"in ke.documentElement.style&&(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];let kl=new p2("MILKDOWN_CUSTOM_INPUTRULES");Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var kc=class{},kd=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw xY();return e}}},ku=class e extends kc{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},kh=class extends kd{#B=hv.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(ku.create(e,[],t)),this),this.closeNode=()=>{try{this.#z()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#$(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#B=e.create(t).addToSet(this.#B),this),this.closeMark=e=>(this.#B=e.removeFromSet(this.#B),this),this.addText=e=>{try{let t=this.top();if(!t)throw xY();let n=t.pop(),r=this.schema.text(e,this.#B);if(!n)return t.push(r),this;let i=this.#F(n,r);if(i)return t.push(i),this;return t.push(n,r),this}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#z();while(this.size())return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#U(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#H=e=>e.isText;#F=(e,t)=>{if(this.#H(e)&&this.#H(t)&&hv.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#W=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t){var n;throw n=e,new xK(xq.parserMatchError,`Cannot match target parser for node: ${JSON.stringify(n,xJ)}.`)}return t};#U=e=>{let t=this.#W(e);t.spec.parseMarkdown.runner(this,e,t)};#z=()=>{this.#B=hv.none;let e=this.close();return this.#$(e.type,e.attrs,e.content)};#$=(e,t,n)=>{let r=e.createAndFill(t,n,this.#B);if(!r){let r,i,o;throw r=`Cannot create node for ${"name"in e?e.name:e}`,i=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(i).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},o=[["[Description]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:i(e):"null")]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]),new xK(xq.createNodeInParserFail,o.join("\n"))}return this.push(r),r}},kp=class e extends kc{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},kf=class extends kd{#B=hv.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(kp.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#z(),this),this.addNode=(e,t,n,r)=>(this.#$(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#V(e,t,n,r),this),this.closeMark=e=>(this.#G(e),this),this.build=()=>{let e=null;do e=this.#z();while(this.size())return e},this.next=e=>(Object.prototype.hasOwnProperty.call(e,"size")?e.forEach(e=>{this.#U(e)}):this.#U(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#W=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t){var n;throw n=e.type,new xK(xq.serializerMatchError,`Cannot match target serializer for node: ${JSON.stringify(n,xJ)}.`)}return t};#q=e=>this.#W(e).spec.toMarkdown.runner(this,e);#K=(e,t)=>this.#W(e).spec.toMarkdown.runner(this,e,t);#U=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#K(t,e))&&this.#q(e),t.forEach(e=>this.#G(e))};#J=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return null!=e.value?null:e;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,o={...e,children:i};return o.children=i,r.children=[o],r};#X=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){let{children:n,...i}=t=this.#J(t,r.type),{children:o,...s}=r;if(t.type===r.type&&n&&o&&JSON.stringify(i)===JSON.stringify(s)){let t={...s,children:[...o,...n]};return e.slice(0,-1).concat(this.#X(t))}}return e.concat(t)},[])),e};#Y=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#Q=(e,t)=>{let n="",r="",i=e.children,o=-1,s=-1;if(i){i&&i.forEach((e,t)=>{"text"===e.type&&e.value&&(o<0&&(o=t),s=t)});let e=i?.[s],t=i?.[o];if(e&&e.value.endsWith(" ")){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#$("text",void 0,n);let a=t();return r.length&&this.#$("text",void 0,r),a};#z=(e=!1)=>{let t=this.close(),n=()=>this.#$(t.type,t.children,t.value,t.props);return e?this.#Q(t,n):n()};#$=(e,t,n,r)=>{let i=kp.create(e,t,n,r),o=this.#X(this.#Y(i));return this.push(o),o};#V=(e,t,n,r)=>e.isInSet(this.#B)?this:(this.#B=e.addToSet(this.#B),this.openNode(t,n,{...r,isMark:!0}));#G=e=>{e.isInSet(this.#B)&&(this.#B=e.type.removeFromSet(this.#B),this.#z(!0))}};function km(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}var kg={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},ky=x2({},"editorView"),kv=x2({},"editorState"),kb=x2([],"initTimer"),kx=x2({},"editor"),kk=x2([],"inputRules"),kw=x2([],"prosePlugins"),kS=x2([],"remarkPlugins"),kC=x2([],"nodeView"),kN=x2([],"markView"),kA=x2(uG().use(d4).use(f1),"remark"),kE=x2({handlers:kg,encode:[]},"remarkStringifyOptions"),kM=x7("ConfigReady"),kT=x7("InitReady"),kI=x7("SchemaReady"),kL=x2([],"schemaTimer"),kO=x2({},"schema"),kD=x2([],"nodes"),kR=x2([],"marks");function kP(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var k_=e=>(e.inject(kO,{}).inject(kD,[]).inject(kR,[]).inject(kL,[kT]).record(kI),async()=>{await e.waitTimers(kL);let t=e.get(kA),n=e.get(kS).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(kA,n);let r=new hK({nodes:Object.fromEntries(e.get(kD).map(([e,t])=>[e,kP(t)])),marks:Object.fromEntries(e.get(kR).map(([e,t])=>[e,kP(t)]))});return e.set(kO,r),e.done(kI),()=>{e.remove(kO).remove(kD).remove(kR).remove(kL).clearTimer(kI)}});km(k_,{displayName:"Schema"});var kj=class{constructor(){this.setCtx=e=>{this.#N=e},this.chain=()=>{if(null==this.#N)throw xQ();let e=this.#N,t=[],n=this.get.bind(this),r={run:()=>{let n=fc(...t),r=e.get(ky);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:(function(e,i){let o=n(e);return t.push(o(i)),r}).bind(this)};return r}}#g=new xZ;#N=null;get ctx(){return this.#N}create(e,t){let n=e.create(this.#g.sliceMap);return n.set(t),n}get(e){return this.#g.get(e).get()}remove(e){return this.#g.remove(e)}call(e,t){if(null==this.#N)throw xQ();let n=this.get(e)(t),r=this.#N.get(ky);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#N)throw xQ();let t=this.#N.get(ky);return e(t.state,t.dispatch,t)}},kB=x2(new kj,"commands"),kz=x2([kI],"commandsTimer"),k$=x7("CommandsReady"),kF=e=>{let t=new kj;return t.setCtx(e),e.inject(kB,t).inject(kz,[kI]).record(k$),async()=>(await e.waitTimers(kz),e.done(k$),()=>{e.remove(kB).remove(kz).clearTimer(k$)})};km(kF,{displayName:"Commands"});var kU=class{constructor(){this.setCtx=e=>{this.#N=e},this.add=e=>(this.#A.push(e),()=>{this.#A=this.#A.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){let r={key:e,onRun:()=>n};this.#A.push(r),t.push(()=>{this.#A=this.#A.filter(e=>e!==r)})}else this.#A.push(n),t.push(()=>{this.#A=this.#A.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=(ff.Backspace=fc(mi,p8,p3,p7),ff);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#A.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#N;if(null==i)throw xX();return fc(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#N=null;#A=[];get ctx(){return this.#N}},kH=x2(new kU,"keymap"),kW=x2([kI],"keymapTimer"),kV=x7("KeymapReady"),kG=e=>{let t=new kU;return t.setCtx(e),e.inject(kH,t).inject(kW,[kI]).record(kV),async()=>(await e.waitTimers(kW),e.done(kV),()=>{e.remove(kH).remove(kW).clearTimer(kV)})},kq=x7("ParserReady"),kK=()=>{throw xX()},kJ=x2(kK,"parser"),kX=x2([],"parserTimer"),kY=e=>(e.inject(kJ,kK).inject(kX,[kI]).record(kq),async()=>{await e.waitTimers(kX);let t=e.get(kA),n=e.get(kO);return e.set(kJ,kh.create(n,t)),e.done(kq),()=>{e.remove(kJ).remove(kX).clearTimer(kq)}});km(kY,{displayName:"Parser"});var kQ=x7("SerializerReady"),kZ=x2([],"serializerTimer"),k0=()=>{throw xX()},k1=x2(k0,"serializer"),k2=e=>(e.inject(k1,k0).inject(kZ,[kI]).record(kQ),async()=>{await e.waitTimers(kZ);let t=e.get(kA),n=e.get(kO);return e.set(k1,kf.create(n,t)),e.done(kQ),()=>{e.remove(k1).remove(kZ).clearTimer(kQ)}});km(k2,{displayName:"Serializer"});var k8=x2("","defaultValue"),k5=x2(e=>e,"stateOptions"),k6=x2([],"editorStateTimer"),k3=x7("EditorStateReady"),k4=new p2("MILKDOWN_STATE_TRACKER"),k7=e=>(e.inject(k8,"").inject(kv,{}).inject(k5,e=>e).inject(k6,[kq,kQ,k$,kV]).record(k3),async()=>{await e.waitTimers(k6);let t=e.get(kO),n=e.get(kJ),r=e.get(kk),i=e.get(k5),o=e.get(kw),s=function(e,t,n){var r;if("string"==typeof e)return t(e);if("html"===e.type)return hX.fromSchema(n).parse(e.dom);if("json"===e.type)return hD.fromJSON(n,e.value);throw r=e,new xK(xq.docTypeError,`Doc type error, unsupported type: ${JSON.stringify(r,xJ)}`)}(e.get(k8),n,t),a=e.get(kH),l=a.addBaseKeymap(),c=[...o,new pZ({key:k4,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(kv,i)}}}),function({rules:e}){let t=new pZ({key:kl,isInputRules:!0,state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,i,o)=>ka(n,r,i,o,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&ka(n,r.pos,r.pos,"",e,t)}),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;let{$cursor:i}=n.state.selection;return!!i&&ka(n,i.pos,i.pos,"\n",e,t)}}});return t}({rules:r}),mE(a.build())];e.set(kw,c);let d=i({schema:t,doc:s,plugins:c}),u=pQ.create(d);return e.set(kv,u),e.done(k3),()=>{l(),e.remove(k8).remove(kv).remove(k5).remove(k6).clearTimer(k3)}});km(k7,{displayName:"EditorState"});var k9=x2([],"pasteRule"),we=x2([kI],"pasteRuleTimer"),wt=x7("PasteRuleReady"),wn=e=>(e.inject(k9,[]).inject(we,[kI]).record(wt),async()=>(await e.waitTimers(we),e.done(wt),()=>{e.remove(k9).remove(we).clearTimer(wt)}));km(wn,{displayName:"PasteRule"});var wr=x7("EditorViewReady"),wi=x2([],"editorViewTimer"),wo=x2({},"editorViewOptions"),ws=x2(null,"root"),wa=x2(null,"rootDOM"),wl=x2({},"rootAttrs"),wc=new p2("MILKDOWN_VIEW_CLEAR"),wd=e=>(e.inject(ws,document.body).inject(ky,{}).inject(wo,{}).inject(wa,null).inject(wl,{}).inject(wi,[k3,wt]).record(wr),async()=>{var t;await e.wait(kT);let n=e.get(ws)||document.body,r="string"==typeof n?document.querySelector(n):n;e.update(kw,t=>[new pZ({key:wc,view:t=>{let n,i=r?((n=document.createElement("div")).className="milkdown",r.appendChild(n),e.set(wa,n),Object.entries(e.get(wl)).forEach(([e,t])=>n.setAttribute(e,t)),n):void 0;if(i&&r){let e=t.dom;r.replaceChild(i,e),i.appendChild(e)}return{destroy:()=>{i?.parentNode&&i?.parentNode.replaceChild(t.dom,i),i?.remove()}}}}),...t]),await e.waitTimers(wi);let i=e.get(kv),o=e.get(wo),s=new y0(r,{state:i,nodeViews:Object.fromEntries(e.get(kC)),markViews:Object.fromEntries(e.get(kN)),transformPasted:(t,n,r)=>(e.get(k9).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});return(t=s.dom).classList.add("editor"),t.setAttribute("role","textbox"),e.set(ky,s),e.done(wr),()=>{s?.destroy(),e.remove(ws).remove(ky).remove(wo).remove(wa).remove(wl).remove(wi).clearTimer(wr)}});km(wd,{displayName:"EditorView"});var wu=((S={}).Idle="Idle",S.OnCreate="OnCreate",S.Created="Created",S.OnDestroy="OnDestroy",S.Destroyed="Destroyed",S);function wh(e){return t=>{let n=t.get(ky),r=t.get(kO),i=t.get(k1);if(!e)return i(n.state.doc);let o=n.state.doc.slice(e.from,e.to,!0),s=r.topNodeType.createAndFill(null,o.content);return s?i(s):(console.error("No document found"),"")}}function wp({value:e,onChange:t,onSave:n}){let r,i,o=(0,et.useRef)(t),s=(0,et.useRef)(n);o.current=t,s.current=n,function(e,t=[]){let n=(0,et.useContext)(xW),r=(0,et.useCallback)(e,t);(0,et.useLayoutEffect)(()=>{n.setEditorFactory(()=>r)},[n,r]),n.loading}(t=>v8.make().config(n=>{n.set(vY,t),n.set(vB,e)}).config(xH).use(xF),[]);let[a,l]=(r=(0,et.useContext)(xW),i=(0,et.useCallback)(()=>r.editor.current,[r.editor]),[r.loading,i]),c=(0,et.useRef)(null),d=(0,et.useRef)(null),u=(0,et.useCallback)(()=>{if(a)return;let e=l();if(e)try{let t=e.action(wh());o.current(t)}catch{}},[a,l]);return(0,et.useEffect)(()=>{let e=c.current?.querySelector(".ProseMirror");if(e)return d.current=new MutationObserver(()=>{u()}),d.current.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{d.current?.disconnect()}},[a,u]),(0,et.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&"s"===e.key){if(e.preventDefault(),a)return;let t=l();if(t)try{let e=t.action(wh());s.current(e)}catch{}}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,l]),(0,ee.jsx)("div",{ref:c,className:"milkdown-wrap flex-1 min-h-0 overflow-auto",children:(0,ee.jsx)(xV,{})})}function wf(e){return(0,ee.jsx)(xG,{children:(0,ee.jsx)(wp,{...e})})}(class e{constructor(){this.enableInspector=(e=!0)=>(this.#E=e,this),this.onStatusChange=e=>(this.#T=e,this),this.config=e=>(this.#M.push(e),this),this.removeConfig=e=>(this.#M=this.#M.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#k===wu.Created&&this.#D(t,this.#I),this},this.remove=async e=>this.#k===wu.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#R([e].flat(),!0),this),this.create=async()=>(this.#k===wu.OnCreate||(this.#k===wu.Created&&await this.destroy(),this.#_(wu.OnCreate),this.#O(),this.#D([...this.#I.keys()],this.#I),await Promise.all([this.#j(this.#L),this.#j(this.#I)].flat()),this.#_(wu.Created)),this),this.destroy=async(e=!1)=>this.#k===wu.Destroyed||this.#k===wu.OnDestroy?this:this.#k===wu.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#M=[]),this.#_(wu.OnDestroy),await this.#R([...this.#I.keys()],e),await this.#P(),this.#_(wu.Destroyed),this),this.action=e=>e(this.#N),this.inspect=()=>this.#E?[...this.#L.values(),...this.#I.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#E=!1;#k=wu.Idle;#M=[];#T=()=>void 0;#g=new xZ;#y=new x6;#I=new Map;#L=new Map;#N=new x5(this.#g,this.#y);#O=()=>{var e,t;let n,r,i=(e=async e=>{await Promise.all(this.#M.map(t=>Promise.resolve(t(e))))},km(n=t=>(t.record(kM),async()=>(await e(t),t.done(kM),()=>{t.clearTimer(kM)})),{displayName:"Config"}),n),o=[k_,kY,k2,kF,kG,wn,k7,wd,(t=this,km(r=e=>(e.inject(kx,t).inject(kw,[]).inject(kS,[]).inject(kk,[]).inject(kC,[]).inject(kN,[]).inject(kE,{handlers:kg,encode:[]}).inject(kA,uG().use(d4).use(f1)).inject(kb,[kM]).record(kT),async()=>{await e.waitTimers(kb);let t=e.get(kE);return e.set(kA,uG().use(d4).use(f1,t)),e.done(kT),()=>{e.remove(kx).remove(kw).remove(kS).remove(kk).remove(kC).remove(kN).remove(kE).remove(kA).remove(kb).clearTimer(kT)}}),{displayName:"Init"}),r),i];this.#D(o,this.#L)};#D=(e,t)=>{e.forEach(e=>{let n=this.#N.produce(this.#E?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#R=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#I.get(e)?.cleanup;return(t?this.#I.delete(e):this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n)?n():n}));#P=async()=>{await Promise.all([...this.#L.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#L.clear()};#_=e=>{this.#k=e,this.#T(e)};#j=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let o=await i();e.set(t,{ctx:r,handler:i,cleanup:o})});get ctx(){return this.#N}get status(){return this.#k}}),v6("abcedfghicklmn",10);let wm={"in-progress":"●",pending:"○",done:"✓",archived:"▪"},wg={"in-progress":"var(--yellow)",pending:"var(--dim)",done:"var(--green)",archived:"var(--dimmer)"};function wy({sessionName:e}){let{data:t,loading:n,refresh:r}=ei((0,et.useCallback)(()=>(0,er.fetchPlans)(e),[e]),1e4),[i,o]=(0,et.useState)("all"),[s,a]=(0,et.useState)(null),[l,c]=(0,et.useState)({content:"",authorship:null}),[d,u]=(0,et.useState)(!1),[h,p]=(0,et.useState)(!1),[f,m]=(0,et.useState)(""),[g,y]=(0,et.useState)(!1),v=(0,et.useMemo)(()=>t?"all"===i?t:t.filter(e=>e.status===i):[],[t,i]),b=(0,et.useMemo)(()=>t?.find(e=>e.path===s)??null,[t,s]);(0,et.useEffect)(()=>{if(!s){c({content:"",authorship:null}),p(!1);return}u(!0),p(!1),(0,er.fetchPlan)(e,s).then(e=>{c(e),m(e.content)}).catch(()=>c({content:"",authorship:null})).finally(()=>u(!1))},[s,e]),(0,et.useEffect)(()=>{!s&&v.length>0&&a(v[0].path)},[v,s]);let x=(0,et.useMemo)(()=>(function(e,t){let n=e.split("\n"),r=[],i="",o=[];for(let e of n){let n=e.match(/^#{1,4}\s+(.+)/);if(n){if(o.length>0||i){let e=t?.sections[i]??null;r.push({heading:i,content:o.join("\n"),author:e?.author??null,authorAt:e?.at??null})}i=n[1].trim(),o=[e]}else o.push(e)}if(o.length>0||i){let e=t?.sections[i]??null;r.push({heading:i,content:o.join("\n"),author:e?.author??null,authorAt:e?.at??null})}return r})(l.content,l.authorship),[l]);async function k(t){if(s){if(y(!0),await (0,er.savePlan)(e,s,t)){let t=await (0,er.fetchPlan)(e,s);c(t),m(t.content),p(!1)}y(!1)}}async function w(){!b||await (0,er.markPlanDone)(e,b.name)&&r()}if(n&&!t)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Loading plans..."});if(!t||0===t.length)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No plan files found in plans/"});let S={};for(let e of t)S[e.status]=(S[e.status]??0)+1;return(0,ee.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,ee.jsxs)("div",{className:"w-[260px] shrink-0 border-r border-[var(--border)] flex flex-col min-h-0",children:[(0,ee.jsx)("div",{className:"flex items-center h-6 bg-[var(--surface)] border-b border-[var(--border)] text-[10px] shrink-0 px-1 gap-px",children:["all","in-progress","pending","done"].map(e=>(0,ee.jsx)("button",{onClick:()=>o(e),className:`px-1.5 py-0.5 transition-colors ${i===e?"text-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"all"===e?`all (${t.length})`:`${e} (${S[e]??0})`},e))}),(0,ee.jsx)("div",{className:"flex-1 overflow-y-auto",children:v.map(e=>{let t=s===e.path;return(0,ee.jsxs)("button",{onClick:()=>a(e.path),className:`w-full text-left px-2 py-1 flex items-start gap-1.5 transition-colors ${t?"bg-[rgba(255,255,255,0.04)] text-[var(--accent)]":"text-[var(--fg)] hover:bg-[rgba(255,255,255,0.02)]"}`,children:[(0,ee.jsx)("span",{className:"shrink-0 mt-0.5 text-[11px]",style:{color:wg[e.status]},children:wm[e.status]}),(0,ee.jsxs)("span",{className:"min-w-0",children:[(0,ee.jsx)("span",{className:"block truncate text-[12px]",children:e.name}),e.completed&&(0,ee.jsx)("span",{className:"block text-[10px] text-[var(--dimmer)]",children:e.completed})]})]},e.path)})})]}),(0,ee.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:d?(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"loading..."}):l.content||h?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{className:"shrink-0 border-b border-[var(--border)] px-3 flex items-center h-7",children:[(0,ee.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[b&&(0,ee.jsxs)("span",{className:"text-[11px]",style:{color:wg[b.status]},children:[wm[b.status]," ",b.status]}),(0,ee.jsx)(u6,{authorship:l.authorship})]}),(0,ee.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[b&&"done"!==b.status&&!h&&(0,ee.jsx)("button",{onClick:w,className:"text-[11px] px-2 py-0.5 text-[var(--green)] border border-[var(--border)] hover:border-[var(--green)] transition-colors",children:"mark done"}),h&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("button",{onClick:()=>k(f),disabled:g,className:"text-[11px] px-2 py-0.5 text-[var(--bg)] bg-[var(--accent)] hover:opacity-90 disabled:opacity-50 transition-opacity",children:g?"saving...":"save"}),(0,ee.jsx)("span",{className:"text-[9px] text-[var(--dimmer)]",children:"cmd+S"})]}),(0,ee.jsx)("button",{onClick:()=>h?p(!1):void(m(l.content),p(!0)),className:`text-[11px] px-2 py-0.5 border border-[var(--border)] transition-colors ${h?"text-[var(--accent)] border-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)] hover:border-[var(--dim)]"}`,children:h?"view":"edit"})]})]}),h?(0,ee.jsx)(wf,{value:f,onChange:m,onSave:k},s):(0,ee.jsx)("div",{className:"flex-1 overflow-y-auto p-4 max-w-3xl",children:x.map((e,t)=>{var n;let r=!!(n=e.author)&&n.startsWith("ai"),i=e.author?r?"var(--ai-color)":"var(--human-color)":"transparent",o=e.author?r?"var(--ai-bg)":"var(--human-bg)":"transparent",s=function(e){if(!e)return"";try{let t=new Date(e),n=Date.now()-t.getTime();if(n<36e5)return`${Math.floor(n/6e4)}m ago`;if(n<864e5)return`${Math.floor(n/36e5)}h ago`;return`${Math.floor(n/864e5)}d ago`}catch{return""}}(e.authorAt);return(0,ee.jsxs)("div",{className:"plan-content",style:{borderLeft:e.author?`2px solid ${i}`:"2px solid transparent",paddingLeft:"12px",marginBottom:"4px",background:o,borderRadius:"2px"},children:[e.author&&e.heading&&(0,ee.jsxs)("div",{className:"flex items-center gap-2 mb-1 -mt-0.5",children:[(0,ee.jsx)("span",{className:"text-[9px] px-1 py-px rounded",style:{color:r?"var(--ai-color)":"var(--human-color)",background:r?"var(--ai-badge)":"var(--human-badge)"},children:e.author}),s&&(0,ee.jsx)("span",{className:"text-[9px] text-[var(--dimmer)]",children:s})]}),(0,ee.jsx)(u8,{children:e.content})]},`${e.heading}-${t}`)})})]}):(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Select a plan to view"})})]})}function wv({project:e,lastUpdate:t,stale:n=!1}){let[r,i]=(0,et.useState)(Date.now()),[o,s]=(0,et.useState)(!1),a=(0,et.useRef)(t);(0,et.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,et.useEffect)(()=>{if(t&&t!==a.current){a.current=t,s(!0);let e=setTimeout(()=>s(!1),300);return()=>clearTimeout(e)}},[t]);let l=e.tasks.filter(e=>"done"===e.status).length,c=e.agents.filter(e=>e.isBusy).length,d=t?Math.max(0,Math.floor((r-t)/1e3)):0,u=new Date(r).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return(0,ee.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 h-6 bg-[var(--bg-weak)] border-t flex items-center px-3 text-[11px] z-20",children:[(0,ee.jsx)("span",{className:"text-[var(--accent)] font-medium",children:e.session}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[(0,ee.jsx)("span",{style:{color:c>0?"var(--yellow)":void 0},children:c}),"/",e.agents.length," agents"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[(0,ee.jsx)("span",{style:{color:l>0?"var(--green)":void 0},children:l}),"/",e.tasks.length," tasks"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["updated ",d,"s ago"]}),(0,ee.jsx)("span",{className:"flex-1"}),(0,ee.jsx)("span",{className:"transition-opacity duration-300",style:{color:n?"var(--red)":"var(--green)",opacity:o?1:.6},children:"●"}),(0,ee.jsx)("span",{className:"text-[var(--dim)] ml-1.5",children:n?"stale":"live"}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:u})]})}let wb=[{id:"kanban",label:"kanban"},{id:"agents",label:"agents"},{id:"diffs",label:"diffs"},{id:"plans",label:"plans"},{id:"validation",label:"validation"},{id:"metrics",label:"metrics"},{id:"activity",label:"activity"}];function wx(){let e=(0,en.usePathname)(),t=(0,en.useRouter)(),n=decodeURIComponent(e.replace(/^\/project\//,"").replace(/\/$/,"")),[r,i]=(0,et.useState)("kanban"),{data:o,error:s,stale:a,lastUpdate:l,refresh:c}=ei((0,et.useCallback)(()=>(0,er.fetchProject)(n),[n]),2e3),{data:d}=ei((0,et.useCallback)(()=>(0,er.fetchEvents)(n),[n]),3e3),{data:u}=ei((0,et.useCallback)(()=>(0,er.fetchMilestones)(n),[n]),3e3),{data:h}=ei((0,et.useCallback)(()=>(0,er.fetchMission)(n),[n]),5e3),{data:p}=ei((0,et.useCallback)(()=>(0,er.fetchSkills)(n),[n]),1e4);if(s)return(0,ee.jsx)("div",{className:"h-screen flex items-center justify-center text-[var(--red)]",children:"failed to load project"});if(!o)return(0,ee.jsx)("div",{className:"h-screen flex items-center justify-center text-[var(--dim)]",children:"loading..."});let f=o.tasks.filter(e=>"done"===e.status).length,m=o.tasks.length,g=m>0?Math.round(f/m*100):0,y=o.agents.filter(e=>e.isBusy).length;return(0,ee.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,ee.jsxs)("div",{className:"flex items-center justify-between px-4 h-7 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ee.jsx)("button",{onClick:()=>t.push("/"),className:"text-[var(--dim)] hover:text-[var(--fg)] transition-colors",children:"< esc"}),(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--accent)]",children:o.session}),o.mission&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)] truncate",children:o.mission.title})]})]}),(0,ee.jsxs)("div",{className:"flex items-center gap-4 text-[var(--dim)]",children:[(0,ee.jsxs)("span",{children:[(0,ee.jsx)("span",{className:"text-[var(--green)]",children:y}),"/",o.agents.length," ","agents"]}),(0,ee.jsxs)("span",{children:[(0,ee.jsx)("span",{className:"text-[var(--green)]",children:f}),"/",m," tasks"]}),(0,ee.jsx)(eo.ProgressBar,{percent:g,width:10})]})]}),o.agents.length>0&&(0,ee.jsx)("div",{className:"flex items-center px-2 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:o.agents.map((e,t)=>(0,ee.jsx)(es,{agent:e},`${e.paneTitle}-${t}`))}),o.goals.length>0&&(0,ee.jsx)("div",{className:"flex items-center gap-4 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:o.goals.map(e=>{let t=o.tasks.filter(t=>t.goal===e.id),n=t.filter(e=>"done"===e.status).length,r=t.length>0?Math.round(n/t.length*100):0;return(0,ee.jsxs)("span",{className:"flex items-center gap-1.5 shrink-0",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] truncate max-w-[20ch]",children:e.title}),(0,ee.jsx)(eo.ProgressBar,{percent:r,width:4})]},e.id)})}),h&&(0,ee.jsxs)("div",{className:"flex items-center gap-4 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"mission:"}),(0,ee.jsx)("span",{className:"complete"===h.mission.status?"text-[var(--green)]":"active"===h.mission.status?"text-[var(--accent)]":"text-[var(--yellow)]",children:h.mission.status}),h.validationSummary.total>0&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"assertions:"}),(0,ee.jsx)("span",{className:"text-[var(--green)]",children:h.validationSummary.passing}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"/"}),(0,ee.jsx)("span",{children:h.validationSummary.total}),h.validationSummary.failing>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["(",h.validationSummary.failing," failing)"]})]}),h.mission.branch&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:h.mission.branch})]})]}),u&&u.length>0&&(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)] shrink-0",children:"milestones:"}),u.map(e=>{let t=e.taskCount>0?Math.round(e.tasksDone/e.taskCount*100):0,n="done"===e.status?"var(--green)":"active"===e.status?"var(--accent)":"validating"===e.status?"var(--yellow)":"var(--dim)";return(0,ee.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[(0,ee.jsx)("span",{style:{color:n},children:e.id}),(0,ee.jsx)("span",{className:"text-[var(--fg)] truncate max-w-[14ch]",children:e.title}),(0,ee.jsx)(eo.ProgressBar,{percent:t,width:3}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[e.tasksDone,"/",e.taskCount]})]},e.id)})]}),p&&p.length>0&&(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)] shrink-0",children:"skills:"}),p.map(e=>(0,ee.jsx)("span",{className:"px-1.5 py-0 text-[10px] border border-[var(--border)] text-[var(--cyan)] shrink-0",title:e.specialties.join(", "),children:e.name},e.name))]}),(0,ee.jsx)("div",{className:"flex border-b border-[var(--border)] bg-[var(--surface)] shrink-0",children:wb.map(e=>(0,ee.jsx)("button",{onClick:()=>i(e.id),className:`px-4 h-7 transition-colors ${r===e.id?"text-[var(--accent)] border-b-2 border-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:e.label},e.id))}),"kanban"===r&&(0,ee.jsx)(t6,{tasks:o.tasks,sessionName:o.session,agents:o.agents,goals:o.goals,onRefresh:c}),"diffs"===r&&(0,ee.jsx)(cc,{sessionName:o.session}),"plans"===r&&(0,ee.jsx)(wy,{sessionName:o.session}),"validation"===r&&(0,ee.jsx)(wE,{sessionName:o.session}),"metrics"===r&&(0,ee.jsx)(wA,{sessionName:o.session}),"activity"===r&&(0,ee.jsx)(ch,{events:d??[]}),"agents"===r&&(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto",children:[(0,ee.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:o.agents.map((e,t)=>(0,ee.jsx)(es,{agent:e},`${e.paneTitle}-${t}`))}),0===o.agents.length&&(0,ee.jsx)("div",{className:"flex items-center justify-center h-32 text-[var(--dim)]",children:"no agents in this session"})]}),(0,ee.jsx)(wv,{project:o,lastUpdate:l,stale:a})]})}let wk={passing:"var(--green)",failing:"var(--red)",pending:"var(--dim)",blocked:"var(--yellow)"};function ww(e){if(e<6e4)return`${Math.round(e/1e3)}s`;if(e<36e5)return`${Math.round(e/6e4)}m`;let t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return`${t}h ${n}m`}function wS(e){return`${Math.round(100*e)}%`}function wC({label:e,value:t,color:n}){return(0,ee.jsxs)("div",{className:"px-3 py-2 bg-[var(--surface)] border border-[var(--border)]",children:[(0,ee.jsx)("div",{className:"text-[var(--dim)] text-[11px]",children:e}),(0,ee.jsx)("div",{className:"text-lg",style:{color:n??"var(--fg)"},children:t})]})}let wN={done:"var(--green)",active:"var(--accent)",validating:"var(--yellow)",locked:"var(--dim)"};function wA({sessionName:e}){let{data:t}=ei((0,et.useCallback)(()=>(0,er.fetchMetrics)(e),[e]),5e3);if(!t)return(0,ee.jsx)("div",{className:"flex-1 p-4 text-[var(--dim)]",children:"loading metrics..."});let n=t.agents.length>0?t.agents.reduce((e,t)=>e+t.utilization,0)/t.agents.length:0;return(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto space-y-4",children:[(0,ee.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[(0,ee.jsx)(wC,{label:"session duration",value:ww(t.session.durationMs)}),(0,ee.jsx)(wC,{label:"completion rate",value:wS(t.tasks.completionRate),color:t.tasks.completionRate>=.8?"var(--green)":"var(--yellow)"}),(0,ee.jsx)(wC,{label:"avg agent utilization",value:wS(n),color:n>=.5?"var(--green)":"var(--dim)"}),(0,ee.jsx)(wC,{label:"retry rate",value:wS(t.tasks.retryRate),color:t.tasks.retryRate>.2?"var(--red)":"var(--green)"})]}),(0,ee.jsxs)("div",{className:"flex gap-4 text-[12px] text-[var(--dim)]",children:[(0,ee.jsxs)("span",{children:["tasks: ",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:t.tasks.completed}),"/",t.tasks.total," done"]}),t.tasks.failed>0&&(0,ee.jsxs)("span",{children:["failed: ",(0,ee.jsx)("span",{className:"text-[var(--red)]",children:t.tasks.failed})]}),t.tasks.avgDurationMs>0&&(0,ee.jsxs)("span",{children:["avg: ",ww(t.tasks.avgDurationMs)]}),t.tasks.medianDurationMs>0&&(0,ee.jsxs)("span",{children:["median: ",ww(t.tasks.medianDurationMs)]}),t.tasks.p90DurationMs>0&&(0,ee.jsxs)("span",{children:["p90: ",ww(t.tasks.p90DurationMs)]})]}),t.tasks.byMilestone.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"milestones"}),(0,ee.jsx)("div",{className:"space-y-px",children:t.tasks.byMilestone.map(e=>{let t=e.taskCount>0?Math.round(e.completedCount/e.taskCount*100):0;return(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)]",children:[(0,ee.jsx)("span",{style:{color:wN[e.status]??"var(--dim)"},className:"w-6 shrink-0",children:e.id}),(0,ee.jsx)("span",{className:"text-[var(--fg)] w-32 truncate shrink-0",children:e.title}),(0,ee.jsx)("span",{style:{color:wN[e.status]??"var(--dim)"},className:"w-20 shrink-0",children:e.status}),(0,ee.jsx)(eo.ProgressBar,{percent:t,width:8}),(0,ee.jsxs)("span",{className:"text-[var(--dim)] text-[11px] shrink-0",children:[e.completedCount,"/",e.taskCount]}),e.durationMs>0&&(0,ee.jsx)("span",{className:"text-[var(--dim)] text-[11px]",children:ww(e.durationMs)})]},e.id)})})]}),t.agents.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"agents"}),(0,ee.jsx)("div",{className:"space-y-px",children:[...t.agents].sort((e,t)=>t.utilization-e.utilization).map(e=>(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)] text-[12px]",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] w-28 truncate shrink-0",children:e.name}),(0,ee.jsxs)("span",{className:"text-[var(--dim)] w-16 shrink-0",children:[e.taskCount," tasks"]}),(0,ee.jsx)("span",{className:"w-14 shrink-0",style:{color:e.utilization>=.5?"var(--green)":"var(--dim)"},children:wS(e.utilization)}),e.retryCount>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)] shrink-0",children:[e.retryCount," retries"]}),e.specialties.length>0&&(0,ee.jsx)("span",{className:"text-[var(--cyan)] text-[10px] truncate",children:e.specialties.join(", ")})]},e.name))})]}),t.mission.title&&(0,ee.jsxs)("div",{className:"flex gap-3 text-[12px]",children:[(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["mission: ",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:t.mission.title})," [",t.mission.status,"]"]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["milestones: ",t.mission.milestonesCompleted]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["validation:"," ",(0,ee.jsx)("span",{className:"text-[var(--green)]",children:wS(t.mission.validationPassRate)})]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["wall clock: ",ww(t.mission.wallClockMs)]})]}),t.timeline.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"timeline"}),(0,ee.jsx)("div",{className:"space-y-px max-h-48 overflow-auto",children:t.timeline.slice(-20).map((e,t)=>(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-2 py-0.5 bg-[var(--surface)] text-[11px] text-[var(--dim)]",children:[(0,ee.jsx)("span",{className:"w-20 shrink-0",children:new Date(e.timestamp).toLocaleTimeString()}),(0,ee.jsxs)("span",{children:["done:",(0,ee.jsx)("span",{className:"text-[var(--green)]",children:e.completedTasks})]}),(0,ee.jsxs)("span",{children:["active:",(0,ee.jsx)("span",{className:"text-[var(--yellow)]",children:e.activeTasks})]}),(0,ee.jsxs)("span",{children:["busy:",(0,ee.jsx)("span",{className:"text-[var(--accent)]",children:e.busyAgents})]}),(0,ee.jsxs)("span",{children:["idle:",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:e.idleAgents})]})]},t))})]})]})}function wE({sessionName:e}){let{data:t}=ei((0,et.useCallback)(()=>(0,er.fetchValidation)(e),[e]),3e3),{data:n}=ei((0,et.useCallback)(()=>(0,er.fetchCoverage)(e),[e]),5e3);if(!t)return(0,ee.jsx)("div",{className:"flex-1 p-4 text-[var(--dim)]",children:"no validation contract found"});let r=t.state?Object.entries(t.state.assertions):[];return(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto space-y-4",children:[t.contract&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"contract"}),(0,ee.jsx)("pre",{className:"text-[var(--fg)] text-[12px] whitespace-pre-wrap bg-[var(--surface)] p-2 border border-[var(--border)]",children:t.contract})]}),r.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"assertions"}),(0,ee.jsx)("div",{className:"space-y-px",children:r.map(([e,t])=>(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)]",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] w-32 shrink-0",children:e}),(0,ee.jsx)("span",{style:{color:wk[t.status]??"var(--dim)"},className:"w-16 shrink-0",children:t.status}),t.verifiedBy&&(0,ee.jsxs)("span",{className:"text-[var(--cyan)] text-[11px]",children:["@",t.verifiedBy]}),t.evidence&&(0,ee.jsx)("span",{className:"text-[var(--dim)] text-[11px] truncate",children:t.evidence})]},e))})]}),n&&(n.unclaimed.length>0||Object.keys(n.duplicates).length>0)&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"coverage"}),n.unclaimed.length>0&&(0,ee.jsxs)("div",{className:"text-[var(--yellow)] text-[12px]",children:["unclaimed: ",n.unclaimed.join(", ")]}),Object.entries(n.duplicates).map(([e,t])=>(0,ee.jsxs)("div",{className:"text-[var(--dim)] text-[12px]",children:[e,": claimed by tasks ",t.join(", ")]},e))]})]})}e.s(["default",()=>wx],36508)}]);
193
+ }`}}applyHunksToDOM(e,t){let{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i="wrap"===n?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let o=!1,s=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),c=this.hunksRenderer.renderCodeAST("additions",t);null!=a?(o=null==this.codeUnified||null!=this.codeAdditions||null!=this.codeDeletions,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=r8({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a),s.push(this.codeUnified)):null!=l||null!=c?(null!=l?(o=null==this.codeDeletions||null!=this.codeUnified,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=r8({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l),s.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),null!=c?(o=o||null==this.codeAdditions||null!=this.codeUnified,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=r8({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(c),s.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),0===s.length?e.textContent="":o&&e.replaceChildren(...s),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:o,options:{diffStyle:s="split"}}=this;if(null==n||null==e||null==t||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||null==this.lastRowCount)return!1;let a=this.getCodeColumns(s,r,o,i);if(null==a)return!1;let l=e.startingLine,c=t.startingLine,d=l+e.totalLines,u=c+t.totalLines,h=Math.max(l,c),p=Math.min(d,u);if(p<=h)return!1;let f=Math.max(0,h-l),m=Math.max(0,d-p),g=this.trimColumns({columns:a,trimStart:f,trimEnd:m,previousStart:l,overlapStart:h,overlapEnd:p,diffStyle:s});if(g<0)throw Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<g)throw Error("applyPartialRender: trimmed beyond DOM row count");let y=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0)&&null!=this.fileDiff)return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},b=v(c,Math.max(h-c,0));if(null==b&&c<h)return!1;let x=v(p,Math.max(u-p,0));if(null==x&&u>p)return!1;let k=(e,t)=>{if(null!=e){if("unified"!==s||Array.isArray(a))if("split"===s&&Array.isArray(a))this.insertPartialHTML(s,a,e,t);else throw Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");else this.insertPartialHTML(s,a,e,t);y+=e.rowCount}};return this.cleanupErrorWrapper(),k(b,"afterbegin"),k(x,"beforeend"),this.lastRowCount!==y&&(this.applyRowSpan(s,a,y),this.lastRowCount=y),!0}insertPartialHTML(e,t,n,r){if("unified"!==e||Array.isArray(t))if("split"===e&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST("deletions",n),i=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error("FileDiff.insertPartialHTML: Invalid argument composition");else{let e=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,e,r)}}renderPartialColumn(e,t,n){if(null==e||null==t)return;let r=lq(t[0]),i=lq(t[1]);if(null==r||null==i)throw Error("FileDiff.insertPartialHTML: Unexpected AST structure");let o=i.at(0);"beforeend"===n&&o?.type==="element"&&"number"==typeof o.properties["data-buffer-size"]&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let s=i.at(-1);"afterbegin"===n&&s?.type==="element"&&"number"==typeof s.properties["data-buffer-size"]&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,o){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let s=this.getBufferSize(t.dataset);null!=s&&(o?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,s+e),this.updateBufferSize(n,s+e))}applyRowSpan(e,t,n){let r=e=>{null!=e&&(e.gutter.style.setProperty("grid-row",`span ${n}`),e.content.style.setProperty("grid-row",`span ${n}`))};if("unified"!==e||Array.isArray(t))if("split"===e&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error("dun fuuuuked up");else r(t)}trimColumnRows(e,t,n){let r=0,i=0,o=0,s=!1,a=n>=0;if(null==e)return 0;let l=Array.from(e.content.children),c=Array.from(e.gutter.children);if(l.length!==c.length)throw Error("FileDiff.trimColumnRows: columns do not match");for(;o<l.length&&(!(t<=0)||a||s);){let e=c[o],d=l[o];if(o++,!(e instanceof HTMLElement)||!(d instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:d}),Error("FileDiff.trimColumnRows: invalid row elements");if(s&&(s=!1,"annotation"===e.dataset.gutterBuffer&&"lineAnnotation"in d.dataset||"metadata"===e.dataset.gutterBuffer&&"noNewline"in d.dataset)){e.remove(),d.remove(),i++;continue}if("lineIndex"in e.dataset&&"lineIndex"in d.dataset){(t>0||a&&r>=n)&&(e.remove(),d.remove(),t>0&&0==--t&&(s=!0),i++),r++;continue}if("separator"in e.dataset&&"separator"in d.dataset||"annotation"===e.dataset.gutterBuffer&&"lineAnnotation"in d.dataset||"metadata"===e.dataset.gutterBuffer&&"noNewline"in d.dataset){(t>0||a&&r>=n)&&(e.remove(),d.remove(),i++);continue}if("buffer"===e.dataset.gutterBuffer&&"contentBuffer"in d.dataset){let o=this.getBufferSize(d.dataset);if(null==o)throw Error("FileDiff.trimColumnRows: invalid element");if(t>0){let n=Math.min(t,o),r=o-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(d,r),i+=n):(e.remove(),d.remove(),i+=o),t-=n}else if(a){let t=r,s=r+o-1;if(n<=t)e.remove(),d.remove(),i+=o;else if(n<=s){let t=s-n+1,r=o-t;this.updateBufferSize(e,r),this.updateBufferSize(d,r),i+=t}}r+=o;continue}throw console.error({gutterElement:e,contentElement:d}),Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:o,trimStart:s}){let a=Math.max(0,r-i),l=n-i;if(l<0)throw Error("FileDiff.trimColumns: overlap ends before previous");let c=s>0,d=o>0;if(!c&&!d)return 0;let u=c?a:0,h=d?l:-1;if("unified"===t&&!Array.isArray(e))return this.trimColumnRows(e,u,h);if("split"===t&&Array.isArray(e)){let t=this.trimColumnRows(e[0],u,h),n=this.trimColumnRows(e[1],u,h);if(null!=e[0]&&null!=e[1]&&t!==n)throw Error("FileDiff.trimColumns: split columns out of sync");return null!=e[0]?t:n}throw console.error({diffStyle:t,columns:e}),Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(e){if(null==e)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&null!=t.dataset.gutter&&null!=n.dataset.content)return{gutter:t,content:n}}if("unified"===e)return i(t);{let e=i(n),t=i(r);return null!=e||null!=t?[e,t]:void 0}}applyBuffers(e,t){let{disableVirtualizationBuffers:n=!1}=this.options;if(n||null==t){null!=this.bufferBefore&&(this.bufferBefore.remove(),this.bufferBefore=void 0),null!=this.bufferAfter&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(null==this.bufferBefore&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):null!=this.bufferBefore&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(null==this.bufferAfter&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):null!=this.bufferAfter&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{themeStyles:t,baseThemeType:n,additionsContentAST:r,deletionsContentAST:i,totalLines:o},s){var a;let{diffIndicators:l="bars",disableBackground:c=!1,disableLineNumbers:d=!1,overflow:u="scroll",themeType:h="system",diffStyle:p="split"}=this.options,f={type:"diff",diffIndicators:l,disableBackground:c,disableLineNumbers:d,overflow:u,split:"unified"!==p&&null!=r&&null!=i,themeStyles:t,themeType:n??h,totalLines:o,customProperties:s};a=this.appliedPreAttributes,(null==f||null==a?f!==a:!function(e=r2,t=r2){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}(f.customProperties,a.customProperties)||f.type!==a.type||f.diffIndicators!==a.diffIndicators||f.disableBackground!==a.disableBackground||f.disableLineNumbers!==a.disableLineNumbers||f.overflow!==a.overflow||f.split!==a.split||f.themeStyles!==a.themeStyles||f.themeType!==a.themeType||f.totalLines!==a.totalLines)&&(!function(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:o,split:s,themeStyles:a,themeType:l,totalLines:c,customProperties:d}){if(null!=d)for(let t in d){let n=d[t];null!=n&&e.setAttribute(t,`${n}`)}switch("diff"===t?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),"system"===l?e.removeAttribute("data-theme-type"):e.setAttribute("data-theme-type",l),n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators")}i?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),r?e.removeAttribute("data-background"):e.setAttribute("data-background",""),"diff"===t?e.setAttribute("data-diff-type",s?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",o),e.tabIndex=0,e.style=a,e.style.setProperty("--diffs-min-number-column-width-default",`${`${c}`.length}ch`)}(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();let n=this.getOrCreatePreNode(t);n.innerHTML="",n.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let r=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.innerHTML="",r.appendChild(this.errorWrapper);let i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);let o=document.createElement("pre");o.dataset.errorStack="",o.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(o)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function lq(e){if(null!=e&&"element"===e.type)return e.children??[]}let lK=-1;var lJ=class extends lG{__id=`little-virtualized-file-diff:${++lK}`;top;height=0;metrics;heightCache=new Map;isVisible=!1;virtualizer;constructor(e,t,n,r,i=!1){super(e,r,i);const{hunkSeparators:o="line-info"}=this.options;this.virtualizer=t,this.metrics=function(e,t){let n={...nu,...t};return n.hunkSeparatorHeight=function(e,t){if(null!=t)return t;switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}(e,t?.hunkSeparatorHeight),n}("function"==typeof o?"custom":o,n)}getLineHeight(e,t=!1){let n=this.heightCache.get(e);return null!=n?n:this.metrics.lineHeight*(t?2:1)}setOptions(e){if(null==e)return;let t=this.options.diffStyle,n=this.options.overflow,r=this.options.collapsed;super.setOptions(e),(t!==this.options.diffStyle||n!==this.options.overflow||r!==this.options.collapsed)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){let{overflow:e="scroll"}=this.options;if(null!=this.fileContainer&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),null==this.fileContainer||null==this.fileDiff){this.height=0;return}if("scroll"===e&&0===this.lineAnnotations.length&&!this.virtualizer.config.resizeDebugging)return;let t=this.getDiffStyle(),n=!1;for(let e of"split"===t?[this.codeDeletions,this.codeAdditions]:[this.codeUnified]){if(null==e)continue;let r=e.children[1];if(r instanceof HTMLElement)for(let e of r.children){if(!(e instanceof HTMLElement))continue;let r=e.dataset.lineIndex;if(null==r)continue;let i=function(e,t){let[n,r]=e.split(",").map(Number);return"split"===t?r:n}(r,t),o=e.getBoundingClientRect().height,s=!1;e.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in e.nextElementSibling.dataset||"noNewline"in e.nextElementSibling.dataset)&&("noNewline"in e.nextElementSibling.dataset&&(s=!0),o+=e.nextElementSibling.getBoundingClientRect().height),o!==this.getLineHeight(i,s)&&(n=!0,o===this.metrics.lineHeight*(s?2:1)?this.heightCache.delete(i):this.heightCache.set(i,o))}}(n||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}onRender=e=>null!=this.fileContainer&&(e&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render());cleanUp(){null!=this.fileContainer&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)};setVisibility(e){null!=this.fileContainer&&(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){let e=0===this.height;if(this.height=0,null==this.fileDiff)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1,hunkSeparators:o="line-info"}=this.options,{diffHeaderHeight:s,fileGap:a,hunkSeparatorHeight:l}=this.metrics,c=this.getDiffStyle(),d="simple"!==o&&"metadata"!==o&&"line-info-basic"!==o?a:0;if(t?"simple"!==o&&"metadata"!==o&&(this.height+=a):this.height+=s,!r&&(ll({diff:this.fileDiff,diffStyle:c,expandedHunks:!!n||this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:n,deletionLine:r,additionLine:i})=>{let s=null!=i?i.splitLineIndex:r.splitLineIndex,a=null!=i?i.unifiedLineIndex:r.unifiedLineIndex,u=(i?.noEOFCR??!1)||(r?.noEOFCR??!1);t>0&&(e>0&&(this.height+=d),this.height+=l+d),this.height+=this.getLineHeight("split"===c?s:a,u),n>0&&"simple"!==o&&(this.height+=d+l)}}),this.fileDiff.hunks.length>0&&(this.height+=a),null!=this.fileContainer&&this.virtualizer.config.resizeDebugging&&!e)){let e=this.fileContainer.getBoundingClientRect();e.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,...i}={}){let o=null==this.fileContainer;if(this.fileDiff??=r??(null!=t&&null!=n?lW(t,n):void 0),e=this.getOrCreateFileContainer(e),null==this.fileDiff)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(o?(this.computeApproximateSize(),this.virtualizer.connect(e,this),this.top??=this.virtualizer.getOffsetInScrollContainer(e),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??=this.virtualizer.getOffsetInScrollContainer(e),!this.isVisible)return this.renderPlaceholder(this.height);let s=this.virtualizer.getWindowSpecs(),a=this.computeRenderRangeFromWindow(this.fileDiff,this.top,s);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:a,oldFile:t,newFile:n,...i})}getDiffStyle(){return this.options.diffStyle??"split"}getExpandedRegion(e,t,n){if(n<=0||e)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(n,0),renderAll:!1};let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;if(r||n<=i)return{fromStart:n,fromEnd:0,collapsedLines:0,renderAll:!0};let o=this.hunksRenderer.getExpandedHunk(t),s=Math.min(Math.max(o.fromStart,0),n),a=Math.min(Math.max(o.fromEnd,0),n),l=s+a;return{fromStart:s,fromEnd:a,collapsedLines:Math.max(n-l,0),renderAll:l>=n}}getExpandedLineCount(e,t){var n;let r,i=0;if(e.isPartial){for(let n of e.hunks)i+="split"===t?n.splitLineCount:n.unifiedLineCount;return i}for(let[n,r]of e.hunks.entries()){i+="split"===t?r.splitLineCount:r.unifiedLineCount;let o=Math.max(r.collapsedBefore,0),{fromStart:s,fromEnd:a,renderAll:l}=this.getExpandedRegion(e.isPartial,n,o);o>0&&(i+=l?o:s+a)}let o=e.hunks.at(-1);if(null!=o&&null!=(r=(n=e).hunks.at(-1))&&!n.isPartial&&0!==n.additionLines.length&&0!==n.deletionLines.length&&(r.additionLineIndex+r.additionCount<n.additionLines.length||r.deletionLineIndex+r.deletionCount<n.deletionLines.length)){let t=e.additionLines.length-(o.additionLineIndex+o.additionCount),n=e.deletionLines.length-(o.deletionLineIndex+o.deletionCount);if(null!=o&&t!==n)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${e.name}`);let r=Math.min(t,n);if(null!=o&&r>0){let{fromStart:t,renderAll:n}=this.getExpandedRegion(e.isPartial,e.hunks.length,r);i+=n?r:t}}return i}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let i,o,s,{disableFileHeader:a=!1,expandUnchanged:l=!1,collapsedContextThreshold:c=1,hunkSeparators:d="line-info"}=this.options,{diffHeaderHeight:u,fileGap:h,hunkLineCount:p,hunkSeparatorHeight:f,lineHeight:m}=this.metrics,g=this.getDiffStyle(),y=this.height,v=this.getExpandedLineCount(e,g),b=a?h:u;if(t<n-y||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:y-b-h};if(v<=p||0===e.hunks.length)return{startingLine:0,totalLines:p,bufferBefore:0,bufferAfter:0};let x=Math.ceil(Math.ceil(Math.max(r-n,0)/m)/p)*p+p,k=x/p,w=[],S=(n+r)/2,C="simple"===d||"metadata"===d||"line-info-basic"===d?0:h,N=t+b,A=0;if(ll({diff:e,diffStyle:g,expandedHunks:!!l||this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:c,callback:({hunkIndex:e,collapsedBefore:a,collapsedAfter:l,deletionLine:c,additionLine:u})=>{let h=null!=u?u.splitLineIndex:c.splitLineIndex,m=null!=u?u.unifiedLineIndex:c.unifiedLineIndex,y=(u?.noEOFCR??!1)||(c?.noEOFCR??!1),v=a>0?f+C+(e>0?C:0):0;0===e&&"simple"===d&&(v=0),N+=v;let x=A%p==0;if(x&&(w.push(N-(t+b+v)),null!=s)){if(s<=0)return!0;s--}let E=this.getLineHeight("split"===g?h:m,y),M=Math.floor(A/p);return N>n-E&&N<r&&(i??=M),null==o&&N+E>S&&(o=M),null==s&&N>=r&&x&&(s=k),A++,N+=E,l>0&&"simple"!==d&&(N+=f+C),!1}}),null==i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:y-b-h};let E=w.length,M=Math.round((o??=i)-k/2),T=Math.max(0,Math.min(M,Math.max(0,E-k))),I=M<0?x+M*p:x,L=w[T]??0,O=T+I/p;return{startingLine:T*p,totalLines:I,bufferBefore:L,bufferAfter:O<w.length?y-b-w[O]-h:y-(N-t)-h}}};let lX=new Set,lY=new Set,lQ=null,lZ=!1;function l0(e){lZ?lX.add(e):(lY.add(e),lQ??=requestAnimationFrame(l1))}function l1(e){for(let t of(lZ=!0,lY))try{t(e)}catch(e){console.error(e)}lY.clear(),lX.size>0?(lY=new Set(lX),lX.clear(),lQ=requestAnimationFrame(l1)):lQ=null,lZ=!1}function l2({scrollTop:e,scrollHeight:t,height:n,containerOffset:r=0,fitPerfectly:i,overscrollSize:o}){let s=n+2*o,a=i?n:s;if(s>=(t=Math.max(t,a))||i){let n=Math.max(e-r,0);return{top:n,bottom:Math.max(Math.min(e+a,t)-r,n)}}let l=e+n/2-s/2,c=l+s;return l<0&&(l=0),c>t&&(c=t),{top:l=Math.floor(Math.max(l-r,0)),bottom:Math.ceil(Math.max(Math.min(c,t)-r,l))}}let l8=[0,1e-6,.99999,1],l5={overscrollSize:1e3,intersectionObserverMargin:4e3,resizeDebugging:!1},l6=0,l3=-1;function l4(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}(class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++l3}`;config;type="basic";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...l5,...e}}setup(t,n){if(null==this.root){for(let[r,i]of(this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:l8,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),l0(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)},this.connectQueue.entries()))this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)}}instanceChanged(e){this.instancesChanged.add(e),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)}getWindowSpecs(){return 0===this.windowSpecs.top&&0===this.windowSpecs.bottom&&(this.windowSpecs=l2({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin;return!(e<n-i-t||e>n+r+i)}handleContainerResize=e=>{if(null==this.root)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:e-l6,newSize:e}),l6=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:e-l6,newSize:e}),l6=e))}t&&l0(this.computeRenderRangeAndEmit)};setupWindow(){if(null==this.root||!(this.root instanceof Document))throw Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(null==this.root||this.root instanceof Document)throw Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),(e??=this.root.firstElementChild??void 0)instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+l4(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error("Virtualizer.connect: instance is already connected...");return null==this.intersectionObserver?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),null!=t&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),l0(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,l0(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{!e.__STOP&&null!=this.root&&this.root instanceof Document&&(this.scrollDirty=!0,l0(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||null==this.root||this.root instanceof Document||(this.scrollDirty=!0,l0(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&0===this.instancesChanged.size)return;if(0===this.instancesChanged.size){var n;let e=l2({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize});if(n=this.windowSpecs,(null==n||null==e?n===e:n.top===e.top&&n.bottom===e.bottom)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&0===this.instancesChanged.size)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let r=this.getScrollAnchor(this.height),i=new Set;for(let e of t?this.observers.values():this.visibleInstances.values())e.onRender(t)&&i.add(e);for(let e of this.instancesChanged)!i.has(e)&&e.onRender(t)&&i.add(e);for(let e of(this.scrollFix(r),this.instancesChanged.size>0&&this.markDOMDirty(),i))e.reconcileHeights();(this.instancesChanged.size>0||t)&&l0(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(null==e)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:o,fileTypeOffset:s}=e;if(null!=n&&null!=r){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=l4(e,t);n!==r&&this.applyScrollFix(n-r);return}}let a=l4(i,t);if("top"===s)a!==o&&this.applyScrollFix(a-o);else{let e=a+i.getBoundingClientRect().height;e!==o&&this.applyScrollFix(e-o)}}applyScrollFix(e){null==this.root||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){let t,n=this.getScrollContainerElement();for(let[r]of this.visibleInstances.entries()){let i,o,s,a,l=l4(r,n),c=l+r.offsetHeight;if(c<=0?(i=c,o="bottom"):(i=l,o="top"),c>0&&l<e)for(let e of r.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(e instanceof HTMLElement))continue;let t=e.dataset.lineIndex;if(null==t)continue;let r=l4(e,n);if(!(r<0)){s=t,a=r;break}}if(t?.lineOffset!=null&&null==a)continue;let d=!1;null==t||null!=a&&(null==t.lineOffset||a<t.lineOffset)?d=!0:null==a&&null==t.lineOffset&&(i>=0&&(t.fileOffset<0||i<t.fileOffset)?d=!0:i<0&&t.fileOffset<0&&i>t.fileOffset&&(d=!0)),d&&(t={fileElement:r,fileTypeOffset:o,fileOffset:i,lineIndex:s,lineOffset:a})}return t}handleIntersectionChange=e=>{for(let{target:t,isIntersecting:n}of(this.scrollDirty=!0,e)){if(!(t instanceof HTMLElement))throw Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");let e=this.observers.get(t);if(null==e)throw Error("Virtualizer.handleIntersectionChange: no instance for target");n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0)}this.visibleInstancesDirty&&l0(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=null==this.root?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty&&(this.scrollHeightDirty=!1,this.scrollHeight=null==this.root?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight),this.scrollHeight}getHeight(){return this.heightDirty&&(this.heightDirty=!1,this.height=null==this.root?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height),this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return null==this.root||this.root instanceof Document?void 0:this.root}});let l7=(0,et.createContext)(void 0);e.i(4135),Symbol("IGNORE_RESPONSE");let l9=(0,et.createContext)(void 0),ce="u"<typeof window?et.useEffect:et.useLayoutEffect;function ct(e,t){return t?{...e,renderGutterUtility:nk}:e}function cn({patch:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:o,style:s,prerenderedHTML:a,renderAnnotation:l,renderHeaderPrefix:c,renderHeaderMetadata:d,renderGutterUtility:u,renderHoverUtility:h}){var p,f;let m=(f=e,(0,et.useMemo)(()=>(function(e){let t=function(e,t,n=!1){let r=[];for(let t of e.split(t4))try{r.push(function(e,t,n=!1){let r,i=t7.test(e),o=e.split(i?t7:t9),s=[];for(let e of o){if(i&&!t7.test(e)||!i&&!t9.test(e)){if(null==r)r=e;else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",e);continue}let o=ng(e,{cacheKey:null!=t?`${t}-${s.length}`:void 0,isGitDiff:i,throwOnError:n});null!=o&&s.push(o)}return{patchMetadata:r,files:s}}(t,void 0,n))}catch(e){if(n)throw e;console.error(e)}return r}(e);if(1!==t.length)throw console.error(t),Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");let{files:n}=t[0];if(1!==n.length)throw console.error(n),Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]})(f),[f])),{ref:g,getHoveredLine:y}=function({oldFile:e,newFile:t,fileDiff:n,options:r,lineAnnotations:i,selectedLines:o,prerenderedHTML:s,metrics:a,hasGutterRenderUtility:l}){var c;let d,u=(0,et.useContext)(l7),h=(0,et.useContext)(l9),p=(0,et.useRef)(null),f=(c=o=>{if(null!=o){if(null!=p.current)throw Error("useFileDiffInstance: An instance should not already exist when a node is created");null!=u?p.current=new lJ(ct(r,l),u,a,h,!0):p.current=new lG(ct(r,l),h,!0),p.current.hydrate({fileDiff:n,oldFile:e,newFile:t,fileContainer:o,lineAnnotations:i,prerenderedHTML:s})}else{if(null==p.current)throw Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");p.current.cleanUp(),p.current=null}},d=(0,et.useRef)(c),(0,et.useInsertionEffect)(()=>void(d.current=c)),(0,et.useCallback)((...e)=>d.current(...e),[]));return ce(()=>{var s;let{current:a}=p;if(null==a)return;let c=ct(r,l),d=(s=a.options,!(le(s?.theme??nc,c?.theme??nc)&&function(e,t,n){if(e===t||null==e||null==t)return e===t;let r=new Set(n),i=Object.keys(e),o=new Set(Object.keys(t));for(let n of i)if(o.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(o))if(!r.has(e))return!1;return!0}(s,c,["theme"])));a.setOptions(c),a.render({forceRender:d,fileDiff:n,oldFile:e,newFile:t,lineAnnotations:i}),void 0!==o&&a.setSelectedLines(o)}),{ref:f,getHoveredLine:(0,et.useCallback)(()=>p.current?.getHoveredLine(),[])}}({fileDiff:m,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,hasGutterRenderUtility:null!=u||null!=h});return(0,ee.jsx)(t3,{ref:g,className:o,style:s,children:(p=function({fileDiff:e,actions:t,deletionFile:n,additionFile:r,renderHeaderPrefix:i,renderHeaderMetadata:o,renderAnnotation:s,renderGutterUtility:a,renderHoverUtility:l,renderMergeConflictUtility:c,lineAnnotations:d,getHoveredLine:u,getInstance:h}){let p=a??l,f=i?.({fileDiff:e,deletionFile:n,additionFile:r}),m=o?.({fileDiff:e,deletionFile:n,additionFile:r});return(0,ee.jsxs)(ee.Fragment,{children:[null!=f&&(0,ee.jsx)("div",{slot:na,children:f}),null!=m&&(0,ee.jsx)("div",{slot:nl,children:m}),null!=s&&d?.map((e,t)=>(0,ee.jsx)("div",{slot:nv(e),children:s(e)},t)),null!=t&&null!=c&&null!=h&&t.map(e=>{let t=function(e){let t=null!=e.incomingLineNumber?{side:"additions",lineNumber:e.incomingLineNumber}:null!=e.currentLineNumber?{side:"deletions",lineNumber:e.currentLineNumber}:void 0;return null!=t?function({side:e,lineNumber:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}({...t,conflictIndex:e.conflictIndex}):void 0}(e);return(0,ee.jsx)("div",{slot:t,style:nx,children:c(e,h)},t)}),null!=p&&(0,ee.jsx)("div",{slot:"gutter-utility-slot",style:nb,children:p(u)})]})}({fileDiff:m,renderHeaderPrefix:c,renderHeaderMetadata:d,renderAnnotation:l,lineAnnotations:r,renderGutterUtility:u,renderHoverUtility:h,getHoveredLine:y}),"u"<typeof window&&null!=a?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("template",{shadowrootmode:"open",dangerouslySetInnerHTML:{__html:a}}),p]}):(0,ee.jsx)(ee.Fragment,{children:p}))})}var cr=et,ci=e.i(21957);class co extends cr.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}function cs({patch:e,diffStyle:t="split",preloaded:n}){let[r,i]=(0,cr.useState)(!1),{theme:o}=(0,ci.useTheme)(),s="light"!==o;if(!e.trim())return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No changes"});let a=e.split("\n"),l=a.length>2e3&&!r,c=l?a.slice(0,2e3).join("\n"):e;return(0,ee.jsxs)("div",{className:"flex-1 overflow-auto",children:[l&&(0,ee.jsxs)("div",{className:"px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex items-center justify-between",children:[(0,ee.jsxs)("span",{className:"text-[var(--yellow)]",children:["showing first ",2e3," of ",a.length," lines"]}),(0,ee.jsx)("button",{onClick:()=>i(!0),className:"text-[var(--accent)] hover:underline",children:"show all"})]}),(0,ee.jsx)(co,{fallback:(0,ee.jsx)(ca,{patch:c}),children:(0,ee.jsx)(cr.Suspense,{fallback:(0,ee.jsx)(ca,{patch:c}),children:n?(0,ee.jsx)(cn,{patch:c,...n,className:"diff-container"}):(0,ee.jsx)(cn,{patch:c,options:{theme:s?"pierre-dark":"pierre-light",diffStyle:t,diffIndicators:"bars",overflow:"scroll",themeType:s?"dark":"light"},className:"diff-container"})})})]})}function ca({patch:e}){let t=e.split("\n").slice(0,500);return(0,ee.jsxs)("div",{className:"flex-1 overflow-auto p-4 font-mono text-xs leading-relaxed",children:[t.map((e,t)=>{let n="var(--fg)",r="var(--bg)";return e.startsWith("+")&&!e.startsWith("+++")?(n="var(--diff-add-text)",r="var(--diff-add-bg)"):e.startsWith("-")&&!e.startsWith("---")?(n="var(--diff-del-text)",r="var(--diff-del-bg)"):e.startsWith("@@")?n="var(--cyan)":(e.startsWith("diff ")||e.startsWith("index "))&&(n="var(--dim)"),(0,ee.jsx)("div",{style:{color:n,background:r,whiteSpace:"pre"},children:e||" "},t)}),t.length>=500&&(0,ee.jsx)("div",{style:{color:"var(--yellow)",padding:"8px 0"},children:"... truncated at 500 lines"})]})}function cl({files:e,selectedFile:t,onSelectFile:n}){return 0===e.length?(0,ee.jsx)("div",{className:"text-[var(--dim)] px-2 py-4",children:"No changed files"}):(0,ee.jsxs)("div",{children:[(0,ee.jsxs)("button",{onClick:()=>n(null),className:`w-full flex items-center h-6 px-2 text-left transition-colors ${null===t?"bg-[var(--surface-active)] text-[var(--accent)]":"text-[var(--dim)] hover:bg-[var(--surface-hover)] hover:text-[var(--fg)]"}`,children:[(0,ee.jsx)("span",{className:"flex-1 truncate",children:"All files"}),(0,ee.jsx)("span",{className:"shrink-0 text-[var(--dim)]",children:e.length})]}),e.map(e=>{let r=e.file.split("/").pop()??e.file,i=e.file.includes("/")?e.file.slice(0,e.file.lastIndexOf("/")+1):"",o=t===e.file;return(0,ee.jsxs)("button",{onClick:()=>n(e.file),className:`w-full flex items-center h-6 px-2 text-left transition-colors ${o?"bg-[var(--surface-active)]":"hover:bg-[var(--surface-hover)]"}`,children:[(0,ee.jsxs)("span",{className:"flex-1 min-w-0 truncate",children:[i&&(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:i}),(0,ee.jsx)("span",{className:o?"text-[var(--accent)]":"text-[var(--fg)]",children:r})]}),(0,ee.jsxs)("span",{className:"shrink-0 flex gap-1.5 ml-2",children:[e.additions>0&&(0,ee.jsxs)("span",{className:"text-[var(--green)]",children:["+",e.additions]}),e.deletions>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["-",e.deletions]})]})]},e.file)})]})}function cc({sessionName:e}){let{data:t,loading:n}=ei((0,et.useCallback)(()=>(0,er.fetchDiff)(e),[e]),5e3),[r,i]=(0,et.useState)(null),[o,s]=(0,et.useState)(""),[a,l]=(0,et.useState)("split"),[c,d]=(0,et.useState)(!1);(0,et.useEffect)(()=>{r?(d(!0),(0,er.fetchFileDiff)(e,r).then(e=>s(e)).catch(()=>s("")).finally(()=>d(!1))):s("")},[r,e]);let u=r?o:"";if(n&&!t)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Loading diffs…"});if(!t||!t.diff.trim())return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No uncommitted changes"});let h=t.files.reduce((e,t)=>e+t.additions,0),p=t.files.reduce((e,t)=>e+t.deletions,0);return(0,ee.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,ee.jsxs)("div",{className:"flex items-center h-7 px-3 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[t.files.length," file",1!==t.files.length?"s":""," changed"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--green)]",children:["+",h]}),(0,ee.jsx)("span",{className:"mx-1 text-[var(--dim)] opacity-30",children:"/"}),(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["-",p]}),(0,ee.jsx)("span",{className:"flex-1"}),(0,ee.jsxs)("div",{className:"flex border border-[var(--border)] rounded overflow-hidden",children:[(0,ee.jsx)("button",{onClick:()=>l("split"),className:`px-2 h-5 text-[11px] transition-colors ${"split"===a?"bg-[var(--surface-active)] text-[var(--fg)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"split"}),(0,ee.jsx)("button",{onClick:()=>l("unified"),className:`px-2 h-5 text-[11px] transition-colors ${"unified"===a?"bg-[var(--surface-active)] text-[var(--fg)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"unified"})]})]}),(0,ee.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,ee.jsx)("div",{className:"w-[260px] shrink-0 border-r border-[var(--border)] overflow-y-auto",children:(0,ee.jsx)(cl,{files:t.files,selectedFile:r,onSelectFile:i})}),r&&u?(0,ee.jsx)(cs,{patch:u,diffStyle:a}):c?(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"loading diff..."}):(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"select a file to view diff"})]})]})}let cd={dispatch:{icon:">",color:"var(--accent)"},completion:{icon:"✓",color:"var(--green)"},stall:{icon:"!",color:"var(--yellow)"},retry:{icon:"~",color:"var(--yellow)"},reconcile:{icon:"×",color:"var(--red)"},error:{icon:"✗",color:"var(--red)"},task_created:{icon:"+",color:"var(--dim)"},status_change:{icon:"—",color:"var(--dim)"}},cu={icon:"·",color:"var(--dim)"};function ch({events:e,maxEvents:t=50}){let n=(0,et.useRef)(null),r=(0,et.useRef)(0);if((0,et.useEffect)(()=>{e.length>r.current&&n.current&&(n.current.scrollTop=0),r.current=e.length},[e.length]),0===e.length)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No activity yet"});let i=e.filter(e=>"agent_heartbeat"!==e.type).slice(0,t);return(0,ee.jsx)("div",{ref:n,className:"flex-1 overflow-y-auto py-1",children:i.map((e,t)=>{let{icon:n,color:r}=cd[e.type]??cu;return(0,ee.jsxs)("div",{className:"flex items-start h-6 px-3 hover:bg-[var(--surface-hover)]",children:[(0,ee.jsx)("span",{className:"w-[10ch] shrink-0 text-right text-[var(--dim)] pr-2",children:e.relative??""}),(0,ee.jsx)("span",{className:"w-3 shrink-0 text-center",style:{color:r},children:n}),(0,ee.jsx)("span",{className:"flex-1 truncate pl-1 text-[var(--fg)]",children:function(e){if(e.message)return e.message;let t=[];return e.agent&&t.push(e.agent),"dispatch"===e.type&&t.push("dispatched"),"completion"===e.type&&t.push("completed"),"stall"===e.type&&t.push("stalled on"),"retry"===e.type&&t.push("retrying"),"reconcile"===e.type&&t.push("released"),e.taskId&&t.push(`task ${e.taskId}`),t.join(" ")}(e)})]},`${e.timestamp}-${t}`)})})}function cp(){}function cf(){}let cm=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cg=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cy={};function cv(e,t){return((t||cy).jsx?cg:cm).test(e)}let cb={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var cx=e.i(63185);let ck=cS("end"),cw=cS("start");function cS(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function cC(e){return e&&"object"==typeof e?"position"in e||"type"in e?cA(e.position):"start"in e||"end"in e?cA(e):"line"in e||"column"in e?cN(e):"":""}function cN(e){return cE(e&&e.line)+":"+cE(e&&e.column)}function cA(e){return cN(e&&e.start)+"-"+cN(e&&e.end)}function cE(e){return e&&"number"==typeof e?e:1}class cM extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=s?s.line:void 0,this.name=cC(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}cM.prototype.file="",cM.prototype.name="",cM.prototype.reason="",cM.prototype.message="",cM.prototype.stack="",cM.prototype.column=void 0,cM.prototype.line=void 0,cM.prototype.ancestors=void 0,cM.prototype.cause=void 0,cM.prototype.fatal=void 0,cM.prototype.place=void 0,cM.prototype.ruleId=void 0,cM.prototype.source=void 0;let cT={}.hasOwnProperty,cI=new Map,cL=/[A-Z]/g,cO=new Set(["table","tbody","thead","tfoot","tr"]),cD=new Set(["td","th"]),cR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cP(e,t,n){var r,i,o,s,a,l,c,d,u;let h,p,f,m,g,y,v,b,x,k,w;return"element"===t.type?(r=e,i=t,o=n,p=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=n1),r.ancestors.push(i),f=cz(r,i.tagName,!1),m=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&cT.call(t.properties,r)){let o=function(e,t,n){let r=ry(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?rp(n):rx(n)),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,cx.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new cM("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=cR+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)cT.call(e,t)&&(n[function(e){let t=e.replace(cL,cF);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?cb[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(o){let[r,s]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof s&&cD.has(t.tagName)?n=s:i[r]=s}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),g=cB(r,i),cO.has(i.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!rw(e)})),c_(r,m,f,i),cj(m,g),r.ancestors.pop(),r.schema=h,r.create(i,f,m,o)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return cp("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}c$(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(s=e,a=t,l=n,v=y=s.schema,"svg"===a.name&&"html"===y.space&&(s.schema=n1),s.ancestors.push(a),b=null===a.name?s.Fragment:cz(s,a.name,!0),x=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];cp("ExpressionStatement"===t.type);let i=t.expression;cp("ObjectExpression"===i.type);let o=i.properties[0];cp("SpreadElement"===o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else c$(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];cp("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else c$(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}(s,a),k=cB(s,a),c_(s,x,b,a),cj(x,k),s.ancestors.pop(),s.schema=y,s.create(a,b,x,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);c$(e,t.position)}(e,t):"root"===t.type?(c=e,d=t,u=n,cj(w={},cB(c,d)),c.create(d,c.Fragment,w,u)):"text"===t.type?t.value:void 0}function c_(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function cj(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function cB(e,t){let n=[],r=-1,i=e.passKeys?new Map:cI;for(;++r<t.children.length;){let o,s=t.children[r];if(e.passKeys){let e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let a=cP(e,s,o);void 0!==a&&n.push(a)}return n}function cz(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=cv(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}cp(e,"always a result"),r=e}else r=cv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return cT.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);c$(e)}function c$(e,t){let n=new cM("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=cR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function cF(e){return"-"+e.toLowerCase()}let cU={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},cH={};function cW(e,t){let n=t||cH;return cV(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function cV(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return cG(e.children,t,n)}return Array.isArray(e)?cG(e,t,n):""}function cG(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=cV(e[i],t,n);return r.join("")}function cq(e,t,n,r){let i,o=e.length,s=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s<r.length;)(i=r.slice(s,s+1e4)).unshift(t,0),e.splice(...i),s+=1e4,t+=1e4}function cK(e,t){return e.length>0?(cq(e,e.length,0,t),e):t}let cJ={}.hasOwnProperty,cX=c7(/[A-Za-z]/),cY=c7(/[\dA-Za-z]/),cQ=c7(/[#-'*+\--9=?A-Z^-~]/);function cZ(e){return null!==e&&(e<32||127===e)}let c0=c7(/\d/),c1=c7(/[\dA-Fa-f]/),c2=c7(/[!-/:-@[-`{-~]/);function c8(e){return null!==e&&e<-2}function c5(e){return null!==e&&(e<0||32===e)}function c6(e){return -2===e||-1===e||32===e}let c3=c7(/\p{P}|\p{S}/u),c4=c7(/\s/);function c7(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function c9(e,t,n,r){let i=r?r-1:1/0,o=0;return function(r){return c6(r)?(e.enter(n),function r(s){return c6(s)&&o++<i?(e.consume(s),r):(e.exit(n),t(s))}(r)):t(r)}}let de={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return c8(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},dt={tokenize:function(e){let t,n,r,i=this,o=[],s=0;return a;function a(t){if(s<o.length){let n=o[s];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(s++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&y();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}g(s);let a=r;for(;a<i.events.length;)i.events[a][1].end={...n},a++;return cq(i.events,o+1,0,i.events.slice(r)),i.events.length=a,c(e)}return a(e)}function c(n){if(s===o.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return f(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(dn,d,u)(n)}function d(e){return t&&y(),g(s),h(e)}function u(e){return i.parser.lazy[i.now().line]=s!==o.length,r=i.now().offset,f(e)}function h(t){return i.containerState={},e.attempt(dn,p,f)(t)}function p(e){return s++,o.push([i.currentConstruct,i.containerState]),h(e)}function f(r){if(null===r){t&&y(),g(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){m(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return c8(n)?(e.consume(n),m(e.exit("chunkFlow")),s=0,i.interrupt=void 0,a):(e.consume(n),t)}(r)}function m(e,o){let a=i.sliceStream(e);if(o&&a.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(a),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let a=i.events.length,l=a;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(g(s),o=a;o<i.events.length;)i.events[o][1].end={...n},o++;cq(i.events,l+1,0,i.events.slice(a)),i.events.length=o}}function g(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function y(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},dn={tokenize:function(e,t,n){return c9(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},dr={partial:!0,tokenize:function(e,t,n){return function(t){return c6(t)?c9(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||c8(e)?t(e):n(e)}}};class di{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&ds(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ds(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ds(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);ds(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);ds(this.left,t.reverse())}}}function ds(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function da(e){let t,n,r,i,o,s,a,l={},c=-1,d=new di(e);for(;++c<d.length;){for(;c in l;)c=l[c];if(t=d.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&((r=0)<(s=t[1]._tokenizer.events).length&&"lineEndingBlank"===s[r][1].type&&(r+=2),r<s.length&&"content"===s[r][1].type))for(;++r<s.length&&"content"!==s[r][1].type;)"chunkText"===s[r][1].type&&(s[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],s=t-1,a=[],l=i._tokenizer;!l&&(l=o.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,d=[],u={},h=-1,p=i,f=0,m=0,g=[0];for(;p;){for(;e.get(++s)[1]!==p;);a.push(s),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&l.defineSkip(p.start),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(m=h+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(l.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),h=g.length;h--;){let t=c.slice(g[h],g[h+1]),n=a.pop();d.push([n,n+t.length-1]),e.splice(n,2,t)}for(d.reverse(),h=-1;++h<d.length;)u[f+d[h][0]]=f+d[h][1],f+=d[h][1]-d[h][0]-1;return u}(d,c)),c=l[c],a=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=d.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...d.get(n)[1].start},(o=d.slice(n,c)).unshift(t),d.splice(n,c-n+1,o))}}return cq(e,0,1/0,d.slice(0)),!a}let dl={resolve:function(e){return da(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):c8(t)?e.check(dc,o,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},dc={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,i,"linePrefix")};function i(i){if(null===i||c8(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},dd={tokenize:function(e){let t=this,n=e.attempt(dr,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,c9(e,e.attempt(this.parser.constructs.flow,r,e.attempt(dl,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},du={resolveAll:dm()},dh=df("string"),dp=df("text");function df(e){return{resolveAll:dm("text"===e?dg:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,s);return o;function o(e){return l(e)?i(e):s(e)}function s(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),a)}function a(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function dm(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function dg(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),s=o.length,a=-1,l=0;for(;s--;){let e=o[s];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)l++,a--;if(a)break;a=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let o={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:i.start._bufferIndex+a,_index:i.start._index+s,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}function dy(e){return null===e||c5(e)||c4(e)?1:c3(e)?2:void 0}function dv(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let db={name:"attention",resolveAll:function(e,t){let n,r,i,o,s,a,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},h={...e[d][1].start};dx(u,-a),dx(h,a),o={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},s={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},i={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:a>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[n][1].end={...o.start},e[d][1].start={...s.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=cK(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=cK(l,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),l=cK(l,dv(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=cK(l,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=cK(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,cq(e,n-1,d-n+3,l),d=n+l.length-c-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=dy(i);return function(s){return n=s,e.enter("attentionSequence"),function s(a){if(a===n)return e.consume(a),s;let l=e.exit("attentionSequence"),c=dy(a),d=!c||2===c&&o||r.includes(a),u=!o||2===o&&c||r.includes(i);return l._open=!!(42===n?d:d&&(o||!u)),l._close=!!(42===n?u:u&&(c||!d)),t(a)}(s)}}};function dx(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let dk={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return c6(t)?c9(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(dk,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return c6(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},dw={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return c2(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},dS=document.createElement("i");function dC(e){let t="&"+e+";";dS.innerHTML=t;let n=dS.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let dN={name:"characterReference",tokenize:function(e,t,n){let r,i,o=this,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=cY,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=c1,c):(e.enter("characterReferenceValue"),r=7,i=c0,c(t))}function c(a){if(59===a&&s){let r=e.exit("characterReferenceValue");return i!==cY||dC(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return i(a)&&s++<r?(e.consume(a),c):n(a)}}},dA={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},dE={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s};function s(t){return e.enter("codeFencedFence"),c6(t)?c9(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(o++,e.consume(i),t):o>=a?(e.exit("codeFencedFenceSequence"),c6(i)?c9(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||c8(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},s=0,a=0;return function(t){var o;let c;return o=t,s=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a<3?n(i):(e.exit("codeFencedFenceSequence"),c6(i)?c9(e,l,"whitespace")(i):l(i))}(o)};function l(o){return null===o||c8(o)?(e.exit("codeFencedFence"),i.interrupt?t(o):e.check(dA,d,f)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||c8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):c6(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c9(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(o))}function c(t){return null===t||c8(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||c8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function d(t){return e.attempt(o,f,u)(t)}function u(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return s>0&&c6(t)?c9(e,p,"linePrefix",s+1)(t):p(t)}function p(t){return null===t||c8(t)?e.check(dA,d,f)(t):(e.enter("codeFlowValue"),function t(n){return null===n||c8(n)?(e.exit("codeFlowValue"),p(n)):(e.consume(n),t)}(t))}function f(n){return e.exit("codeFenced"),t(n)}}},dM={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),c9(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?o(n):c8(n)?e.attempt(dT,t,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||c8(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function o(n){return e.exit("codeIndented"),t(n)}}},dT={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):c9(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):c8(e)?i(e):n(e)}}};function dI(e,t,n,r,i,o,s,a,l){let c=l||1/0,d=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),u):null===t||32===t||41===t||cZ(t)?n(t):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),f(t))};function u(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),u(t)):null===t||60===t||c8(t)?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(i){return!d&&(null===i||41===i||c5(i))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(i)):d<c&&40===i?(e.consume(i),d++,f):41===i?(e.consume(i),d--,f):null===i||32===i||40===i||cZ(i)?n(i):(e.consume(i),92===i?m:f)}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function dL(e,t,n,r,i,o){let s,a=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),c};function c(u){return l>999||null===u||91===u||93===u&&!s||94===u&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):93===u?(e.exit(o),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):c8(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||c8(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),s||(s=!c6(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function dO(e,t,n,r,i,o){let s;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),s=40===t?41:t,a):n(t)};function a(n){return n===s?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),l(n))}function l(t){return t===s?(e.exit(o),a(s)):null===t?n(t):c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c9(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||c8(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===s||92===t?(e.consume(t),c):c(t)}}function dD(e,t){let n;return function r(i){return c8(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):c6(i)?c9(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function dR(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let dP={partial:!0,tokenize:function(e,t,n){return function(t){return c5(t)?dD(e,r)(t):n(t)};function r(t){return dO(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return c6(t)?c9(e,o,"whitespace")(t):o(t)}function o(e){return null===e||c8(e)?t(e):n(e)}}},d_=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],dj=["pre","script","style","textarea"],dB={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(dr,t,n)}}},dz={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return c8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},d$={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&cq(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,o,s=e.length,a=0;for(;s--;)if(n=e[s][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[s][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[s][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=s,"labelLink"!==n.type)){a=2;break}}else"labelEnd"===n.type&&(i=s);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[r+a+2][1].end},end:{...e[i-2][1].start}};return o=cK(o=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+a+3)),o=cK(o,[["enter",d,t]]),o=cK(o,dv(t.parser.constructs.insideSpan.null,e.slice(r+a+4,i-3),t)),o=cK(o,[["exit",d,t],e[i-2],e[i-1],["exit",c,t]]),o=cK(o,e.slice(i+1)),o=cK(o,[["exit",l,t]]),cq(e,r,e.length,o),e},tokenize:function(e,t,n){let r,i,o=this,s=o.events.length;for(;s--;)if(("labelImage"===o.events[s][1].type||"labelLink"===o.events[s][1].type)&&!o.events[s][1]._balanced){r=o.events[s][1];break}return function(t){return r?r._inactive?d(t):(i=o.parser.defined.includes(dR(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),a):n(t)};function a(t){return 40===t?e.attempt(dF,c,i?c:d)(t):91===t?e.attempt(dU,c,i?l:d)(t):i?c(t):d(t)}function l(t){return e.attempt(dH,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},dF={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return c5(t)?dD(e,i)(t):i(t)}function i(t){return 41===t?c(t):dI(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return c5(t)?dD(e,a)(t):c(t)}function s(e){return n(e)}function a(t){return 34===t||39===t||40===t?dO(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return c5(t)?dD(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},dU={tokenize:function(e,t,n){let r=this;return function(t){return dL.call(r,e,i,o,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(dR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},dH={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},dW={name:"labelStartImage",resolveAll:d$.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},dV={name:"labelStartLink",resolveAll:d$.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},dG={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),c9(e,t,"linePrefix")}}},dq={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(o){var s;return e.enter("thematicBreak"),r=s=o,function o(s){return s===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),c6(n)?c9(e,o,"whitespace")(n):o(n))}(s)):i>=3&&(null===s||c8(s))?(e.exit("thematicBreak"),t(s)):n(s)}(s)}}},dK={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(dr,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,c9(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!c6(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(dX,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,c9(e,e.attempt(dK,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,s=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:c0(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(dq,n,a)(t):a(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return c0(i)&&++s<10?(e.consume(i),t):(!r.interrupt||s<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),a(i)):n(i)}(t)}return n(t)};function a(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(dr,r.interrupt?n:l,e.attempt(dJ,d,c))}function l(e){return r.containerState.initialBlankLine=!0,o++,d(e)}function c(t){return c6(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},dJ={partial:!0,tokenize:function(e,t,n){let r=this;return c9(e,function(e){let i=r.events[r.events.length-1];return!c6(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},dX={partial:!0,tokenize:function(e,t,n){let r=this;return c9(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},dY={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let s={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",s,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=s,e.push(["exit",s,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var s;let a,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){a="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||a)?(e.enter("setextHeadingLine"),r=t,s=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),c6(n)?c9(e,o,"lineSuffix")(n):o(n))}(s)):n(t)};function o(r){return null===r||c8(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,dL.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(t){return(r=dR(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return c5(t)?dD(e,a)(t):a(t)}function a(t){return dI(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(dP,c,c)(t)}function c(t){return c6(t)?c9(e,d,"whitespace")(t):d(t)}function d(o){return null===o||c8(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}}},"disable",0,{null:[]},"document",0,{42:dK,43:dK,45:dK,48:dK,49:dK,50:dK,51:dK,52:dK,53:dK,54:dK,55:dK,56:dK,57:dK,62:dk},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},cq(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var o;return e.enter("atxHeading"),o=i,e.enter("atxHeadingSequence"),function i(o){return 35===o&&r++<6?(e.consume(o),i):null===o||c5(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||c8(r)?(e.exit("atxHeading"),t(r)):c6(r)?c9(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||c5(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(o)):n(o)}(o)}}},42:dq,45:[dY,dq],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,o,s,a,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(s){return 33===s?(e.consume(s),d):47===s?(e.consume(s),i=!0,p):63===s?(e.consume(s),r=3,l.interrupt?t:O):cX(s)?(e.consume(s),o=String.fromCharCode(s),f):n(s)}function d(i){return 45===i?(e.consume(i),r=2,u):91===i?(e.consume(i),r=5,s=0,h):cX(i)?(e.consume(i),r=4,l.interrupt?t:O):n(i)}function u(r){return 45===r?(e.consume(r),l.interrupt?t:O):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(s++)?(e.consume(r),s===i.length)?l.interrupt?t:C:h:n(r)}function p(t){return cX(t)?(e.consume(t),o=String.fromCharCode(t),f):n(t)}function f(s){if(null===s||47===s||62===s||c5(s)){let a=47===s,c=o.toLowerCase();return!a&&!i&&dj.includes(c)?(r=1,l.interrupt?t(s):C(s)):d_.includes(o.toLowerCase())?(r=6,a)?(e.consume(s),m):l.interrupt?t(s):C(s):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(s):i?function t(n){return c6(n)?(e.consume(n),t):w(n)}(s):g(s))}return 45===s||cY(s)?(e.consume(s),o+=String.fromCharCode(s),f):n(s)}function m(r){return 62===r?(e.consume(r),l.interrupt?t:C):n(r)}function g(t){return 47===t?(e.consume(t),w):58===t||95===t||cX(t)?(e.consume(t),y):c6(t)?(e.consume(t),g):w(t)}function y(t){return 45===t||46===t||58===t||95===t||cY(t)?(e.consume(t),y):v(t)}function v(t){return 61===t?(e.consume(t),b):c6(t)?(e.consume(t),v):g(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,x):c6(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||c5(n)?v(n):(e.consume(n),t)}(t)}function x(t){return t===a?(e.consume(t),a=null,k):null===t||c8(t)?n(t):(e.consume(t),x)}function k(e){return 47===e||62===e||c6(e)?g(e):n(e)}function w(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||c8(t)?C(t):c6(t)?(e.consume(t),S):n(t)}function C(t){return 45===t&&2===r?(e.consume(t),M):60===t&&1===r?(e.consume(t),T):62===t&&4===r?(e.consume(t),D):63===t&&3===r?(e.consume(t),O):93===t&&5===r?(e.consume(t),L):c8(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(dB,R,N)(t)):null===t||c8(t)?(e.exit("htmlFlowData"),N(t)):(e.consume(t),C)}function N(t){return e.check(dz,A,R)(t)}function A(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||c8(t)?N(t):(e.enter("htmlFlowData"),C(t))}function M(t){return 45===t?(e.consume(t),O):C(t)}function T(t){return 47===t?(e.consume(t),o="",I):C(t)}function I(t){if(62===t){let n=o.toLowerCase();return dj.includes(n)?(e.consume(t),D):C(t)}return cX(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),I):C(t)}function L(t){return 93===t?(e.consume(t),O):C(t)}function O(t){return 62===t?(e.consume(t),D):45===t&&2===r?(e.consume(t),O):C(t)}function D(t){return null===t||c8(t)?(e.exit("htmlFlowData"),R(t)):(e.consume(t),D)}function R(n){return e.exit("htmlFlow"),t(n)}}},61:dY,95:dq,96:dE,126:dE},"flowInitial",0,{[-2]:dM,[-1]:dM,32:dM},"insideSpan",0,{null:[db,du]},"string",0,{38:dN,92:dw},"text",0,{[-5]:dG,[-4]:dG,[-3]:dG,33:dW,38:dN,42:db,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return cX(t)?(e.consume(t),o):64===t?n(t):a(t)}function o(t){return 43===t||45===t||46===t||cY(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,s):(43===n||45===n||46===n||cY(n))&&r++<32?(e.consume(n),t):(r=0,a(n))}(t)):a(t)}function s(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||cZ(r)?n(r):(e.consume(r),s)}function a(t){return 64===t?(e.consume(t),l):cQ(t)?(e.consume(t),a):n(t)}function l(i){return cY(i)?function i(o){return 46===o?(e.consume(o),r=0,l):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(o){if((45===o||cY(o))&&r++<63){let n=45===o?t:i;return e.consume(o),n}return n(o)}(o)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,o,s=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),x):63===t?(e.consume(t),v):cX(t)?(e.consume(t),w):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,p):cX(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):c8(t)?(o=d,I(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),h):d(t)}function h(e){return 62===e?T(e):45===e?u(e):d(e)}function p(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):c8(t)?(o=f,I(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),g):f(t)}function g(t){return 62===t?T(t):93===t?(e.consume(t),g):f(t)}function y(t){return null===t||62===t?T(t):c8(t)?(o=y,I(t)):(e.consume(t),y)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):c8(t)?(o=v,I(t)):(e.consume(t),v)}function b(e){return 62===e?T(e):v(e)}function x(t){return cX(t)?(e.consume(t),k):n(t)}function k(t){return 45===t||cY(t)?(e.consume(t),k):function t(n){return c8(n)?(o=t,I(n)):c6(n)?(e.consume(n),t):T(n)}(t)}function w(t){return 45===t||cY(t)?(e.consume(t),w):47===t||62===t||c5(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),T):58===t||95===t||cX(t)?(e.consume(t),C):c8(t)?(o=S,I(t)):c6(t)?(e.consume(t),S):T(t)}function C(t){return 45===t||46===t||58===t||95===t||cY(t)?(e.consume(t),C):function t(n){return 61===n?(e.consume(n),N):c8(n)?(o=t,I(n)):c6(n)?(e.consume(n),t):S(n)}(t)}function N(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,A):c8(t)?(o=N,I(t)):c6(t)?(e.consume(t),N):(e.consume(t),E)}function A(t){return t===r?(e.consume(t),r=void 0,M):null===t?n(t):c8(t)?(o=A,I(t)):(e.consume(t),A)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||c5(t)?S(t):(e.consume(t),E)}function M(e){return 47===e||62===e||c5(e)?S(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function I(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),L}function L(t){return c6(t)?c9(e,O,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),o(t)}}}],91:dV,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return c8(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},dw],93:d$,95:db,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),o++,t):(e.exit("codeTextSequence"),s(n))}(t)};function s(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),s):96===l?(i=e.enter("codeTextSequence"),r=0,function n(s){return 96===s?(e.consume(s),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(s)):(i.type="codeTextData",a(s))}(l)):c8(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):(e.enter("codeTextData"),a(l))}function a(t){return null===t||32===t||96===t||c8(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),a)}}}}],19210);var dQ=e.i(19210);let dZ=/[\0\t\n\r]/g;function d0(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let d1=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function d2(e){return e.replace(d1,d8)}function d8(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return d0(n.slice(t?2:1),t?16:10)}return dC(n)||e}let d5={}.hasOwnProperty;function d6(e){return{line:e.line,column:e.column,offset:e.offset}}function d3(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+cC({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cC({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+cC({start:t.start,end:t.end})+") is still open")}function d4(e){let t=this;t.parser=function(n){var r,i;let o,s,a,l;return"object"==typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(y),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(f),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(p),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(p,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(m),hardBreakTrailing:r(m),htmlFlow:r(g,i),htmlFlowData:c,htmlText:r(g,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(y),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(v),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(f),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:s(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:s(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:s(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=d0(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=dC(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=d6(e.end)},codeFenced:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:s(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dR(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:s(),hardBreakEscape:s(u),hardBreakTrailing:s(u),htmlFlow:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=d2(t),n.identifier=dR(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=d6(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),d.call(this,e))},link:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dR(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:s(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:s(),thematicBreak:s()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(d5.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},s={stack:[r],tokenStack:[],config:t,enter:o,exit:a,buffer:i,resume:l,data:n},c=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?c.push(d):d=function(e,t,n){let r,i,o,s,a=t-1,l=-1,c=!1;for(;++a<=n;){let t=e[a];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||s||l||o||(o=a),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let s=a;for(i=void 0;s--;){let t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=s}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||a,0,["exit",r,t[2]]),a++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(a,0,["enter",i,t[2]]),a++,n++,o=void 0,s=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];d5.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},s),e[d][1])}if(s.tokenStack.length>0){let e=s.tokenStack[s.tokenStack.length-1];(e[1]||d3).call(s,void 0,e[0])}for(r.position={start:d6(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:d6(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r};function r(e,t){return function(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:d6(t.start),end:void 0}}function s(e){return function(t){e&&e.call(this,t),a.call(this,t)}}function a(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||d3).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+cC({start:e.start,end:e.end})+"): it’s not open");n.position.end=d6(e.end)}function l(){return cW(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:d6(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=d6(e.end)}function u(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function f(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function g(){return{type:"html",value:""}}function y(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!da(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(cJ.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){cJ.call(i,r)||(i[r]=[]);let e=o[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);cq(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([dQ,...(e||{}).extensions||[]]),content:n(de),defined:[],document:n(dt),flow:n(dd),lazy:{},string:n(dh),text:n(dp)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],s=[],a=[],l={attempt:f(function(e,t){m(e,t.from)}),check:f(p),consume:function(e){c8(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,g()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),a.push(n),n},exit:function(e){let t=a.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:f(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,g()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,s=e[r];if("string"==typeof s)o=s;else switch(s){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(s)}n=-2===s,i.push(o)}return i.join("")}(u(e),t)},sliceStream:u,write:function(e){return(s=cK(s,e),function(){let e;for(;r._index<s.length;){let n=s[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),d=d(t)}else d=d(n)}}(),null!==s[s.length-1])?[]:(m(t,0),c.events=dv(o,c.events,c),c.events)}},d=t.tokenize.call(c,l);return t.resolveAll&&o.push(t),c;function u(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,s=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,s)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}s>0&&n.push(e[o].slice(0,s))}return n}(s,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function p(e,t){t.restore()}function f(e,t){return function(n,i,o){var s;let d,u,p,f;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):(s=n,function(e){let t=null!==e&&s[e],n=null!==e&&s.null;return m([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function m(e){return(d=e,u=0,0===e.length)?o:y(e[u])}function y(e){return function(n){let i,o,s,d,u;return(i=h(),o=c.previous,s=c.currentConstruct,d=c.events.length,u=Array.from(a),f={from:d,restore:function(){r=i,c.previous=o,c.currentConstruct=s,c.events.length=d,a=u,g()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,v,b)(n)}}function v(t){return e(p,f),i}function b(e){return(f.restore(),++u<d.length)?y(d[u]):o}}}function m(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&cq(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((s=1,a="",l=!0,function(e,t,n){let r,i,c,d,u,h=[];for(e=a+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,a="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(dZ.lastIndex=c,d=(r=dZ.exec(e))&&void 0!==r.index?r.index:e.length,u=e.charCodeAt(d),!r){a=e.slice(c);break}if(10===u&&c===d&&o)h.push(-3),o=void 0;else switch(o&&(h.push(-5),o=void 0),c<d&&(h.push(e.slice(c,d)),s+=d-c),u){case 0:h.push(65533),s++;break;case 9:for(i=4*Math.ceil(s/4),h.push(-2);s++<i;)h.push(-1);break;case 10:h.push(-4),s=1;break;default:o=!0,s=1}c=d+1}return n&&(o&&h.push(-5),a&&h.push(a),h.push(null)),h})(n,r,!0))))}}let d7="object"==typeof self?self:globalThis,d9=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[o,s]=e[i];switch(o){case 0:case -1:return n(s,i);case 1:{let e=n([],i);for(let t of s)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of s)e[r(t)]=r(n);return e}case 3:return n(new Date(s),i);case 4:{let{source:e,flags:t}=s;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of s)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of s)e.add(r(t));return e}case 7:{let{name:e,message:t}=s;return n(new d7[e](t),i)}case 8:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:e}=new Uint8Array(s);return n(new DataView(e),s)}}return n(new d7[o](s),i)})(0)},{toString:ue}={},{keys:ut}=Object,un=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=ue.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},ur=([e,t])=>0===e&&("function"===t||"symbol"===t),ui=(e,{json:t,lossy:n}={})=>{var r,i,o;let s,a,l=[];return(r=!(t||n),i=!!t,o=new Map,s=(e,t)=>{let n=l.push(e)-1;return o.set(t,n),n},a=e=>{if(o.has(e))return o.get(e);let[t,n]=un(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return s([-1],e)}return s([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),s([n,[...t]],e)}let r=[],i=s([t,r],e);for(let t of e)r.push(a(t));return i}case 2:{if(n)switch(n){case"BigInt":return s([n,e.toString()],e);case"Boolean":case"Number":case"String":return s([n,e.valueOf()],e)}if(i&&"toJSON"in e)return a(e.toJSON());let o=[],l=s([t,o],e);for(let t of ut(e))(r||!ur(un(e[t])))&&o.push([a(t),a(e[t])]);return l}case 3:return s([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return s([t,{source:n,flags:r}],e)}case 5:{let n=[],i=s([t,n],e);for(let[t,i]of e)(r||!(ur(un(t))||ur(un(i))))&&n.push([a(t),a(i)]);return i}case 6:{let n=[],i=s([t,n],e);for(let t of e)(r||!ur(un(t)))&&n.push(a(t));return i}}let{message:l}=e;return s([t,{name:n,message:l}],e)})(e),l},uo="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?d9(ui(e,t)):structuredClone(e):(e,t)=>d9(ui(e,t));function us(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),s="";if(37===o&&cY(e.charCodeAt(n+1))&&cY(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(s=String.fromCharCode(o,t),i=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ua(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function ul(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let uc=function(e){var t,n;if(null==e)return uu;if("function"==typeof e)return ud(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=uc(e[n]);return ud(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,ud(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,ud(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function ud(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function uu(){return!0}let uh=[],up="skip";function uf(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let o=uc(i),s=r?-1:1;(function e(i,a,l){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return d;function d(){var c;let d,u,h,p=uh;if((!t||o(i,a,l[l.length-1]||void 0))&&!1===(p=Array.isArray(c=n(i,l))?c:"number"==typeof c?[!0,c]:null==c?uh:[c])[0])return p;if("children"in i&&i.children&&i.children&&p[0]!==up)for(u=(r?i.children.length:-1)+s,h=l.concat(i);u>-1&&u<i.children.length;){if(!1===(d=e(i.children[u],u,h)())[0])return d;u="number"==typeof d[1]?d[1]:u+s}return p}})(e,void 0,[])()}function um(e,t,n,r){let i,o,s;"function"==typeof t&&"function"!=typeof n?(o=void 0,s=t,i=n):(o=t,s=n,i=r),uf(e,o,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return s(e,r,n)},i)}function ug(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let s=i[i.length-1];return s&&"text"===s.type?s.value+=r:i.push({type:"text",value:r}),i}function uy(e){let t=e.spread;return null==t?e.children.length>1:t}function uv(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let ub={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=us(i.toLowerCase()),s=e.footnoteOrder.indexOf(i),a=e.footnoteCounts.get(i);void 0===a?(a=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=s+1,a+=1,e.footnoteCounts.set(i,a);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ug(e,t);let i={src:us(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:us(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ug(e,t);let i={href:us(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:us(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=uy(n[r])}return t}(n):uy(t),o={},s=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let e=r[a];(i||0!==a||"element"!==e.type||"p"!==e.tagName)&&s.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?s.push(e):s.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&s.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=cw(t.children[1]),s=ck(t.children[t.children.length-1]);o&&s&&(r.position={start:o,end:s}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,s=o?o.length:t.children.length,a=-1,l=[];for(;++a<s;){let n=t.children[a],r={},s=o?o[a]:void 0;s&&(r.align=s);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(uv(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(uv(t.slice(i),i>0,!1)),o.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:ux,yaml:ux,definition:ux,footnoteDefinition:ux};function ux(){}let uk={}.hasOwnProperty,uw={};function uS(e,t){e.position&&(t.position=function(e){let t=cw(e),n=ck(e);if(t&&n)return{start:t,end:n}}(e))}function uC(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,uo(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function uN(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function uA(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function uE(e,t){let n,r,i,o,s=(n=t||uw,r=new Map,i=new Map,o={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=uA(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=uA(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:uC,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ub,...n.handlers},one:function(e,t){let n=e.type,r=o.handlers[n];if(uk.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=uo(n);return r.children=o.all(e),r}return uo(e)}return(o.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(uk.call(n,"hProperties")||uk.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(o,e,t)},options:n,patch:uS,wrap:uN},um(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o),a=s.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ua,r=e.options.footnoteBackLabel||ul,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let o=e.all(i),s=String(i.identifier).toUpperCase(),c=us(s.toLowerCase()),d=0,u=[],h=e.footnoteCounts.get(s);for(;void 0!==h&&++d<=h;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else o.push(...u);let f={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(o,!0)};e.patch(i,f),a.push(f)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...uo(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(s),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return l&&(cp("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function uM(e,t){return e&&"run"in e?async function(n,r){let i=uE(n,{file:r,...t});await e.run(i,r)}:function(n,r){return uE(n,{file:r,...e||t})}}function uT(e){if(e)throw e}var uI=e.i(75609);function uL(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let uO=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');u_(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let s=-1,a=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else s<0&&(n=!0,s=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(i=o):(a=-1,i=s));return r===i?i=s:i<0&&(i=e.length),e.slice(r,i)},uD=function(e){let t;if(u_(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},uR=function(e){let t;u_(e);let n=e.length,r=-1,i=0,o=-1,s=0;for(;n--;){let a=e.codePointAt(n);if(47===a){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===a?o<0?o=n:1!==s&&(s=1):o>-1&&(s=-1)}return o<0||r<0||0===s||1===s&&o===r-1&&o===i+1?"":e.slice(o,r)},uP=function(...e){var t;let n,r,i,o=-1;for(;++o<e.length;)u_(e[o]),e[o]&&(i=void 0===i?e[o]:i+"/"+e[o]);return void 0===i?".":(u_(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",o=0,s=-1,a=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(s===l-1||1===a);else if(s!==l-1&&2===a){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),s=l,a=0;continue}}else if(i.length>0){i="",o=0,s=l,a=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(s+1,l):i=e.slice(s+1,l),o=l-s-1;s=l,a=0}else 46===n&&a>-1?a++:a=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function u_(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function uj(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let uB=["history","path","basename","stem","extname","dirname"];class uz{constructor(e){let t,n;t=e?uj(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<uB.length;){const e=uB[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)uB.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?uO(this.path):void 0}set basename(e){uF(e,"basename"),u$(e,"basename"),this.path=uP(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?uD(this.path):void 0}set dirname(e){uU(this.basename,"dirname"),this.path=uP(e||"",this.basename)}get extname(){return"string"==typeof this.path?uR(this.path):void 0}set extname(e){if(u$(e,"extname"),uU(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=uP(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){uj(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!uj(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),uF(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?uO(this.path,this.extname):void 0}set stem(e){uF(e,"stem"),u$(e,"stem"),this.path=uP(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new cM(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function u$(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function uF(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function uU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let uH=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},uW={}.hasOwnProperty;class uV extends uH{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(o,...s){let a=e[++n],l=-1;if(o)return void r(o);for(;++l<t.length;)(null===s[l]||void 0===s[l])&&(s[l]=t[l]);t=s,a?(function(e,t){let n;return function(...t){let o,s=e.length>t.length;s&&t.push(r);try{o=e.apply(this,t)}catch(e){if(s&&n)throw e;return r(e)}s||(o&&o.then&&"function"==typeof o.then?o.then(i,r):o instanceof Error?r(o):i(o))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(a,i)(...s):r(null,...s)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new uV,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,uI.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(uJ("data",this.frozen),this.namespace[e]=t,this):uW.call(this.namespace,e)&&this.namespace[e]||void 0:e?(uJ("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=uQ(e),n=this.parser||this.Parser;return uq("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),uq("process",this.parser||this.Parser),uK("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=uQ(e),s=n.parse(o);function a(e,n){e||!n?i(e):r?r(n):(cp(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(s,o,function(e,t,r){var i,o;if(e||!t||!r)return a(e);let s=n.stringify(t,r);"string"==typeof(i=s)||(o=i)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?r.value=s:r.result=s,a(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),uq("processSync",this.parser||this.Parser),uK("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,uT(e),t=r}),uY("processSync","process",n),cp(t,"we either bailed on an error or have a tree"),t}run(e,t,n){uX(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){cp("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let s=uQ(t);r.run(e,s,function(t,r,s){let a=r||e;t?o(t):i?i(a):(cp(n,"`done` is defined if `resolve` is not"),n(void 0,a,s))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){uT(e),n=t,r=!0}),uY("runSync","run",r),cp(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=uQ(t),r=this.compiler||this.Compiler;return uK("stringify",r),uX(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(uJ("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else if("object"==typeof e)Array.isArray(e)?o(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,uI.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)s(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,s=n[i][1];uL(s)&&uL(r)&&(r=(0,uI.default)(!0,s,r)),n[i]=[e,r,...o]}}}}let uG=new uV().freeze();function uq(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function uK(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function uJ(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function uX(e){if(!uL(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function uY(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function uQ(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new uz(e)}let uZ=[],u0={allowDangerousHtml:!0},u1=/^(https?|ircs?|mailto|xmpp)$/i,u2=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function u8(e){var t;let n,r,i,o,s,a=(n=(t=e).rehypePlugins||uZ,r=t.remarkPlugins||uZ,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...u0}:u0,uG().use(d4).use(r).use(uM,i).use(n)),l=(o=e.children||"",s=new uz,"string"==typeof o?s.value=o:cf("Unexpected value `"+o+"` for `children` prop, expected `string`"),s);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||u5;for(let e of u2)Object.hasOwn(t,e.from)&&cf("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&o&&cf("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),um(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return s?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in cU)if(Object.hasOwn(cU,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=cU[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let s=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!s&&r&&"number"==typeof t&&(s=!r(e,t,i)),s&&i&&"number"==typeof t)return a&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,o;let s;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let a=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=a,r=t.jsxDEV,s=function(e,t,i,o){let s=Array.isArray(i.children),a=cw(e);return r(t,i,o,s,{columnNumber:a?a.column-1:void 0,fileName:n,lineNumber:a?a.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,o=t.jsxs,s=function(e,t,n,r){let s=Array.isArray(n.children)?o:i;return r?s(t,n,r):s(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?n1:n0,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=cP(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:ee.Fragment,components:i,ignoreInvalidStyle:!0,jsx:ee.jsx,jsxs:ee.jsxs,passKeys:!0,passNode:!0})}(a.runSync(a.parse(l),l),e)}function u5(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||u1.test(e.slice(0,t))?e:""}function u6({authorship:e}){if(!e)return(0,ee.jsx)("div",{className:"text-[10px] text-[var(--dim)] px-1 py-1",children:"No authorship data"});let{aiPercent:t,humanPercent:n,totalChars:r}=e.stats;return(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-1 py-1.5",children:[(0,ee.jsxs)("div",{className:"flex h-1.5 flex-1 overflow-hidden rounded-sm",children:[t>0&&(0,ee.jsx)("div",{className:"h-full transition-all duration-300",style:{width:`${t}%`,backgroundColor:"var(--ai-color)",opacity:.6}}),n>0&&(0,ee.jsx)("div",{className:"h-full transition-all duration-300",style:{width:`${n}%`,backgroundColor:"var(--human-color)",opacity:.6}})]}),(0,ee.jsxs)("span",{className:"text-[10px] shrink-0 flex gap-2",children:[(0,ee.jsxs)("span",{style:{color:"var(--ai-color)"},children:[t,"% AI"]}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"/"}),(0,ee.jsxs)("span",{style:{color:"var(--human-color)"},children:[n,"% human"]}),(0,ee.jsxs)("span",{className:"text-[var(--dimmer)]",children:["(",Math.round(r/1e3),"k chars)"]})]})]})}var u3=((x=u3||{}).docTypeError="docTypeError",x.contextNotFound="contextNotFound",x.timerNotFound="timerNotFound",x.ctxCallOutOfScope="ctxCallOutOfScope",x.createNodeInParserFail="createNodeInParserFail",x.stackOverFlow="stackOverFlow",x.parserMatchError="parserMatchError",x.serializerMatchError="serializerMatchError",x.getAtomFromSchemaFail="getAtomFromSchemaFail",x.expectDomTypeError="expectDomTypeError",x.callCommandBeforeEditorView="callCommandBeforeEditorView",x.missingRootElement="missingRootElement",x.missingNodeInSchema="missingNodeInSchema",x.missingMarkInSchema="missingMarkInSchema",x.ctxNotBind="ctxNotBind",x.missingYjsDoc="missingYjsDoc",x);class u4 extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}let u7=(e,t)=>"function"==typeof t?"[Function]":t;function u9(){return new u4(u3.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function he(){return new u4(u3.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function ht(e){return new u4(u3.expectDomTypeError,`Expect to be a dom, but get: ${JSON.stringify(e,u7)}.`)}function hn(){return new u4(u3.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}class hr{constructor(){this.sliceMap=new Map,this.get=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t){var n;throw n="string"==typeof e?e:e.name,new u4(u3.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}return t},this.remove=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}}class hi{constructor(e,t,n){this.#s=[],this.#a=()=>{this.#s.forEach(e=>e(this.#l))},this.set=e=>{this.#l=e,this.#a()},this.get=()=>this.#l,this.update=e=>{this.#l=e(this.#l),this.#a()},this.type=n,this.#l=t,e.set(n.id,this)}#s;#l;#a;on(e){return this.#s.push(e),()=>{this.#s=this.#s.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#s=this.#s.filter(t=>t!==e)}offAll(){this.#s=[]}}class ho{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw u9()}}create(e,t=this._defaultValue){return new hi(e,t,this)}}let hs=(e,t)=>new ho(e,t);class ha{constructor(e,t,n){this.#c=new Set,this.#d=new Set,this.#u=new Map,this.#h=new Map,this.read=()=>({metadata:this.#p,injectedSlices:[...this.#c].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),consumedSlices:[...this.#d].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),recordedTimers:[...this.#u].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)})),waitTimers:[...this.#h].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)}))}),this.onRecord=e=>{this.#u.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#u.delete(e)},this.onDone=e=>{let t=this.#u.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#h.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#c.add(e)},this.onRemove=e=>{this.#c.delete(e)},this.onUse=e=>{this.#d.add(e)},this.#f=e=>this.#g.get(e).get(),this.#m=e=>this.#y.get(e).status,this.#g=e,this.#y=t,this.#p=n}#p;#g;#y;#c;#d;#u;#h;#f;#m}class hl{constructor(e,t,n){this.produce=e=>e&&Object.keys(e).length?new hl(this.#g,this.#y,{...e}):this,this.inject=(e,t)=>{let n=e.create(this.#g.sliceMap);return null!=t&&n.set(t),this.#v?.onInject(e),this},this.remove=e=>(this.#g.remove(e),this.#v?.onRemove(e),this),this.record=e=>(e.create(this.#y.store),this.#v?.onRecord(e),this),this.clearTimer=e=>(this.#y.remove(e),this.#v?.onClear(e),this),this.isInjected=e=>this.#g.has(e),this.isRecorded=e=>this.#y.has(e),this.use=e=>(this.#v?.onUse(e),this.#g.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#y.get(e),this.done=e=>{this.timer(e).done(),this.#v?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#v?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#g=e,this.#y=t,this.#p=n,n&&(this.#v=new ha(e,t,n))}#g;#y;#p;#v;get meta(){return this.#p}get inspector(){return this.#v}}class hc{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t){var n;throw n=e.name,new u4(u3.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}class hd{constructor(e,t){this.#b=null,this.#x=null,this.#k="pending",this.start=()=>(this.#b??=new Promise((e,t)=>{this.#x=t=>{t instanceof CustomEvent&&t.detail.id===this.#w&&(this.#k="resolved",this.#S(),t.stopImmediatePropagation(),e())},this.#C(()=>{"pending"===this.#k&&(this.#k="rejected"),this.#S(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#k="pending",addEventListener(this.type.name,this.#x)}),this.#b),this.done=()=>{dispatchEvent(new CustomEvent(this.type.name,{detail:{id:this.#w}}))},this.#S=()=>{this.#x&&removeEventListener(this.type.name,this.#x)},this.#C=e=>{setTimeout(()=>{e()},this.type.timeout)},this.#w=Symbol(t.name),this.type=t,e.set(t.id,this)}#b;#x;#w;#k;get status(){return this.#k}#S;#C}class hu{constructor(e,t=3e3){this.create=e=>new hd(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}let hh=(e,t=3e3)=>new hu(e,t);function hp(e){this.content=e}hp.prototype={constructor:hp,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return -1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new hp(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new hp(n)},addToStart:function(e,t){return new hp([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new hp(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new hp(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=hp.from(e)).size?new hp(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=hp.from(e)).size?new hp(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hp.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},hp.from=function(e){if(e instanceof hp)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new hp(t)};class hf{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,i||null,o)&&a.content.size){let i=s+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",o=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(o?o=!1:i+=n),i+=l},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new hf(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,o=0;o<t;i++){let s=this.content[i],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),r+=s.nodeSize),o=a}return new hf(n,r)}cutByIndex(e,t){return e==t?hf.empty:0==e&&t==this.content.length?this:new hf(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new hf(r,i)}addToStart(e){return new hf([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new hf(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let i=0;;i++){if(i==t.childCount||i==n.childCount)return t.childCount==n.childCount?null:r;let o=t.child(i),s=n.child(i);if(o==s){r+=o.nodeSize;continue}if(!o.sameMarkup(s))return r;if(o.isText&&o.text!=s.text){for(let e=0;o.text[e]==s.text[e];e++)r++;return r}if(o.content.size||s.content.size){let t=e(o.content,s.content,r+1);if(null!=t)return t}r+=o.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,i){for(let o=t.childCount,s=n.childCount;;){if(0==o||0==s)return o==s?null:{a:r,b:i};let a=t.child(--o),l=n.child(--s),c=a.nodeSize;if(a==l){r-=c,i-=c;continue}if(!a.sameMarkup(l))return{a:r,b:i};if(a.isText&&a.text!=l.text){let e=0,t=Math.min(a.text.length,l.text.length);for(;e<t&&a.text[a.text.length-e-1]==l.text[l.text.length-e-1];)e++,r--,i--;return{a:r,b:i}}if(a.content.size||l.content.size){let t=e(a.content,l.content,r-1,i-1);if(t)return t}r-=c,i-=c}}(this,e,t,n)}findIndex(e){if(0==e)return hg(0,e);if(e==this.size)return hg(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e){if(r==e)return hg(t+1,r);return hg(t,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return hf.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return new hf(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return hf.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new hf(t||e,n)}static from(e){if(!e)return hf.empty;if(e instanceof hf)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new hf([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}hf.empty=new hf([],0);let hm={index:0,offset:0};function hg(e,t){return hm.index=e,hm.offset=t,hm}function hy(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!hy(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!hy(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class hv{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hy(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return hv.none;if(e instanceof hv)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}hv.none=[];class hb extends Error{}class hx{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,r,i){let{index:o,offset:s}=t.findIndex(n),a=t.maybeChild(o);if(s==n||a.isText)return i&&!i.canReplace(o,o,r)?null:t.cut(0,n).append(r).append(t.cut(n));let l=e(a.content,n-s-1,r,a);return l&&t.replaceChild(o,a.copy(l))}(this.content,e+this.openStart,t);return n&&new hx(n,this.openStart,this.openEnd)}removeBetween(e,t){return new hx(function e(t,n,r){let{index:i,offset:o}=t.findIndex(n),s=t.maybeChild(i),{index:a,offset:l}=t.findIndex(r);if(o==n||s.isText){if(l!=r&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=a)throw RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(e(s.content,n-o-1,r-o-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return hx.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new hx(hf.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new hx(e,n,r)}}function hk(e,t){if(!t.type.compatibleContent(e.type))throw new hb("Cannot join "+t.type.name+" onto "+e.type.name)}function hw(e,t,n){let r=e.node(n);return hk(r,t.node(n)),r}function hS(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function hC(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(hS(e.nodeAfter,r),o++));for(let e=o;e<s;e++)hS(i.child(e),r);t&&t.depth==n&&t.textOffset&&hS(t.nodeBefore,r)}function hN(e,t){return e.type.checkContent(t),e.copy(t)}function hA(e,t,n){let r=[];return hC(null,e,n,r),e.depth>n&&hS(hN(hw(e,t,n+1),hA(e,t,n+1)),r),hC(t,null,n,r),new hf(r)}hx.empty=new hx(hf.empty,0,0);class hE{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return hv.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||r&&i[o].isInSet(r.marks)||(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new hL(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(i),s=i-o;if(n.push(t,e,r+o),!s||(t=t.child(e)).isText)break;i=s-1,r+=o+1}return new hE(t,n,i)}static resolveCached(e,t){let n=hI.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else hI.set(e,n=new hM);let r=n.elts[n.i]=hE.resolve(e,t);return n.i=(n.i+1)%hT,r}}class hM{constructor(){this.elts=[],this.i=0}}let hT=12,hI=new WeakMap;class hL{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let hO=Object.create(null);class hD{constructor(e,t,n,r=hv.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||hf.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&hy(this.attrs,t||e.defaultAttrs||hO)&&hv.sameSet(this.marks,n||hv.none)}copy(e=null){return e==this.content?this:new hD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new hD(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return hx.empty;let r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),s=r.start(o);return new hx(r.node(o).content.cut(r.pos-s,i.pos-s),r.depth-o,i.depth-o)}replace(e,t,n){var r=this.resolve(e),i=this.resolve(t);if(n.openStart>r.depth)throw new hb("Inserted content deeper than insertion position");if(r.depth-n.openStart!=i.depth-n.openEnd)throw new hb("Inconsistent open depths");return function e(t,n,r,i){let o=t.index(i),s=t.node(i);if(o==n.index(i)&&i<t.depth-r.openStart){let a=e(t,n,r,i+1);return s.copy(s.content.replaceChild(o,a))}if(!r.content.size)return hN(s,hA(t,n,i));if(r.openStart||r.openEnd||t.depth!=i||n.depth!=i){let{start:e,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(hf.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return hN(s,function e(t,n,r,i,o){let s=t.depth>o&&hw(t,n,o+1),a=i.depth>o&&hw(r,i,o+1),l=[];return hC(null,t,o,l),s&&a&&n.index(o)==r.index(o)?(hk(s,a),hS(hN(s,e(t,n,r,i,o+1)),l)):(s&&hS(hN(s,hA(t,n,o+1)),l),hC(n,r,o,l),a&&hS(hN(a,hA(r,i,o+1)),l)),hC(i,null,o,l),new hf(l)}(t,e,o,n,i))}{let e=t.parent,i=e.content;return hN(e,i.cut(0,t.parentOffset).append(r.content).append(i.cut(n.parentOffset)))}}(r,i,n,0)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return hE.resolveCached(this,e)}resolveNoCache(e){return hE.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),hP(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=hf.empty,r=0,i=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,i),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=hv.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!hv.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=hf.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}hD.prototype.text=void 0;class hR extends hD{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):hP(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new hR(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hR(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function hP(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class h_{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){var n;let r,i=new hj(e,t);if(null==i.next)return h_.empty;let o=function e(t){let n=[];do n.push(function(t){let n=[];do n.push(function(t){let n=function(t){if(t.eat("(")){let n=e(t);return t.eat(")")||t.err("Missing closing paren"),n}if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=(function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i})(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(t);for(;;)if(t.eat("+"))n={type:"plus",expr:n};else if(t.eat("*"))n={type:"star",expr:n};else if(t.eat("?"))n={type:"opt",expr:n};else if(t.eat("{"))n=function(e,t){let n=hB(e),r=n;return e.eat(",")&&(r="}"!=e.next?hB(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}(t,n);else break;return n}(t));while(t.next&&")"!=t.next&&"|"!=t.next)return 1==n.length?n[0]:{type:"seq",exprs:n}}(t));while(t.eat("|"))return 1==n.length?n[0]:{type:"choice",exprs:n}}(i);i.next&&i.err("Unexpected trailing text");let s=(n=function(e){let t=[[]];return i(function e(t,o){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,o)),[]);if("seq"==t.type)for(let r=0;;r++){let s=e(t.exprs[r],o);if(r==t.exprs.length-1)return s;i(s,o=n())}else if("star"==t.type){let s=n();return r(o,s),i(e(t.expr,s),s),[r(s)]}else if("plus"==t.type){let s=n();return i(e(t.expr,o),s),i(e(t.expr,s),s),[r(s)]}else if("opt"==t.type)return[r(o)].concat(e(t.expr,o));else if("range"==t.type){let s=o;for(let r=0;r<t.min;r++){let r=n();i(e(t.expr,s),r),s=r}if(-1==t.max)i(e(t.expr,s),s);else for(let o=t.min;o<t.max;o++){let o=n();r(s,o),i(e(t.expr,s),o),s=o}return[r(s)]}else if("name"==t.type)return[r(o,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}}(o),r=Object.create(null),function e(t){let i=[];t.forEach(e=>{n[e].forEach(({term:e,to:t})=>{let r;if(e){for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);h$(n,t).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})}})});let o=r[t.join(",")]=new h_(t.indexOf(n.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(hz);o.next.push({type:i[t][0],next:r[n.join(",")]||e(n)})}return o}(h$(n,0)));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),-1==r.indexOf(s)&&r.push(s)}i&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(o,s){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return hf.from(s.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=i(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:o,next:s}=i.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}h_.empty=new h_(!0);class hj{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function hB(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function hz(e,t){return t-e}function h$(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:o}=i[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(hz)}function hF(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function hU(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function hH(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function hW(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new hG(e,r,t[r]);return n}class hV{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=hW(e,n.attrs),this.defaultAttrs=hF(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==h_.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:hU(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new hD(this,this.computeAttrs(e),hf.from(t),hv.setFrom(n))}createChecked(e=null,t,n){return t=hf.from(t),this.checkContent(t),new hD(this,this.computeAttrs(e),t,hv.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=hf.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(hf.empty,!0);return i?new hD(this,e,t.append(i),hv.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){hH(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:hv.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new hV(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class hG{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(0>r.indexOf(i))throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class hq{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=hW(e,r.attrs),this.excluded=null;let i=hF(this.attrs);this.instance=i?new hv(this,i):null}create(e=null){return!e&&this.instance?this.instance:new hv(this,hU(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new hq(e,r++,t,i)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){hH(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class hK{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=hp.from(e.nodes),t.marks=hp.from(e.marks||{}),this.nodes=hV.compile(this.spec.nodes,this),this.marks=hq.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=h_.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==i?null:i?hJ(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:hJ(this,n.split(" "))}this.nodeFromJSON=e=>hD.fromJSON(this,e),this.markFromJSON=e=>hv.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof hV){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new hR(n,n.defaultAttrs,e,hv.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function hJ(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=r)}if(!s)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class hX{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new h2(this,t,!1);return n.addAll(e,hv.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new h2(this,t,!0);return n.addAll(e,hv.none,t.from,t.to),hx.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){var r,i;let n=this.tags[o];if(r=e,i=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,i)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],o=r.style;if(0==o.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(o.length>e.length)||61==o.charCodeAt(e.length)&&o.slice(e.length+1)==t)){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=h8(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=h8(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new hX(e,hX.schemaRules(e)))}}let hY={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},hQ={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hZ={ol:!0,ul:!0};function h0(e,t,n){return null!=t?!!t|2*("full"===t):e&&"pre"==e.whitespace?3:-5&n}class h1{constructor(e,t,n,r,i,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=hv.none,this.match=i||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(hf.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=hf.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(hf.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!hY.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class h2{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,o=h0(null,t.preserveWhitespace,0)|4*!!n;i=r?new h1(r.type,r.attrs,hv.none,!0,t.topMatch||r.type.contentMatch,o):n?new h1(null,null,hv.none,!0,null,o):new h1(e.schema.topNodeType,null,hv.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),s;hZ.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&hZ.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,n));t:if(a?a.ignore:hQ.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(hY.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break t}let s=a&&a.skip?t:this.readStyles(e,t);s&&this.addAll(e,s),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?s:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,o=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+o)&&(r=a,i=s,!a.length))break;if(s.solid){if(n)break;o+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=hv.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):h5(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let s=h0(e,i,o.options);4&o.options&&0==o.content.length&&(s|=4);let a=hv.none;return n=n.filter(t=>(o.type?!o.type.allowsMarkType(t.type):!h5(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new h1(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=i;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=i?n.node(s-i).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function h8(e){let t={};for(let n in e)t[n]=e[n];return t}function h5(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||0>o.indexOf(i)&&s(i))return!0}};if(s(i.contentMatch))return!0}}class h6{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=h4(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,o=0;for(;n<i.length&&o<e.marks.length;){let t=e.marks[o];if(!this.marks[t.type.name]){o++;continue}if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,o++}for(;n<i.length;)r=i.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(i.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=h9(h4(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&h9(h4(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return h9(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new h6(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=h3(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return h3(e.marks)}}function h3(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function h4(e){return e.document||window.document}let h7=new WeakMap;function h9(e,t,n,r){let i,o,s;if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(o=h7.get(r))&&h7.set(r,(s=null,!function e(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])s||(s=[]),s.push(t);else for(let n=0;n<t.length;n++)e(t[n]);else for(let n in t)e(t[n])}(r),o=s)),l=o)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let c=a.indexOf(" ");c>0&&(n=a.slice(0,c),a=a.slice(c+1));let d=n?e.createElementNS(n,a):e.createElement(a),u=t[1],h=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){for(let e in h=2,u)if(null!=u[e]){let t=e.indexOf(" ");t>0?d.setAttributeNS(e.slice(0,t),e.slice(t+1),u[e]):"style"==e&&d.style?d.style.cssText=u[e]:d.setAttribute(e,u[e])}}for(let o=h;o<t.length;o++){let s=t[o];if(0===s){if(o<t.length-1||o>h)throw RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}{let{dom:t,contentDOM:o}=h9(e,s,n,r);if(d.appendChild(t),o){if(i)throw RangeError("Multiple content holes");i=o}}}return{dom:d,contentDOM:i}}class pe{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class pt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&pt.empty)return pt.empty}recover(e){let t=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+(e-(65535&e))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+i],c=this.ranges[s+o],d=a+l;if(e<=d){let i=l?e==a?-1:e==d?1:t:t,o=a+r+(i<0?0:c);if(n)return o;let u=e==(t<0?a:d)?null:s/3+(e-a)*65536,h=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(h|=8),new pe(o,h,u)}r+=c-l}return n?e+r:new pe(e+r,0,null)}touches(e,t){let n=0,r=65535&t,i=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+i];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let o=this.ranges[r],s=o-(this.inverted?i:0),a=o+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),i+=c-l}}invert(){return new pt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?pt.empty:new pt(e<0?[0,-e,0]:[0,0,e])}}pt.empty=new pt([]);class pn{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new pn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new pn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new pe(e,r,null)}}let pr=Object.create(null);class pi{getMap(){return pt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=pr[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pr)throw RangeError("Duplicate use of step JSON ID "+e);return pr[e]=t,t.prototype.jsonID=e,t}}class po{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new po(e,null)}static fail(e){return new po(null,e)}static fromReplace(e,t,n,r){try{return po.ok(e.replace(t,n,r))}catch(e){if(e instanceof hb)return po.fail(e.message);throw e}}}function ps(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(ps(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return hf.fromArray(r)}class pa extends pi{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new hx(ps(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return po.fromReplace(e,this.from,this.to,i)}invert(){return new pl(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new pa(t.pos,n.pos,this.mark)}merge(e){return e instanceof pa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pa(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new pa(t.from,t.to,e.markFromJSON(t.mark))}}pi.jsonID("addMark",pa);class pl extends pi{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new hx(ps(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return po.fromReplace(e,this.from,this.to,n)}invert(){return new pa(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new pl(t.pos,n.pos,this.mark)}merge(e){return e instanceof pl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pl(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pl(t.from,t.to,e.markFromJSON(t.mark))}}pi.jsonID("removeMark",pl);class pc extends pi{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new pc(this.pos,t.marks[n]);return new pc(this.pos,this.mark)}}return new pd(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pc(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new pc(t.pos,e.markFromJSON(t.mark))}}pi.jsonID("addNodeMark",pc);class pd extends pi{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new pc(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pd(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pd(t.pos,e.markFromJSON(t.mark))}}pi.jsonID("removeNodeMark",pd);class pu extends pi{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&pp(e,this.from,this.to)?po.fail("Structure replace would overwrite content"):po.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pt([this.from,this.to-this.from,this.slice.size])}invert(e){return new pu(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new pu(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof pu)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?hx.empty:new hx(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new pu(e.from,this.to,t,this.structure)}{let t=this.slice.size+e.slice.size==0?hx.empty:new hx(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new pu(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new pu(t.from,t.to,hx.fromJSON(e,t.slice),!!t.structure)}}pi.jsonID("replace",pu);class ph extends pi{constructor(e,t,n,r,i,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=o,this.structure=s}apply(e){if(this.structure&&(pp(e,this.from,this.gapFrom)||pp(e,this.gapTo,this.to)))return po.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return po.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?po.fromReplace(e,this.from,this.to,n):po.fail("Content does not fit in gap")}getMap(){return new pt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ph(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new ph(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ph(t.from,t.to,t.gapFrom,t.gapTo,hx.fromJSON(e,t.slice),t.insert,!!t.structure)}}function pp(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function pf(e,t,n,r=n.contentMatch,i=!0){let o=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<o.childCount;t++){let l=o.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new pl(a,c,l.marks[t]));if(i&&l.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(l.text);)r||(r=new hx(hf.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new pu(a+e.index,a+e.index+e[0].length,r))}}else s.push(new pu(a,c,hx.empty));a=c}if(!r.validEnd){let t=r.fillBefore(hf.empty,!0);e.replace(a,a,new hx(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function pm(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,a,t))return n;if(0==n||o.type.spec.isolating||!((0==s||o.canReplace(s,o.childCount))&&(a==o.childCount||o.canReplace(0,a))))break;s&&(r=1),a<o.childCount&&(i=1)}return null}function pg(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}(e,t),o=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return o?i.map(py).concat({type:t,attrs:n}).concat(o.map(py)):null}function py(e){return{type:e,attrs:null}}function pv(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let i=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function pb(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function px(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>o;e--,t--){let n=i.node(e),o=i.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(o+1,n.childCount)||!l.type.validContent(s))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function pk(e,t){var n,r;let i=e.resolve(t),o=i.index();return n=i.nodeBefore,r=i.nodeAfter,!!(n&&r&&!n.isLeaf&&function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(s))||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(n,r))&&i.parent.canReplace(o,o+1)}function pw(e,t,n=t,r=hx.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return pS(i,o,r)?new pu(t,n,r):new pC(i,o,r).fit()}function pS(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}pi.jsonID("replaceAround",ph);class pC{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=hf.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=hf.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,o=n.depth,s=r.depth;for(;o&&s&&1==i.childCount;)i=i.firstChild.content,o--,s--;let a=new hx(i,o,s);return e>-1?new ph(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new pu(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e=null,r=(n?(e=pE(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let i=this.depth;i>=0;i--){let{type:o,match:s}=this.frontier[i],a,l=null;if(1==t&&(r?s.matchType(r.type)||(l=s.fillBefore(hf.from(r),!1)):e&&o.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:i,parent:e,inject:l};if(2==t&&r&&(a=s.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:i,parent:e,wrap:a};if(e&&s.matchType(e.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=pE(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new hx(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=pE(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new hx(pN(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new hx(pN(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let o=this.unplaced,s=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=s.size+e-(o.content.size-o.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;(++l>1||0==a||e.content.size)&&(d=t,c.push(function e(t,n,r){if(n<=0)return t;let i=t.content;return n>1&&(i=i.replaceChild(0,e(i.firstChild,n-1,1==i.childCount?r-1:0))),n>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(hf.empty,!0)))),t.copy(i)}(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=pA(this.placed,t,hf.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?hx.empty:new hx(pN(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new hx(pN(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!pM(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){n:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=pM(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=pM(e,n,r,t,!0);if(!i||i.childCount)continue n}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=pA(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=pA(this.placed,this.depth,hf.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(hf.empty,!0);e.childCount&&(this.placed=pA(this.placed,this.frontier.length,e))}}function pN(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(pN(e.firstChild.content,t-1,n)))}function pA(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(pA(e.lastChild.content,t-1,n)))}function pE(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function pM(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?a:null}function pT(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class pI extends pi{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return po.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return po.fromReplace(e,this.pos,this.pos+1,new hx(hf.from(r),0,+!t.isLeaf))}getMap(){return pt.empty}invert(e){return new pI(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pI(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new pI(t.pos,t.attr,t.value)}}pi.jsonID("attr",pI);class pL extends pi{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return po.ok(n)}getMap(){return pt.empty}invert(e){return new pL(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new pL(t.attr,t.value)}}pi.jsonID("docAttr",pL);let pO=class extends Error{};(pO=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),pO.prototype.constructor=pO,pO.prototype.name="TransformError";class pD{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new pO(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,o)=>{e=Math.min(e,i),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=hx.empty){let r=pw(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new hx(hf.from(n),0,0))}delete(e,t){return this.replace(e,t,hx.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(pS(i,o,r))return e.step(new pu(t,n,r));let s=pT(i,o);0==s[s.length-1]&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:i.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){var u;let t=c[e],n=(u=t.type).spec.defining||u.spec.definingForContent;if(n&&!t.sameMarkup(i.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let h=i.node(c-1),p=i.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(i.before(c),d?o.after(c):n,new hx(function e(t,n,r,i,o){if(n<r){let o=t.firstChild;t=t.replaceChild(0,o.copy(e(o.content,n+1,r,i,o)))}if(n>i){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(hf.empty,!0))}return t}(r.content,0,r.openStart,a),a,r.openEnd))}}let h=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>h));a--){let e=s[a];e<0||(t=i.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){var r=e,i=t;if(!n.isInline&&r==i&&this.doc.resolve(r).parent.content.size){let e=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)break}return null}(this.doc,r,n.type);null!=e&&(r=i=e)}return this.replaceRange(r,i,new hx(hf.from(n),0,0)),this}deleteRange(e,t){return!function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),o=pT(r,i);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(t-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return e.delete(r.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:i,depth:o}=t,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=hf.empty,u=0;for(let e=o,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=hf.from(r.node(e).copy(d)),u++):l--;let h=hf.empty,p=0;for(let e=o,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,h=hf.from(i.node(e).copy(h)),p++):c++;e.step(new ph(l,c,s,a,new hx(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),s=o.node().type;if(i&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);pb(e,r.node(),r.before(),a)}s.inlineContent&&pf(e,t+n-1,s,o.node().contentMatchAt(o.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new pu(c,l.map(t+n,-1),hx.empty,!0)),!0===r){let t=e.doc.resolve(c);pv(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return!function(e,t,n){let r=hf.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=hf.from(n[e].type.create(n[e].attrs,r))}let i=t.start,o=t.end;e.step(new ph(i,o,i,o,new hx(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){var i=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let o=i.steps.length;return i.doc.nodesBetween(e,t,(e,t)=>{var s,a,l;let c,d,u="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(n,u)&&(s=i.doc,a=i.mapping.slice(o).map(t),l=n,d=(c=s.resolve(a)).index(),c.parent.canReplaceWith(d,d+1,l))){let r=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&pb(i,e,t,o),pf(i,i.mapping.slice(o).map(t,1),n,void 0,null===r);let s=i.mapping.slice(o),a=s.map(t,1),l=s.map(t+e.nodeSize,1);return i.step(new ph(a,l,a+1,l-1,new hx(hf.from(n.create(u,null,e.marks)),0,0),1,!0)),!0===r&&pv(i,e,t,o),!1}}),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw RangeError("Invalid content for node type "+n.name);e.step(new ph(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new hx(hf.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new pI(e,t,n)),this}setDocAttribute(e,t){return this.step(new pL(e,t)),this}addNodeMark(e,t){return this.step(new pc(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof hv)t.isInSet(n.marks)&&this.step(new pd(e,t));else{let r=n.marks,i,o=[];for(;i=t.isInSet(r);)o.push(new pd(e,i)),r=i.removeFromSet(r);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let i=e.doc.resolve(t),o=hf.empty,s=hf.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){o=hf.from(i.node(e).copy(o));let t=r&&r[a];s=hf.from(t?t.type.create(t.attrs,s):i.node(e).copy(s))}e.step(new pu(t,t,new hx(o.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var r;let i,o,s,a;return r=this,s=[],a=[],r.doc.nodesBetween(e,t,(r,l,c)=>{if(!r.isInline)return;let d=r.marks;if(!n.isInSet(d)&&c.type.allowsMarkType(n.type)){let c=Math.max(l,e),u=Math.min(l+r.nodeSize,t),h=n.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(i&&i.to==c&&i.mark.eq(d[e])?i.to=u:s.push(i=new pl(c,u,d[e])));o&&o.to==c?o.to=u:a.push(o=new pa(c,u,n))}}),s.forEach(e=>r.step(e)),a.forEach(e=>r.step(e)),this}removeMark(e,t,n){var r;let i,o;return r=this,i=[],o=0,r.doc.nodesBetween(e,t,(r,s)=>{if(!r.isInline)return;o++;let a=null;if(n instanceof hq){let e=r.marks,t;for(;t=n.isInSet(e);)(a||(a=[])).push(t),e=t.removeFromSet(e)}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length){let n=Math.min(s+r.nodeSize,t);for(let t=0;t<a.length;t++){let r=a[t],l;for(let e=0;e<i.length;e++){let t=i[e];t.step==o-1&&r.eq(i[e].style)&&(l=t)}l?(l.to=n,l.step=o):i.push({style:r,from:Math.max(s,e),to:n,step:o})}}}),i.forEach(e=>r.step(new pl(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return pf(this,e,t,n),this}}let pR=Object.create(null);class pP{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new p_(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=hx.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:a,$to:l}=o[s],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),s?hx.empty:t),0==s&&pG(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(s.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),pG(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new pz(e):pV(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?pV(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):pV(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new pH(e.node(0))}static atStart(e){return pV(e,e,0,0,1)||new pH(e)}static atEnd(e){return pV(e,e,e.content.size,e.childCount,-1)||new pH(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=pR[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pR)throw RangeError("Duplicate use of selection JSON ID "+e);return pR[e]=t,t.prototype.jsonID=e,t}getBookmark(){return pz.between(this.$anchor,this.$head).getBookmark()}}pP.prototype.visible=!0;class p_{constructor(e,t){this.$from=e,this.$to=t}}let pj=!1;function pB(e){pj||e.parent.inlineContent||(pj=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class pz extends pP{constructor(e,t=e){pB(e),pB(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return pP.near(n);let r=e.resolve(t.map(this.anchor));return new pz(r.parent.inlineContent?r:n,n)}replace(e,t=hx.empty){if(super.replace(e,t),t==hx.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof pz&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new p$(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new pz(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let e=pP.findFrom(t,n,!0)||pP.findFrom(t,-n,!0);if(!e)return pP.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r?e=t:(e=(pP.findFrom(e,-n,!0)||pP.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0&&(e=t)),new pz(e,t)}}pP.jsonID("text",pz);class p${constructor(e,t){this.anchor=e,this.head=t}map(e){return new p$(e.map(this.anchor),e.map(this.head))}resolve(e){return pz.between(e.resolve(this.anchor),e.resolve(this.head))}}class pF extends pP{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?pP.near(i):new pF(i)}content(){return new hx(hf.from(this.node),0,0)}eq(e){return e instanceof pF&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new pU(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new pF(e.resolve(t.anchor))}static create(e,t){return new pF(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}pF.prototype.visible=!1,pP.jsonID("node",pF);class pU{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new p$(n,n):new pU(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&pF.isSelectable(n)?new pF(t):pP.near(t)}}class pH extends pP{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=hx.empty){if(t==hx.empty){e.delete(0,e.doc.content.size);let t=pP.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new pH(e)}map(e){return new pH(e)}eq(e){return e instanceof pH}getBookmark(){return pW}}pP.jsonID("all",pH);let pW={map(){return this},resolve:e=>new pH(e)};function pV(e,t,n,r,i,o=!1){if(t.inlineContent)return pz.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let r=t.child(s);if(r.isAtom){if(!o&&pF.isSelectable(r))return pF.create(e,n-(i<0?r.nodeSize:0))}else{let t=pV(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function pG(e,t,n){let r,i=e.steps.length-1;if(i<t)return;let o=e.steps[i];(o instanceof pu||o instanceof ph)&&(e.mapping.maps[i].forEach((e,t,n,i)=>{null==r&&(r=i)}),e.setSelection(pP.near(e.doc.resolve(r),n)))}class pq extends pD{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return hv.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||hv.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(pP.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function pK(e,t){return t&&e?e.bind(t):e}class pJ{constructor(e,t,n){this.name=e,this.init=pK(t.init,n),this.apply=pK(t.apply,n)}}let pX=[new pJ("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new pJ("selection",{init:(e,t)=>e.selection||pP.atStart(t.doc),apply:e=>e.selection}),new pJ("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new pJ("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class pY{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pX.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new pJ(e.key,e.spec.state,e))})}}class pQ{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new pQ(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new pq(this)}static create(e){let t=new pY(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new pQ(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new pY(this.schema,e.plugins),n=t.fields,r=new pQ(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new pY(e.schema,e.plugins),i=new pQ(r);return r.fields.forEach(r=>{if("doc"==r.name)i.doc=hD.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=pP.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let s=n[o],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o)){i[r.name]=a.fromJSON.call(s,e,t[o],i);return}}i[r.name]=r.init(e,i)}}),i}}class pZ{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let i in t){let o=t[i];o instanceof Function?o=o.bind(n):"handleDOMEvents"==i&&(o=e(o,n,{})),r[i]=o}return r}(e.props,this,this.props),this.key=e.key?e.key.key:p1("plugin")}getState(e){return e[this.key]}}let p0=Object.create(null);function p1(e){return e in p0?e+"$"+ ++p0[e]:(p0[e]=0,e+"$")}class p2{constructor(e="key"){this.key=p1(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let p8=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function p5(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let p6=(e,t,n)=>{let r=p5(e,n);if(!r)return!1;let i=p9(r);if(!i){let n=r.blockRange(),i=n&&pm(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let o=i.nodeBefore;if(fn(e,i,t,-1))return!0;if(0==r.parent.content.size&&(p4(o,"end")||pF.isSelectable(o)))for(let n=r.depth;;n--){let s=pw(e.doc,r.before(n),r.after(n),hx.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(p4(o,"end")?pP.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):pF.create(n.doc,i.pos-o.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!!o.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0)},p3=(e,t,n)=>{let r=p5(e,n);if(!r)return!1;let i=p9(r);return!!i&&function(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let o=t.nodeAfter,s=t.pos+1;for(;!o.isTextblock;s++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let a=pw(e.doc,i,s,hx.empty);if(!a||a.from!=i||a instanceof pu&&a.slice.size>=s-i)return!1;if(n){let t=e.tr.step(a);t.setSelection(pz.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,i,t)};function p4(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let p7=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=p9(r)}let s=o&&o.nodeBefore;return!!s&&!!pF.isSelectable(s)&&(t&&t(e.tr.setSelection(pF.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function p9(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 fe(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}function ft(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function fn(e,t,n,r){let i,o,s,a=t.nodeBefore,l=t.nodeAfter,c,d,u=a.type.spec.isolating||l.type.spec.isolating;if(!u&&(i=t.nodeBefore,o=t.nodeAfter,s=t.index(),i&&o&&i.type.compatibleContent(o.type)&&(!i.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),!0):!!t.parent.canReplace(s,s+1)&&!!(o.isTextblock||pk(e.doc,t.pos))&&(n&&n(e.tr.join(t.pos).scrollIntoView()),!0))))return!0;let h=!u&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(c=(d=a.contentMatchAt(a.childCount)).findWrapping(l.type))&&d.matchType(c[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=hf.empty;for(let e=c.length-1;e>=0;e--)i=hf.from(c[e].create(null,i));i=hf.from(a.copy(i));let o=e.tr.step(new ph(t.pos-1,r,t.pos,r,new hx(i,1,0),c.length,!0)),s=o.doc.resolve(r+2*c.length);s.nodeAfter&&s.nodeAfter.type==a.type&&pk(o.doc,s.pos)&&o.join(s.pos),n(o.scrollIntoView())}return!0}let p=l.type.spec.isolating||r>0&&u?null:pP.findFrom(t,1),f=p&&p.$from.blockRange(p.$to),m=f&&pm(f);if(null!=m&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(h&&p4(l,"start",!0)&&p4(a,"end")){let r=a,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let o=l,s=1;for(;!o.isTextblock;o=o.firstChild)s++;if(r.canReplace(r.childCount,r.childCount,o.content)){if(n){let r=hf.empty;for(let e=i.length-1;e>=0;e--)r=hf.from(i[e].copy(r));n(e.tr.step(new ph(t.pos-i.length,t.pos+l.nodeSize,t.pos+s,t.pos+l.nodeSize-s,new hx(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(pz.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}let fi=fr(-1),fo=fr(1);function fs(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&pg(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function fa(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(o,s,(r,o)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(o),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];i.setBlockType(o,s,e,t)}r(i.scrollIntoView())}return!0}}function fl(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),i=!1!==(n&&n.enterInlineAtoms),o=!(n&&n.includeWhitespace);return function(n,s){let{empty:a,$cursor:l,ranges:c}=n.selection;if(a&&!l||!function(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:o,$to:s}=t[i],a=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.pos,s.pos,(e,t)=>{if(a||!r&&e.isAtom&&e.isInline&&t>=o.pos&&t+e.nodeSize<=s.pos)return!1;a=e.inlineContent&&e.type.allowsMarkType(n)}),a)return!0}return!1}(n.doc,c,e,i))return!1;if(s)if(l)s(e.isInSet(n.storedMarks||l.marks())?n.tr.removeStoredMark(e):n.tr.addStoredMark(e.create(t)));else{let a,l=n.tr;i||(c=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new p_(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new p_(r,i))}return t}(c)),a=r?!c.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!c.every(t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,o)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!o&&o.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<c.length;n++){let{$from:r,$to:i}=c[n];if(a){let n=r.pos,s=i.pos,a=r.nodeAfter,c=i.nodeBefore,d=o&&a&&a.isText?/^\s*/.exec(a.text)[0].length:0,u=o&&c&&c.isText?/\s*$/.exec(c.text)[0].length:0;n+d<s&&(n+=d,s-=u),l.addMark(n,s,e.create(t))}else l.removeMark(r.pos,i.pos,e)}s(l.scrollIntoView())}return!0}}function fc(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}let fd=fc(p8,p6,p7),fu=fc(p8,(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}(e,n);if(!r)return!1;let i=fe(r);if(!i)return!1;let o=i.nodeAfter;if(fn(e,i,t,1))return!0;if(0==r.parent.content.size&&(p4(o,"start")||pF.isSelectable(o))){let n=pw(e.doc,r.before(),r.after(),hx.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(p4(o,"start")?pP.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):pF.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!!o.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=fe(r)}let s=o&&o.nodeAfter;return!!s&&!!pF.isSelectable(s)&&(t&&t(e.tr.setSelection(pF.create(e.doc,o.pos)).scrollIntoView()),!0)}),fh={Enter:fc((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof pH||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ft(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(pz.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(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 r=n.before();if(px(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&pm(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof pF&&e.selection.node.isBlock)return!!n.parentOffset&&!!px(e.doc,n.pos)&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let i=[],o,s,a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){let t;a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),s=ft(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));i.unshift(t||(a&&s?{type:s}:null)),o=e;break}if(1==e)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof pz||e.selection instanceof pH)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=px(c.doc,d,i.length,i);if(u||(i[0]=s?{type:s}:null,u=px(c.doc,d,i.length,i)),!u)return!1;if(c.split(d,i.length,i),!a&&l&&n.node(o).type!=s){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);s&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&c.setNodeMarkup(c.mapping.map(n.before(o)),s)}return t&&t(c.scrollIntoView()),!0}),"Mod-Enter":(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=ft(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,s.createAndFill());i.setSelection(pP.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Backspace:fd,"Mod-Backspace":fd,"Shift-Backspace":fd,Delete:fu,"Mod-Delete":fu,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new pH(e.doc))),!0)},fp={"Ctrl-h":fh.Backspace,"Alt-Backspace":fh["Mod-Backspace"],"Ctrl-d":fh.Delete,"Ctrl-Alt-Backspace":fh["Mod-Delete"],"Alt-Delete":fh["Mod-Delete"],"Alt-d":fh["Mod-Delete"],"Ctrl-a":fi,"Ctrl-e":fo};for(let e in fh)fp[e]=fh[e];let ff=("u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&!!os.platform&&"darwin"==os.platform())?fp:fh,fm={}.hasOwnProperty;function fg(e,t,n){return">"+(n?"":" ")+e}function fy(e,t){return fv(e,t.inConstruct,!0)&&!fv(e,t.notInConstruct,!1)}function fv(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function fb(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if("\n"===n.unsafe[i].character&&fy(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function fx(e,t){return!!(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fk(e,t,n){return(n?"":" ")+e}function fw(e){let t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function fS(e){return"&#x"+e.toString(16).toUpperCase()+";"}function fC(e,t,n){let r=dy(e),i=dy(t);return void 0===r?void 0===i?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===i?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===i?{inside:!1,outside:!1}:1===i?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===i?{inside:!1,outside:!1}:1===i?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function fN(e,t,n,r){let i=function(e){let t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i),l=s.move(n.containerPhrasing(e,{after:i,before:a,...s.current()})),c=l.charCodeAt(0),d=fC(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=fS(c)+l.slice(1));let u=l.charCodeAt(l.length-1),h=fC(r.after.charCodeAt(0),u,i);h.inside&&(l=l.slice(0,-1)+fS(u));let p=s.move(i);return o(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+l+p}function fA(e,t){let n=!1;return um(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,!1}),!!((!e.depth||e.depth<3)&&cW(e)&&(t.options.setext||n))}function fE(e){return e.value||""}function fM(e,t,n,r){let i=fw(n),o='"'===i?"Quote":"Apostrophe",s=n.enter("image"),a=n.enter("label"),l=n.createTracker(r),c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),s(),c}function fT(e,t,n,r){let i=e.referenceType,o=n.enter("imageReference"),s=n.enter("label"),a=n.createTracker(r),l=a.move("!["),c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),s();let d=n.stack;n.stack=[],s=n.enter("reference");let u=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return s(),n.stack=d,o(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(u+"]"),l}function fI(e,t,n){let r=e.value||"",i="`",o=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){let e,t=n.unsafe[o],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}function fL(e,t){let n=cW(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function fO(e,t,n,r){let i,o,s=fw(n),a='"'===s?"Quote":"Apostrophe",l=n.createTracker(r);if(fL(e,n)){let t=n.stack;n.stack=[],i=n.enter("autolink");let r=l.move("<");return r+=l.move(n.containerPhrasing(e,{before:r,after:">",...l.current()})),r+=l.move(">"),i(),n.stack=t,r}i=n.enter("link"),o=n.enter("label");let c=l.move("[");return c+=l.move(n.containerPhrasing(e,{before:c,after:"](",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${a}`),c+=l.move(" "+s),c+=l.move(n.safe(e.title,{before:c,after:s,...l.current()})),c+=l.move(s),o()),c+=l.move(")"),i(),c}function fD(e,t,n,r){let i=e.referenceType,o=n.enter("linkReference"),s=n.enter("label"),a=n.createTracker(r),l=a.move("["),c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),s();let d=n.stack;n.stack=[],s=n.enter("reference");let u=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return s(),n.stack=d,o(),"full"!==i&&c&&c===u?"shortcut"===i?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(u+"]"),l}function fR(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function fP(e){let t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}fN.peek=function(e,t,n){return n.options.emphasis||"*"},fE.peek=function(){return"<"},fM.peek=function(){return"!"},fT.peek=function(){return"!"},fI.peek=function(){return"`"},fO.peek=function(e,t,n){return fL(e,n)?"<":"["},fD.peek=function(){return"["};let f_=uc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function fj(e,t,n,r){let i=function(e){let t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i),l=s.move(n.containerPhrasing(e,{after:i,before:a,...s.current()})),c=l.charCodeAt(0),d=fC(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=fS(c)+l.slice(1));let u=l.charCodeAt(l.length-1),h=fC(r.after.charCodeAt(0),u,i);h.inside&&(l=l.slice(0,-1)+fS(u));let p=s.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},a+l+p}fj.peek=function(e,t,n){return n.options.strong||"*"};let fB={blockquote:function(e,t,n,r){let i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);let s=n.indentLines(n.containerFlow(e,o.current()),fg);return i(),s},break:fb,code:function(e,t,n,r){let i=function(e){let t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),o=e.value||"",s="`"===i?"GraveAccent":"Tilde";if(fx(e,n)){let e=n.enter("codeIndented"),t=n.indentLines(o,fk);return e(),t}let a=n.createTracker(r),l=i.repeat(Math.max(function(e,t){let n=String(e),r=n.indexOf(t),i=r,o=0,s=0;if("string"!=typeof t)throw TypeError("Expected substring");for(;-1!==r;)r===i?++o>s&&(s=o):o=1,i=r+t.length,r=n.indexOf(t,i);return s}(o,i)+1,3)),c=n.enter("codeFenced"),d=a.move(l);if(e.lang){let t=n.enter(`codeFencedLang${s}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${s}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:"\n",encode:["`"],...a.current()})),t()}return d+=a.move("\n"),o&&(d+=a.move(o+"\n")),d+=a.move(l),c(),d},definition:function(e,t,n,r){let i=fw(n),o='"'===i?"Quote":"Apostrophe",s=n.enter("definition"),a=n.enter("label"),l=n.createTracker(r),c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),a(),e.title&&(a=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),s(),c},emphasis:fN,hardBreak:fb,heading:function(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(fA(e,n)){let t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...o.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===i?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}let s="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");o.move(s+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...o.current()});return/^[\t ]/.test(c)&&(c=fS(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),l(),a(),c},html:fE,image:fM,imageReference:fT,inlineCode:fI,link:fO,linkReference:fD,list:function(e,t,n,r){let i=n.enter("list"),o=n.bulletCurrent,s=e.ordered?function(e){let t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):fR(n),a=e.ordered?"."===s?")":".":function(e){let t=fR(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n),l=!!t&&!!n.bulletLastUsed&&s===n.bulletLastUsed;if(!e.ordered){let t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),fP(n)===s&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(s=a),n.bulletCurrent=s;let c=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=o,i(),c},listItem:function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),o=n.bulletCurrent||fR(n);t&&"list"===t.type&&t.ordered&&(o=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+o);let s=o.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));let a=n.createTracker(r);a.move(o+" ".repeat(s-o.length)),a.shift(s);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),function(e,t,n){return t?(n?"":" ".repeat(s))+e:(n?o:o+" ".repeat(s-o.length))+e});return l(),c},paragraph:function(e,t,n,r){let i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,r);return o(),i(),s},root:function(e,t,n,r){return(e.children.some(function(e){return f_(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:fj,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){let r=(fP(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}},fz=[function(e,t,n,r){if("code"===t.type&&fx(t,r)&&("list"===e.type||e.type===t.type&&fx(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&fA(t,r)))return;return+!!n.spread}}],f$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],fF=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:f$},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"+",after:"(?:[ \r\n])"},{atBreak:!0,character:"-",after:"(?:[ \r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:f$},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:f$},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:f$},{atBreak:!0,character:"~"}];function fU(e){return e.label||!e.identifier?e.label||"":d2(e.identifier)}function fH(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}let fW=/\r?\n|\r/g;function fV(e,t){let n,r=[],i=0,o=0;for(;n=fW.exec(e);)s(e.slice(i,n.index)),r.push(n[0]),i=n.index+n[0].length,o++;return s(e.slice(i)),r.join("");function s(e){r.push(t(e,o,!e))}}function fG(e,t){return e-t}function fq(e,t){let n,r=/\\(?=[!-/:-@[-`{-~])/g,i=[],o=[],s=e+t,a=-1,l=0;for(;n=r.exec(s);)i.push(n.index);for(;++a<i.length;)l!==i[a]&&o.push(e.slice(l,i[a])),o.push("\\"),l=i[a];return o.push(e.slice(l)),o.join("")}function fK(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,o=n.column||1;return{move:function(e){let t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return i+=n.length-1,o=1===n.length?o+s.length:1+s.length+r,t},current:function(){return{now:{line:i,column:o},lineShift:r}},shift:function(e){r+=e}}}function fJ(e){throw Error("Cannot handle value `"+e+"`, expected node")}function fX(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function fY(e,t){if("definition"===e.type&&e.type===t.type)return 0}function fQ(e,t){return function(e,t,n){let r,i=t.indexStack,o=e.children||[],s=[],a=-1,l=n.before;i.push(-1);let c=t.createTracker(n);for(;++a<o.length;){let d,u=o[a];if(i[i.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),d=n?n(o[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else d=n.after;s.length>0&&("\r"===l||"\n"===l)&&"html"===u.type&&(s[s.length-1]=s[s.length-1].replace(/(\r?\n|\r)$/," "),l=" ",(c=t.createTracker(n)).move(s.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:l});r&&r===h.slice(0,1)&&(h=fS(r.charCodeAt(0))+h.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,r=void 0,p&&(s.length>0&&p.before&&l===s[s.length-1].slice(-1)&&(s[s.length-1]=s[s.length-1].slice(0,-1)+fS(l.charCodeAt(0))),p.after&&(r=d)),c.move(h),s.push(h),l=h.slice(-1)}return i.pop(),s.join("")}(e,this,t)}function fZ(e,t){return function(e,t,n){let r=t.indexStack,i=e.children||[],o=t.createTracker(n),s=[],a=-1;for(r.push(-1);++a<i.length;){let n=i[a];r[r.length-1]=a,s.push(o.move(t.handle(n,e,t,{before:"\n",after:"\n",...o.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<i.length-1&&s.push(o.move(function(e,t,n,r){let i=r.join.length;for(;i--;){let o=r.join[i](e,t,n,r);if(!0===o||1===o)break;if("number"==typeof o)return"\n".repeat(1+o);if(!1===o)return"\n\n<!---->\n\n"}return"\n\n"}(n,i[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function f0(e,t){return function(e,t,n){let r=(n.before||"")+(t||"")+(n.after||""),i=[],o=[],s={},a=-1;for(;++a<e.unsafe.length;){let t,n=e.unsafe[a];if(!fy(e.stack,n))continue;let o=e.compilePattern(n);for(;t=o.exec(r);){let e="before"in n||!!n.atBreak,r="after"in n,o=t.index+(e?t[1].length:0);i.includes(o)?(s[o].before&&!e&&(s[o].before=!1),s[o].after&&!r&&(s[o].after=!1)):(i.push(o),s[o]={before:e,after:r})}}i.sort(fG);let l=n.before?n.before.length:0,c=r.length-(n.after?n.after.length:0);for(a=-1;++a<i.length;){let e=i[a];!(e<l)&&!(e>=c)&&(!(e+1<c)||i[a+1]!==e+1||!s[e].after||s[e+1].before||s[e+1].after)&&(i[a-1]!==e-1||!s[e].before||s[e-1].before||s[e-1].after)&&(l!==e&&o.push(fq(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(o.push(fS(r.charCodeAt(e))),l++):o.push("\\"))}return o.push(fq(r.slice(l,c),n.after)),o.join("")}(this,e,t)}function f1(e){let t=this;t.compiler=function(n){var r;let i,o;return r={...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]},!function e(t,n){var r,i,o,s;let a,l=-1;if(n.extensions)for(;++l<n.extensions.length;)e(t,n.extensions[l]);for(a in n)if(fm.call(n,a))switch(a){case"extensions":break;case"unsafe":case"join":r=t[a],(i=n[a])&&r.push(...i);break;case"handlers":o=t[a],(s=n[a])&&Object.assign(o,s);break;default:t.options[a]=n[a]}return t}(i={associationId:fU,containerPhrasing:fQ,containerFlow:fZ,createTracker:fK,compilePattern:fH,enter:function(e){return i.stack.push(e),function(){i.stack.pop()}},handlers:{...fB},handle:void 0,indentLines:fV,indexStack:[],join:[...fz],options:{},safe:f0,stack:[],unsafe:[...fF]},r||{}),i.options.tightDefinitions&&i.join.push(fY),i.handle=n8("type",{invalid:fJ,unknown:fX,handlers:i.handlers}),(o=i.handle(n,void 0,i,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0}))&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}}var f2=e=>{throw TypeError(e)},f8=(e,t,n)=>t.has(e)||f2("Cannot "+n),f5=(e,t,n)=>(f8(e,t,"read from private field"),n?n.call(e):t.get(e)),f6=(e,t,n)=>t.has(e)?f2("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),f3=(e,t,n,r)=>(f8(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class f4{}class f7{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw he();return e}}}class f9 extends f4{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new f9(e,t,n)}}let me=class extends f7{constructor(e){super(),f6(this,R),f6(this,P),f6(this,_),f6(this,j),f6(this,B),f6(this,z),f6(this,$),f3(this,R,hv.none),f3(this,P,e=>e.isText),f3(this,_,(e,t)=>{if(f5(this,P).call(this,e)&&f5(this,P).call(this,t)&&hv.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)}),f3(this,j,e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t){var n;throw n=e,new u4(u3.parserMatchError,`Cannot match target parser for node: ${JSON.stringify(n,u7)}.`)}return t}),f3(this,B,e=>{let t=f5(this,j).call(this,e);t.spec.parseMarkdown.runner(this,e,t)}),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(f9.create(e,[],t)),this),f3(this,z,()=>{f3(this,R,hv.none);let e=this.close();return f5(this,$).call(this,e.type,e.attrs,e.content)}),this.closeNode=()=>{try{f5(this,z).call(this)}catch(e){console.error(e)}return this},f3(this,$,(e,t,n)=>{let r=e.createAndFill(t,n,f5(this,R));if(!r){let r,i,o,s;throw r="name"in e?e.name:e,i=`Cannot create node for ${r}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},s=[["[Description]",i],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{let r=`${t}: ${o(n)}.`;return e.concat(r)},[]),new u4(u3.createNodeInParserFail,s.join("\n"))}return this.push(r),r}),this.addNode=(e,t,n)=>{try{f5(this,$).call(this,e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{let n=e.create(t);return f3(this,R,n.addToSet(f5(this,R))),this},this.closeMark=e=>(f3(this,R,e.removeFromSet(f5(this,R))),this),this.addText=e=>{try{let t=this.top();if(!t)throw he();let n=t.pop(),r=this.schema.text(e,f5(this,R));if(!n)return t.push(r),this;let i=f5(this,_).call(this,n,r);if(i)return t.push(i),this;return t.push(n,r),this}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=f5(this,z).call(this);while(this.size())return e},this.next=(e=[])=>([e].flat().forEach(e=>f5(this,B).call(this,e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}};R=new WeakMap,P=new WeakMap,_=new WeakMap,j=new WeakMap,B=new WeakMap,z=new WeakMap,$=new WeakMap,me.create=(e,t)=>{let n=new me(e);return e=>(n.run(t,e),n.toDoc())};let mt=class extends f4{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}};mt.create=(e,t,n,r={})=>new mt(e,t,n,r);let mn=class extends f7{constructor(e){super(),f6(this,F),f6(this,U),f6(this,H),f6(this,W),f6(this,V),f6(this,G),f6(this,q),f6(this,K),f6(this,J),f6(this,X),f6(this,Y),f6(this,Q),f6(this,Z),f3(this,F,hv.none),f3(this,U,e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t){var n;throw n=e.type,new u4(u3.serializerMatchError,`Cannot match target serializer for node: ${JSON.stringify(n,u7)}.`)}return t}),f3(this,H,e=>f5(this,U).call(this,e).spec.toMarkdown.runner(this,e)),f3(this,W,(e,t)=>f5(this,U).call(this,e).spec.toMarkdown.runner(this,e,t)),f3(this,V,e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!f5(this,W).call(this,t,e))&&f5(this,H).call(this,e),t.forEach(e=>f5(this,Z).call(this,e))}),f3(this,G,(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,o={...e,children:i};return o.children=i,r.children=[o],r}),f3(this,q,e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){let{children:n,...i}=t=f5(this,G).call(this,t,r.type),{children:o,...s}=r;if(t.type===r.type&&n&&o&&JSON.stringify(i)===JSON.stringify(s)){let t={...s,children:[...o,...n]};return e.slice(0,-1).concat(f5(this,q).call(this,t))}}return e.concat(t)},[])),e}),f3(this,K,e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t}),this.openNode=(e,t,n)=>(this.open(mt.create(e,void 0,t,n)),this),f3(this,J,(e,t)=>{let n="",r="",i=e.children,o=-1,s=-1;if(i){i&&i.forEach((e,t)=>{"text"===e.type&&e.value&&(o<0&&(o=t),s=t)});let e=i?.[s],t=i?.[o];if(e&&e.value.endsWith(" ")){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&f5(this,Y).call(this,"text",void 0,n);let a=t();return r.length&&f5(this,Y).call(this,"text",void 0,r),a}),f3(this,X,(e=!1)=>{let t=this.close(),n=()=>f5(this,Y).call(this,t.type,t.children,t.value,t.props);return e?f5(this,J).call(this,t,n):n()}),this.closeNode=()=>(f5(this,X).call(this),this),f3(this,Y,(e,t,n,r)=>{let i=mt.create(e,t,n,r),o=f5(this,q).call(this,f5(this,K).call(this,i));return this.push(o),o}),this.addNode=(e,t,n,r)=>(f5(this,Y).call(this,e,t,n,r),this),f3(this,Q,(e,t,n,r)=>e.isInSet(f5(this,F))?this:(f3(this,F,e.addToSet(f5(this,F))),this.openNode(t,n,{...r,isMark:!0}))),f3(this,Z,e=>{e.isInSet(f5(this,F))&&(f3(this,F,e.type.removeFromSet(f5(this,F))),f5(this,X).call(this,!0))}),this.withMark=(e,t,n,r)=>(f5(this,Q).call(this,e,t,n,r),this),this.closeMark=e=>(f5(this,Z).call(this,e),this),this.build=()=>{let e=null;do e=f5(this,X).call(this);while(this.size())return e},this.next=e=>(Object.prototype.hasOwnProperty.call(e,"size")?e.forEach(e=>{f5(this,V).call(this,e)}):f5(this,V).call(this,e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}};F=new WeakMap,U=new WeakMap,H=new WeakMap,W=new WeakMap,V=new WeakMap,G=new WeakMap,q=new WeakMap,K=new WeakMap,J=new WeakMap,X=new WeakMap,Y=new WeakMap,Q=new WeakMap,Z=new WeakMap,mn.create=(e,t)=>{let n=new mn(e);return e=>(n.run(e),n.toString(t))};class mr{constructor(e,t,n={}){this.match=e,this.match=e,this.handler="string"==typeof t?function(e){return function(t,n,r,i){let o=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);o+=n[0].slice(e+n[1].length);let t=(r+=e)-i;t>0&&(o=n[0].slice(e-t,e)+o,r=i)}return t.tr.insertText(o,r,i)}}(t):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}let mi=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function mo(e,t,n=null,r){return new mr(e,(e,i,o,s)=>{let a=n instanceof Function?n(i):n,l=e.tr.delete(o,s),c=l.doc.resolve(o).blockRange(),d=c&&pg(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(o-1).nodeBefore;return u&&u.type==t&&pk(l.doc,o-1)&&(!r||r(i,u))&&l.join(o-1),l})}function ms(e,t,n=null){return new mr(e,(e,r,i,o)=>{let s=e.doc.resolve(i),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(i,o).setBlockType(i,i,t,a):null})}new mr(/--$/,"—",{inCodeMark:!1}),new mr(/\.\.\.$/,"…",{inCodeMark:!1}),new mr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new mr(/"$/,"”",{inCodeMark:!1}),new mr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new mr(/'$/,"’",{inCodeMark:!1});let ma="u">typeof navigator?navigator:null,ml="u">typeof document?document:null,mc=ma&&ma.userAgent||"",md=/Edge\/(\d+)/.exec(mc),mu=/MSIE \d/.exec(mc),mh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mc),mp=!!(mu||mh||md);mu?document.documentMode:mh?mh[1]:md&&md[1],!mp&&/gecko\/(\d+)/i.test(mc)&&(/Firefox\/(\d+)/.exec(mc)||[0,0])[1];let mf=!mp&&/Chrome\/(\d+)/.exec(mc);function mm(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of i){let i=a.match.exec(l),c=i&&i[0]&&a.handler(s,i,t-(i[0].length-r.length),n);if(c)return!1!==a.undoable&&c.setMeta(o,{transform:c,from:t,to:n,text:r}),e.dispatch(c),!0}return!1}mf&&mf[1],!mp&&ma&&/Apple Computer/.test(ma.vendor)&&(/Mobile\/\w+/.test(mc)||ma&&ma.maxTouchPoints>2)||ma&&/Mac/.test(ma.platform),/Android \d/.test(mc),ml&&"webkitFontSmoothing"in ml.documentElement.style&&(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];let mg=new p2("MILKDOWN_CUSTOM_INPUTRULES");function my(e,t,n={}){return new mr(e,(e,r,i,o)=>{var s,a,l,c;let{tr:d}=e,u=r.length,h=r[u-1],p=r[0],f=[],m=o,g={group:h,fullMatch:p,start:i,end:o},y=null==(s=n.updateCaptured)?void 0:s.call(n,g);if(Object.assign(g,y),{group:h,fullMatch:p,start:i,end:o}=g,null===p||(null==h?void 0:h.trim())==="")return null;if(h){let e=p.search(/\S/),s=i+p.indexOf(h),u=s+h.length;f=null!=(a=d.storedMarks)?a:[],u<o&&d.delete(u,o),s>i&&d.delete(i+e,s),m=i+e+h.length;let g=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(i,m,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:i,end:o,tr:d})}return d})}Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;for(var mv={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:"'"},mb={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mx="u">typeof navigator&&/Mac/.test(navigator.platform),mk="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),mw=0;mw<10;mw++)mv[48+mw]=mv[96+mw]=String(mw);for(var mw=1;mw<=24;mw++)mv[mw+111]="F"+mw;for(var mw=65;mw<=90;mw++)mv[mw]=String.fromCharCode(mw+32),mb[mw]=String.fromCharCode(mw);for(var mS in mv)mb.hasOwnProperty(mS)||(mb[mS]=mv[mS]);let mC="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),mN="u">typeof navigator&&/Win/.test(navigator.platform);function mA(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 mE(e){let t;return new pZ({props:{handleKeyDown:(t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else if(/^mod$/i.test(s))mC?i=!0:n=!0;else throw Error("Unrecognized modifier name: "+s)}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}(n)]=e[n];return t}(e),function(e,n){var r;let i=("Esc"==(r=!(mx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||mk&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?mb:mv)[n.keyCode]||n.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o,s=t[mA(i,n)];if(s&&s(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[mA(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(mN&&n.ctrlKey&&n.altKey)&&(o=mv[n.keyCode])&&o!=i){let r=t[mA(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1})}})}let mM=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},mT=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},mI=null,mL=function(e,t,n){let r=mI||(mI=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},mO=function(){mI=null},mD=function(e,t,n,r){return n&&(mP(e,t,n,r,-1)||mP(e,t,n,r,1))},mR=/^(img|br|input|textarea|hr)$/i;function mP(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:m_(e))){let n=e.parentNode;if(!n||1!=n.nodeType||mj(e)||mR.test(e.nodeName)||"false"==e.contentEditable)return!1;t=mM(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable)if(null==(o=n.pmViewDesc)||!o.ignoreForSelection)return!1;else t+=i;else e=n,t=i<0?m_(e):0}}}function m_(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function mj(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)}let mB=function(e){return e.focusNode&&mD(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function mz(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let m$="u">typeof navigator?navigator:null,mF="u">typeof document?document:null,mU=m$&&m$.userAgent||"",mH=/Edge\/(\d+)/.exec(mU),mW=/MSIE \d/.exec(mU),mV=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mU),mG=!!(mW||mV||mH),mq=mW?document.documentMode:mV?+mV[1]:mH?+mH[1]:0,mK=!mG&&/gecko\/(\d+)/i.test(mU);mK&&(/Firefox\/(\d+)/.exec(mU)||[0,0])[1];let mJ=!mG&&/Chrome\/(\d+)/.exec(mU),mX=!!mJ,mY=mJ?+mJ[1]:0,mQ=!mG&&!!m$&&/Apple Computer/.test(m$.vendor),mZ=mQ&&(/Mobile\/\w+/.test(mU)||!!m$&&m$.maxTouchPoints>2),m0=mZ||!!m$&&/Mac/.test(m$.platform),m1=!!m$&&/Win/.test(m$.platform),m2=/Android \d/.test(mU),m8=!!mF&&"webkitFontSmoothing"in mF.documentElement.style,m5=m8?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function m6(e,t){return"number"==typeof e?e:e[t]}function m3(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=mT(s);continue}let e=s,n=e==o.body,a=n?function(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}}(o):function(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}}(e),l=0,c=0;if(t.top<a.top+m6(r,"top")?c=-(a.top-t.top+m6(i,"top")):t.bottom>a.bottom-m6(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+m6(i,"top")-a.top:t.bottom-a.bottom+m6(i,"bottom")),t.left<a.left+m6(r,"left")?l=-(a.left-t.left+m6(i,"left")):t.right>a.right-m6(r,"right")&&(l=t.right-a.right+m6(i,"right")),l||c)if(n)o.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,o=e.scrollTop-r;t={left:t.left-i,top:t.top-o,right:t.right-i,bottom:t.bottom-o}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:mT(s)}}function m4(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=mT(r));return t}function m7(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:o}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let m9=null;function ge(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function gt(e){return e.top<e.bottom||e.left<e.right}function gn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(gt(e))return e}return Array.prototype.find.call(n,gt)||e.getBoundingClientRect()}let gr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gi(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=m8||mK;if(3==r.nodeType)if(s&&(gr.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=gn(mL(r,i,i),n);if(mK&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=gn(mL(r,i-1,i-1),-1);if(t.top==e.top){let n=gn(mL(r,i,i+1),-1);if(n.top!=e.top)return go(n,n.left<t.left)}}return e}else{let e=i,t=i,o=n<0?1:-1;return n<0&&!i?(t++,o=-1):n>=0&&i==r.nodeValue.length?(e--,o=1):n<0?e--:t++,go(gn(mL(r,e,t),o),o<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&i&&(n<0||i==m_(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return gs(e.getBoundingClientRect(),!1)}if(null==o&&i<m_(r)){let e=r.childNodes[i];if(1==e.nodeType)return gs(e.getBoundingClientRect(),!0)}return gs(r.getBoundingClientRect(),n>=0)}if(null==o&&i&&(n<0||i==m_(r))){let e=r.childNodes[i-1],t=3==e.nodeType?mL(e,m_(e)-!s):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return go(gn(t,1),!1)}if(null==o&&i<m_(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?mL(e,0,+!s):1==e.nodeType?e:null:null;if(t)return go(gn(t,-1),!0)}return go(gn(3==r.nodeType?mL(r):r,-n),n>=0)}function go(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function gs(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function ga(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}let gl=/[\u0590-\u08ac]/,gc=null,gd=null,gu=!1;class gh{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){let r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}if(e==this.dom&&this.contentDOM)r=t>mM(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),o;if(i&&(!t||i.node))if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;else n=!1}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],o=t+i.size;if(o>e||i instanceof gb){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof gp&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?mM(e.dom)+1:0}}{let e,r=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?mM(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let o=n,s=0;;s++){let n=this.children[s],a=o+n.size;if(-1==r&&e<=a){let i=o+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=mM(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=mM(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(i>a&&o<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((mK||mQ)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if((d=!!(t&&"\n"==e.nodeValue[t-1]))&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){"BR"==n.nodeName&&(s=a={node:n.parentNode,offset:mM(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(mK&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&mQ)&&mD(s.node,s.offset,c.anchorNode,c.anchorOffset)&&mD(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&!(d&&mK)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let r=n+i.border,s=o-i.border;if(e>=r&&t<=s){this.dirty=e==n||t==o?2:1,e==r&&t==s&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=3:i.markDirty(e-r,t-r);return}i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class gp extends gh{constructor(e,t,n,r){let i,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class gf extends gh{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class gm extends gh{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(e,t,n,r){let i=r.nodeViews[t.type.name],o=i&&i(t,r,n);return o&&o.dom||(o=h6.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new gm(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=gm.create(this.parent,this.mark,!0,n),i=this.children,o=this.size;t<o&&(i=gI(i,t,o,n)),e>0&&(i=gI(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gg extends gh{constructor(e,t,n,r,i,o,s,a,l){super(e,[],i,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,o){let s=i.nodeViews[t.type.name],a,l=s&&s(t,i,()=>a?a.parent?a.parent.posBeforeChild(a):void 0:o,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=h6.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return(c=gN(c,n,t),l)?a=new gx(e,t,n,r,c,d||null,u,l,i,o+1):t.isText?new gv(e,t,n,r,c,u,i):new gg(e,t,n,r,c,d||null,u,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>hf.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&gA(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,s=i&&i.pos<0,a=new gM(this,o&&o.node,e);(function(e,t,n,r){let i=t.locals(e),o=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,i,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<i.length&&i[s].to==o;){let e=i[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(gT);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else if(c<e.childCount)p=c,h=e.child(c++);else break;for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let f=o+h.nodeSize;if(h.isText){let e=f;s<i.length&&i[s].from<e&&(e=i[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-o),h=h.cut(0,e-o),f=e,p=-1)}else for(;s<i.length&&i[s].to<f;)s++;let m=h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice();r(h,m,t.forChild(o,h),p),o=f}})(this.node,this.innerDeco,(t,i,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!o&&a.syncToMarks(i==this.node.childCount?hv.none:this.node.child(i).marks,n,e,i),a.placeWidget(t,e,r)},(t,o,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,o,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,l,d,e)||a.updateNextNode(t,o,l,e,c,r)||a.addNode(t,o,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),function e(t,n,r){let i=t.firstChild,o=!1;for(let s=0;s<n.length;s++){let a=n[s],l=a.dom;if(l.parentNode==t){for(;l!=i;)i=gE(i),o=!0;i=i.nextSibling}else o=!0,t.insertBefore(l,i);if(a instanceof gm){let n=i?i.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),i=n?n.nextSibling:t.firstChild}}for(;i;)i=gE(i),o=!0;o&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),mZ&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof pz)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(!this.node.inlineContent)return{node:i,pos:-1,text:""};{let e=i.nodeValue,o=function(e,t,n,r){for(let i=0,o=0;i<e.childCount&&o<=r;){let s=e.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<e.childCount;){let t=e.child(i++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}if(o>=n){if(o>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return -1}(this.node.content,e,n-t,r-t);return o<0?null:{node:i,pos:o,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new gf(this,i,t,r);e.input.compositionNodes.push(o),this.children=gI(this.children,n,n+r.length,e,o)}update(e,t,n,r){return 3!=this.dirty&&!!e.sameMarkup(this.node)&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(gA(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=gC(this.dom,this.nodeDOM,gS(this.outerDeco,this.node,t),gS(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function gy(e,t,n,r,i){gN(r,t,e);let o=new gg(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class gv extends gg{constructor(e,t,n,r,i,o,s){super(e,t,n,r,i,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!e.sameMarkup(this.node)&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new gv(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class gb extends gh{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gx extends gg{constructor(e,t,n,r,i,o,s,a,l,c){super(e,t,n,r,i,o,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return(!!this.contentDOM||!!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let gk=function(e){e&&(this.nodeName=e)};gk.prototype=Object.create(null);let gw=[new gk];function gS(e,t,n){if(0==e.length)return gw;let r=n?gw[0]:new gk,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s)for(let e in s.nodeName&&i.push(r=new gk(s.nodeName)),s){let o=s[e];null!=o&&(n&&1==i.length&&i.push(r=new gk(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}return i}function gC(e,t,n,r){if(n==gw&&r==gw)return t;let i=t;for(let t=0;t<r.length;t++){let o=r[t],s=n[t];if(t){let t;s&&s.nodeName==o.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==o.nodeName||((t=document.createElement(o.nodeName)).pmIsDeco=!0,t.appendChild(i),s=gw[0]),i=t}!function(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}(i,s||gw[0],o)}return i}function gN(e,t,n){return gC(e,e,gw,gS(t,n,1!=e.nodeType))}function gA(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 gE(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class gM{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];r:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(e instanceof gm)n=e,r=e.children.length;else{a=e,r--;break}}else if(n==t)break r;else r=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(l){if(l!=e.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let i=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=gm.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let i=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return -1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return -1}e=t}}updateNextNode(e,t,n,r,i,o){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof gg){let l=this.preMatch.matched.get(a);if(null!=l&&l!=i)return!1;let c=a.dom,d,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&gA(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(a,e,t,n,r,o)))return this.destroyBetween(this.index,s),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=2,d.updateChildren(r,o+1),d.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!gA(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=gg.create(this.top,t,n,r,i,o);if(s.contentDOM)for(let t of(s.children=e.children,e.children=[],s.children))t.parent=s;return e.destroy(),s}addNode(e,t,n,r,i){let o=gg.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new gp(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof gm;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof gv)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((mQ||mX)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new gb(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function gT(e,t){return e.type.side-t.type.side}function gI(e,t,n,r,i){let o=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?o.push(l):(c<t&&o.push(l.slice(0,t-c,r)),i&&(o.push(i),i=void 0),d>n&&o.push(l.slice(n-c,l.size,r)))}return o}function gL(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(mB(n)){for(l=s;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&pF.isSelectable(e)&&i.parent&&!(e.isInline&&function(e,t,n){for(let r=0==t,i=t==m_(e);r||i;){if(e==n)return!0;let t=mM(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==m_(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;c=new pF(s==e?a:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,i=s;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(t<0)return null;[l,s]=i==e.state.selection.anchor?[i,t]:[t,i],a=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let n="pointer"==t||e.state.selection.head<a.pos&&!o?1:-1;c=g$(e,d,a,n)}return c}function gO(e){return e.editable?e.hasFocus():gU(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gD(e,t=!1){let n=e.state.selection;if(gB(e,n),gO(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&mX){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&mD(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,mM(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&mG&&mq<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var r;let i,o,s,a,{anchor:l,head:c}=n,d,u;gR&&!(n instanceof pz)&&(n.$from.parent.inlineContent||(d=gP(e,n.from)),n.empty||n.$from.parent.inlineContent||(u=gP(e,n.to))),e.docView.setSelection(l,c,e,t),gR&&(d&&gj(d),u&&gj(u)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((i=(r=e).dom.ownerDocument).removeEventListener("selectionchange",r.input.hideSelectionGuard),s=(o=r.domSelectionRange()).anchorNode,a=o.anchorOffset,i.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(o.anchorNode!=s||o.anchorOffset!=a)&&(i.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!gO(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let gR=mQ||mX&&mY<63;function gP(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(mQ&&i&&"false"==i.contentEditable)return g_(i);if((!i||"false"==i.contentEditable)&&(!o||"false"==o.contentEditable)){if(i)return g_(i);else if(o)return g_(o)}}function g_(e){return e.contentEditable="true",mQ&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function gj(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function gB(e,t){if(t instanceof pF){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(gz(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else gz(e)}function gz(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function g$(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||pz.between(t,n,r)}function gF(e){return(!e.editable||!!e.hasFocus())&&gU(e)}function gU(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function gH(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return o&&pP.findFrom(o,t)}function gW(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function gV(e,t,n){let r=e.state.selection;if(r instanceof pz){if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return gW(e,new pz(r.$anchor,o))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=gH(e.state,t);return!!n&&n instanceof pF&&gW(e,n)}else if(!(m0&&n.indexOf("m")>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,o;if(!i||i.isText)return!1;let s=t<0?n.pos-i.nodeSize:n.pos;return!!(i.isAtom||(o=e.docView.descAt(s))&&!o.contentDOM)&&(pF.isSelectable(i)?gW(e,new pF(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):!!m8&&gW(e,new pz(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}else{if(r instanceof pF&&r.node.isInline)return gW(e,new pz(t>0?r.$to:r.$from));let n=gH(e.state,t);return!!n&&gW(e,n)}}function gG(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function gq(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function gK(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=!1;for(mK&&1==n.nodeType&&r<gG(n)&&gq(n.childNodes[r],-1)&&(s=!0);;)if(r>0)if(1!=n.nodeType)break;else{let e=n.childNodes[r-1];if(gq(e,-1))i=n,o=--r;else if(3==e.nodeType)r=(n=e).nodeValue.length;else break}else if(gJ(n))break;else{let t=n.previousSibling;for(;t&&gq(t,-1);)i=n.parentNode,o=mM(t),t=t.previousSibling;if(t)r=gG(n=t);else{if((n=n.parentNode)==e.dom)break;r=0}}s?gX(e,n,r):i&&gX(e,i,o)}(e):function(e){let t,n,r=e.domSelectionRange(),i=r.focusNode,o=r.focusOffset;if(!i)return;let s=gG(i);for(;;)if(o<s){if(1!=i.nodeType)break;if(gq(i.childNodes[o],1))t=i,n=++o;else break}else if(gJ(i))break;else{let r=i.nextSibling;for(;r&&gq(r,1);)t=r.parentNode,n=mM(r)+1,r=r.nextSibling;if(r)o=0,s=gG(i=r);else{if((i=i.parentNode)==e.dom)break;o=s=0}}t&&gX(e,t,n)}(e)}function gJ(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function gX(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!mj(e);)t=mM(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!mj(e);)t=mM(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(mB(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&gD(e)},50)}function gY(e,t){let n=e.state.doc.resolve(t);if(!(mX||m1)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function gQ(e,t,n){let r=e.state.selection;if(r instanceof pz&&!r.empty||n.indexOf("s")>-1||m0&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=gH(e.state,t);if(n&&n instanceof pF)return gW(e,n)}if(!i.parent.inlineContent){let n=t<0?i:o,s=r instanceof pH?pP.near(n,t):pP.findFrom(n,t);return!!s&&gW(e,s)}return!1}function gZ(e,t){if(!(e.state.selection instanceof pz))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return t<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function g0(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function g1(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:o}=t;for(;i>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||h6.fromSchema(e.state.schema),a=g9(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&1==c.nodeType&&(d=g4[c.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function g2(e,t,n,r,i){let o,s,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new hx(hf.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,s=h6.fromSchema(r);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),o=function(e){var t;let n,r=/^(\s*<meta [^>]*>)*/.exec(e);r&&(e=e.slice(r[0].length));let i=g9().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),s;if((s=o&&g4[o[1].toLowerCase()])&&(e=s.map(e=>"<"+e+">").join("")+e+s.map(e=>"</"+e+">").reverse().join("")),i.innerHTML=(t=e,(n=window.trustedTypes)?(ye||(ye=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),ye.createHTML(t)):t),s)for(let e=0;e<s.length;e++)i=i.querySelector(s[e])||i;return i}(n),m8&&function(e){let t=e.querySelectorAll(mX?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(s||(s=(e.someProp("clipboardParser")||e.someProp("domParser")||hX.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||g8.test(e.parentNode.nodeName)?null:{ignore:!0}})),d)s=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch(t){return e}let{content:i,openStart:o,openEnd:s}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=hf.from(t.create(r[e+1],i)),o++,s++}return new hx(i,o,s)}(g3(s,+d[1],+d[2]),d[4]);else if((s=hx.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,o=[];if(e.forEach(e=>{if(!o)return;let t=r.findWrapping(e.type),n;if(!t)return o=null;if(n=o.length&&i.length&&function e(t,n,r,i,o){if(o<t.length&&o<n.length&&t[o]==n[o]){let s=e(t,n,r,i.lastChild,o+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(o==t.length-1?r.type:t[o+1]))return i.copy(i.content.append(hf.from(g5(r,t,o+1))))}}(t,i,e,o[o.length-1],0))o[o.length-1]=n;else{o.length&&(o[o.length-1]=function e(t,n){if(0==n)return t;let r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(hf.empty,!0);return t.copy(r.append(i))}(o[o.length-1],i.length));let n=g5(e,t);o.push(n),r=r.matchType(n.type),i=t}}),o)return hf.from(o)}return e}(s.content,i),!0)).openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=g3(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}let g8=/^(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 g5(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,hf.from(e));return e}function g6(e,t,n,r,i,o){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(o=0),i<r-1&&(a=g6(a,t,n,r,i+1,o)),i>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(hf.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function g3(e,t,n){return t<e.openStart&&(e=new hx(g6(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new hx(g6(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let g4={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},g7=null;function g9(){return g7||(g7=document.implementation.createHTMLDocument("title"))}let ye=null,yt={},yn={},yr={touchstart:!0,touchmove:!0};class yi{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 yo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ys(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ya(e,t))})}function ya(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function yl(e){return{left:e.clientX,top:e.clientY}}function yc(e,t,n,r,i){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let r=o.depth+1;r>0;r--)if(e.someProp(t,t=>r>o.depth?t(e,n,o.nodeAfter,o.before(r),i,!0):t(e,n,o.node(r),o.before(r),i,!1)))return!0;return!1}function yd(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}yn.keydown=(e,t)=>{if((e.input.shiftKey=16==t.keyCode||t.shiftKey,!yp(e,t))&&(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!m2||!mX||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!mZ||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){let n,r=t.keyCode,i=(n="",t.ctrlKey&&(n+="c"),t.metaKey&&(n+="m"),t.altKey&&(n+="a"),t.shiftKey&&(n+="s"),n);if(8==r||m0&&72==r&&"c"==i)return gZ(e,-1)||gK(e,-1);if(46==r&&!t.shiftKey||m0&&68==r&&"c"==i)return gZ(e,1)||gK(e,1);if(13==r||27==r)return!0;if(37==r||m0&&66==r&&"c"==i){let t=37==r?"ltr"==gY(e,e.state.selection.from)?-1:1:-1;return gV(e,t,i)||gK(e,t)}if(39==r||m0&&70==r&&"c"==i){let t=39==r?"ltr"==gY(e,e.state.selection.from)?1:-1:1;return gV(e,t,i)||gK(e,t)}else if(38==r||m0&&80==r&&"c"==i)return gQ(e,-1,i)||gK(e,-1);else if(40==r||m0&&78==r&&"c"==i)return function(e){if(!mQ||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;g0(e,n,"true"),setTimeout(()=>g0(e,n,"false"),20)}return!1}(e)||gQ(e,1,i)||gK(e,1);else if(i==(m0?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():yo(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},yn.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},yn.keypress=(e,t)=>{if(yp(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||m0&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t)))return void t.preventDefault();let n=e.state.selection;if(!(n instanceof pz)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),i=()=>e.state.tr.insertText(r).scrollIntoView();/[\r\n]/.test(r)||e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,r,i))||e.dispatch(i()),t.preventDefault()}};let yu=m0?"metaKey":"ctrlKey";yt.mousedown=(e,t)=>{var n;let r,i;e.input.shiftKey=t.shiftKey;let o=yy(e),s=Date.now(),a="singleClick";s-e.input.lastClick.time<500&&(r=(n=e.input.lastClick).x-t.clientX)*r+(i=n.y-t.clientY)*i<100&&!t[yu]&&e.input.lastClick.button==t.button&&("singleClick"==e.input.lastClick.type?a="doubleClick":"doubleClick"==e.input.lastClick.type&&(a="tripleClick")),e.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:a,button:t.button};let l=e.posAtCoords(yl(t));l&&("singleClick"==a?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new yh(e,l,t,!!o)):("doubleClick"==a?function(e,t,n,r){return yc(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}:function(e,t,n,r){return yc(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(yd(e,pz.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),o=i.before(t);if(n.inlineContent)yd(e,pz.create(r,o+1,o+1+n.content.size),"pointer");else{if(!pF.isSelectable(n))continue;yd(e,pF.create(r,o),"pointer")}return!0}}(e,n,r)})(e,l.pos,l.inside,t)?t.preventDefault():yo(e,"pointer"))};class yh{constructor(e,t,n,r){let i,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[yu],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,o=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof pF&&l.from<=o&&l.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&mK&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),yo(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>gD(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yl(e))),this.updateAllowDefault(e),this.allowDefault||!t)yo(this.view,"pointer");else{var n,r,i,o;(n=this.view,r=t.pos,i=t.inside,o=this.selectNode,yc(n,"handleClickOn",r,i,e)||n.someProp("handleClick",t=>t(n,r,e))||(o?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,i;n instanceof pF&&(r=n.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if(pF.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?o.before(n.$from.depth):o.before(e);break}}return null!=i&&(yd(e,pF.create(e.state.doc,i),"pointer"),!0)}(n,i):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&pF.isSelectable(r))&&(yd(e,new pF(n),"pointer"),!0)}(n,i)))?e.preventDefault():0==e.button&&(this.flushed||mQ&&this.mightDrag&&!this.mightDrag.node.isAtom||mX&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(yd(this.view,pP.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):yo(this.view,"pointer")}}move(e){this.updateAllowDefault(e),yo(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function yp(e,t){return!!e.composing||!!(mQ&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}yt.touchstart=e=>{e.input.lastTouch=Date.now(),yy(e),yo(e,"pointer")},yt.touchmove=e=>{e.input.lastTouch=Date.now(),yo(e,"pointer")},yt.contextmenu=e=>yy(e);let yf=m2?5e3:-1;function ym(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>yy(e),t))}function yg(e){let t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function yy(e,t=!1){if(!m2||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),yg(e),t||e.docView&&e.docView.dirty){let n=gL(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}}yn.compositionstart=yn.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof pz&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||mX&&m1&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),yy(e,!0),e.markCursor=null;else if(yy(e,!t.selection.empty),mK&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}ym(e,yf)},yn.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,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++,ym(e,20))};let yv=mG&&mq<15||mZ&&m5<604;function yb(e,t,n,r,i){let o=g2(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,o||hx.empty)))return!0;if(!o)return!1;let s=0==o.openStart&&0==o.openEnd&&1==o.content.childCount?o.content.firstChild:null,a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function yx(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," "):""}yt.copy=yn.cut=(e,t)=>{let n=e.state.selection,r="cut"==t.type;if(n.empty)return;let i=yv?null:t.clipboardData,{dom:o,text:s}=g1(e,n.content());i?(t.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",s)):function(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(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,o),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},yn.paste=(e,t)=>{if(e.composing&&!m2)return;let n=yv?null:t.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&yb(e,yx(n),n.getData("text/html"),r,t)?t.preventDefault():function(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 i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?yb(e,r.value,null,i,t):yb(e,r.textContent,r.innerHTML,i,t)},50)}(e,t)};class yk{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let yw=m0?"altKey":"ctrlKey";function yS(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[yw]}for(let e in yt.dragstart=(e,t)=>{let n,r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=e.state.selection,o=i.empty?null:e.posAtCoords(yl(t));if(o&&o.pos>=i.from&&o.pos<=(i instanceof pF?i.to-1:i.to));else if(r&&r.mightDrag)n=pF.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=pF.create(e.state.doc,r.posBefore))}let s=(n||e.state.selection).content(),{dom:a,text:l,slice:c}=g1(e,s);t.dataTransfer.files.length&&mX&&!(mY>120)||t.dataTransfer.clearData(),t.dataTransfer.setData(yv?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",yv||t.dataTransfer.setData("text/plain",l),e.dragging=new yk(c,yS(e,t),n)},yt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},yn.dragover=yn.dragenter=(e,t)=>t.preventDefault(),yn.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(yl(t));if(!r)return;let i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=g2(e,yx(t.dataTransfer),yv?null:t.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&yS(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||hx.empty,s)))return t.preventDefault();if(!o)return;t.preventDefault();let a=o?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,o=r.index(t)+ +(n>0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(o,o,i);else{let e=s.contentMatchAt(o).findWrapping(i.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,i.pos,o):i.pos;null==a&&(a=i.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&pF.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new pF(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),l.setSelection(g$(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},yt.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())&&gD(e)},20))},yt.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},yt.beforeinput=(e,t)=>{if(mX&&m2&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,mz(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},yn)yt[e]=yn[e];function yC(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}class yN{constructor(e,t){this.toDOM=e,this.spec=t||yI,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new yM(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof yN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yC(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class yA{constructor(e,t){this.attrs=e,this.spec=t||yI}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new yM(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof yA&&yC(this.attrs,e.attrs)&&yC(this.spec,e.spec)}static is(e){return e.type instanceof yA}destroy(){}}class yE{constructor(e,t){this.attrs=e,this.spec=t||yI}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new yM(i.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(e){return this==e||e instanceof yE&&yC(this.attrs,e.attrs)&&yC(this.spec,e.spec)}destroy(){}}class yM{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new yM(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new yM(e,e,new yN(t,n))}static inline(e,t,n,r){return new yM(e,t,new yA(n,r))}static node(e,t,n,r){return new yM(e,t,new yE(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof yA}get widget(){return this.type instanceof yN}}let yT=[],yI={};class yL{constructor(e,t){this.local=e.length?e:yT,this.children=t.length?t:yT}static create(e,t){return t.length?yj(t,e,0,yI):yO}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,r+s,i)}}map(e,t,n){return this==yO||0==e.maps.length?this:this.mapInner(e,t,0,0,n||yI)}mapInner(e,t,n,r,i){let o;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,i,o,s){let a=e.slice();for(let e=0,t=o;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,o)=>{let s=o-i-(n-e);for(let i=0;i<a.length;i+=3){let o=a[i+1];if(o<0||e>o+t-r)continue;let l=a[i]+t-r;n>=l?a[i+1]=e<=l?-2:-1:e>=t&&s&&(a[i]+=s,a[i+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+o),d=c-i;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+o,-1)-i,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+o+1,s);r!=yO?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=yj(function(e,t,n,r,i,o,s){for(let a=0;a<e.length;a+=3)-1==e[a+1]&&function e(t,o){for(let e=0;e<t.local.length;e++){let a=t.local[e].map(r,i,o);a?n.push(a):s.onRemove&&s.onRemove(t.local[e].spec)}for(let n=0;n<t.children.length;n+=3)e(t.children[n+2],t.children[n]+o+1)}(e[a+2],t[a]+o+1);return n}(a,e,t,n,i,o,s),r,0,s);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new yL(t.sort(yB),a)}(this.children,o||[],e,t,n,r,i):o?new yL(o.sort(yB),yT):yO}add(e,t){return t.length?this==yO?yL.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach((e,o)=>{let s=o+n,a;if(a=yP(t,e,s)){for(r||(r=this.children.slice());i<r.length&&r[i]<o;)i+=3;r[i]==o?r[i+2]=r[i+2].addInner(e,a,s+1):r.splice(i,0,o,o+e.nodeSize,yj(a,e,s+1,yI)),i+=3}});let o=yR(i?y_(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new yL(o.length?this.local.concat(o).sort(yB):this.local,r||this.children)}remove(e){return 0==e.length||this==yO?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,o=n[r]+t,s=n[r+1]+t;for(let t=0,n;t<e.length;t++)(n=e[t])&&n.from>o&&n.to<s&&(e[t]=null,(i||(i=[])).push(n));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,o+1);a!=yO?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length){for(let n=0,i;n<e.length;n++)if(i=e[n])for(let e=0;e<r.length;e++)r[e].eq(i,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new yL(r,n):yO}forChild(e,t){let n,r;if(this==yO)return this;if(t.isLeaf)return yL.empty;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,o=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>i&&t.type instanceof yA){let e=Math.max(i,t.from)-i,n=Math.min(o,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new yL(r.sort(yB),yT);return n?new yD([e,n]):e}return n||yO}eq(e){if(this==e)return!0;if(!(e instanceof yL)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return yz(this.localsInner(e))}localsInner(e){if(this==yO)return yT;if(e.inlineContent||!this.local.some(yA.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof yA||t.push(this.local[e]);return t}forEachSet(e){e(this)}}yL.empty=new yL([],[]),yL.removeOverlap=yz;let yO=yL.empty;class yD{constructor(e){this.members=e}map(e,t){let n=this.members.map(n=>n.map(e,t,yI));return yD.from(n)}forChild(e,t){if(t.isLeaf)return yL.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=yO&&(i instanceof yD?n=n.concat(i.members):n.push(i))}return yD.from(n)}eq(e){if(!(e instanceof yD)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?yz(n?t:t.sort(yB)):yT}static from(e){switch(e.length){case 0:return yO;case 1:return e[0];default:return new yD(e.every(e=>e instanceof yL)?e:e.reduce((e,t)=>e.concat(t instanceof yL?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function yR(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new yM(i.from+t,i.to+t,i.type))}return n}function yP(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,o;t<e.length;t++)(o=e[t])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),e[t]=null);return i}function y_(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function yj(e,t,n,r){let i=[],o=!1;t.forEach((t,s)=>{let a=yP(e,t,s+n);if(a){o=!0;let e=yj(a,t,n+s+1,r);e!=yO&&i.push(s,s+t.nodeSize,e)}});let s=yR(o?y_(e):e,-n).sort(yB);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||i.length?new yL(s,i):yO}function yB(e,t){return e.from-t.from||e.to-t.to}function yz(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let o=t[i];if(o.from==r.from){o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),y$(t,i+1,o.copy(r.to,o.to)));continue}o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),y$(t,i,r.copy(o.from,r.to)));break}}return t}function y$(e,t,n){for(;t<e.length&&yB(n,e[t])>0;)t++;e.splice(t,0,n)}function yF(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=yO&&t.push(r)}),e.cursorWrapper&&t.push(yL.create(e.state.doc,[e.cursorWrapper.deco])),yD.from(t)}let yU={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yH=mG&&mq<=11;class yW{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class yV{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yW,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);mG&&mq<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():mQ&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),yH&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,yU)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);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(gF(this.view)){if(this.suppressingSelectionUpdates)return gD(this.view);if(mG&&mq<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&mD(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=mT(n))t.add(n);for(let r=e.anchorNode;r;r=mT(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){var e;let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&gF(t)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],l);t&&(o=o<0?t.from:Math.min(t.from,o),s=s<0?t.to:Math.max(t.to,s),t.typeOver&&(a=!0))}if(l.some(e=>"BR"==e.nodeName)&&(8==t.input.lastKeyCode||46==t.input.lastKeyCode)){for(let e of l)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(mK&&l.length){let e=l.filter(e=>"BR"==e.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(t,n)!=e)&&r.remove()}}}let c=null;o<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&mB(r)&&(c=gL(t))&&c.eq(pP.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,gD(t),this.currentSelection.set(r),t.scrollToSelection()):(o>-1||i)&&(o>-1&&(t.docView.markDirty(o,s),e=t,!yG.has(e)&&(yG.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))&&(e.requiresGeckoHackNode=mK,yq||(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."),yq=!0))),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let o of t)if((null==(n=o.parentNode)?void 0:n.nodeName)=="TR"){let t=o.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}(t,l)),this.handleDOMChange(o,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||gD(t),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(mG&&mq<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(r=n),(!o||0>Array.prototype.indexOf.call(e.addedNodes,o))&&(i=o)}let o=r&&r.parentNode==e.target?mM(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?mM(i):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let yG=new WeakMap,yq=!1;function yK(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return mD(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function yJ(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(mQ&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(e.parentNode.lastChild==e||mQ&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let yX=/^(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){return Math.max(n.anchor,n.head)>t.content.size?null:g$(e,t.resolve(n.anchor),t.resolve(n.head))}function yQ(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function yZ(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class y0{constructor(e,t){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 yi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(y6),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=y8(this),y2(this),this.nodeViews=y5(this),this.docView=gy(this.state.doc,y1(this),yF(this),this.dom,this),this.domObserver=new yV(this,(e,t,n,r)=>(function(e,t,n,r,i){let o,s,a,l=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=gL(e,t);if(n&&!e.state.selection.eq(n)){if(mX&&m2&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let c=e.state.doc.resolve(t),d=c.sharedDepth(n);t=c.before(d+1),n=e.state.doc.resolve(n).after(d+1);let u=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:o,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],mB(c)||r.push({node:c.focusNode,offset:c.focusOffset})),mX&&8===e.input.lastKeyCode)for(let e=s;e>o;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,h=e.someProp("domParser")||hX.fromSchema(e.state.schema),p=u.resolve(a),f=null,m=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:yJ,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,f=p.slice(h.from,h.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(o=e.state.selection.to,s="end"):(o=e.state.selection.from,s="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,i){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){let e=Math.max(0,o-Math.min(s,a));r-=s+e-o}if(s<o&&e.size<t.size){let e=r<=o&&r>=s?o-r:0;(o-=e)&&o<t.size&&yZ(t.textBetween(o-1,o+1))&&(o+=e?1:-1),a=o+(a-s),s=o}else if(a<o){let t=r<=o&&r>=a?o-r:0;(o-=t)&&o<e.size&&yZ(e.textBetween(o-1,o+1))&&(o+=t?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}(f.content,h.doc.content,h.from,o,s);if(m&&e.input.domChangeCount++,(mZ&&e.input.lastIOSEnter>Date.now()-225||m2)&&i.some(e=>1==e.nodeType&&!yX.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&u instanceof pz&&!u.empty&&u.$head.sameParent(u.$anchor)&&!e.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))m={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let t=yY(e,e.state.doc,h.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof pz&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),mG&&mq<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>h.from&&"  "==h.doc.textBetween(m.start-h.from-1,m.start-h.from+1)&&(m.start--,m.endA--,m.endB--);let g=h.doc.resolveNoCache(m.start-h.from),y=h.doc.resolveNoCache(m.endB-h.from),v=p.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&v.end()>=m.endA;if((mZ&&e.input.lastIOSEnter>Date.now()-225&&(!b||i.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&g.pos<h.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(h.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,mz(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||yQ(r,!0,!1)<i.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==t+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(yQ(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||yQ(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",t=>t(e,mz(8,"Backspace")))){m2&&mX&&e.domObserver.suppressSelectionUpdates();return}mX&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),m2&&!b&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==m.endA&&(m.endB-=2,y=h.doc.resolveNoCache(m.endB-h.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,mz(13,"Enter"))})},20));let x=m.start,k=m.endA,w=t=>{let n=t||e.state.tr.replace(x,k,h.doc.slice(m.start-h.from,m.endB-h.from));if(h.sel){let t=yY(e,n.doc,h.sel);t&&!(mX&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==x||t.head==n.mapping.map(k)-1)||mG&&t.empty&&t.head==x)&&n.setSelection(t)}return l&&n.setMeta("composition",l),n.scrollIntoView()};if(b)if(g.pos==y.pos){mG&&mq<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gD(e),20));let t=w(e.state.tr.delete(x,k)),n=p.resolve(m.start).marksAcross(p.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(a=function(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,o=r,s,a,l;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)o=n[e].removeFromSet(o);if(1==i.length&&0==o.length)a=i[0],s="add",l=e=>e.mark(a.addToSet(e.marks));else{if(0!=i.length||1!=o.length)return null;a=o[0],s="remove",l=e=>e.mark(a.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(l(t.child(e)));if(hf.from(c).eq(e))return{mark:a,type:s}}(g.parent.content.cut(g.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start())))){let t=w(e.state.tr);"add"==a.type?t.addMark(x,k,a.mark):t.removeMark(x,k,a.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-!y.textOffset){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>w(e.state.tr.insertText(t,x,k));e.someProp("handleTextInput",r=>r(e,x,k,t,n))||e.dispatch(n())}else e.dispatch(w());else e.dispatch(w())})(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in yt){let n=yt[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!function(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||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||ya(e,t)||!e.editable&&t.type in yn||n(e,t)},yr[t]?{passive:!0}:void 0)}mQ&&e.dom.addEventListener("input",()=>null),ys(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ys(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(y6),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,r,i;let o=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(yg(this),a=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=y5(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ys(this),this.editable=y8(this),y2(this);let c=yF(this),d=y1(this),u=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",h=s||!this.docView.matchesNode(e.doc,d,c);(h||!e.selection.eq(o.selection))&&(a=!0);let p="preserve"==u&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let o=(r.left+r.right)/2,s=i+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(o,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:m4(e.dom)}}(this);if(a){let t,n,a;this.domObserver.stop();let l=h&&(mG||mX)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&(r=o.selection,i=e.selection,a=Math.min(r.$anchor.sharedDepth(r.head),i.$anchor.sharedDepth(i.head)),r.$anchor.start(a)!=i.$anchor.start(a));if(h){let t=mX?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=m_(e=e.childNodes[t-1])}else{if(!e.parentNode||mj(e))return null;t=mM(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||mj(e))return null;t=mM(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}(this)),(s||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=gy(e.doc,d,c,this.dom,this)),!t||this.trackWrites&&this.dom.contains(this.trackWrites)||(l=!0)}l||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(t=this.docView.domFromPos(this.state.selection.anchor,0),n=this.domSelectionRange(),mD(t.node,t.offset,n.anchorNode,n.anchorOffset)))?gD(this,l):(gB(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null==(n=this.dragging)?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():p&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;m7(n,0==r?0:r-t)}(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof pF){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&m3(this,t.getBoundingClientRect(),e)}else m3(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new yk(e.slice,e.move,r<0?void 0:pF.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(null!=n&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(null!=i&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let o=i[n].props[e];if(null!=o&&(r=t?t(o):o))return r}}hasFocus(){if(mG){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(m9)return e.focus(m9);let t=m4(e);e.focus(null==m9?{get preventScroll(){return m9={preventScroll:!0},!0}}:void 0),m9||(m9=!1,m7(t,0))}(this.dom),gD(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n;let r,i,o=e.dom.ownerDocument,s,a=0,l=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(m_(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(m_(r.startContainer),r.startOffset)}}}(o,t.left,t.top);l&&({node:s,offset:a}=l);let c=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!c||!e.dom.contains(1!=c.nodeType?c.parentNode:c)){let n=e.dom.getBoundingClientRect();if(!ge(t,n)||!(c=function e(t,n,r){let i=t.childNodes.length;if(i&&r.top<r.bottom)for(let o=Math.max(0,Math.min(i-1,Math.floor(i*(n.top-r.top)/(r.bottom-r.top))-2)),s=o;;){let r=t.childNodes[s];if(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let o=t[i];if(ge(n,o))return e(r,n,o)}}if((s=(s+1)%i)==o)break}return t}(e.dom,t,n)))return null}if(mQ)for(let e=c;s&&e;e=mT(e))e.draggable&&(s=void 0);if(c=(r=(n=c).parentNode)&&/^li$/i.test(r.nodeName)&&t.left<n.getBoundingClientRect().left?r:n,s){let n;if(mK&&1==s.nodeType&&(a=Math.min(a,s.childNodes.length))<s.childNodes.length){let e=s.childNodes[a],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&a++}m8&&a&&1==s.nodeType&&1==(n=s.childNodes[a-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&a--,s==e.dom&&a==s.childNodes.length-1&&1==s.lastChild.nodeType&&t.top>s.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:(0==a||1!=s.nodeType||"BR"!=s.childNodes[a-1].nodeName)&&(i=function(e,t,n,r){let i=-1;for(let n=t,o=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),s;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((s=t.dom.getBoundingClientRect()).width||s.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!o&&s.left>r.left||s.top>r.top?i=t.posBefore:(!o&&s.right<r.left||s.bottom<r.top)&&(i=t.posAfter),o=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(s.top+s.bottom)/2:r.left<(s.left+s.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,s,a,t))}null==i&&(i=function(e,t,n){let{node:r,offset:i}=function e(t,n){let r,i,o,s=2e8,a,l=0,c=n.top,d=n.top;for(let e=t.firstChild,u=0;e;e=e.nextSibling,u++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=mL(e).getClientRects()}for(let h=0;h<t.length;h++){let p=t[h];if(p.top<=c&&p.bottom>=d){c=Math.max(p.bottom,c),d=Math.min(p.top,d);let t=p.left>n.left?p.left-n.left:p.right<n.left?n.left-p.right:0;if(t<s){o=e,s=t,a=t&&3==o.nodeType?{left:p.right<n.left?p.right:p.left,top:n.top}:n,1==e.nodeType&&t&&(l=u+ +(n.left>=(p.left+p.right)/2));continue}}else p.top>n.top&&!r&&p.left<=n.left&&p.right>=n.left&&(r=e,i={left:Math.max(p.left,Math.min(p.right,n.left)),top:p.top});!o&&(n.left>=p.right&&n.top>=p.top||n.left>=p.left&&n.top>=p.bottom)&&(l=u+1)}}return(!o&&r&&(o=r,a=i,s=0),o&&3==o.nodeType)?function(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=gn(r,1);if(n.top!=n.bottom&&ge(t,n)){i={node:e,offset:o+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}(o,a):!o||s&&1==o.nodeType?{node:t,offset:l}:e(o,a)}(t,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,o)}(e,c,t));let d=e.docView.nearestDesc(c,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}(this,e)}coordsAtPos(e,t=1){return gi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){let r,i;return gc==t&&gd==n?gu:(gc=t,gd=n,gu="up"==n||"down"==n?(r=t.selection,i="up"==n?r.$from:r.$to,ga(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=gi(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=mL(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=i==r.parent.content.size,s=e.domSelection();return s?gl.test(r.parent.textContent)&&s.modify?ga(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:o,anchorOffset:a}=e.domSelectionRange(),l=s.caretBidiLevel;s.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&i==u;try{s.collapse(o,a),t&&(t!=o||i!=a)&&s.extend&&s.extend(t,i)}catch(e){}return null!=l&&(s.caretBidiLevel=l),h}):"left"==n||"backward"==n?!i:o:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return yb(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return yb(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return g1(this,e)}destroy(){if(this.docView){for(let e in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(e,this.input.eventHandlers[e]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],yF(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,mO()}}get isDestroyed(){return null==this.docView}dispatchEvent(e){!ya(this,e)&&yt[e.type]&&(this.editable||!(e.type in yn))&&yt[e.type](this,e)}domSelectionRange(){let e=this.domSelection();return e?mQ&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return yK(e,n)}function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?yK(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function y1(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[yM.node(0,e.state.doc.content.size,t)]}function y2(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:yM.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function y8(e){return!e.someProp("editable",t=>!1===t(e.state))}function y5(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function y6(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}function y3(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}y0.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};let y4={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},y7=hs({},"editorView"),y9=hs({},"editorState"),ve=hs([],"initTimer"),vt=hs({},"editor"),vn=hs([],"inputRules"),vr=hs([],"prosePlugins"),vi=hs([],"remarkPlugins"),vo=hs([],"nodeView"),vs=hs([],"markView"),va=hs(uG().use(d4).use(f1),"remark"),vl=hs({handlers:y4,encode:[]},"remarkStringifyOptions"),vc=hh("ConfigReady"),vd=hh("InitReady"),vu=hh("SchemaReady"),vh=hs([],"schemaTimer"),vp=hs({},"schema"),vf=hs([],"nodes"),vm=hs([],"marks");function vg(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}let vy=e=>(e.inject(vp,{}).inject(vf,[]).inject(vm,[]).inject(vh,[vd]).record(vu),async()=>{await e.waitTimers(vh);let t=e.get(va),n=e.get(vi).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(va,n);let r=new hK({nodes:Object.fromEntries(e.get(vf).map(([e,t])=>[e,vg(t)])),marks:Object.fromEntries(e.get(vm).map(([e,t])=>[e,vg(t)]))});return e.set(vp,r),e.done(vu),()=>{e.remove(vp).remove(vf).remove(vm).remove(vh).clearTimer(vu)}});y3(vy,{displayName:"Schema"});class vv{constructor(){this.#g=new hr,this.#N=null,this.setCtx=e=>{this.#N=e},this.chain=()=>{if(null==this.#N)throw hn();let e=this.#N,t=[],n=this.get.bind(this),r={run:()=>{let n=fc(...t),r=e.get(y7);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:(function(e,i){let o=n(e);return t.push(o(i)),r}).bind(this)};return r}}#g;#N;get ctx(){return this.#N}create(e,t){let n=e.create(this.#g.sliceMap);return n.set(t),n}get(e){return this.#g.get(e).get()}remove(e){return this.#g.remove(e)}call(e,t){if(null==this.#N)throw hn();let n=this.get(e)(t),r=this.#N.get(y7);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#N)throw hn();let t=this.#N.get(y7);return e(t.state,t.dispatch,t)}}let vb=hs(new vv,"commands"),vx=hs([vu],"commandsTimer"),vk=hh("CommandsReady"),vw=e=>{let t=new vv;return t.setCtx(e),e.inject(vb,t).inject(vx,[vu]).record(vk),async()=>(await e.waitTimers(vx),e.done(vk),()=>{e.remove(vb).remove(vx).clearTimer(vk)})};y3(vw,{displayName:"Commands"});class vS{constructor(){this.#N=null,this.#A=[],this.setCtx=e=>{this.#N=e},this.add=e=>(this.#A.push(e),()=>{this.#A=this.#A.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){let r={key:e,onRun:()=>n};this.#A.push(r),t.push(()=>{this.#A=this.#A.filter(e=>e!==r)})}else this.#A.push(n),t.push(()=>{this.#A=this.#A.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=(ff.Backspace=fc(mi,p8,p3,p7),ff);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#A.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#N;if(null==i)throw u9();return fc(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#N;#A;get ctx(){return this.#N}}let vC=hs(new vS,"keymap"),vN=hs([vu],"keymapTimer"),vA=hh("KeymapReady"),vE=e=>{let t=new vS;return t.setCtx(e),e.inject(vC,t).inject(vN,[vu]).record(vA),async()=>(await e.waitTimers(vN),e.done(vA),()=>{e.remove(vC).remove(vN).clearTimer(vA)})},vM=hh("ParserReady"),vT=()=>{throw u9()},vI=hs(vT,"parser"),vL=hs([],"parserTimer"),vO=e=>(e.inject(vI,vT).inject(vL,[vu]).record(vM),async()=>{await e.waitTimers(vL);let t=e.get(va),n=e.get(vp);return e.set(vI,me.create(n,t)),e.done(vM),()=>{e.remove(vI).remove(vL).clearTimer(vM)}});y3(vO,{displayName:"Parser"});let vD=hh("SerializerReady"),vR=hs([],"serializerTimer"),vP=()=>{throw u9()},v_=hs(vP,"serializer"),vj=e=>(e.inject(v_,vP).inject(vR,[vu]).record(vD),async()=>{await e.waitTimers(vR);let t=e.get(va),n=e.get(vp);return e.set(v_,mn.create(n,t)),e.done(vD),()=>{e.remove(v_).remove(vR).clearTimer(vD)}});y3(vj,{displayName:"Serializer"});let vB=hs("","defaultValue"),vz=hs(e=>e,"stateOptions"),v$=hs([],"editorStateTimer"),vF=hh("EditorStateReady"),vU=new p2("MILKDOWN_STATE_TRACKER"),vH=e=>(e.inject(vB,"").inject(y9,{}).inject(vz,e=>e).inject(v$,[vM,vD,vk,vA]).record(vF),async()=>{await e.waitTimers(v$);let t=e.get(vp),n=e.get(vI),r=e.get(vn),i=e.get(vz),o=e.get(vr),s=function(e,t,n){var r;if("string"==typeof e)return t(e);if("html"===e.type)return hX.fromSchema(n).parse(e.dom);if("json"===e.type)return hD.fromJSON(n,e.value);throw r=e,new u4(u3.docTypeError,`Doc type error, unsupported type: ${JSON.stringify(r,u7)}`)}(e.get(vB),n,t),a=e.get(vC),l=a.addBaseKeymap(),c=[...o,new pZ({key:vU,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(y9,i)}}}),function({rules:e}){let t=new pZ({key:mg,isInputRules:!0,state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,i,o)=>mm(n,r,i,o,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&mm(n,r.pos,r.pos,"",e,t)}),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;let{$cursor:i}=n.state.selection;return!!i&&mm(n,i.pos,i.pos,"\n",e,t)}}});return t}({rules:r}),mE(a.build())];e.set(vr,c);let d=i({schema:t,doc:s,plugins:c}),u=pQ.create(d);return e.set(y9,u),e.done(vF),()=>{l(),e.remove(vB).remove(y9).remove(vz).remove(v$).clearTimer(vF)}});y3(vH,{displayName:"EditorState"});let vW=hs([],"pasteRule"),vV=hs([vu],"pasteRuleTimer"),vG=hh("PasteRuleReady"),vq=e=>(e.inject(vW,[]).inject(vV,[vu]).record(vG),async()=>(await e.waitTimers(vV),e.done(vG),()=>{e.remove(vW).remove(vV).clearTimer(vG)}));y3(vq,{displayName:"PasteRule"});let vK=hh("EditorViewReady"),vJ=hs([],"editorViewTimer"),vX=hs({},"editorViewOptions"),vY=hs(null,"root"),vQ=hs(null,"rootDOM"),vZ=hs({},"rootAttrs"),v0=new p2("MILKDOWN_VIEW_CLEAR"),v1=e=>(e.inject(vY,document.body).inject(y7,{}).inject(vX,{}).inject(vQ,null).inject(vZ,{}).inject(vJ,[vF,vG]).record(vK),async()=>{var t;await e.wait(vd);let n=e.get(vY)||document.body,r="string"==typeof n?document.querySelector(n):n;e.update(vr,t=>[new pZ({key:v0,view:t=>{let n,i=r?((n=document.createElement("div")).className="milkdown",r.appendChild(n),e.set(vQ,n),Object.entries(e.get(vZ)).forEach(([e,t])=>n.setAttribute(e,t)),n):void 0;if(i&&r){let e=t.dom;r.replaceChild(i,e),i.appendChild(e)}return{destroy:()=>{i?.parentNode&&i?.parentNode.replaceChild(t.dom,i),i?.remove()}}}}),...t]),await e.waitTimers(vJ);let i=e.get(y9),o=e.get(vX),s=new y0(r,{state:i,nodeViews:Object.fromEntries(e.get(vo)),markViews:Object.fromEntries(e.get(vs)),transformPasted:(t,n,r)=>(e.get(vW).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});return(t=s.dom).classList.add("editor"),t.setAttribute("role","textbox"),e.set(y7,s),e.done(vK),()=>{s?.destroy(),e.remove(vY).remove(y7).remove(vX).remove(vQ).remove(vZ).remove(vJ).clearTimer(vK)}});y3(v1,{displayName:"EditorView"});var v2=((k=v2||{}).Idle="Idle",k.OnCreate="OnCreate",k.Created="Created",k.OnDestroy="OnDestroy",k.Destroyed="Destroyed",k);class v8{constructor(){this.#E=!1,this.#k="Idle",this.#M=[],this.#T=()=>void 0,this.#g=new hr,this.#y=new hc,this.#I=new Map,this.#L=new Map,this.#N=new hl(this.#g,this.#y),this.#O=()=>{var e,t;let n,r,i=(e=async e=>{await Promise.all(this.#M.map(t=>Promise.resolve(t(e))))},y3(n=t=>(t.record(vc),async()=>(await e(t),t.done(vc),()=>{t.clearTimer(vc)})),{displayName:"Config"}),n),o=[vy,vO,vj,vw,vE,vq,vH,v1,(t=this,y3(r=e=>(e.inject(vt,t).inject(vr,[]).inject(vi,[]).inject(vn,[]).inject(vo,[]).inject(vs,[]).inject(vl,{handlers:y4,encode:[]}).inject(va,uG().use(d4).use(f1)).inject(ve,[vc]).record(vd),async()=>{await e.waitTimers(ve);let t=e.get(vl);return e.set(va,uG().use(d4).use(f1,t)),e.done(vd),()=>{e.remove(vt).remove(vr).remove(vi).remove(vn).remove(vo).remove(vs).remove(vl).remove(va).remove(ve).clearTimer(vd)}}),{displayName:"Init"}),r),i];this.#D(o,this.#L)},this.#D=(e,t)=>{e.forEach(e=>{let n=this.#N.produce(this.#E?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#R=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#I.get(e),r=n?.cleanup;return(t?this.#I.delete(e):this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof r)?r():r})),this.#P=async()=>{await Promise.all([...this.#L.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#L.clear()},this.#_=e=>{this.#k=e,this.#T(e)},this.#j=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let o=await i();e.set(t,{ctx:r,handler:i,cleanup:o})}),this.enableInspector=(e=!0)=>(this.#E=e,this),this.onStatusChange=e=>(this.#T=e,this),this.config=e=>(this.#M.push(e),this),this.removeConfig=e=>(this.#M=this.#M.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),"Created"===this.#k&&this.#D(t,this.#I),this},this.remove=async e=>"OnCreate"===this.#k?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#R([e].flat(),!0),this),this.create=async()=>("OnCreate"===this.#k||("Created"===this.#k&&await this.destroy(),this.#_("OnCreate"),this.#O(),this.#D([...this.#I.keys()],this.#I),await Promise.all([this.#j(this.#L),this.#j(this.#I)].flat()),this.#_("Created")),this),this.destroy=async(e=!1)=>"Destroyed"===this.#k||"OnDestroy"===this.#k?this:"OnCreate"===this.#k?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#M=[]),this.#_("OnDestroy"),await this.#R([...this.#I.keys()],e),await this.#P(),this.#_("Destroyed"),this),this.action=e=>e(this.#N),this.inspect=()=>this.#E?[...this.#L.values(),...this.#I.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new v8}#E;#k;#M;#T;#g;#y;#I;#L;#N;#O;#D;#R;#P;#_;#j;get ctx(){return this.#N}get status(){return this.#k}}let v5=e=>crypto.getRandomValues(new Uint8Array(e)),v6=(e,t=21)=>{var n;let r,i;return n=0|t,i=-~(1.6*(r=(2<<Math.log2(e.length-1))-1)*n/e.length),(t=n)=>{let o="";for(;;){let n=v5(i),s=0|i;for(;s--;)if((o+=e[n[s]&r]||"").length>=t)return o}}};function v3(e,t){let n=function(e="cmdKey"){return hs(()=>()=>!1,e)}(e),r=i=>async()=>{r.key=n,await i.wait(vk);let o=t(i);return i.get(vb).create(n,o),r.run=t=>i.get(vb).call(e,t),()=>{i.get(vb).remove(n)}};return r}function v4(e){let t=n=>async()=>{await n.wait(vu);let r=e(n);return n.update(vn,e=>[...e,r]),t.inputRule=r,()=>{n.update(vn,e=>e.filter(e=>e!==r))}};return t}function v7(e,t){let n=r=>async()=>{let i=t(r);return r.update(vf,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(vf,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(vp).nodes[e];if(!n)throw new u4(u3.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`);return n},n}function v9(e){let t,n=n=>async()=>(await n.wait(vu),t=e(n),n.update(vr,e=>[...e,t]),()=>{n.update(vr,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function be(e,t){let n=hs(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function bt(e,t){let n=be(t,e),r=v7(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>bt(e,n(t)),i}function bn(e,t){var n;let r,i=be(t,e),o=(n=e=>e.get(i.key)(e),(r=t=>async()=>{let i=n(t);return t.update(vm,t=>[...t.filter(t=>t[0]!==e),[e,i]]),r.id=e,r.schema=i,()=>{t.update(vm,t=>t.filter(([t])=>t!==e))}}).type=t=>{let n=t.get(vp).marks[e];if(!n)throw new u4(u3.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`);return n},r),s=[i,o];return s.id=o.id,s.mark=o,s.type=e=>o.type(e),s.ctx=i,s.key=i.key,s.extendSchema=n=>bn(e,n(t)),s}function br(e,t){var n;let r,i=be(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),o=(n=e=>{let n=e.get(i.key);return Object.fromEntries(Object.entries(t).flatMap(([e,{command:t}])=>{let r=n[e],i=[r.shortcuts].flat(),o=r.priority;return i.map(e=>[e,{key:e,onRun:t,priority:o}])}))},r=e=>async()=>{await e.wait(vA);let t=e.get(vC),i=n(e),o=t.addObjectKeymap(i);return r.keymap=i,()=>{o()}}),s=[i,o];return s.ctx=i,s.shortcuts=o,s.key=i.key,s.keymap=o.keymap,s}v6("abcedfghicklmn",10);let bi=(e,t=()=>({}))=>be(t,`${e}Attr`),bo=(e,t=()=>({}))=>be(t,`${e}Attr`);function bs(e,t,n){let r=be(n??{},e),i=e=>async()=>{await e.wait(vd);let n={plugin:t(e),options:e.get(r.key)};return e.update(vi,e=>[...e,n]),()=>{e.update(vi,e=>e.filter(e=>e!==n))}},o=[r,i];return o.id=e,o.plugin=i,o.options=r,o}function ba(e){return String(e||"").toUpperCase()}function bl(){return function(e){let t=function(e){let t=new Map;if(!e||!e.type)throw Error("mdast-util-definitions expected node");return um(e,"definition",function(e){let n=ba(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){let n=ba(e);return t.get(n)}}(e);um(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[up,n];if("imageReference"===e.type||"linkReference"===e.type){let i=t(e.identifier);if(i&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:i.url,title:i.title,alt:e.alt}:{type:"link",url:i.url,title:i.title,children:e.children},[up,n]}})}}function bc(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name==="hardbreak"))return void e.next(t.content);let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(hf.fromArray(n))}function bd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}let bu=bo("emphasis");bd(bu,{displayName:"Attr<emphasis>",group:"Emphasis"});let bh=bn("emphasis",e=>({attrs:{marker:{default:e.get(vl).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(bu.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));bd(bh.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),bd(bh.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});let bp=v3("ToggleEmphasis",e=>()=>fl(bh.type(e)));bd(bp,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});let bf=v4(e=>my(/(?:^|[^*])\*([^*]+)\*$/,bh.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));bd(bf,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});let bm=v4(e=>my(/\b_(?![_\s])(.*?[^_\s])_\b/,bh.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));bd(bm,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});let bg=br("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{let t=e.get(vb);return()=>t.call(bp.key)}}});bd(bg.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),bd(bg.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});let by=bo("strong");bd(by,{displayName:"Attr<strong>",group:"Strong"});let bv=bn("strong",e=>({attrs:{marker:{default:e.get(vl).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(by.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));bd(bv.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),bd(bv.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});let bb=v3("ToggleStrong",e=>()=>fl(bv.type(e)));bd(bb,{displayName:"Command<toggleStrongCommand>",group:"Strong"});let bx=v4(e=>my(RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),bv.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));bd(bx,{displayName:"InputRule<strong>",group:"Strong"});let bk=br("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{let t=e.get(vb);return()=>t.call(bb.key)}}});bd(bk.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),bd(bk.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});let bw=bo("inlineCode");bd(bw,{displayName:"Attr<inlineCode>",group:"InlineCode"});let bS=bn("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(bw.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>{e.withMark(t,"inlineCode",n.text||"")}}}));bd(bS.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),bd(bS.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});let bC=v3("ToggleInlineCode",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:o,to:s}=r;return t.doc.rangeHasMark(o,s,bS.type(e))?n?.(i.removeMark(o,s,bS.type(e))):(Object.keys(t.schema.marks).filter(e=>e!==bS.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(o,s,e)}),n?.(i.addMark(o,s,bS.type(e).create()))),!0});bd(bC,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});let bN=v4(e=>my(/(?:`)([^`]+)(?:`)$/,bS.type(e)));bd(bN,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});let bA=br("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{let t=e.get(vb);return()=>t.call(bC.key)}}});bd(bA.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),bd(bA.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});let bE=bo("link");bd(bE,{displayName:"Attr<link>",group:"Link"});let bM=bn("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(bE.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));bd(bM.mark,{displayName:"MarkSchema<link>",group:"Link"});let bT=v3("ToggleLink",e=>(t={})=>fl(bM.type(e),t));bd(bT,{displayName:"Command<toggleLinkCommand>",group:"Link"});let bI=v3("UpdateLink",e=>(t={})=>(n,r)=>{let i;if(!r)return!1;let o=-1,{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(bM.type(e).isInSet(t.marks))return i=t,o=n,!1}),!i)return!1;let c=i.marks.find(({type:t})=>t===bM.type(e));if(!c)return!1;let d=o,u=o+i.nodeSize,{tr:h}=n,p=bM.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new pz(h.selection.$anchor)).scrollIntoView()),!0)});bd(bI,{displayName:"Command<updateLinkCommand>",group:"Link"});let bL=v7("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function bO(e){return uf(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);-1!==r&&n.children.splice(r,1)},!0)}bd(bL,{displayName:"NodeSchema<doc>",group:"Doc"});let bD=bs("remark-preserve-empty-line",()=>()=>bO);bd(bD.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),bd(bD.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});let bR=bi("paragraph");bd(bR,{displayName:"Attr<paragraph>",group:"Paragraph"});let bP=bt("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(bR.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{let r=e.get(y7),i=r.state?.doc.lastChild;t.openNode("paragraph"),(!n.content||0===n.content.size)&&n!==i&&function(e){let t=!1;try{e.get(bD.id),t=!0}catch{t=!1}return t}(e)?t.addNode("html",void 0,"<br />"):bc(t,n),t.closeNode()}}}));bd(bP.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),bd(bP.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});let b_=v3("TurnIntoText",e=>()=>fa(bP.type(e)));bd(b_,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});let bj=br("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{let t=e.get(vb);return()=>t.call(b_.key)}}});bd(bj.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),bd(bj.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});let bB=Array(6).fill(0).map((e,t)=>t+1),bz=be(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");bd(bz,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});let b$=bi("heading");bd(b$,{displayName:"Attr<heading>",group:"Heading"});let bF=bt("heading",e=>{let t=e.get(bz.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:bB.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw ht(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(b$.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),bc(e,t),e.closeNode()}}}});bd(bF.node,{displayName:"NodeSchema<heading>",group:"Heading"}),bd(bF.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});let bU=v4(e=>ms(/^(?<hashes>#+)\s$/,bF.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(y7).state.selection,i=r.node();if("heading"===i.type.name){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));bd(bU,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});let bH=v3("WrapInHeading",e=>t=>(t??=1)<1?fa(bP.type(e)):fa(bF.type(e),{level:t}));bd(bH,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});let bW=v3("DowngradeHeading",e=>()=>(t,n,r)=>{let{$from:i}=t.selection,o=i.node();if(o.type!==bF.type(e)||!t.selection.empty||0!==i.parentOffset)return!1;let s=o.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):fa(bP.type(e))(t,n,r)});bd(bW,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});let bV=br("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{let t=e.get(vb);return()=>t.call(bH.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{let t=e.get(vb);return()=>t.call(bW.key)}}});bd(bV.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),bd(bV.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});let bG=bi("blockquote");bd(bG,{displayName:"Attr<blockquote>",group:"Blockquote"});let bq=bt("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(bG.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));bd(bq.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),bd(bq.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});let bK=v4(e=>mo(/^\s*>\s$/,bq.type(e)));bd(bK,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});let bJ=v3("WrapInBlockquote",e=>()=>fs(bq.type(e)));bd(bJ,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});let bX=br("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{let t=e.get(vb);return()=>t.call(bJ.key)}}});bd(bX.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),bd(bX.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});let bY=bi("codeBlock",()=>({pre:{},code:{}}));bd(bY,{displayName:"Attr<codeBlock>",group:"CodeBlock"});let bQ=bt("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(bY.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...i},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{let r=t.lang??"",i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));bd(bQ.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),bd(bQ.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});let bZ=v4(e=>ms(/^```(?<language>[a-z]*)?[\s\n]$/,bQ.type(e),e=>({language:e.groups?.language??""})));bd(bZ,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});let b0=v3("CreateCodeBlock",e=>(t="")=>fa(bQ.type(e),{language:t}));bd(b0,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),bd(v3("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});let b1=br("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{let t=e.get(vb);return()=>t.call(b0.key)}}});bd(b1.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),bd(b1.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});let b2=bi("image");bd(b2,{displayName:"Attr<image>",group:"Image"});let b8=bt("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(b2.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{let r=t.url,i=t.alt,o=t.title;e.addNode(n,{src:r,alt:i,title:o})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));bd(b8.node,{displayName:"NodeSchema<image>",group:"Image"}),bd(b8.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});let b5=v3("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=t,a=b8.type(e).create({src:i,alt:o,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});bd(b5,{displayName:"Command<insertImageCommand>",group:"Image"});let b6=v3("UpdateImage",e=>(t={})=>(n,r)=>{let i=function(e,t){if(!(e instanceof pF))return;let{node:n,$from:r}=e;if(Array.isArray(t)&&t.includes(n.type)||n.type===t)return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}(n.selection,b8.type(e));if(!i)return!1;let{node:o,pos:s}=i,a={...o.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});bd(b6,{displayName:"Command<updateImageCommand>",group:"Image"}),bd(v4(e=>new mr(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[o,s,a="",l]=n;return o?t.tr.replaceWith(r,i,b8.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});let b3=bi("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));bd(b3,{displayName:"Attr<hardbreak>",group:"Hardbreak"});let b4=bt("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(b3.key)(t)," "]:["br",e.get(b3.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));bd(b4.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),bd(b4.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});let b7=v3("InsertHardbreak",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof pz))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name==="hardbreak")return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(pP.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta("hardbreak",!0).replaceSelectionWith(b4.type(e).create()).scrollIntoView()),!0});bd(b7,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});let b9=br("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{let t=e.get(vb);return()=>t.call(b7.key)}}});bd(b9.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),bd(b9.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});let xe=bi("hr");bd(xe,{displayName:"Attr<hr>",group:"Hr"});let xt=bt("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(xe.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));bd(xt.node,{displayName:"NodeSchema<hr>",group:"Hr"}),bd(xt.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});let xn=v4(e=>new mr(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:o}=t;return n[0]&&o.replaceWith(r-1,i,xt.type(e).create()),o}));bd(xn,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});let xr=v3("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;let r=bP.node.type(e).create(),{tr:i,selection:o}=t,{from:s}=o,a=xt.type(e).create();if(!a)return!0;let l=i.replaceSelectionWith(a).insert(s,r),c=pP.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});bd(xr,{displayName:"Command<insertHrCommand>",group:"Hr"});let xi=bi("bulletList");bd(xi,{displayName:"Attr<bulletList>",group:"BulletList"});let xo=bt("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(xi.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{let r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));bd(xo.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),bd(xo.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});let xs=v4(e=>mo(/^\s*([-+*])\s$/,xo.type(e)));bd(xs,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});let xa=v3("WrapInBulletList",e=>()=>fs(xo.type(e)));bd(xa,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});let xl=br("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{let t=e.get(vb);return()=>t.call(xa.key)}}});bd(xl.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),bd(xl.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});let xc=bi("orderedList");bd(xc,{displayName:"Attr<orderedList>",group:"OrderedList"});let xd=bt("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(xc.key)(t),...1===t.attrs.order?{}:t.attrs.order,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{let r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));bd(xd.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),bd(xd.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});let xu=v4(e=>mo(/^\s*(\d+)\.\s$/,xd.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));bd(xu,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});let xh=v3("WrapInOrderedList",e=>()=>fs(xd.type(e)));bd(xh,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});let xp=br("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{let t=e.get(vb);return()=>t.call(xh.key)}}});bd(xp.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),bd(xp.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});let xf=bi("listItem");bd(xf,{displayName:"Attr<listItem>",group:"ListItem"});let xm=bt("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw ht(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(xf.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{let r=null!=t.label?`${t.label}.`:"•",i=null!=t.label?"ordered":"bullet",o=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:i,spread:o}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));bd(xm.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),bd(xm.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});let xg=v3("SinkListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,e=>e.childCount>0&&e.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,i=hf.from(r?t.create():null),s=new hx(hf.from(t.create(null,hf.from(a.type.create(null,i)))),r?3:1,0),c=o.start,d=o.end;n(e.tr.step(new ph(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0}});bd(xg,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});let xy=v3("LiftListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,e=>e.childCount>0&&e.firstChild.type==t);return!!o&&(!n||(r.node(o.depth-1).type==t?function(e,t,n,r){let i=e.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new ph(o-1,s,o,s,new hx(hf.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new hL(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let a=pm(r);if(null==a)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return pk(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),t(i.scrollIntoView()),!0}(e,n,t,o):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,o=n.startIndex;t>o;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+ +!a,d+1,s.content.append(l?hf.empty:hf.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new ph(u-!!a,h+ +!!l,u+1,h-1,new hx((a?hf.empty:hf.from(i.copy(hf.empty))).append(l?hf.empty:hf.from(i.copy(hf.empty))),+!a,+!l),+!a)),t(r.scrollIntoView()),!0}(e,n,o)))}});bd(xy,{displayName:"Command<liftListItemCommand>",group:"ListItem"});let xv=v3("SplitListItem",e=>()=>{var t;return t=xm.type(e),function(e,n){let{$from:r,$to:i,node:o}=e.selection;if(o&&o.isBlock||r.depth<2||!r.sameParent(i))return!1;let s=r.node(-1);if(s.type!=t)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=t||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let i=hf.empty,o=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-o;e>=r.depth-3;e--)i=hf.from(r.node(e).copy(i));let s=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;i=i.append(hf.from(t.createAndFill()));let a=r.before(r.depth-(o-1)),l=e.tr.replace(a,r.after(-s),new hx(i,4-o,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(pP.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=i.pos==r.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(r.pos,i.pos),c=a?[null,{type:a}]:void 0;return!!px(l.doc,r.pos,2,c)&&(n&&n(l.split(r.pos,2,c).scrollIntoView()),!0)}});bd(xv,{displayName:"Command<splitListItemCommand>",group:"ListItem"});let xb=v3("LiftFirstListItem",e=>()=>(t,n,r)=>{let{selection:i}=t;if(!(i instanceof pz))return!1;let{empty:o,$from:s}=i;return!!o&&0===s.parentOffset&&s.node(-1).type===xm.type(e)&&p6(t,n,r)});bd(xb,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});let xx=br("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{let t=e.get(vb);return()=>t.call(xv.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{let t=e.get(vb);return()=>t.call(xg.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{let t=e.get(vb);return()=>t.call(xy.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{let t=e.get(vb);return()=>t.call(xb.key)}}});bd(xx.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),bd(xx.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});let xk=v7("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));bd(xk,{displayName:"NodeSchema<text>",group:"Text"});let xw=bi("html");bd(xw,{displayName:"Attr<html>",group:"Html"});let xS=bt("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{let n=document.createElement("span"),r={...e.get(xw.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>"html"===e,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));bd(xS.node,{displayName:"NodeSchema<html>",group:"Html"}),bd(xS.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});let xC=[bL,bR,bP,bz,b$,bF,b3,b4,bG,bq,bY,bQ,xe,xt,b2,b8,xi,xo,xc,xd,xf,xm,bu,bh,by,bv,bw,bS,bE,bM,xw,xS,xk].flat(),xN=[bK,xs,xu,bZ,xn,bU].flat(),xA=[bf,bm,bN,bx],xE=[b_,bJ,bH,bW,b0,b7,xr,b5,b6,xh,xa,xg,xv,xy,xb,bp,bC,bb,bT,bI,v3("IsMarkSelected",()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),v3("IsNoteSelected",()=>e=>t=>!!e&&((e,t)=>{let{selection:n,doc:r}=e;if(n instanceof pF)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:o}=n,s=!1,a=-1,l=null;return r.nodesBetween(i,o,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}})(t,e).hasNode),v3("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:o}=r,{pos:s}=i,a=o-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),v3("SetBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr,{from:s,to:a}=o.selection;try{o.setBlockType(s,a,r,i)}catch{return!1}return n?.(o),!0}),v3("WrapInBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let{$from:e,$to:t}=o.selection,n=e.blockRange(t),s=n&&pg(n,r,i);if(!s)return!1;o=o.wrap(n,s)}catch{return!1}return n?.(o),!0}),v3("AddBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let e=r instanceof hD?r:r.createAndFill(i);if(!e)return!1;o.replaceSelectionWith(e)}catch{return!1}return n?.(o),!0}),v3("SelectTextNearPos",()=>e=>(t,n)=>{let{pos:r}=e??{};if(null==r)return!1;let i=t.tr;try{let e,n=t.doc.resolve((e=t.doc.content.size,Math.min(Math.max(r,0),e)));i.setSelection(pz.near(n))}catch{return!1}return n?.(i.scrollIntoView()),!0})],xM=[bX,b1,b9,bV,xx,xp,xl,bj,bg,bA,bk].flat(),xT=bs("remarkAddOrderInList",()=>()=>e=>{um(e,"list",e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});bd(xT.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),bd(xT.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});let xI=bs("remarkLineBreak",()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;um(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;let i=[],o=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){let n=s.index;o!==n&&i.push({type:"text",value:e.value.slice(o,n)}),i.push({type:"break",data:{isInline:!0}}),o=n+s[0].length,s=t.exec(e.value)}if(i.length>0&&r&&"number"==typeof n)return o<e.value.length&&i.push({type:"text",value:e.value.slice(o)}),r.children.splice(n,1,...i),n+i.length})});bd(xI.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),bd(xI.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});let xL=bs("remarkInlineLink",()=>bl);bd(xL.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),bd(xL.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});let xO=["root","blockquote","listItem"],xD=bs("remarkHTMLTransformer",()=>()=>e=>{(function e(t,n,r){if(t.children){let n=[];for(let r=0,i=t.children.length;r<i;r++){let i=t.children[r];if(i){let o=e(i,r,t);if(o)for(let e=0,t=o.length;e<t;e++){let t=o[e];t&&n.push(t)}}}t.children=n}return((e,t,n)=>("html"!==e.type||n&&xO.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]))(t,n,r)})(e,0,null)[0]});bd(xD.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),bd(xD.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});let xR=bs("remarkMarker",()=>()=>(e,t)=>{um(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=t.value.charAt(e.position.start.offset)})});bd(xR.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),bd(xR.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});let xP=v9(()=>{let e=!1,t=new pZ({key:new p2("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!n&&!!r&&!!n.isInline&&!n.isText&&!!r.isInline&&!r.isText}},props:{handleDOMEvents:{compositionend:(n,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement("span"),r=yM.widget(t,n,{side:-1}),i=document.createElement("span"),o=yM.widget(t,i);return setTimeout(()=>{n.contentEditable="true",i.contentEditable="true"}),yL.create(e.doc,[r,o])}return yL.empty}}});return t});bd(xP,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});let x_=v9(e=>new pZ({key:new p2("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof pu))return;let{from:t}=o;return r.tr.setNodeMarkup(t,b4.type(e),void 0,[])}if(o instanceof pa){let t=r.tr,{from:n,to:i}=o;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===b4.type(e)&&(t=t.setNodeMarkup(r,b4.type(e),void 0,[]))}),t}}}));bd(x_,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});let xj=be(["table","code_block"],"hardbreakFilterNodes");bd(xj,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});let xB=v9(e=>{let t=e.get(xj.key);return new pZ({key:new p2("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{let r=e.getMeta("hardbreak"),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),o=r.depth,s=!0;for(;o>0;)t.includes(r.node(o).type.name)&&(s=!1),o--;return s}return!0}})});bd(xB,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});let xz=v9(e=>{let t=new p2("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;let r=e.get(bz.key),i=n.state.tr.setMeta("addToHistory",!1),o=!1,s={};n.state.doc.descendants((n,a)=>{if(n.type===bF.type(e)){if(0===n.textContent.trim().length)return;let e=n.attrs,l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(o=!0,i.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),o&&n.dispatch(i)};return new pZ({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});bd(xz,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});let x$=v9(e=>new pZ({key:new p2("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;let i=xd.type(e),o=xo.type(e),s=xm.type(e),a=(e,t)=>{let n=!1,r=`${t+1}.`;return e.label!==r&&(e.label=r,n=!0),n},l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===o){let n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,i,{spread:"true"}),e.descendants((e,t,n,r)=>{if(e.type===s){let n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===i){let i={...e.attrs},o=!1;"ordered"!==i.listType&&(i.listType="ordered",o=!0),n?.maybeChild(0)&&(o=a(i,r)),o&&(l=l.setNodeMarkup(t,void 0,i),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));bd(x$,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});let xF=[xC,xN,xA,xE,xM,[x_,xj,xB,xP,xT,xL,xI,xD,xR,bD,xz,x$].flat()].flat(),xU=function(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=function e(t){var n,r,i="";if("string"==typeof t||"number"==typeof t)i+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(r=e(t[n]))&&(i&&(i+=" "),i+=r)}else for(r in t)t[r]&&(i&&(i+=" "),i+=r);return i}(e))&&(r&&(r+=" "),r+=t);return r};function xH(e){e.update(vX,e=>{let t=e.attributes;return{...e,attributes:e=>{let n="function"==typeof t?t(e):t;return{...n,class:xU("prose dark:prose-invert",n?.class||"","milkdown-theme-nord")}}}})}let xW=(0,et.createContext)({}),xV=()=>{let e=function(){let{dom:e,editor:t,setLoading:n,editorFactory:r}=(0,et.useContext)(xW),i=(0,et.useRef)(null);return(0,et.useEffect)(()=>{let o=i.current;if(!r||!o)return;e.current=o;let s=r(o);if(s)return n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}},[e,t,r,n]),i}();return et.default.createElement("div",{"data-milkdown-root":!0,ref:e})},xG=({children:e})=>{let t=(0,et.useRef)(void 0),[n,r]=(0,et.useState)(void 0),i=(0,et.useRef)(void 0),[o,s]=(0,et.useState)(!0),a=(0,et.useMemo)(()=>({loading:o,dom:t,editor:i,setLoading:s,editorFactory:n,setEditorFactory:r}),[o,n]);return et.default.createElement(xW.Provider,{value:a},e)};var xq=((w={}).docTypeError="docTypeError",w.contextNotFound="contextNotFound",w.timerNotFound="timerNotFound",w.ctxCallOutOfScope="ctxCallOutOfScope",w.createNodeInParserFail="createNodeInParserFail",w.stackOverFlow="stackOverFlow",w.parserMatchError="parserMatchError",w.serializerMatchError="serializerMatchError",w.getAtomFromSchemaFail="getAtomFromSchemaFail",w.expectDomTypeError="expectDomTypeError",w.callCommandBeforeEditorView="callCommandBeforeEditorView",w.missingRootElement="missingRootElement",w.missingNodeInSchema="missingNodeInSchema",w.missingMarkInSchema="missingMarkInSchema",w.ctxNotBind="ctxNotBind",w.missingYjsDoc="missingYjsDoc",w),xK=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},xJ=(e,t)=>"function"==typeof t?"[Function]":t;function xX(){return new xK(xq.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function xY(){return new xK(xq.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function xQ(){return new xK(xq.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}var xZ=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t){var n;throw n="string"==typeof e?e:e.name,new xK(xq.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}return t},this.remove=e=>{let t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},x0=class{#s=[];#l;#a=()=>{this.#s.forEach(e=>e(this.#l))};constructor(e,t,n){this.set=e=>{this.#l=e,this.#a()},this.get=()=>this.#l,this.update=e=>{this.#l=e(this.#l),this.#a()},this.type=n,this.#l=t,e.set(n.id,this)}on(e){return this.#s.push(e),()=>{this.#s=this.#s.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#s=this.#s.filter(t=>t!==e)}offAll(){this.#s=[]}},x1=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw xX()}}create(e,t=this._defaultValue){return new x0(e,t,this)}},x2=(e,t)=>new x1(e,t),x8=class{#p;#g;#y;#c=new Set;#d=new Set;#u=new Map;#h=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#p,injectedSlices:[...this.#c].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),consumedSlices:[...this.#d].map(e=>({name:"string"==typeof e?e:e.name,value:this.#f(e)})),recordedTimers:[...this.#u].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)})),waitTimers:[...this.#h].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#m(e)}))}),this.onRecord=e=>{this.#u.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#u.delete(e)},this.onDone=e=>{let t=this.#u.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#h.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#c.add(e)},this.onRemove=e=>{this.#c.delete(e)},this.onUse=e=>{this.#d.add(e)},this.#g=e,this.#y=t,this.#p=n}#f=e=>this.#g.get(e).get();#m=e=>this.#y.get(e).status},x5=class e{#g;#y;#p;#v;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#g,this.#y,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#g.sliceMap);return null!=t&&n.set(t),this.#v?.onInject(e),this},this.remove=e=>(this.#g.remove(e),this.#v?.onRemove(e),this),this.record=e=>(e.create(this.#y.store),this.#v?.onRecord(e),this),this.clearTimer=e=>(this.#y.remove(e),this.#v?.onClear(e),this),this.isInjected=e=>this.#g.has(e),this.isRecorded=e=>this.#y.has(e),this.use=e=>(this.#v?.onUse(e),this.#g.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#y.get(e),this.done=e=>{this.timer(e).done(),this.#v?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#v?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#g=t,this.#y=n,this.#p=r,r&&(this.#v=new x8(t,n,r))}get meta(){return this.#p}get inspector(){return this.#v}},x6=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t){var n;throw n=e.name,new xK(xq.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},x3=class{#b=null;#x=null;#w;#k="pending";constructor(e,t){this.start=()=>(this.#b??=new Promise((e,t)=>{this.#x=t=>{t instanceof CustomEvent&&t.detail.id===this.#w&&(this.#k="resolved",this.#S(),t.stopImmediatePropagation(),e())},this.#C(()=>{"pending"===this.#k&&(this.#k="rejected"),this.#S(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#k="pending",addEventListener(this.type.name,this.#x)}),this.#b),this.done=()=>{dispatchEvent(new CustomEvent(this.type.name,{detail:{id:this.#w}}))},this.#w=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#k}#S=()=>{this.#x&&removeEventListener(this.type.name,this.#x)};#C=e=>{setTimeout(()=>{e()},this.type.timeout)}},x4=class{constructor(e,t=3e3){this.create=e=>new x3(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},x7=(e,t=3e3)=>new x4(e,t);let x9="u">typeof navigator?navigator:null,ke="u">typeof document?document:null,kt=x9&&x9.userAgent||"",kn=/Edge\/(\d+)/.exec(kt),kr=/MSIE \d/.exec(kt),ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kt),ko=!!(kr||ki||kn);kr?document.documentMode:ki?ki[1]:kn&&kn[1],!ko&&/gecko\/(\d+)/i.test(kt)&&(/Firefox\/(\d+)/.exec(kt)||[0,0])[1];let ks=!ko&&/Chrome\/(\d+)/.exec(kt);function ka(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of i){let i=a.match.exec(l),c=i&&i[0]&&a.handler(s,i,t-(i[0].length-r.length),n);if(c)return!1!==a.undoable&&c.setMeta(o,{transform:c,from:t,to:n,text:r}),e.dispatch(c),!0}return!1}ks&&ks[1],!ko&&x9&&/Apple Computer/.test(x9.vendor)&&(/Mobile\/\w+/.test(kt)||x9&&x9.maxTouchPoints>2)||x9&&/Mac/.test(x9.platform),/Android \d/.test(kt),ke&&"webkitFontSmoothing"in ke.documentElement.style&&(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];let kl=new p2("MILKDOWN_CUSTOM_INPUTRULES");Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var kc=class{},kd=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw xY();return e}}},ku=class e extends kc{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},kh=class extends kd{#B=hv.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(ku.create(e,[],t)),this),this.closeNode=()=>{try{this.#z()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#$(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#B=e.create(t).addToSet(this.#B),this),this.closeMark=e=>(this.#B=e.removeFromSet(this.#B),this),this.addText=e=>{try{let t=this.top();if(!t)throw xY();let n=t.pop(),r=this.schema.text(e,this.#B);if(!n)return t.push(r),this;let i=this.#F(n,r);if(i)return t.push(i),this;return t.push(n,r),this}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#z();while(this.size())return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#U(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#H=e=>e.isText;#F=(e,t)=>{if(this.#H(e)&&this.#H(t)&&hv.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#W=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t){var n;throw n=e,new xK(xq.parserMatchError,`Cannot match target parser for node: ${JSON.stringify(n,xJ)}.`)}return t};#U=e=>{let t=this.#W(e);t.spec.parseMarkdown.runner(this,e,t)};#z=()=>{this.#B=hv.none;let e=this.close();return this.#$(e.type,e.attrs,e.content)};#$=(e,t,n)=>{let r=e.createAndFill(t,n,this.#B);if(!r){let r,i,o;throw r=`Cannot create node for ${"name"in e?e.name:e}`,i=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(i).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},o=[["[Description]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:i(e):"null")]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]),new xK(xq.createNodeInParserFail,o.join("\n"))}return this.push(r),r}},kp=class e extends kc{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},kf=class extends kd{#B=hv.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(kp.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#z(),this),this.addNode=(e,t,n,r)=>(this.#$(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#V(e,t,n,r),this),this.closeMark=e=>(this.#G(e),this),this.build=()=>{let e=null;do e=this.#z();while(this.size())return e},this.next=e=>(Object.prototype.hasOwnProperty.call(e,"size")?e.forEach(e=>{this.#U(e)}):this.#U(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#W=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t){var n;throw n=e.type,new xK(xq.serializerMatchError,`Cannot match target serializer for node: ${JSON.stringify(n,xJ)}.`)}return t};#q=e=>this.#W(e).spec.toMarkdown.runner(this,e);#K=(e,t)=>this.#W(e).spec.toMarkdown.runner(this,e,t);#U=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#K(t,e))&&this.#q(e),t.forEach(e=>this.#G(e))};#J=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return null!=e.value?null:e;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,o={...e,children:i};return o.children=i,r.children=[o],r};#X=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){let{children:n,...i}=t=this.#J(t,r.type),{children:o,...s}=r;if(t.type===r.type&&n&&o&&JSON.stringify(i)===JSON.stringify(s)){let t={...s,children:[...o,...n]};return e.slice(0,-1).concat(this.#X(t))}}return e.concat(t)},[])),e};#Y=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#Q=(e,t)=>{let n="",r="",i=e.children,o=-1,s=-1;if(i){i&&i.forEach((e,t)=>{"text"===e.type&&e.value&&(o<0&&(o=t),s=t)});let e=i?.[s],t=i?.[o];if(e&&e.value.endsWith(" ")){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#$("text",void 0,n);let a=t();return r.length&&this.#$("text",void 0,r),a};#z=(e=!1)=>{let t=this.close(),n=()=>this.#$(t.type,t.children,t.value,t.props);return e?this.#Q(t,n):n()};#$=(e,t,n,r)=>{let i=kp.create(e,t,n,r),o=this.#X(this.#Y(i));return this.push(o),o};#V=(e,t,n,r)=>e.isInSet(this.#B)?this:(this.#B=e.addToSet(this.#B),this.openNode(t,n,{...r,isMark:!0}));#G=e=>{e.isInSet(this.#B)&&(this.#B=e.type.removeFromSet(this.#B),this.#z(!0))}};function km(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}var kg={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),a=s.move(i+i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),a=s.move(i);return a+=s.move(n.containerPhrasing(e,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},ky=x2({},"editorView"),kv=x2({},"editorState"),kb=x2([],"initTimer"),kx=x2({},"editor"),kk=x2([],"inputRules"),kw=x2([],"prosePlugins"),kS=x2([],"remarkPlugins"),kC=x2([],"nodeView"),kN=x2([],"markView"),kA=x2(uG().use(d4).use(f1),"remark"),kE=x2({handlers:kg,encode:[]},"remarkStringifyOptions"),kM=x7("ConfigReady"),kT=x7("InitReady"),kI=x7("SchemaReady"),kL=x2([],"schemaTimer"),kO=x2({},"schema"),kD=x2([],"nodes"),kR=x2([],"marks");function kP(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var k_=e=>(e.inject(kO,{}).inject(kD,[]).inject(kR,[]).inject(kL,[kT]).record(kI),async()=>{await e.waitTimers(kL);let t=e.get(kA),n=e.get(kS).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(kA,n);let r=new hK({nodes:Object.fromEntries(e.get(kD).map(([e,t])=>[e,kP(t)])),marks:Object.fromEntries(e.get(kR).map(([e,t])=>[e,kP(t)]))});return e.set(kO,r),e.done(kI),()=>{e.remove(kO).remove(kD).remove(kR).remove(kL).clearTimer(kI)}});km(k_,{displayName:"Schema"});var kj=class{constructor(){this.setCtx=e=>{this.#N=e},this.chain=()=>{if(null==this.#N)throw xQ();let e=this.#N,t=[],n=this.get.bind(this),r={run:()=>{let n=fc(...t),r=e.get(ky);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:(function(e,i){let o=n(e);return t.push(o(i)),r}).bind(this)};return r}}#g=new xZ;#N=null;get ctx(){return this.#N}create(e,t){let n=e.create(this.#g.sliceMap);return n.set(t),n}get(e){return this.#g.get(e).get()}remove(e){return this.#g.remove(e)}call(e,t){if(null==this.#N)throw xQ();let n=this.get(e)(t),r=this.#N.get(ky);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#N)throw xQ();let t=this.#N.get(ky);return e(t.state,t.dispatch,t)}},kB=x2(new kj,"commands"),kz=x2([kI],"commandsTimer"),k$=x7("CommandsReady"),kF=e=>{let t=new kj;return t.setCtx(e),e.inject(kB,t).inject(kz,[kI]).record(k$),async()=>(await e.waitTimers(kz),e.done(k$),()=>{e.remove(kB).remove(kz).clearTimer(k$)})};km(kF,{displayName:"Commands"});var kU=class{constructor(){this.setCtx=e=>{this.#N=e},this.add=e=>(this.#A.push(e),()=>{this.#A=this.#A.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){let r={key:e,onRun:()=>n};this.#A.push(r),t.push(()=>{this.#A=this.#A.filter(e=>e!==r)})}else this.#A.push(n),t.push(()=>{this.#A=this.#A.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=(ff.Backspace=fc(mi,p8,p3,p7),ff);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#A.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#N;if(null==i)throw xX();return fc(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#N=null;#A=[];get ctx(){return this.#N}},kH=x2(new kU,"keymap"),kW=x2([kI],"keymapTimer"),kV=x7("KeymapReady"),kG=e=>{let t=new kU;return t.setCtx(e),e.inject(kH,t).inject(kW,[kI]).record(kV),async()=>(await e.waitTimers(kW),e.done(kV),()=>{e.remove(kH).remove(kW).clearTimer(kV)})},kq=x7("ParserReady"),kK=()=>{throw xX()},kJ=x2(kK,"parser"),kX=x2([],"parserTimer"),kY=e=>(e.inject(kJ,kK).inject(kX,[kI]).record(kq),async()=>{await e.waitTimers(kX);let t=e.get(kA),n=e.get(kO);return e.set(kJ,kh.create(n,t)),e.done(kq),()=>{e.remove(kJ).remove(kX).clearTimer(kq)}});km(kY,{displayName:"Parser"});var kQ=x7("SerializerReady"),kZ=x2([],"serializerTimer"),k0=()=>{throw xX()},k1=x2(k0,"serializer"),k2=e=>(e.inject(k1,k0).inject(kZ,[kI]).record(kQ),async()=>{await e.waitTimers(kZ);let t=e.get(kA),n=e.get(kO);return e.set(k1,kf.create(n,t)),e.done(kQ),()=>{e.remove(k1).remove(kZ).clearTimer(kQ)}});km(k2,{displayName:"Serializer"});var k8=x2("","defaultValue"),k5=x2(e=>e,"stateOptions"),k6=x2([],"editorStateTimer"),k3=x7("EditorStateReady"),k4=new p2("MILKDOWN_STATE_TRACKER"),k7=e=>(e.inject(k8,"").inject(kv,{}).inject(k5,e=>e).inject(k6,[kq,kQ,k$,kV]).record(k3),async()=>{await e.waitTimers(k6);let t=e.get(kO),n=e.get(kJ),r=e.get(kk),i=e.get(k5),o=e.get(kw),s=function(e,t,n){var r;if("string"==typeof e)return t(e);if("html"===e.type)return hX.fromSchema(n).parse(e.dom);if("json"===e.type)return hD.fromJSON(n,e.value);throw r=e,new xK(xq.docTypeError,`Doc type error, unsupported type: ${JSON.stringify(r,xJ)}`)}(e.get(k8),n,t),a=e.get(kH),l=a.addBaseKeymap(),c=[...o,new pZ({key:k4,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(kv,i)}}}),function({rules:e}){let t=new pZ({key:kl,isInputRules:!0,state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,i,o)=>ka(n,r,i,o,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&ka(n,r.pos,r.pos,"",e,t)}),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;let{$cursor:i}=n.state.selection;return!!i&&ka(n,i.pos,i.pos,"\n",e,t)}}});return t}({rules:r}),mE(a.build())];e.set(kw,c);let d=i({schema:t,doc:s,plugins:c}),u=pQ.create(d);return e.set(kv,u),e.done(k3),()=>{l(),e.remove(k8).remove(kv).remove(k5).remove(k6).clearTimer(k3)}});km(k7,{displayName:"EditorState"});var k9=x2([],"pasteRule"),we=x2([kI],"pasteRuleTimer"),wt=x7("PasteRuleReady"),wn=e=>(e.inject(k9,[]).inject(we,[kI]).record(wt),async()=>(await e.waitTimers(we),e.done(wt),()=>{e.remove(k9).remove(we).clearTimer(wt)}));km(wn,{displayName:"PasteRule"});var wr=x7("EditorViewReady"),wi=x2([],"editorViewTimer"),wo=x2({},"editorViewOptions"),ws=x2(null,"root"),wa=x2(null,"rootDOM"),wl=x2({},"rootAttrs"),wc=new p2("MILKDOWN_VIEW_CLEAR"),wd=e=>(e.inject(ws,document.body).inject(ky,{}).inject(wo,{}).inject(wa,null).inject(wl,{}).inject(wi,[k3,wt]).record(wr),async()=>{var t;await e.wait(kT);let n=e.get(ws)||document.body,r="string"==typeof n?document.querySelector(n):n;e.update(kw,t=>[new pZ({key:wc,view:t=>{let n,i=r?((n=document.createElement("div")).className="milkdown",r.appendChild(n),e.set(wa,n),Object.entries(e.get(wl)).forEach(([e,t])=>n.setAttribute(e,t)),n):void 0;if(i&&r){let e=t.dom;r.replaceChild(i,e),i.appendChild(e)}return{destroy:()=>{i?.parentNode&&i?.parentNode.replaceChild(t.dom,i),i?.remove()}}}}),...t]),await e.waitTimers(wi);let i=e.get(kv),o=e.get(wo),s=new y0(r,{state:i,nodeViews:Object.fromEntries(e.get(kC)),markViews:Object.fromEntries(e.get(kN)),transformPasted:(t,n,r)=>(e.get(k9).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});return(t=s.dom).classList.add("editor"),t.setAttribute("role","textbox"),e.set(ky,s),e.done(wr),()=>{s?.destroy(),e.remove(ws).remove(ky).remove(wo).remove(wa).remove(wl).remove(wi).clearTimer(wr)}});km(wd,{displayName:"EditorView"});var wu=((S={}).Idle="Idle",S.OnCreate="OnCreate",S.Created="Created",S.OnDestroy="OnDestroy",S.Destroyed="Destroyed",S);function wh(e){return t=>{let n=t.get(ky),r=t.get(kO),i=t.get(k1);if(!e)return i(n.state.doc);let o=n.state.doc.slice(e.from,e.to,!0),s=r.topNodeType.createAndFill(null,o.content);return s?i(s):(console.error("No document found"),"")}}function wp({value:e,onChange:t,onSave:n}){let r,i,o=(0,et.useRef)(t),s=(0,et.useRef)(n);o.current=t,s.current=n,function(e,t=[]){let n=(0,et.useContext)(xW),r=(0,et.useCallback)(e,t);(0,et.useLayoutEffect)(()=>{n.setEditorFactory(()=>r)},[n,r]),n.loading}(t=>v8.make().config(n=>{n.set(vY,t),n.set(vB,e)}).config(xH).use(xF),[]);let[a,l]=(r=(0,et.useContext)(xW),i=(0,et.useCallback)(()=>r.editor.current,[r.editor]),[r.loading,i]),c=(0,et.useRef)(null),d=(0,et.useRef)(null),u=(0,et.useCallback)(()=>{if(a)return;let e=l();if(e)try{let t=e.action(wh());o.current(t)}catch{}},[a,l]);return(0,et.useEffect)(()=>{let e=c.current?.querySelector(".ProseMirror");if(e)return d.current=new MutationObserver(()=>{u()}),d.current.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{d.current?.disconnect()}},[a,u]),(0,et.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&"s"===e.key){if(e.preventDefault(),a)return;let t=l();if(t)try{let e=t.action(wh());s.current(e)}catch{}}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,l]),(0,ee.jsx)("div",{ref:c,className:"milkdown-wrap flex-1 min-h-0 overflow-auto",children:(0,ee.jsx)(xV,{})})}function wf(e){return(0,ee.jsx)(xG,{children:(0,ee.jsx)(wp,{...e})})}(class e{constructor(){this.enableInspector=(e=!0)=>(this.#E=e,this),this.onStatusChange=e=>(this.#T=e,this),this.config=e=>(this.#M.push(e),this),this.removeConfig=e=>(this.#M=this.#M.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#k===wu.Created&&this.#D(t,this.#I),this},this.remove=async e=>this.#k===wu.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#R([e].flat(),!0),this),this.create=async()=>(this.#k===wu.OnCreate||(this.#k===wu.Created&&await this.destroy(),this.#_(wu.OnCreate),this.#O(),this.#D([...this.#I.keys()],this.#I),await Promise.all([this.#j(this.#L),this.#j(this.#I)].flat()),this.#_(wu.Created)),this),this.destroy=async(e=!1)=>this.#k===wu.Destroyed||this.#k===wu.OnDestroy?this:this.#k===wu.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#M=[]),this.#_(wu.OnDestroy),await this.#R([...this.#I.keys()],e),await this.#P(),this.#_(wu.Destroyed),this),this.action=e=>e(this.#N),this.inspect=()=>this.#E?[...this.#L.values(),...this.#I.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#E=!1;#k=wu.Idle;#M=[];#T=()=>void 0;#g=new xZ;#y=new x6;#I=new Map;#L=new Map;#N=new x5(this.#g,this.#y);#O=()=>{var e,t;let n,r,i=(e=async e=>{await Promise.all(this.#M.map(t=>Promise.resolve(t(e))))},km(n=t=>(t.record(kM),async()=>(await e(t),t.done(kM),()=>{t.clearTimer(kM)})),{displayName:"Config"}),n),o=[k_,kY,k2,kF,kG,wn,k7,wd,(t=this,km(r=e=>(e.inject(kx,t).inject(kw,[]).inject(kS,[]).inject(kk,[]).inject(kC,[]).inject(kN,[]).inject(kE,{handlers:kg,encode:[]}).inject(kA,uG().use(d4).use(f1)).inject(kb,[kM]).record(kT),async()=>{await e.waitTimers(kb);let t=e.get(kE);return e.set(kA,uG().use(d4).use(f1,t)),e.done(kT),()=>{e.remove(kx).remove(kw).remove(kS).remove(kk).remove(kC).remove(kN).remove(kE).remove(kA).remove(kb).clearTimer(kT)}}),{displayName:"Init"}),r),i];this.#D(o,this.#L)};#D=(e,t)=>{e.forEach(e=>{let n=this.#N.produce(this.#E?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#R=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#I.get(e)?.cleanup;return(t?this.#I.delete(e):this.#I.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n)?n():n}));#P=async()=>{await Promise.all([...this.#L.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#L.clear()};#_=e=>{this.#k=e,this.#T(e)};#j=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let o=await i();e.set(t,{ctx:r,handler:i,cleanup:o})});get ctx(){return this.#N}get status(){return this.#k}}),v6("abcedfghicklmn",10);let wm={"in-progress":"●",pending:"○",done:"✓",archived:"▪"},wg={"in-progress":"var(--yellow)",pending:"var(--dim)",done:"var(--green)",archived:"var(--dimmer)"};function wy({sessionName:e}){let{data:t,loading:n,refresh:r}=ei((0,et.useCallback)(()=>(0,er.fetchPlans)(e),[e]),1e4),[i,o]=(0,et.useState)("all"),[s,a]=(0,et.useState)(null),[l,c]=(0,et.useState)({content:"",authorship:null}),[d,u]=(0,et.useState)(!1),[h,p]=(0,et.useState)(!1),[f,m]=(0,et.useState)(""),[g,y]=(0,et.useState)(!1),v=(0,et.useMemo)(()=>t?"all"===i?t:t.filter(e=>e.status===i):[],[t,i]),b=(0,et.useMemo)(()=>t?.find(e=>e.path===s)??null,[t,s]);(0,et.useEffect)(()=>{if(!s){c({content:"",authorship:null}),p(!1);return}u(!0),p(!1),(0,er.fetchPlan)(e,s).then(e=>{c(e),m(e.content)}).catch(()=>c({content:"",authorship:null})).finally(()=>u(!1))},[s,e]),(0,et.useEffect)(()=>{!s&&v.length>0&&a(v[0].path)},[v,s]);let x=(0,et.useMemo)(()=>(function(e,t){let n=e.split("\n"),r=[],i="",o=[];for(let e of n){let n=e.match(/^#{1,4}\s+(.+)/);if(n){if(o.length>0||i){let e=t?.sections[i]??null;r.push({heading:i,content:o.join("\n"),author:e?.author??null,authorAt:e?.at??null})}i=n[1].trim(),o=[e]}else o.push(e)}if(o.length>0||i){let e=t?.sections[i]??null;r.push({heading:i,content:o.join("\n"),author:e?.author??null,authorAt:e?.at??null})}return r})(l.content,l.authorship),[l]);async function k(t){if(s){if(y(!0),await (0,er.savePlan)(e,s,t)){let t=await (0,er.fetchPlan)(e,s);c(t),m(t.content),p(!1)}y(!1)}}async function w(){!b||await (0,er.markPlanDone)(e,b.name)&&r()}if(n&&!t)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Loading plans..."});if(!t||0===t.length)return(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"No plan files found in plans/"});let S={};for(let e of t)S[e.status]=(S[e.status]??0)+1;return(0,ee.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,ee.jsxs)("div",{className:"w-[260px] shrink-0 border-r border-[var(--border)] flex flex-col min-h-0",children:[(0,ee.jsx)("div",{className:"flex items-center h-6 bg-[var(--surface)] border-b border-[var(--border)] text-[10px] shrink-0 px-1 gap-px",children:["all","in-progress","pending","done"].map(e=>(0,ee.jsx)("button",{onClick:()=>o(e),className:`px-1.5 py-0.5 transition-colors ${i===e?"text-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:"all"===e?`all (${t.length})`:`${e} (${S[e]??0})`},e))}),(0,ee.jsx)("div",{className:"flex-1 overflow-y-auto",children:v.map(e=>{let t=s===e.path;return(0,ee.jsxs)("button",{onClick:()=>a(e.path),className:`w-full text-left px-2 py-1 flex items-start gap-1.5 transition-colors ${t?"bg-[rgba(255,255,255,0.04)] text-[var(--accent)]":"text-[var(--fg)] hover:bg-[rgba(255,255,255,0.02)]"}`,children:[(0,ee.jsx)("span",{className:"shrink-0 mt-0.5 text-[11px]",style:{color:wg[e.status]},children:wm[e.status]}),(0,ee.jsxs)("span",{className:"min-w-0",children:[(0,ee.jsx)("span",{className:"block truncate text-[12px]",children:e.name}),e.completed&&(0,ee.jsx)("span",{className:"block text-[10px] text-[var(--dimmer)]",children:e.completed})]})]},e.path)})})]}),(0,ee.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:d?(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"loading..."}):l.content||h?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{className:"shrink-0 border-b border-[var(--border)] px-3 flex items-center h-7",children:[(0,ee.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[b&&(0,ee.jsxs)("span",{className:"text-[11px]",style:{color:wg[b.status]},children:[wm[b.status]," ",b.status]}),(0,ee.jsx)(u6,{authorship:l.authorship})]}),(0,ee.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[b&&"done"!==b.status&&!h&&(0,ee.jsx)("button",{onClick:w,className:"text-[11px] px-2 py-0.5 text-[var(--green)] border border-[var(--border)] hover:border-[var(--green)] transition-colors",children:"mark done"}),h&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("button",{onClick:()=>k(f),disabled:g,className:"text-[11px] px-2 py-0.5 text-[var(--bg)] bg-[var(--accent)] hover:opacity-90 disabled:opacity-50 transition-opacity",children:g?"saving...":"save"}),(0,ee.jsx)("span",{className:"text-[9px] text-[var(--dimmer)]",children:"cmd+S"})]}),(0,ee.jsx)("button",{onClick:()=>h?p(!1):void(m(l.content),p(!0)),className:`text-[11px] px-2 py-0.5 border border-[var(--border)] transition-colors ${h?"text-[var(--accent)] border-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)] hover:border-[var(--dim)]"}`,children:h?"view":"edit"})]})]}),h?(0,ee.jsx)(wf,{value:f,onChange:m,onSave:k},s):(0,ee.jsx)("div",{className:"flex-1 overflow-y-auto p-4 max-w-3xl",children:x.map((e,t)=>{var n;let r=!!(n=e.author)&&n.startsWith("ai"),i=e.author?r?"var(--ai-color)":"var(--human-color)":"transparent",o=e.author?r?"var(--ai-bg)":"var(--human-bg)":"transparent",s=function(e){if(!e)return"";try{let t=new Date(e),n=Date.now()-t.getTime();if(n<36e5)return`${Math.floor(n/6e4)}m ago`;if(n<864e5)return`${Math.floor(n/36e5)}h ago`;return`${Math.floor(n/864e5)}d ago`}catch{return""}}(e.authorAt);return(0,ee.jsxs)("div",{className:"plan-content",style:{borderLeft:e.author?`2px solid ${i}`:"2px solid transparent",paddingLeft:"12px",marginBottom:"4px",background:o,borderRadius:"2px"},children:[e.author&&e.heading&&(0,ee.jsxs)("div",{className:"flex items-center gap-2 mb-1 -mt-0.5",children:[(0,ee.jsx)("span",{className:"text-[9px] px-1 py-px rounded",style:{color:r?"var(--ai-color)":"var(--human-color)",background:r?"var(--ai-badge)":"var(--human-badge)"},children:e.author}),s&&(0,ee.jsx)("span",{className:"text-[9px] text-[var(--dimmer)]",children:s})]}),(0,ee.jsx)(u8,{children:e.content})]},`${e.heading}-${t}`)})})]}):(0,ee.jsx)("div",{className:"flex-1 flex items-center justify-center text-[var(--dim)]",children:"Select a plan to view"})})]})}function wv({project:e,lastUpdate:t,stale:n=!1}){let[r,i]=(0,et.useState)(Date.now()),[o,s]=(0,et.useState)(!1),a=(0,et.useRef)(t);(0,et.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,et.useEffect)(()=>{if(t&&t!==a.current){a.current=t,s(!0);let e=setTimeout(()=>s(!1),300);return()=>clearTimeout(e)}},[t]);let l=e.tasks.filter(e=>"done"===e.status).length,c=e.agents.filter(e=>e.isBusy).length,d=t?Math.max(0,Math.floor((r-t)/1e3)):0,u=new Date(r).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return(0,ee.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 h-6 bg-[var(--bg-weak)] border-t flex items-center px-3 text-[11px] z-20",children:[(0,ee.jsx)("span",{className:"text-[var(--accent)] font-medium",children:e.session}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[(0,ee.jsx)("span",{style:{color:c>0?"var(--yellow)":void 0},children:c}),"/",e.agents.length," agents"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[(0,ee.jsx)("span",{style:{color:l>0?"var(--green)":void 0},children:l}),"/",e.tasks.length," tasks"]}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["updated ",d,"s ago"]}),(0,ee.jsx)("span",{className:"flex-1"}),(0,ee.jsx)("span",{className:"transition-opacity duration-300",style:{color:n?"var(--red)":"var(--green)",opacity:o?1:.6},children:"●"}),(0,ee.jsx)("span",{className:"text-[var(--dim)] ml-1.5",children:n?"stale":"live"}),(0,ee.jsx)("span",{className:"mx-2 text-[var(--dim)] opacity-30",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:u})]})}let wb=[{id:"kanban",label:"kanban"},{id:"agents",label:"agents"},{id:"diffs",label:"diffs"},{id:"plans",label:"plans"},{id:"validation",label:"validation"},{id:"metrics",label:"metrics"},{id:"activity",label:"activity"}];function wx(){let e=(0,en.usePathname)(),t=(0,en.useRouter)(),n=decodeURIComponent(e.replace(/^\/project\//,"").replace(/\/$/,"")),[r,i]=(0,et.useState)("kanban"),{data:o,error:s,stale:a,lastUpdate:l,refresh:c}=ei((0,et.useCallback)(()=>(0,er.fetchProject)(n),[n]),2e3),{data:d}=ei((0,et.useCallback)(()=>(0,er.fetchEvents)(n),[n]),3e3),{data:u}=ei((0,et.useCallback)(()=>(0,er.fetchMilestones)(n),[n]),3e3),{data:h}=ei((0,et.useCallback)(()=>(0,er.fetchMission)(n),[n]),5e3),{data:p}=ei((0,et.useCallback)(()=>(0,er.fetchSkills)(n),[n]),1e4);if(s)return(0,ee.jsx)("div",{className:"h-screen flex items-center justify-center text-[var(--red)]",children:"failed to load project"});if(!o)return(0,ee.jsx)("div",{className:"h-screen flex items-center justify-center text-[var(--dim)]",children:"loading..."});let f=o.tasks.filter(e=>"done"===e.status).length,m=o.tasks.length,g=m>0?Math.round(f/m*100):0,y=o.agents.filter(e=>e.isBusy).length;return(0,ee.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,ee.jsxs)("div",{className:"flex items-center justify-between px-4 h-7 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ee.jsx)("button",{onClick:()=>t.push("/"),className:"text-[var(--dim)] hover:text-[var(--fg)] transition-colors",children:"< esc"}),(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--accent)]",children:o.session}),o.mission&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)] truncate",children:o.mission.title})]})]}),(0,ee.jsxs)("div",{className:"flex items-center gap-4 text-[var(--dim)]",children:[(0,ee.jsxs)("span",{children:[(0,ee.jsx)("span",{className:"text-[var(--green)]",children:y}),"/",o.agents.length," ","agents"]}),(0,ee.jsxs)("span",{children:[(0,ee.jsx)("span",{className:"text-[var(--green)]",children:f}),"/",m," tasks"]}),(0,ee.jsx)(eo.ProgressBar,{percent:g,width:10})]})]}),o.agents.length>0&&(0,ee.jsx)("div",{className:"flex items-center px-2 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:o.agents.map((e,t)=>(0,ee.jsx)(es,{agent:e},`${e.paneTitle}-${t}`))}),o.goals.length>0&&(0,ee.jsx)("div",{className:"flex items-center gap-4 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:o.goals.map(e=>{let t=o.tasks.filter(t=>t.goal===e.id),n=t.filter(e=>"done"===e.status).length,r=t.length>0?Math.round(n/t.length*100):0;return(0,ee.jsxs)("span",{className:"flex items-center gap-1.5 shrink-0",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] truncate max-w-[20ch]",children:e.title}),(0,ee.jsx)(eo.ProgressBar,{percent:r,width:4})]},e.id)})}),h&&(0,ee.jsxs)("div",{className:"flex items-center gap-4 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"mission:"}),(0,ee.jsx)("span",{className:"complete"===h.mission.status?"text-[var(--green)]":"active"===h.mission.status?"text-[var(--accent)]":"text-[var(--yellow)]",children:h.mission.status}),h.validationSummary.total>0&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"assertions:"}),(0,ee.jsx)("span",{className:"text-[var(--green)]",children:h.validationSummary.passing}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:"/"}),(0,ee.jsx)("span",{children:h.validationSummary.total}),h.validationSummary.failing>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)]",children:["(",h.validationSummary.failing," failing)"]})]}),h.mission.branch&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"text-[var(--border)]",children:"│"}),(0,ee.jsx)("span",{className:"text-[var(--dim)]",children:h.mission.branch})]})]}),u&&u.length>0&&(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)] shrink-0",children:"milestones:"}),u.map(e=>{let t=e.taskCount>0?Math.round(e.tasksDone/e.taskCount*100):0,n="done"===e.status?"var(--green)":"active"===e.status?"var(--accent)":"validating"===e.status?"var(--yellow)":"var(--dim)";return(0,ee.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[(0,ee.jsx)("span",{style:{color:n},children:e.id}),(0,ee.jsx)("span",{className:"text-[var(--fg)] truncate max-w-[14ch]",children:e.title}),(0,ee.jsx)(eo.ProgressBar,{percent:t,width:3}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:[e.tasksDone,"/",e.taskCount]})]},e.id)})]}),p&&p.length>0&&(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-4 h-6 bg-[var(--surface)] border-b border-[var(--border)] shrink-0 overflow-x-auto",children:[(0,ee.jsx)("span",{className:"text-[var(--dim)] shrink-0",children:"skills:"}),p.map(e=>(0,ee.jsx)("span",{className:"px-1.5 py-0 text-[10px] border border-[var(--border)] text-[var(--cyan)] shrink-0",title:e.specialties.join(", "),children:e.name},e.name))]}),(0,ee.jsx)("div",{className:"flex border-b border-[var(--border)] bg-[var(--surface)] shrink-0",children:wb.map(e=>(0,ee.jsx)("button",{onClick:()=>i(e.id),className:`px-4 h-7 transition-colors ${r===e.id?"text-[var(--accent)] border-b-2 border-[var(--accent)]":"text-[var(--dim)] hover:text-[var(--fg)]"}`,children:e.label},e.id))}),"kanban"===r&&(0,ee.jsx)(t6,{tasks:o.tasks,sessionName:o.session,agents:o.agents,goals:o.goals,onRefresh:c}),"diffs"===r&&(0,ee.jsx)(cc,{sessionName:o.session}),"plans"===r&&(0,ee.jsx)(wy,{sessionName:o.session}),"validation"===r&&(0,ee.jsx)(wE,{sessionName:o.session}),"metrics"===r&&(0,ee.jsx)(wA,{sessionName:o.session}),"activity"===r&&(0,ee.jsx)(ch,{events:d??[]}),"agents"===r&&(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto",children:[(0,ee.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:o.agents.map((e,t)=>(0,ee.jsx)(es,{agent:e},`${e.paneTitle}-${t}`))}),0===o.agents.length&&(0,ee.jsx)("div",{className:"flex items-center justify-center h-32 text-[var(--dim)]",children:"no agents in this session"})]}),(0,ee.jsx)(wv,{project:o,lastUpdate:l,stale:a})]})}let wk={passing:"var(--green)",failing:"var(--red)",pending:"var(--dim)",blocked:"var(--yellow)"};function ww(e){if(e<6e4)return`${Math.round(e/1e3)}s`;if(e<36e5)return`${Math.round(e/6e4)}m`;let t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return`${t}h ${n}m`}function wS(e){return`${Math.round(100*e)}%`}function wC({label:e,value:t,color:n}){return(0,ee.jsxs)("div",{className:"px-3 py-2 bg-[var(--surface)] border border-[var(--border)]",children:[(0,ee.jsx)("div",{className:"text-[var(--dim)] text-[11px]",children:e}),(0,ee.jsx)("div",{className:"text-lg",style:{color:n??"var(--fg)"},children:t})]})}let wN={done:"var(--green)",active:"var(--accent)",validating:"var(--yellow)",locked:"var(--dim)"};function wA({sessionName:e}){let{data:t}=ei((0,et.useCallback)(()=>(0,er.fetchMetrics)(e),[e]),5e3);if(!t)return(0,ee.jsx)("div",{className:"flex-1 p-4 text-[var(--dim)]",children:"loading metrics..."});let n=t.agents.length>0?t.agents.reduce((e,t)=>e+t.utilization,0)/t.agents.length:0;return(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto space-y-4",children:[(0,ee.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[(0,ee.jsx)(wC,{label:"session duration",value:ww(t.session.durationMs)}),(0,ee.jsx)(wC,{label:"completion rate",value:wS(t.tasks.completionRate),color:t.tasks.completionRate>=.8?"var(--green)":"var(--yellow)"}),(0,ee.jsx)(wC,{label:"avg agent utilization",value:wS(n),color:n>=.5?"var(--green)":"var(--dim)"}),(0,ee.jsx)(wC,{label:"retry rate",value:wS(t.tasks.retryRate),color:t.tasks.retryRate>.2?"var(--red)":"var(--green)"})]}),(0,ee.jsxs)("div",{className:"flex gap-4 text-[12px] text-[var(--dim)]",children:[(0,ee.jsxs)("span",{children:["tasks: ",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:t.tasks.completed}),"/",t.tasks.total," done"]}),t.tasks.failed>0&&(0,ee.jsxs)("span",{children:["failed: ",(0,ee.jsx)("span",{className:"text-[var(--red)]",children:t.tasks.failed})]}),t.tasks.avgDurationMs>0&&(0,ee.jsxs)("span",{children:["avg: ",ww(t.tasks.avgDurationMs)]}),t.tasks.medianDurationMs>0&&(0,ee.jsxs)("span",{children:["median: ",ww(t.tasks.medianDurationMs)]}),t.tasks.p90DurationMs>0&&(0,ee.jsxs)("span",{children:["p90: ",ww(t.tasks.p90DurationMs)]})]}),t.tasks.byMilestone.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"milestones"}),(0,ee.jsx)("div",{className:"space-y-px",children:t.tasks.byMilestone.map(e=>{let t=e.taskCount>0?Math.round(e.completedCount/e.taskCount*100):0;return(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)]",children:[(0,ee.jsx)("span",{style:{color:wN[e.status]??"var(--dim)"},className:"w-6 shrink-0",children:e.id}),(0,ee.jsx)("span",{className:"text-[var(--fg)] w-32 truncate shrink-0",children:e.title}),(0,ee.jsx)("span",{style:{color:wN[e.status]??"var(--dim)"},className:"w-20 shrink-0",children:e.status}),(0,ee.jsx)(eo.ProgressBar,{percent:t,width:8}),(0,ee.jsxs)("span",{className:"text-[var(--dim)] text-[11px] shrink-0",children:[e.completedCount,"/",e.taskCount]}),e.durationMs>0&&(0,ee.jsx)("span",{className:"text-[var(--dim)] text-[11px]",children:ww(e.durationMs)})]},e.id)})})]}),t.agents.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"agents"}),(0,ee.jsx)("div",{className:"space-y-px",children:[...t.agents].sort((e,t)=>t.utilization-e.utilization).map(e=>(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)] text-[12px]",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] w-28 truncate shrink-0",children:e.name}),(0,ee.jsxs)("span",{className:"text-[var(--dim)] w-16 shrink-0",children:[e.taskCount," tasks"]}),(0,ee.jsx)("span",{className:"w-14 shrink-0",style:{color:e.utilization>=.5?"var(--green)":"var(--dim)"},children:wS(e.utilization)}),e.retryCount>0&&(0,ee.jsxs)("span",{className:"text-[var(--red)] shrink-0",children:[e.retryCount," retries"]}),e.specialties.length>0&&(0,ee.jsx)("span",{className:"text-[var(--cyan)] text-[10px] truncate",children:e.specialties.join(", ")})]},e.name))})]}),t.mission.title&&(0,ee.jsxs)("div",{className:"flex gap-3 text-[12px]",children:[(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["mission: ",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:t.mission.title})," [",t.mission.status,"]"]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["milestones: ",t.mission.milestonesCompleted]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["validation:"," ",(0,ee.jsx)("span",{className:"text-[var(--green)]",children:wS(t.mission.validationPassRate)})]}),(0,ee.jsxs)("span",{className:"text-[var(--dim)]",children:["wall clock: ",ww(t.mission.wallClockMs)]})]}),t.timeline.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"timeline"}),(0,ee.jsx)("div",{className:"space-y-px max-h-48 overflow-auto",children:t.timeline.slice(-20).map((e,t)=>(0,ee.jsxs)("div",{className:"flex items-center gap-3 px-2 py-0.5 bg-[var(--surface)] text-[11px] text-[var(--dim)]",children:[(0,ee.jsx)("span",{className:"w-20 shrink-0",children:new Date(e.timestamp).toLocaleTimeString()}),(0,ee.jsxs)("span",{children:["done:",(0,ee.jsx)("span",{className:"text-[var(--green)]",children:e.completedTasks})]}),(0,ee.jsxs)("span",{children:["active:",(0,ee.jsx)("span",{className:"text-[var(--yellow)]",children:e.activeTasks})]}),(0,ee.jsxs)("span",{children:["busy:",(0,ee.jsx)("span",{className:"text-[var(--accent)]",children:e.busyAgents})]}),(0,ee.jsxs)("span",{children:["idle:",(0,ee.jsx)("span",{className:"text-[var(--fg)]",children:e.idleAgents})]})]},t))})]})]})}function wE({sessionName:e}){let{data:t}=ei((0,et.useCallback)(()=>(0,er.fetchValidation)(e),[e]),3e3),{data:n}=ei((0,et.useCallback)(()=>(0,er.fetchCoverage)(e),[e]),5e3);if(!t)return(0,ee.jsx)("div",{className:"flex-1 p-4 text-[var(--dim)]",children:"no validation contract found"});let r=t.state?Object.entries(t.state.assertions):[];return(0,ee.jsxs)("div",{className:"flex-1 p-4 overflow-auto space-y-4",children:[t.contract&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"contract"}),(0,ee.jsx)("pre",{className:"text-[var(--fg)] text-[12px] whitespace-pre-wrap bg-[var(--surface)] p-2 border border-[var(--border)]",children:t.contract})]}),r.length>0&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"assertions"}),(0,ee.jsx)("div",{className:"space-y-px",children:r.map(([e,t])=>(0,ee.jsxs)("div",{className:"flex items-center gap-2 px-2 py-0.5 bg-[var(--surface)]",children:[(0,ee.jsx)("span",{className:"text-[var(--fg)] w-32 shrink-0",children:e}),(0,ee.jsx)("span",{style:{color:wk[t.status]??"var(--dim)"},className:"w-16 shrink-0",children:t.status}),t.verifiedBy&&(0,ee.jsxs)("span",{className:"text-[var(--cyan)] text-[11px]",children:["@",t.verifiedBy]}),t.evidence&&(0,ee.jsx)("span",{className:"text-[var(--dim)] text-[11px] truncate",children:t.evidence})]},e))})]}),n&&(n.unclaimed.length>0||Object.keys(n.duplicates).length>0)&&(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"text-[var(--accent)] mb-1",children:"coverage"}),n.unclaimed.length>0&&(0,ee.jsxs)("div",{className:"text-[var(--yellow)] text-[12px]",children:["unclaimed: ",n.unclaimed.join(", ")]}),Object.entries(n.duplicates).map(([e,t])=>(0,ee.jsxs)("div",{className:"text-[var(--dim)] text-[12px]",children:[e,": claimed by tasks ",t.join(", ")]},e))]})]})}e.s(["default",()=>wx],36508)}]);