Add the block types Docmost has and Docwell lacked
CI / desktop (ubuntu-latest) (push) Successful in 1h15m48s
CI / mobile (push) Failing after 3m6s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / go (Media) (push) Successful in 10m21s
CI / go (Server) (push) Failing after 19m16s
CI / go (Web-App) (push) Successful in 10m27s
CI / frontend (push) Failing after 7m25s
CI / docker (push) Successful in 46m48s

The slash menu gains Video, Audio, Page break, Footnote, Tabs, Status,
Emoji, Subpages, Synced block and a fifth column size:
- Video and audio upload a file that plays on the page.
- Page breaks show as a labelled line and start a new page in print,
  Word and PDF.
- Footnotes are numbered in reading order and listed at the end of the
  page. Their notes hold bold, italic, code and links, with a plain copy
  kept for search.
- Tabs hold blocks on several named tabs; which one shows is each
  reader's own choice.
- Status badges are coloured words in the text.
- Typing ":" and a word picks an emoji, from the list the page icon
  picker uses, now kept in the editor package.
- Subpages lists the page's child pages, read afresh from the page tree.
- A synced block is a synced page that shows one block of another page,
  made from a copied block link.

Exports (HTML, Markdown, Word, PDF) and search handle every new block.
Page and space exports list a page's subpages. Labels are translated in
all five languages.

The phone toolbar gets Tabs, Footnote, Status, Emoji, Subpages and Page
break, and the app answers the editor's request for the page's
subpages. The bridge protocol goes to version 5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-17 17:37:32 +01:00
1 parent 30c2d82f26
commit e441880f2f
48 files changed
+3197 -219

No files matched your search

+6
View File
@@ -69,6 +69,12 @@
"dev:admin"
],
"port": 5174
},
{
"name": "editor-bridge",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev", "-w", "@docwell/editor-bridge", "--", "--port", "5180", "--strictPort"],
"port": 5180
}
]
}
+92 -90
View File
@@ -9,28 +9,28 @@
`)}};fe.empty=new fe(!0);var pe=class{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 me(e){let t=[];do t.push(he(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function he(e){let t=[];do t.push(ge(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ge(e){let t=be(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ve(e,t);else break;return t}function _e(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ve(e,t){let n=_e(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:_e(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function ye(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 i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function be(e){if(e.eat(`(`)){let t=me(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=ye(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function xe(e){let t=[[]];return i(a(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)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Se(e,t){return t-e}function Ce(e,t){let n=[];return r(t),n.sort(Se);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function we(e){let t=Object.create(null);return n(Ce(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ce(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new fe(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Se);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Te(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Ee(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 De(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function Oe(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new je(e,r,t[r]);return n}var ke=class e{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=Oe(e,n.attrs),this.defaultAttrs=Ee(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==fe.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:De(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new ce(this,this.coLine truncated
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Be.hasOwnProperty(a)&&this.parser.normalizeLists&&qe(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:ze.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Re.hasOwnProperty(a))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 out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),t)}ignoreFallback(e,t){e.nodeName!=`BR`||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)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,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 o=this.top;if(a&&a.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;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?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(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=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.matchType(e.type);let n=d.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Xe(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&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=We(e,i,a.options);a.options&Ue&&a.content.length==0&&(o|=Ue);let s=d.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):Xe(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Ge(e,t,s,r,null,o)),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|=Ve);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++)this.find[t].pos==null&&e.nodeType==1&&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++)this.find[r].pos==null&&e.nodeType==1&&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,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(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 qe(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Be.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Je(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatcheLine truncated
`))}})}function Ut(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Wt(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Dt(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new p(s.from(o),0,0),1,!0))}function Gt(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Kt(e,t,n=1,r){let i=e.doc.resolve(t),a=s.empty,o=s.empty;for(let e=i.depth,t=i.depth-n,c=n-1;e>t;e--,c--){a=s.from(i.node(e).copy(a));let t=r&&r[c];o=s.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Et(t,t,new p(a.append(o),n,n),!0))}function qt(e,t){let n=e.resolve(t),r=n.index();return Yt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Jt(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 a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Yt(e,t){return!!(e&&t&&!e.isLeaf&&Jt(e,t))}function Xt(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Yt(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Zt(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Ht(e,r.node(),r.before(),s)}o.inlineContent&&jt(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Et(l,c.map(t+n,-1),p.empty,!0)),r===!0){let t=e.doc.resolve(l);Vt(e,t.node(),t.before(),e.steps.length)}return e}function Qt(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)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)return null}return null}function $t(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<=(n.openStart==0&&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,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function en(e,t,n=t,r=p.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return tn(i,a,r)?new Et(t,n,r):new nn(i,a,r).fit()}function tn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var nn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.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=s.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,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new p(i,a,o);return e>-1?new Dt(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Et(n.pos,r.pos,s):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=t=Line truncated
`).scrollIntoView()),!0)};function sr(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var cr=(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),a=n.indexAfter(-1),o=sr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(w.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},lr=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Dn||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=sr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(T.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},ur=(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(Gt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Nt(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function dr(e){return(t,n)=>{if(t.selection instanceof E&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Gt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof T||t.selection instanceof Dn)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=sr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Gt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Gt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var fr=dr(),pr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(E.create(e.doc,i))),!0)},mr=(e,t)=>(t&&t(e.tr.setSelection(new Dn(e.doc))),!0);function hr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||qt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function gr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,c,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&hr(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,c=s.empty;for(let e=o.length-1;e>=0;e--)c=s.from(o[e].create(null,c));c=s.from(i.copy(c));let l=e.tr.step(new Dt(t.pos-1,r,t.pos,r,new p(c,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&qt(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:w.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),m=f&&Nt(f);if(m!=null&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(u&&Xn(a,`start`,!0)&&Xn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let c=a,l=1;for(;!c.isTextblock;c=c.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,c.content)){if(n){let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].copy(r));n(e.tr.step(new Dt(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new p(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _r(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(T.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var vr=_r(-1),yr=_r(1);function br(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Ft(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function xr(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),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:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function Sr(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Cr=Sr(Wn,Kn,Zn),wr=Sr(Wn,er,tr),Tr={Enter:Sr(or,lrLine truncated
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:Fr(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(ci&&l.focusNode&&l.focusNode!=s.node&&O(l.focusNode)){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&fi)&&Br(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Br(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&ci)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}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],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?$i:Qi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ea:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?$i:ea}n=a}this.dirty=$i}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?$i:Qi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},na=class extends ta{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=O(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Zi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ra=class extends ta{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.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},ia=class e extends ta{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Ze.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ea||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ea&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Zi){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Zi}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Ta(a,n,o,r)),t>0&&(a=Ta(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},aa=class e extends ta{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Wr(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Ze.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ga(u,r,n),l?c=new la(t,n,r,i,u,d||null,f,l):n.isText?new sa(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;Line truncated
`))}})}function Ut(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Wt(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Dt(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new p(s.from(o),0,0),1,!0))}function Gt(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Kt(e,t,n=1,r){let i=e.doc.resolve(t),a=s.empty,o=s.empty;for(let e=i.depth,t=i.depth-n,c=n-1;e>t;e--,c--){a=s.from(i.node(e).copy(a));let t=r&&r[c];o=s.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Et(t,t,new p(a.append(o),n,n),!0))}function qt(e,t){let n=e.resolve(t),r=n.index();return Yt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Jt(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 a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Yt(e,t){return!!(e&&t&&!e.isLeaf&&Jt(e,t))}function Xt(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Yt(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Zt(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Ht(e,r.node(),r.before(),s)}o.inlineContent&&jt(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Et(l,c.map(t+n,-1),p.empty,!0)),r===!0){let t=e.doc.resolve(l);Vt(e,t.node(),t.before(),e.steps.length)}return e}function Qt(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)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)return null}return null}function $t(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<=(n.openStart==0&&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,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function en(e,t,n=t,r=p.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return tn(i,a,r)?new Et(t,n,r):new nn(i,a,r).fit()}function tn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var nn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.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=s.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,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new p(i,a,o);return e>-1?new Dt(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Et(n.pos,r.pos,s):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=t=Line truncated
`).scrollIntoView()),!0)};function or(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var sr=(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),a=n.indexAfter(-1),o=or(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(w.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},cr=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Dn||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=or(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(T.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},lr=(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(Gt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Nt(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function ur(e){return(t,n)=>{if(t.selection instanceof E&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Gt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof T||t.selection instanceof Dn)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=or(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Gt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Gt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var dr=ur(),fr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(E.create(e.doc,i))),!0)},pr=(e,t)=>(t&&t(e.tr.setSelection(new Dn(e.doc))),!0);function mr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||qt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function hr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,c,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&mr(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,c=s.empty;for(let e=o.length-1;e>=0;e--)c=s.from(o[e].create(null,c));c=s.from(i.copy(c));let l=e.tr.step(new Dt(t.pos-1,r,t.pos,r,new p(c,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&qt(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:w.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),m=f&&Nt(f);if(m!=null&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(u&&Yn(a,`start`,!0)&&Yn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let c=a,l=1;for(;!c.isTextblock;c=c.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,c.content)){if(n){let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].copy(r));n(e.tr.step(new Dt(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new p(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function gr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(T.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var _r=gr(-1),vr=gr(1);function yr(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Ft(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function br(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),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:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function xr(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Sr=xr(Un,Gn,Xn),Cr=xr(Un,$n,er),wr={Enter:xr(ar,crLine truncated
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:Pr(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(si&&l.focusNode&&l.focusNode!=s.node&&k(l.focusNode)){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&di)&&zr(o.node,o.offset,l.anchorNode,l.anchorOffset)&&zr(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&si)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}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],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Qi:Zi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=$i:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Qi:$i}n=a}this.dirty=Qi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Qi:Zi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},ta=class extends ea{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=k(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Xi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},na=class extends ea{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.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},ra=class e extends ea{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Ze.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$i||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$i&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xi){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Xi}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=wa(a,n,o,r)),t>0&&(a=wa(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},ia=class e extends ea{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Ur(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Ze.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ha(u,r,n),l?c=new ca(t,n,r,i,u,d||null,f,l):n.isText?new oa(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;Line truncated
`),slice:t}}function oo(e,t,n,r,i){let a=i.parent.type.spec.code,o,c;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 c=new p(s.from(e.state.schema.text(t.replace(/\r\n?/g,`
`))),0,0),e.someProp(`transformPasted`,t=>{c=t(c,e,!0)}),c;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)c=n;else{let n=i.marks(),{schema:r}=e.state,a=Ze.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=yo(n),_i&&bo(o);let u=o&&o.querySelector(`[data-pm-slice]`),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&!O(e);)e=e.nextSibling;if(!e)break;o=e}if(c||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Le.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!so.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)c=xo(mo(c,+d[1],+d[2]),d[4]);else if(c=p.maxOpen(co(c.content,i),!0),c.openStart||c.openEnd){let e=0,t=0;for(let t=c.content.firstChild;e<c.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=c.content.lastChild;t<c.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);c=mo(c,e,t)}return e.someProp(`transformPasted`,t=>{c=t(c,e,l)}),c}var so=/^(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 co(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,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&uo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=fo(a[a.length-1],i.length));let n=lo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return s.from(a)}return e}function lo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,s.from(e));return e}function uo(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=uo(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(s.from(lo(n,e,i+1))))}}function fo(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,fo(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(r))}function po(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,c=o.content;return e.childCount>1&&(a=0),i<r-1&&(c=po(c,t,n,r,i+1,a)),i>=n&&(c=t<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(c))}function mo(e,t,n){return t<e.openStart&&(e=new p(po(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(po(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var ho={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function go(){return document.implementation.createHTMLDocument(`title`)}var _o=null;function vo(e){let t=window.trustedTypes;if(!t)return e;if(!_o){if(_o=t.defaultPolicy)try{return _o.createHTML(e)}catch{}_o=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return _o.createHTML(e)}function yo(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=go(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&ho[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=vo(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function bo(e){let t=e.querySelectorAll(ui?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function xo(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=s.from(t.create(r[e+1],i))}catch{break}a++,o++}return new p(i,a,o)}var So={},Co={},wo={touchstart:!0,touchmove:!0},To=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariCompoLine truncated
`),slice:t}}function ao(e,t,n,r,i){let a=i.parent.type.spec.code,o,c;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 c=new p(s.from(e.state.schema.text(t.replace(/\r\n?/g,`
`))),0,0),e.someProp(`transformPasted`,t=>{c=t(c,e,!0)}),c;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)c=n;else{let n=i.marks(),{schema:r}=e.state,a=Ze.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=vo(n),gi&&yo(o);let u=o&&o.querySelector(`[data-pm-slice]`),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&!k(e);)e=e.nextSibling;if(!e)break;o=e}if(c||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Le.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!oo.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)c=bo(po(c,+d[1],+d[2]),d[4]);else if(c=p.maxOpen(so(c.content,i),!0),c.openStart||c.openEnd){let e=0,t=0;for(let t=c.content.firstChild;e<c.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=c.content.lastChild;t<c.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);c=po(c,e,t)}return e.someProp(`transformPasted`,t=>{c=t(c,e,l)}),c}var oo=/^(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 so(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,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&lo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=uo(a[a.length-1],i.length));let n=co(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return s.from(a)}return e}function co(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,s.from(e));return e}function lo(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=lo(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(s.from(co(n,e,i+1))))}}function uo(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,uo(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(r))}function fo(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,c=o.content;return e.childCount>1&&(a=0),i<r-1&&(c=fo(c,t,n,r,i+1,a)),i>=n&&(c=t<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(c))}function po(e,t,n){return t<e.openStart&&(e=new p(fo(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(fo(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var mo={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function ho(){return document.implementation.createHTMLDocument(`title`)}var go=null;function _o(e){let t=window.trustedTypes;if(!t)return e;if(!go){if(go=t.defaultPolicy)try{return go.createHTML(e)}catch{}go=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return go.createHTML(e)}function vo(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ho(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&mo[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=_o(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function yo(e){let t=e.querySelectorAll(li?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function bo(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=s.from(t.create(r[e+1],i))}catch{break}a++,o++}return new p(i,a,o)}var xo={},So={},Co={touchstart:!0,touchmove:!0},wo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariCompoLine truncated
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function qu(e,t){return Ku(e,{from:0,to:e.content.size},t)}function Ju(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Yu(e,t){let n=il(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Xu(e,t){let n=nu(typeof t==`string`?t:t.name,e.schema);return n===`node`?Yu(e,t):n===`mark`?mu(e,t):{}}function Zu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Qu(e){let t=Zu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function $u(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Qu(r)}function ed(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=_l(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var td=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},nd=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function rd(e,t){return t.nodes[e]||t.marks[e]||null}function id(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var ad=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function od(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?vl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>ml(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>ml(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function sd(e,t,n={}){if(!t)return Zl(e,null,n)||od(e,null,n);let r=nu(t,e.schema);return r===`node`?Zl(e,t,n):r===`mark`&&od(e,t,n)}var cd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=yu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},ld=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function ud(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function dd(e,t){let{nodeExtensions:n}=Au(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=Nu(k(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function fd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(fd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function pd(e){return e instanceof E}function md(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function hd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!md(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var gd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function _d(e,t){let n=t.mapping.mapResult(e.position);return{position:new gd(n.pos),mapResult:n}}function Line truncated
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function Ku(e,t){return Gu(e,{from:0,to:e.content.size},t)}function qu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ju(e,t){let n=rl(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Yu(e,t){let n=tu(typeof t==`string`?t:t.name,e.schema);return n===`node`?Ju(e,t):n===`mark`?pu(e,t):{}}function Xu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Zu(e){let t=Xu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function Qu(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Zu(r)}function $u(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=gl(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var ed=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},td=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function nd(e,t){return t.nodes[e]||t.marks[e]||null}function rd(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var id=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function ad(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?_l(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>pl(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>pl(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function od(e,t,n={}){if(!t)return Xl(e,null,n)||ad(e,null,n);let r=tu(t,e.schema);return r===`node`?Xl(e,t,n):r===`mark`&&ad(e,t,n)}var sd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=vu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},cd=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function ld(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function ud(e,t){let{nodeExtensions:n}=ku(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=Mu(A(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function dd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(dd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function fd(e){return e instanceof E}function pd(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function md(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!pd(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var hd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function gd(e,t){let n=t.mapping.mapResult(e.position);return{position:new hd(n.pos),mapResult:n}}function Line truncated
`);return`:::${l}${i}\n\n${o}\n\n:::`}}}function Zf(e){let t={};return Kf(e,`shortcode`).forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),t}function Qf(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function $f(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Zf,serializeAttributes:a=Qf,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=u(e.attrs||{}),i=a(n),o=i?` ${i}`:``;return s?`[${l}${o}]`:`[${l}${o}]${t}[/${l}]`}}}function ep(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function tp(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function np(e,t,n){let r=t.split(`
`),i=n.isParagraphContinuation??(e=>tp(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(`
`);return`:::${l}${i}\n\n${o}\n\n:::`}}}function Xf(e){let t={};return Gf(e,`shortcode`).forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),t}function Zf(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function Qf(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Xf,serializeAttributes:a=Zf,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=u(e.attrs||{}),i=a(n),o=i?` ${i}`:``;return s?`[${l}${o}]`:`[${l}${o}]${t}[/${l}]`}}}function $f(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function ep(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function tp(e,t,n){let r=t.split(`
`),i=n.isParagraphContinuation??(e=>ep(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(`
`),nestedContent:r.slice(a).join(`
`)}}function rp(e,t,n){let r=e.split(`
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],u=e.match(t.itemPattern);if(!u){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;o<r.length;){var c;let e=r[o];if(e.trim()===``){var l;let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=np(p,g.map(e=>ep(e,f+s)).join(`
`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var ip=4;function ap(e){let t=0;for(let n of e)t=n===` `?t+ip-t%ip:t+1;return t}function op(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(`
`)}}function np(e,t,n){let r=e.split(`
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],u=e.match(t.itemPattern);if(!u){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;o<r.length;){var c;let e=r[o];if(e.trim()===``){var l;let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=tp(p,g.map(e=>$f(e,f+s)).join(`
`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var rp=4;function ip(e){let t=0;for(let n of e)t=n===` `?t+rp-t%rp:t+1;return t}function ap(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(`
`).map((e,n)=>n===0?e:t.indent(e)).join(`
`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=ap(a);return(ap(n)>=r?n:` `.repeat(r))+e},o=r.split(`
`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=ip(a);return(ip(n)>=r?n:` `.repeat(r))+e},o=r.split(`
`).map(e=>n(e||``)).join(`
`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function sp(e,t){let n={...e};return Nf(e)&&Nf(t)&&Object.keys(t).forEach(r=>{Nf(t[r])&&Nf(e[r])?n[r]=sp(e[r],t[r]):n[r]=t[r]}),n}function cp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var lp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},up=(e,t)=>{if(pl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function dp(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:zn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function fp(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=dp({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Yc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Xc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Vc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function pp(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function mp(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=ad(l)+i;for(let e of a){let a=up(u,e.find);if(a&&pp(l,a,i)&&fp({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function hp(e){let{editor:t,rules:n}=e,r=new D({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let c=e.getMeta(`applyInputRules`);return c&&setTimeout(()=>{let{text:e}=c;e=typeof e==`string`?e:xu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;mp({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return mp({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&mp({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?mp({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var gp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Nu(k(this,`addOptions`,{name:this.name}))}}get storage(){return{...Nu(k(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>sp(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},_p=class e extends gp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},vp=class{constructor(e){this.find=e.find,this.handler=e.handler}},yp=(e,t,n)=>{if(pl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function bp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Xc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||yp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var xp=null,Sp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Cp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c;try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let s=e.tr,l=Yc({state:e,transaction:s});if(bp({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:c})&&s.steps.length){try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s}};return t.on(`destroy`,()=>{xp===t&&(xp=null)}),n.map(e=>new D({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(xp=t)},i=()=>{xp&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,c=t,!a){let e=xp;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let c=t[0],u=c.getMeta(`uiEvent`)===`paste`&&!i,d=c.getMeta(`uiEvent`)===`drop`&&!a,f=c.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:xu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=Sp(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(jf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var wp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Gu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Uu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=k(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:rd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Wu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:rd(t.name,this.schema)},r=[],i=k(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&k(t,`exitable`,n)&&(a.ArrowRight=()=>_p.handleExit({editor:e,mark:t})),i){Line truncated
`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function op(e,t){let n={...e};return Mf(e)&&Mf(t)&&Object.keys(t).forEach(r=>{Mf(t[r])&&Mf(e[r])?n[r]=op(e[r],t[r]):n[r]=t[r]}),n}function sp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var cp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},lp=(e,t)=>{if(fl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function up(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:zn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function dp(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=up({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Jc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Yc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Bc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function fp(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function pp(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=id(l)+i;for(let e of a){let a=lp(u,e.find);if(a&&fp(l,a,i)&&dp({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function mp(e){let{editor:t,rules:n}=e,r=new D({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let c=e.getMeta(`applyInputRules`);return c&&setTimeout(()=>{let{text:e}=c;e=typeof e==`string`?e:bu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;pp({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return pp({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&pp({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?pp({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var hp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Mu(A(this,`addOptions`,{name:this.name}))}}get storage(){return{...Mu(A(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>op(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},gp=class e extends hp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},_p=class{constructor(e){this.find=e.find,this.handler=e.handler}},vp=(e,t,n)=>{if(fl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function yp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Yc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||vp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var bp=null,xp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Sp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c;try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let s=e.tr,l=Jc({state:e,transaction:s});if(yp({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:c})&&s.steps.length){try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s}};return t.on(`destroy`,()=>{bp===t&&(bp=null)}),n.map(e=>new D({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(bp=t)},i=()=>{bp&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,c=t,!a){let e=bp;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let c=t[0],u=c.getMeta(`uiEvent`)===`paste`&&!i,d=c.getMeta(`uiEvent`)===`drop`&&!a,f=c.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:bu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=xp(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(Af(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var Cp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Wu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Hu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=A(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:nd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Uu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:nd(t.name,this.schema)},r=[],i=A(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&A(t,`exitable`,n)&&(a.ArrowRight=()=>gp.handleExit({editor:e,mark:t})),i){Line truncated
`)}}})]}}),Dp=Tp.create({name:`commands`,addCommands(){return{...tf}}}),Op=Tp.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=hu(e.before,[e,...t]);$u(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof xt){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),kp=Tp.create({name:`drop`,addProseMirrorPlugins(){return[new D({key:new Un(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Ap=Tp.create({name:`editable`,addProseMirrorPlugins(){return[new D({key:new Un(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),jp=new Un(`focusEvents`),Mp=Tp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new D({key:jp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Np=Tp.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:w.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tl()||Jl()?i:r},addProseMirrorPlugins(){return[new D({key:new Un(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=w.atStart(t.doc).from,l=w.atEnd(t.doc).to;if(a||o!==c||s!==l||!fd(n.doc))return;let u=n.tr,d=Yc({state:n,transaction:u}),{commands:f}=new Xc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),Pp=Tp.create({name:`paste`,addProseMirrorPlugins(){return[new D({key:new Un(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Fp=Tp.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new D({key:new Un(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Ip=Tp.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Au(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new D({key:new Un(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Lp=!1;function Rp(e){if(Lp)return;Lp=!0;let t;try{let n=Et.fromLine truncated
`)}}})]}}),Ep=wp.create({name:`commands`,addCommands(){return{...ef}}}),Dp=wp.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=mu(e.before,[e,...t]);Qu(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof xt){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),Op=wp.create({name:`drop`,addProseMirrorPlugins(){return[new D({key:new O(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),kp=wp.create({name:`editable`,addProseMirrorPlugins(){return[new D({key:new O(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Ap=new O(`focusEvents`),jp=wp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new D({key:Ap,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Mp=wp.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:w.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return wl()||ql()?i:r},addProseMirrorPlugins(){return[new D({key:new O(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=w.atStart(t.doc).from,l=w.atEnd(t.doc).to;if(a||o!==c||s!==l||!dd(n.doc))return;let u=n.tr,d=Jc({state:n,transaction:u}),{commands:f}=new Yc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),Np=wp.create({name:`paste`,addProseMirrorPlugins(){return[new D({key:new O(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Pp=wp.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new D({key:new O(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Fp=wp.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=ku(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new D({key:new O(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Ip=!1;function Lp(e){if(Ip)return;Ip=!0;let t;try{let n=Et.fromJSON(e,Line truncated
position: relative;
}
@@ -100,21 +100,21 @@ img.ProseMirror-separator {
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`,Vp=class extends of{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:_d,createMappablePosition:vd},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=Cl(t,this.options.autofocus);this.editorState=zn.create({doc:t,schema:this.schema,selection:e||void 0})}Rp(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Xc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Xc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Of(Bp,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return sf&&!this.hasWarnedStaleDecorationRead&&af(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Mu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
}`,Bp=class extends af{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:gd,createMappablePosition:_d},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=Sl(t,this.options.autofocus);this.editorState=zn.create({doc:t,schema:this.schema,selection:e||void 0})}Lp(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Yc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Yc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Df(zp,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return of&&!this.hasWarnedStaleDecorationRead&&rf(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=ju(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
`,textSerializers:n={}}=e||{};return qu(this.state.doc,{blockSeparator:t,textSerializers:{...Ju(this.schema),...n}})}get isEmpty(){return fd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new zp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Hp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(ed(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Up(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Wp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=Nu(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Gp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=Nu(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Ft(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&qt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Kp=e=>`touches`in e,qp=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resLine truncated
`)}},Ng=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Bh]?Vh(e,t):dm(e)?cm(e,e=>lm(t,t=>Ng(e,t))):Hh(e)?Jh(e,(e,n)=>Ng(e,t[n])):!1,Pg=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Ng(t,n)}equals(e){return this.constructor===e.constructor&&tg(this.shape,e.shape)}[jg](){return!0}[Bh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ch()}get nullable(){return p_(this,O_)}get optional(){return new Gg(this)}cast(e){return M_(e,this),e}expect(e){return M_(e,this),e}},Fg=class extends Pg{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Ig=(e,t=null)=>new Fg(e,t);Ig(Fg);var Lg=class extends Pg{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Rg=e=>new Lg(e);Ig(Lg);var zg=class extends Pg{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Bg=(...e)=>new zg(e),Vg=Ig(zg),Hg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Ug=e=>{if(C_.check(e))return[Hg(e)];if(Vg.check(e))return e.shape.map(e=>e+``);if(S_.check(e))return[`[+-]?\\d+.?\\d*`];if(w_.check(e))return[`.*`];if(m_.check(e))return e.shape.map(Ug).flat(1);lh()};Ig(class extends Pg{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Ug).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Wg=Symbol(`optional`),Gg=class extends Pg{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Wg](){return!0}},Kg=Ig(Gg),qg=class extends Pg{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new qg,Ig(qg);var Jg=class e extends Pg{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Jh(this.shape,(n,r)=>{let i=this._isPartial&&!Yh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Yg=e=>new Jg(e),Xg=Ig(Jg),Zg=Rg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Qg=class extends Pg{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Jh(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},$g=(e,t)=>new Qg(e,t),e_=Ig(Qg),t_=class extends Pg{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Jh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},n_=(...e)=>new t_(e);Ig(t_);var r_=class extends Pg{constructor(e){super(),this.shape=e.length===1?e[0]:new f_(e)}check(e,t){let n=dm(e)&&cm(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},i_=(...e)=>new r_(e),a_=Ig(r_),o_=Rg(e=>dm(e)),s_=class extends Pg{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},c_=(e,t=null)=>new s_(e,t);Ig(s_);var l_=c_(Pg),u_=Ig(class extends Pg{constructor(e){super(),this.len=e.length-1,this.args=n_(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),d_=Rg(e=>typeof e==`function`);Ig(class extends Pg{constructor(e){super(),this.shape=e}check(e,t){let n=cm(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var f_=class extends Pg{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=lm(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},p_=(...e)=>e.findIndex(e=>m_.check(e))>=0?p_(...e.map(e=>j_(e)).map(e=>m_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new f_(e),m_=Ig(f_),h_=()=>!0,g_=Rg(h_),__=Ig(Lg,e=>e.shape===h_),v_=Rg(e=>typeof e==`bigint`),y_=Rg(e=>e===v_),b_=Rg(e=>typeof e==`symbol`);Rg(e=>e===b_);var x_=Rg(e=>typeof e==`number`),S_=Rg(e=>e===x_),C_=Rg(e=>typeof e==`string`),w_=Rg(e=>e===C_),T_=Rg(e=>typeof e==`boolean`),E_=Rg(e=>e===T_),D_=Bg(void 0);Ig(zg,e=>e.shape.length===1&&e.shape[0]===void 0),Bg(void 0);var O_=Bg(null),k_=Ig(zg,e=>e.shape.length===1&&e.shape[0]===null);Ig(Uint8Array),Ig(Fg,e=>e.shape===Uint8Array);var A_=p_(x_,C_,O_,D_,v_,T_,b_);(()=>{let e=i_(g_),t=$g(C_,g_),n=p_(x_,C_,O_,T_,e,t);return e.shape=n,t.shape.values=n,n})();var j_=e=>{if(l_.check(e))return e;ifLine truncated
`;n.right=new Qx(N(o,wy(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Fx(i)),n.right.integrate(e,0),n.forward()}Kb(e,t,n,s)},Qb=(e,t,n,r,i)=>{let a=t,o=$p();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Ox){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Ox:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&qb(i,n);break}}}t=t.right}return s},$b=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Ox){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},ex=e=>{let t=0;return By(e.doc,n=>{let r=e._start,i=e._start,a=$p(),o=em(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Ox:qb(o,i.content);break;default:t+=Qb(n,r,i,a,o),a=em(o),r=i}i=i.right}}),t},tx=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&My(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Ox&&e.constructor!==vx&&t.add(e.parent)})}By(n,n=>{dv(e,e.deleteSet,e=>{if(e instanceof vx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Ox?t.add(r):$b(n,e)});for(let e of t)ex(e)})},nx=(e,t,n)=>{let r=n,i=em(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Gx:case Ex:case Fx:n<t.right.length&&ky(e,N(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Qb(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&mb(o._searchMarker,t.index,-r+n),t},rx=class extends ib{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];By(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},qh(o)||(e.attributes=Uh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Gx:case Ex:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Fx:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Ox:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Hb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Hb(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Hb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Hb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),qb(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},ix=class e extends gb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ob(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new rx(this,e,t);hb(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ob();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Fx&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):By(this.doc,n=>{let r=new Ub(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Xb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&nx(n,r,a.delete):Zb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??ob();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(by(s,e)||t!==void 0&&by(s,t))switch(s.content.constructor){case Fx:{let r=i.get(`ychange`);e!==void 0&&!by(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!by(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Gx:case Ex:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Ox:by(s,e)&&(c(),qb(i,s.content))}s=s.right}c()};return e||t?By(a,n=>{e&&xy(n,e),t&&xy(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):By(r,r=>{let i=Gb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Xb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):By(r,r=>{let i=Gb(r,this,e,!n);Xb(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):By(n,n=>{nx(n,Gb(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):By(r,r=>{let i=Gb(r,this,e,!1);i.right!==null&&Zb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):By(this.doc,t=>{kb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):By(this.doc,n=>{Ab(n,this,e,t)})}getAttribute(e){return jb(this,e)}getAttributes(){return Mb(this)}_write(e){e.writeTypeRef(Bx)}},ax=e=>new ix,ox=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ob()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===lx||t.constructor===sx)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},sx=class e extends gb{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof gb?e.clone():e)),t}get length(){return this.doc??ob(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ox(this,e)}querySelector(e){e=e.toUpperCase();let t=new ox(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),sm(new ox(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){hb(this,e,new dx(this,t,e))}toString(){return xb(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),bb(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):By(this.doc,n=>{Eb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)By(this.doc,n=>{let r=e&&e instanceof gb?e._item:e;wb(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw sh(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):By(this.doc,n=>{Ob(n,this,e,t)})}toArray(){return vb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Cb(this,e)}slice(e=0,t=this.length){return _b(this,e,t)}forEach(e){bb(this,e)}_write(e){e.writeTypeRef(Hx)}},cx=e=>new sx,lx=class e extends sx{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Gh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>eLine truncated
`,textSerializers:n={}}=e||{};return Ku(this.state.doc,{blockSeparator:t,textSerializers:{...qu(this.schema),...n}})}get isEmpty(){return dd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Rp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Vp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Mu(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if($u(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Hp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Mu(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Up(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=Mu(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Wp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=Mu(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Ft(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&qt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Gp=e=>`touches`in e,Kp=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resLine truncated
`)}},Mg=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[zh]?Bh(e,t):um(e)?sm(e,e=>cm(t,t=>Mg(e,t))):Vh(e)?qh(e,(e,n)=>Mg(e,t[n])):!1,Ng=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Mg(t,n)}equals(e){return this.constructor===e.constructor&&eg(this.shape,e.shape)}[Ag](){return!0}[zh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){sh()}get nullable(){return f_(this,D_)}get optional(){return new Wg(this)}cast(e){return j_(e,this),e}expect(e){return j_(e,this),e}},Pg=class extends Ng{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Fg=(e,t=null)=>new Pg(e,t);Fg(Pg);var Ig=class extends Ng{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Lg=e=>new Ig(e);Fg(Ig);var Rg=class extends Ng{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},zg=(...e)=>new Rg(e),Bg=Fg(Rg),Vg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Hg=e=>{if(S_.check(e))return[Vg(e)];if(Bg.check(e))return e.shape.map(e=>e+``);if(x_.check(e))return[`[+-]?\\d+.?\\d*`];if(C_.check(e))return[`.*`];if(p_.check(e))return e.shape.map(Hg).flat(1);ch()};Fg(class extends Ng{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Hg).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Ug=Symbol(`optional`),Wg=class extends Ng{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Ug](){return!0}},Gg=Fg(Wg),Kg=class extends Ng{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Kg,Fg(Kg);var qg=class e extends Ng{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):qh(this.shape,(n,r)=>{let i=this._isPartial&&!Jh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Jg=e=>new qg(e),Yg=Fg(qg),Xg=Lg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Zg=class extends Ng{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&qh(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Qg=(e,t)=>new Zg(e,t),$g=Fg(Zg),e_=class extends Ng{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&qh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},t_=(...e)=>new e_(e);Fg(e_);var n_=class extends Ng{constructor(e){super(),this.shape=e.length===1?e[0]:new d_(e)}check(e,t){let n=um(e)&&sm(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},r_=(...e)=>new n_(e),i_=Fg(n_),a_=Lg(e=>um(e)),o_=class extends Ng{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},s_=(e,t=null)=>new o_(e,t);Fg(o_);var c_=s_(Ng),l_=Fg(class extends Ng{constructor(e){super(),this.len=e.length-1,this.args=t_(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),u_=Lg(e=>typeof e==`function`);Fg(class extends Ng{constructor(e){super(),this.shape=e}check(e,t){let n=sm(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var d_=class extends Ng{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=cm(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},f_=(...e)=>e.findIndex(e=>p_.check(e))>=0?f_(...e.map(e=>A_(e)).map(e=>p_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new d_(e),p_=Fg(d_),m_=()=>!0,h_=Lg(m_),g_=Fg(Ig,e=>e.shape===m_),__=Lg(e=>typeof e==`bigint`),v_=Lg(e=>e===__),y_=Lg(e=>typeof e==`symbol`);Lg(e=>e===y_);var b_=Lg(e=>typeof e==`number`),x_=Lg(e=>e===b_),S_=Lg(e=>typeof e==`string`),C_=Lg(e=>e===S_),w_=Lg(e=>typeof e==`boolean`),T_=Lg(e=>e===w_),E_=zg(void 0);Fg(Rg,e=>e.shape.length===1&&e.shape[0]===void 0),zg(void 0);var D_=zg(null),O_=Fg(Rg,e=>e.shape.length===1&&e.shape[0]===null);Fg(Uint8Array),Fg(Pg,e=>e.shape===Uint8Array);var k_=f_(b_,S_,D_,E_,__,w_,y_);(()=>{let e=r_(h_),t=Qg(S_,h_),n=f_(b_,S_,D_,w_,e,t);return e.shape=n,t.shape.values=n,n})();var A_=e=>{if(c_.check(e))return e;ifLine truncated
`;n.right=new Zx(P(o,Cy(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Px(i)),n.right.integrate(e,0),n.forward()}Gb(e,t,n,s)},Zb=(e,t,n,r,i)=>{let a=t,o=Qp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Dx){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Dx:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Kb(i,n);break}}}t=t.right}return s},Qb=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Dx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},$b=e=>{let t=0;return zy(e.doc,n=>{let r=e._start,i=e._start,a=Qp(),o=$p(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Dx:Kb(o,i.content);break;default:t+=Zb(n,r,i,a,o),a=$p(o),r=i}i=i.right}}),t},ex=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&jy(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Dx&&e.constructor!==_x&&t.add(e.parent)})}zy(n,n=>{uv(e,e.deleteSet,e=>{if(e instanceof _x||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Dx?t.add(r):Qb(n,e)});for(let e of t)$b(e)})},tx=(e,t,n)=>{let r=n,i=$p(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Wx:case Tx:case Px:n<t.right.length&&Oy(e,P(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Zb(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&pb(o._searchMarker,t.index,-r+n),t},nx=class extends rb{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];zy(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Kh(o)||(e.attributes=Hh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Wx:case Tx:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Px:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Dx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Vb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Vb(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Vb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Vb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Kb(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},rx=class e extends hb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ab(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new nx(this,e,t);mb(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ab();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Px&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):zy(this.doc,n=>{let r=new Hb(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Yb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&tx(n,r,a.delete):Xb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??ab();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(yy(s,e)||t!==void 0&&yy(s,t))switch(s.content.constructor){case Px:{let r=i.get(`ychange`);e!==void 0&&!yy(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!yy(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Wx:case Tx:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Dx:yy(s,e)&&(c(),Kb(i,s.content))}s=s.right}c()};return e||t?zy(a,n=>{e&&by(n,e),t&&by(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):zy(r,r=>{let i=Wb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Yb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):zy(r,r=>{let i=Wb(r,this,e,!n);Yb(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):zy(n,n=>{tx(n,Wb(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):zy(r,r=>{let i=Wb(r,this,e,!1);i.right!==null&&Xb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):zy(this.doc,t=>{Ob(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):zy(this.doc,n=>{kb(n,this,e,t)})}getAttribute(e){return Ab(this,e)}getAttributes(){return jb(this)}_write(e){e.writeTypeRef(zx)}},ix=e=>new rx,ax=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ab()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===cx||t.constructor===ox)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},ox=class e extends hb{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof hb?e.clone():e)),t}get length(){return this.doc??ab(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ax(this,e)}querySelector(e){e=e.toUpperCase();let t=new ax(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),om(new ax(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){mb(this,e,new ux(this,t,e))}toString(){return bb(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),yb(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):zy(this.doc,n=>{Tb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)zy(this.doc,n=>{let r=e&&e instanceof hb?e._item:e;Cb(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw oh(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):zy(this.doc,n=>{Db(n,this,e,t)})}toArray(){return _b(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Sb(this,e)}slice(e=0,t=this.length){return gb(this,e,t)}forEach(e){yb(this,e)}_write(e){e.writeTypeRef(Vx)}},sx=e=>new ox,cx=class e extends ox{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Wh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>eLine truncated
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
`))}),n.join(`
>
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>AT(this.editor,this.type)}},addInputRules(){return[Gp({find:jT,type:this.type})]}}),NT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,PT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,FT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,IT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,LT=_p.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return kT(`strong`,{...A(this.options.HTMLAttributes,e),children:kT(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Hp({find:NT,type:this.type}),Hp({find:FT,type:this.type})]},addPasteRules(){return[Yp({find:PT,type:this.type}),Yp({find:IT,type:this.type})]}}),RT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},zT=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function BT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var VT=_p.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(BT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hp({find:RT,type:this.type})]},addPasteRules(){return[Yp({find:zT,type:this.type})]}}),HT=4,UT=/^```([a-z]+)?[\s\n]$/,WT=/^~~~([a-z]+)?[\s\n]$/,GT=Jp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:HT,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,A(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??HT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>kT(this.editor,this.type)}},addInputRules(){return[Wp({find:AT,type:this.type})]}}),MT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,NT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,PT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,FT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,IT=gp.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return OT(`strong`,{...j(this.options.HTMLAttributes,e),children:OT(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Vp({find:MT,type:this.type}),Vp({find:PT,type:this.type})]},addPasteRules(){return[Jp({find:NT,type:this.type}),Jp({find:FT,type:this.type})]}}),LT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},RT=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function zT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var BT=gp.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,j(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(zT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Vp({find:LT,type:this.type})]},addPasteRules(){return[Jp({find:RT,type:this.type})]}}),VT=4,HT=/^```([a-z]+)?[\s\n]$/,UT=/^~~~([a-z]+)?[\s\n]$/,WT=qp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:VT,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,j(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??VT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
`,`
`).split(`
`).map(e=>o+e).join(`
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??HT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??VT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
`,`
`).split(`
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(T.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
@@ -123,51 +123,53 @@ img.ProseMirror-separator {
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(w.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Wp({find:UT,type:this.type,getAttributes:e=>({language:e[1]})}),Wp({find:WT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new D({key:new Un(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(T.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),KT=GT,qT=Jp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(w.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Up({find:HT,type:this.type,getAttributes:e=>({language:e[1]})}),Up({find:UT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new D({key:new O(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(T.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),GT=WT,KT=qp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``}),JT=Jp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,A(this.options.HTMLAttributes,e)]},renderText(){return`
`):``}),qT=qp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,j(this.options.HTMLAttributes,e)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),YT=Jp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Wp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),XT=Jp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,A(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Df(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(T.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(E.create(t.doc,n.pos)):t.setSelection(T.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(T.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Up({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ZT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,QT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,$T=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,eE=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,tE=_p.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hp({find:ZT,type:this.type}),Hp({find:$T,type:this.type})]},addPasteRules(){return[Yp({find:QT,type:this.type}),Yp({find:eE,type:this.type})]}}),nE=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,AD=`️`,jD=`‍`,MD=``,ND=null,PD=null;function FD(e=[]){let t={};_E.groups=t;let n=new _E;ND??=zD(nE),PD??=zD(rE),P(n,`'`,XE),P(n,`{`,NE),P(n,`}`,PE),P(n,`[`,FE),P(n,`]`,IE),P(n,`(`,LE),P(n,`)`,RE),P(n,`<`,zE),P(n,`>`,BE),P(n,`(`,VE),P(n,`)`,HE),P(n,`「`,UE),P(n,`」`,WE),P(n,`『`,GE),P(n,`』`,KE),P(n,`<`,qE),P(n,`>`,JE),P(n,`&`,YE),P(n,`*`,ZE),P(n,`@`,QE),P(n,"`",eD),P(n,`^`,tD),P(n,`:`,nD),P(n,`,`,rD),P(n,`$`,iD),P(n,`.`,aD),P(n,`=`,oD),P(n,`!`,sD),P(n,`-`,cD),P(n,`%`,lD),P(n,`|`,uD),P(n,`+`,dD),P(n,`#`,fD),P(n,`?`,pD),P(n,`"`,mD),P(n,`/`,_D),P(n,`;`,gD),P(n,`~`,vD),P(n,`_`,yD),P(n,`\\`,$E),P(n,`・`,hD);let r=yE(n,ED,AE,{[iE]:!0});yE(r,ED,r);let i=yE(r,CD,CE,{[sE]:!0}),a=yE(r,wD,wE,{[cE]:!0}),o=yE(n,CD,xE,{[aE]:!0});yE(o,ED,i),yE(o,CD,o),yE(i,ED,i),yE(i,CD,i);let s=yE(n,wD,SE,{[oE]:!0});yE(s,CD),yE(s,ED,a),yE(s,wD,s),yE(a,ED,a),yE(a,CD),yE(a,wD,a);let c=P(n,kD,ME,{[pE]:!0}),l=P(n,OD,jE,{[pE]:!0}),u=yE(n,DD,jE,{[pE]:!0});P(n,MD,u),P(l,kD,c),P(l,MD,u),yE(l,DD,u),P(u,OD),P(u,kD),yE(u,DD,u),P(u,MD,u);let d=yE(n,TD,bD,{[uE]:!0});P(d,`#`),yE(d,TD,d),P(d,AD,d);let f=P(d,jD);P(f,`#`),yE(f,TD,d);let p=[[CD,o],[ED,i]],m=[[CD,null],[wD,s],[ED,a]];for(let e=0;e<ND.length;e++)RD(n,ND[e],EE,xE,p);for(let e=0;e<PD.length;e++)RD(n,PD[e],DE,SE,m);hE(EE,{tld:!0,ascii:!0},t),hE(DE,{utld:!0,alpha:!0},t),RD(n,`file`,OE,xE,p),RD(n,`mailto`,OE,xE,p),RD(n,`http`,kE,xE,p),RD(n,`https`,kE,xE,p),RD(n,`ftp`,kE,xE,p),RD(n,`ftps`,kE,xE,p),hE(OE,{scheme:!0,ascii:!0},t),hE(kE,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[dE]:!0}:{[fE]:!0};r.indexOf(`-`)>=0?i[lE]=!0:CD.test(r)?ED.test(r)?i[sE]=!0:i[aE]=!0:i[iE]=!0,bE(n,r,r,i)}return bE(n,`localhost`,TE,{ascii:!0}),n.jd=new _E(xD),{start:n,tokens:Object.assign({groups:t},SD)}}function ID(e,t){let n=LD(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function LD(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function RD(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new _E(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new _E(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function zD(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var BD={defaultProtocol:`http`,events:null,format:HD,formatHref:HD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function VD(e,t=null){let n=Object.assign({},BD);e&&(n=Object.assign(n,e instanceof VD?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i,this.ignoreClasses=n.ignoreClasses.slice()}VD.prototype={o:BD,ignoreTags:[],ignoreClasses:[],isIgnoredClass(e){if(typeof e!=`string`||this.ignoreClasses.length===0)return!1;let t=e.split(/\s+/);for(let e=0;e<t.length;e++)if(this.ignoreClasses.indexOf(t[e])>=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:BD[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function HD(e){return e}function UD(e,t){this.t=`token`,this.v=e,this.tk=t}UD.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=BD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);reLine truncated
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),JT=qp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,j(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Up({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),YT=qp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,j(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Ef(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return fd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(T.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(E.create(t.doc,n.pos)):t.setSelection(T.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(T.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Hp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),XT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ZT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,QT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$T=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,eE=gp.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,j(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Vp({find:XT,type:this.type}),Vp({find:QT,type:this.type})]},addPasteRules(){return[Jp({find:ZT,type:this.type}),Jp({find:$T,type:this.type})]}}),tE=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,kD=`️`,AD=`‍`,jD=``,MD=null,ND=null;function PD(e=[]){let t={};gE.groups=t;let n=new gE;MD??=RD(tE),ND??=RD(nE),F(n,`'`,YE),F(n,`{`,ME),F(n,`}`,NE),F(n,`[`,PE),F(n,`]`,FE),F(n,`(`,IE),F(n,`)`,LE),F(n,`<`,RE),F(n,`>`,zE),F(n,`(`,BE),F(n,`)`,VE),F(n,`「`,HE),F(n,`」`,UE),F(n,`『`,WE),F(n,`』`,GE),F(n,`<`,KE),F(n,`>`,qE),F(n,`&`,JE),F(n,`*`,XE),F(n,`@`,ZE),F(n,"`",$E),F(n,`^`,eD),F(n,`:`,tD),F(n,`,`,nD),F(n,`$`,rD),F(n,`.`,iD),F(n,`=`,aD),F(n,`!`,oD),F(n,`-`,sD),F(n,`%`,cD),F(n,`|`,lD),F(n,`+`,uD),F(n,`#`,dD),F(n,`?`,fD),F(n,`"`,pD),F(n,`/`,gD),F(n,`;`,hD),F(n,`~`,_D),F(n,`_`,vD),F(n,`\\`,QE),F(n,`・`,mD);let r=vE(n,TD,kE,{[rE]:!0});vE(r,TD,r);let i=vE(r,SD,SE,{[oE]:!0}),a=vE(r,CD,CE,{[sE]:!0}),o=vE(n,SD,bE,{[iE]:!0});vE(o,TD,i),vE(o,SD,o),vE(i,TD,i),vE(i,SD,i);let s=vE(n,CD,xE,{[aE]:!0});vE(s,SD),vE(s,TD,a),vE(s,CD,s),vE(a,TD,a),vE(a,SD),vE(a,CD,a);let c=F(n,OD,jE,{[fE]:!0}),l=F(n,DD,AE,{[fE]:!0}),u=vE(n,ED,AE,{[fE]:!0});F(n,jD,u),F(l,OD,c),F(l,jD,u),vE(l,ED,u),F(u,DD),F(u,OD),vE(u,ED,u),F(u,jD,u);let d=vE(n,wD,yD,{[lE]:!0});F(d,`#`),vE(d,wD,d),F(d,kD,d);let f=F(d,AD);F(f,`#`),vE(f,wD,d);let p=[[SD,o],[TD,i]],m=[[SD,null],[CD,s],[TD,a]];for(let e=0;e<MD.length;e++)LD(n,MD[e],TE,bE,p);for(let e=0;e<ND.length;e++)LD(n,ND[e],EE,xE,m);mE(TE,{tld:!0,ascii:!0},t),mE(EE,{utld:!0,alpha:!0},t),LD(n,`file`,DE,bE,p),LD(n,`mailto`,DE,bE,p),LD(n,`http`,OE,bE,p),LD(n,`https`,OE,bE,p),LD(n,`ftp`,OE,bE,p),LD(n,`ftps`,OE,bE,p),mE(DE,{scheme:!0,ascii:!0},t),mE(OE,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[uE]:!0}:{[dE]:!0};r.indexOf(`-`)>=0?i[cE]=!0:SD.test(r)?TD.test(r)?i[oE]=!0:i[iE]=!0:i[rE]=!0,yE(n,r,r,i)}return yE(n,`localhost`,wE,{ascii:!0}),n.jd=new gE(bD),{start:n,tokens:Object.assign({groups:t},xD)}}function FD(e,t){let n=ID(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function ID(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function LD(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new gE(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new gE(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function RD(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var zD={defaultProtocol:`http`,events:null,format:VD,formatHref:VD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function BD(e,t=null){let n=Object.assign({},zD);e&&(n=Object.assign(n,e instanceof BD?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i,this.ignoreClasses=n.ignoreClasses.slice()}BD.prototype={o:zD,ignoreTags:[],ignoreClasses:[],isIgnoredClass(e){if(typeof e!=`string`||this.ignoreClasses.length===0)return!1;let t=e.split(/\s+/);for(let e=0;e<t.length;e++)if(this.ignoreClasses.indexOf(t[e])>=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:zD[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function VD(e){return e}function HD(e,t){this.t=`token`,this.v=e,this.tk=t}HD.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=zD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);reLine truncated
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);tO.customSchemes.push([e,t])}function iO(){tO.scanner=FD(tO.customSchemes);for(let e=0;e<tO.tokenQueue.length;e++)tO.tokenQueue[e][1]({scanner:tO.scanner});tO.parser=XD(tO.scanner.tokens);for(let e=0;e<tO.pluginQueue.length;e++)tO.pluginQueue[e][1]({scanner:tO.scanner,parser:tO.parser});return tO.initialized=!0,tO}function aO(e){return tO.initialized||iO(),ZD(tO.parser.start,e,ID(tO.scanner.start,e))}aO.scan=ID;function oO(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new VD(n),i=aO(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var sO=`[\0- \xA0 ᠎ -\u2029  ]`,cO=new RegExp(sO),lO=RegExp(`${sO}$`),uO=RegExp(`${sO}+$`),dO=new RegExp(sO,`g`);function fO(e,t,n){let r=e.doc.resolve(t.to);if(!r.nodeBefore?.isText)return;let i=e.doc.textBetween(t.from,t.to,``,``).match(uO)?.[0];if(!i)return;let a=t.to-i.length,o=ed(a,t.to,e.doc).filter(e=>e.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function pO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function mO(e){return new D({key:new Un(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=hu(n.doc,[...t]);if(!t.some(Jc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Et)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);i<a&&t.push({from:i,to:a})}),t.sort((e,t)=>t.to-e.to),t.forEach(t=>fO(o,t,e.type))}if($u(s).forEach(({newRange:t})=>{let n=_u(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!lO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(cO).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=aO(n).map(t=>t.toObject(e.defaultProtocol));if(!pO(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{ed(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function hO(e){return new D({key:new Un(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Xu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var gO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,_O=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function vO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function yO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&vO(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function bO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||vO(e,t.index??0)||yO(e,t.index??0)?!1:!!r.trim()&&n(i)}function xO(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function SO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function CO(e){return{href:e.data?.href,title:e.data?.title??null}}function wO(e){let t=Hp({find:t=>{let n=gO.exec(t);return!n||!bO(t,n,e.isAllowedHref)?null:xO(n)},type:e.type,getAttributes:CO});return new lp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function TO(e){let t=Yp({find:t=>{let n=[];for(let r of t.matchAll(_O))bO(t,r,e.isAllowedHref)&&n.push(xO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>SO(t,e)));return[...n,...r]},type:e.type,getAttributes:CO});return new vp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function EO(e){return new D({key:new Un(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=oOLine truncated
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kO,this.editor.getAttributes(AO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Gp({find:jO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Gp({find:jO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(AO),editor:this.editor})),[e]}}),NO=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},PO=(e,t,n,r)=>{let i=NO(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:c,insertPos:l,items:u}=i,d=e.tr;d.delete(c,c+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,s.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},FO=(e,t,n)=>PO(e.state,e.view.dispatch,t,n),IO=(e,t)=>Tp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>FO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),LO=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],RO=`abcdefghijklmnopqrstuvwxyz`,zO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function BO(e){let t=e,n=``;for(let[e,r]of LO)for(;t>=e;)n+=r,t-=e;return n}function VO(e){return BO(e).toUpperCase()}function HO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of LO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function UO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=HO(e);return t<=0?!1:(e===e.toLowerCase()?BO(t):VO(t))===e}function WO(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function GO(e){if(e<=26)return RO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?RO[n]:RO[t]+RO[n]}function KO(e){if(e&&!/^\d+$/.test(e)){if(UO(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function qO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=KO(e);if(t===`i`||t===`I`)return HO(e);if(t===`a`||t===`A`){let t=WO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function JO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return GO(t);case`A`:return GO(t).toUpperCase();case`i`:return BO(t);case`I`:return VO(t);default:return String(t)}}function YO(e){if(e.length===0)return!1;let t=KO(e[0])??`numeric`,n=qO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=JO(t,n+r);if(e[r]!==i)return!1}return!0}function XO(e){return{type:KO(e),start:qO(e)}}function ZO(e){let{type:t,start:n}=XO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function QO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${GO(r)}${n}`;case`A`:return`${GO(r).toUpperCase()}${n}`;case`i`:return`${BO(r)}${n}`;case`I`:return`${VO(r)}${n}`;default:return`${r}${n}`}}function $O(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function ek(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var tk=`&nbsp;`,nk=1,rk=e=>(e?.level??nk)>nk;function ik(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function ak(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var ok=Jp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(ik(e))return{type:`listItem`,content:[{type:`paragraph`,content:ak(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]}Line truncated
3. "-" cannot repeat`);eO.customSchemes.push([e,t])}function rO(){eO.scanner=PD(eO.customSchemes);for(let e=0;e<eO.tokenQueue.length;e++)eO.tokenQueue[e][1]({scanner:eO.scanner});eO.parser=YD(eO.scanner.tokens);for(let e=0;e<eO.pluginQueue.length;e++)eO.pluginQueue[e][1]({scanner:eO.scanner,parser:eO.parser});return eO.initialized=!0,eO}function iO(e){return eO.initialized||rO(),XD(eO.parser.start,e,FD(eO.scanner.start,e))}iO.scan=FD;function aO(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new BD(n),i=iO(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var oO=`[\0- \xA0 ᠎ -\u2029  ]`,sO=new RegExp(oO),cO=RegExp(`${oO}$`),lO=RegExp(`${oO}+$`),uO=new RegExp(oO,`g`);function dO(e,t,n){let r=e.doc.resolve(t.to);if(!r.nodeBefore?.isText)return;let i=e.doc.textBetween(t.from,t.to,``,``).match(lO)?.[0];if(!i)return;let a=t.to-i.length,o=$u(a,t.to,e.doc).filter(e=>e.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function fO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function pO(e){return new D({key:new O(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=mu(n.doc,[...t]);if(!t.some(qc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Et)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);i<a&&t.push({from:i,to:a})}),t.sort((e,t)=>t.to-e.to),t.forEach(t=>dO(o,t,e.type))}if(Qu(s).forEach(({newRange:t})=>{let n=gu(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!cO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(sO).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=iO(n).map(t=>t.toObject(e.defaultProtocol));if(!fO(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{$u(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function mO(e){return new D({key:new O(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Yu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var hO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,gO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function _O(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function vO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&_O(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function yO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||_O(e,t.index??0)||vO(e,t.index??0)?!1:!!r.trim()&&n(i)}function bO(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function xO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function SO(e){return{href:e.data?.href,title:e.data?.title??null}}function CO(e){let t=Vp({find:t=>{let n=hO.exec(t);return!n||!yO(t,n,e.isAllowedHref)?null:bO(n)},type:e.type,getAttributes:SO});return new cp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function wO(e){let t=Jp({find:t=>{let n=[];for(let r of t.matchAll(gO))yO(t,r,e.isAllowedHref)&&n.push(bO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>xO(t,e)));return[...n,...r]},type:e.type,getAttributes:SO});return new _p({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function TO(e){return new D({key:new O(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=aO(c,Line truncated
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(OO,this.editor.getAttributes(kO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Wp({find:AO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Wp({find:AO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kO),editor:this.editor})),[e]}}),MO=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},NO=(e,t,n,r)=>{let i=MO(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:c,insertPos:l,items:u}=i,d=e.tr;d.delete(c,c+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,s.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},PO=(e,t,n)=>NO(e.state,e.view.dispatch,t,n),FO=(e,t)=>wp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>PO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),IO=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],LO=`abcdefghijklmnopqrstuvwxyz`,RO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function zO(e){let t=e,n=``;for(let[e,r]of IO)for(;t>=e;)n+=r,t-=e;return n}function BO(e){return zO(e).toUpperCase()}function VO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of IO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function HO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=VO(e);return t<=0?!1:(e===e.toLowerCase()?zO(t):BO(t))===e}function UO(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function WO(e){if(e<=26)return LO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?LO[n]:LO[t]+LO[n]}function GO(e){if(e&&!/^\d+$/.test(e)){if(HO(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function KO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=GO(e);if(t===`i`||t===`I`)return VO(e);if(t===`a`||t===`A`){let t=UO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function qO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return WO(t);case`A`:return WO(t).toUpperCase();case`i`:return zO(t);case`I`:return BO(t);default:return String(t)}}function JO(e){if(e.length===0)return!1;let t=GO(e[0])??`numeric`,n=KO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=qO(t,n+r);if(e[r]!==i)return!1}return!0}function YO(e){return{type:GO(e),start:KO(e)}}function XO(e){let{type:t,start:n}=YO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function ZO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${WO(r)}${n}`;case`A`:return`${WO(r).toUpperCase()}${n}`;case`i`:return`${zO(r)}${n}`;case`I`:return`${BO(r)}${n}`;default:return`${r}${n}`}}function QO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function $O(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var ek=`&nbsp;`,tk=1,nk=e=>(e?.level??tk)>tk;function rk(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function ik(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var ak=qp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,j(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(rk(e))return{type:`listItem`,content:[{type:`paragraph`,content:ik(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]}Line truncated
`).trim(),contentLines:m,raw:g.join(`
`)}),r=h,n=h}return[t,r]}var wk=RegExp(`^(${zO})([.)])\\s+(.+)$`);function Tk(e){let t=e.split(`
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(wk);if(!t)return null;n.push({marker:t[1],content:t[3]})}return YO(n.map(e=>e.marker))?{type:`orderedList`,attrs:ZO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Ek(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=Sk(a.contentLines),c=o.join(`
`)}),r=h,n=h}return[t,r]}var Ck=RegExp(`^(${RO})([.)])\\s+(.+)$`);function wk(e){let t=e.split(`
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(Ck);if(!t)return null;n.push({marker:t[1],content:t[3]})}return JO(n.map(e=>e.marker))?{type:`orderedList`,attrs:XO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Tk(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=xk(a.contentLines),c=o.join(`
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=Ek(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function Dk(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var Ok=64;function kk(e,t){let n=[],r=0;for(;n.length<t;){let t=e.indexOf(`
`,r);if(t===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,t)),r=t+1}return n}function Ak(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!gk.test(n))return[[],0,[]];let r=Ok,i=kk(e,r),a=Ck(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=kk(e,r),a=Ck(i);return[a[0],a[1],i]}var jk=`listItem`,Mk=`textStyle`,Nk=/^(\d+)\.\s$/;function Pk(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Fk=Jp.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Pk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Pk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=A(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?Dk(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=Ak(e);if(r.length===0)return;let o=Ek(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jk,this.editor.getAttributes(Mk)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new D({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=Tk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Gp({find:Nk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:Nk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Mk)}),joinPredicate:e,editor:this.editor})),[t]}}),Ik=/^\s*(\[([( |x])?\])\s$/,Lk=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Rk=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},zk=Jp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>op(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[IO(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Lk;let l=e=>{let t=Rk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Gp({find:Ik,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Bk=Jp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`uLine truncated
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(MO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ok.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(hk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Fk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(zk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Bk.configure(this.options.taskList)),e}});var Vk=`&nbsp;`,Hk=`\xA0`,Uk=Jp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Vk||n[0].text===Vk||n[0].raw===Hk||n[0].text===Hk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Vk||r[0].text===Hk)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?Vk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Wk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Gk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Kk=_p.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hp({find:Wk,type:this.type})]},addPasteRules(){return[Yp({find:Gk,type:this.type})]}}),qk=Jp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Jk=_p.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`<u>${t.renderChildren(e)}</u>`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(`<u>`)},tokenize(e,t,n){if(!/^<u>/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleLine truncated
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=Tk(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function Ek(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var Dk=64;function Ok(e,t){let n=[],r=0;for(;n.length<t;){let t=e.indexOf(`
`,r);if(t===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,t)),r=t+1}return n}function kk(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!hk.test(n))return[[],0,[]];let r=Dk,i=Ok(e,r),a=Sk(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=Ok(e,r),a=Sk(i);return[a[0],a[1],i]}var Ak=`listItem`,jk=`textStyle`,Mk=/^(\d+)\.\s$/;function Nk(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Pk=qp.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Nk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Nk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=j(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?Ek(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=kk(e);if(r.length===0)return;let o=Tk(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ak,this.editor.getAttributes(jk)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new D({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=wk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Wp({find:Mk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wp({find:Mk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(jk)}),joinPredicate:e,editor:this.editor})),[t]}}),Fk=/^\s*(\[([( |x])?\])\s$/,Ik=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Lk=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},Rk=qp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,j(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>ap(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[FO(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Ik;let l=e=>{let t=Lk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Iu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Wp({find:Fk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),zk=qp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`uLine truncated
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=np(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=np(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});wp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(jO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ak.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(mk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Pk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Rk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(zk.configure(this.options.taskList)),e}});var Bk=`&nbsp;`,Vk=`\xA0`,Hk=qp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,j(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Bk||n[0].text===Bk||n[0].raw===Vk||n[0].text===Vk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Bk||r[0].text===Vk)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?Bk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Uk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Wk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Gk=gp.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,j(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Vp({find:Uk,type:this.type})]},addPasteRules(){return[Jp({find:Wk,type:this.type})]}}),Kk=qp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),qk=gp.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,j(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`<u>${t.renderChildren(e)}</u>`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(`<u>`)},tokenize(e,t,n){if(!/^<u>/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleLine truncated
`).length:0;c!==o&&(o=c,i.textContent=Array.from({length:c},(e,t)=>t+1).join(`
`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),Rj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function zj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Bj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-left":[`M14 6l-6 6 6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8Line truncated
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:hP(e)).join(`
`)}function _P(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function vP(e,t){return t?e.split(t).join(`
`):e}function yP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function bP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>vP(t.renderChildren(e),n.cellLineSeparator)).join(`
`):vP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=yP(_P(r.replace(/[ \t]*\r?\n[ \t]*/g,`<br>`))),o=e.type===`tableHeader`,s=JN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;t<i;t+=1){let n=(e[t]?.text||``).length;n>a[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;t<i;t+=1)!l[t]&&e[t]?.align&&(l[t]=e[t].align)});let u=`
`,d=Array.from({length:i}).map((e,t)=>c&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var xP=new Un(`preserveCellSelectionOnContextMenu`);function SP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function CP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t<r+e.nodeSize&&(n=!0)}),n}function wP(){return new D({key:xP,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!fP(n)||n.ranges.length<2)return!1;let r=SP(e,t);return r==null||!CP(n,r)?!1:(t.preventDefault(),!0)}}}})}var TP=Jp.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:sP,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=cP(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,A(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=KN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=KN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>bP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),Lj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function Rj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var zj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-left":[`M14 6l-6 6 6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8Line truncated
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:mP(e)).join(`
`)}function gP(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function _P(e,t){return t?e.split(t).join(`
`):e}function vP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function yP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>_P(t.renderChildren(e),n.cellLineSeparator)).join(`
`):_P(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=vP(gP(r.replace(/[ \t]*\r?\n[ \t]*/g,`<br>`))),o=e.type===`tableHeader`,s=qN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;t<i;t+=1){let n=(e[t]?.text||``).length;n>a[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;t<i;t+=1)!l[t]&&e[t]?.align&&(l[t]=e[t].align)});let u=`
`,d=Array.from({length:i}).map((e,t)=>c&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var bP=new O(`preserveCellSelectionOnContextMenu`);function xP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function SP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t<r+e.nodeSize&&(n=!0)}),n}function CP(){return new D({key:bP,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!dP(n)||n.ranges.length<2)return!1;let r=xP(e,t);return r==null||!SP(n,r)?!1:(t.preventDefault(),!0)}}}})}var wP=qp.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:oP,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=sP(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,j(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=GN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=GN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>yP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(`
`),i=r>=0?e.slice(0,r):e,a=i.split(`
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=gP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=hP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
`).length,u=e.split(`
`).slice(0,l).join(`
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=dP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>BM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>VM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return UM(e,t&&(e=>{n&&mP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>KM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>qM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return YM(e,t&&(e=>{n&&mP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>cN(e,t),mergeCells:()=>({state:e,dispatch:t})=>QM(e,t),splitCell:()=>({state:e,dispatch:t})=>$M(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>iN(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>iN(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>aN(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>QM(e,t)?!0:$M(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>tN(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>sN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>sN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&IM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=OM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:pP,"Mod-Backspace":pP,Delete:pP,"Mod-Delete":pP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[jN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],GN({allowTableNodeSelection:this.options.allowTableNodeSelection}),wP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),EP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(TP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(nP.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(rP.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(iP.configure(this.options.tableRow)),e}}),DP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function OP(){return[Bk.configure({HTMLAttributes:{class:`dw-tasks`}}),zk.configure({nested:!0})]}function kP(){return[EP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var AP=DP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),jP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),MP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,NP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,PP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`)){if(!o){a.push(``);continue}let e=``;for(let s of o.split(/(\s+)/)){let o=e+s;if(!e||oI(o,t,r,i)<=n)e=o;else for(a.push(e.trimEnd()),e=s.trimStart();e&&oI(e,t,r,i)>n;){let o=e.length-1;for(;o>1&&oI(e.slice(0,o),t,r,i)>n;)o--;a.push(e.slice(0,o)),e=e.slice(o)}}a.push(e)}return a}function cI(e,t){let n=t===0?18:15,r=t===0?600:400,i=sI(e||` `,n,260,nI,r),a=Math.max(...i.map(e=>oI(e,n,nI,r)),t===0?60:40);return{w:Math.ceil(a)+(t===0?32:24),h:i.length*Math.round(n*1.4)+(t===0?20:14)}}var lI=56,uI=14;function dI(e){let t=Object.entries(e).filter(([,t])=>!t.parent||!e[t.parent]);return t.sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)),t[0]?.[0]??null}function fI(e,t){return Object.entries(e).filter(([e,n])=>n.parent===t&&e!==t).sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)).map(([e])=>e)}function pI(e,t,n){let r=dI(e),i=new Map,a=[];if(!r)return{root:``,boxes:i,edges:a,bounds:{x:0,y:0,w:0,h:0}};let o=new Map,s=new Set,c=(t,r)=>{if(!(s.has(t)||r>50)){s.add(t),o.set(t,n(e[t].text,r));for(let n of fI(e,t))c(n,r+1)}};c(r,0);let l=t=>fI(e,t).filter(e=>o.has(e)),u=new Map,d=e=>{let t=u.get(e);if(t!==void 0)return t;let n=l(e),r=n.reduce((e,t)=>e+d(t),0)+uI*Math.max(0,n.length-1),i=Math.max(o.get(e).h,r);return u.set(e,i),i},f=(e,t,n,r,a,s)=>{let c=o.get(e),u=a===1?t:t-c.w;i.set(e,{id:e,x:u,y:n-c.h/2,w:c.w,h:c.h,depth:r,dir:a,parent:s}),p(e,l(e),a===1?u+c.w+lI:u-lI,n,r+1,a)},p=(e,t,n,r,i,a)=>{let o=r-(t.reduce((e,t)=>e+d(t),0)+uI*Math.max(0,t.length-1))/2;for(let r of t){let t=d(r);f(r,n,o+t/2,i,a,e),o+=t+uI}},m=o.get(r);i.set(r,{id:r,x:0,y:0,w:m.w,h:m.h,depth:0,dir:1,parent:``});let h=m.h/2,g=l(r);if(t===`right`)p(r,g,m.w+lI,h,1,1);else if(t===`left`)p(r,g,-56,h,1,-1);else{let e=Math.ceil(g.length/2);p(r,g.slice(0,e),m.w+lI,h,1,1),p(r,g.slice(e),-56,h,1,-1)}for(let e of i.values()){if(!e.parent)continue;let t=i.get(e.parent),n=e.dir===1?[t.x+t.w,t.y+t.h/2]:[t.x,t.y+t.h/2],r=e.dir===1?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2];a.push({from:n,to:r,child:e.id})}let _=1/0,v=1/0,y=-1/0,b=-1/0;for(let e of i.values())_=Math.min(_,e.x),v=Math.min(v,e.y),y=Math.max(y,e.x+e.w),b=Math.max(b,e.y+e.h);return{root:r,boxes:i,edges:a,bounds:{x:_,y:v,w:y-_,h:b-v}}}function mI(e,t,n,r){let i=e.boxes.get(n);if(!i)return null;if(r===`ArrowUp`||r===`ArrowDown`){let a=i.parent?fI(t,i.parent).filter(t=>e.boxes.get(t)?.dir===i.dir):[];return a[a.indexOf(n)+(r===`ArrowUp`?-1:1)]??null}let a=r===`ArrowRight`?1:-1;return i.parent?a===i.dir?fI(t,n)[0]??null:i.parent:fI(t,n).find(t=>e.boxes.get(t)?.dir===a)??null}function hI(e,t){let n=(e[0]+t[0])/2;return`M${e[0]} ${e[1]} C${n} ${e[1]} ${n} ${t[1]} ${t[0]} ${t[1]}`}function gI(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function _I(e){return[-e[0],-e[1]]}function vI(e,t){return[e[0]+t[0],e[1]+t[1]]}function yI(e,t){return[e[0]-t[0],e[1]-t[1]]}function bI(e,t){return[e[0]*t,e[1]*t]}function xI(e,t){return[e[0]/t,e[1]/t]}function SI(e){return[e[1],-e[0]]}function CI(e,t){return e[0]*t[0]+e[1]*t[1]}function wI(e,t){return e[0]===t[0]&&e[1]===t[1]}function TI(e){return Math.hypot(e[0],e[1])}function EI(e){return e[0]*e[0]+e[1]*e[1]}function DI(e,t){return EI(yI(e,t))}function OI(e){return xI(e,TI(e))}function kI(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function AI(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function jI(e,t,n){return vI(e,bI(yI(t,e),n))}function MI(e,t,n){return vI(e,bI(t,n))}var{min:NI,PI}=Math,FI=.275,II=PI+1e-4;function LI(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=NI(1,t.distance/n);r=NI(1,e+(NI(1,1-i)-e)*(i*FI))}return(e+r)/2},e[0].pressure),x=gI(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,ee=e[0].point,te=ee,ne=ee,re=te,ie=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=NI(1,l/n),t=NI(1,1-e);r=NI(1,b+(t-b)*(e*FI))}x=gI(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,ae=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,ae));let oe=(t<e.length-1?e[t+1]:e[t]).vector,se=t<e.length-1?CI(c,oe):1,ce=CI(c,C)<0&&!ie,le=se!==null&&se<0;if(ce||le){let e=bI(SI(C),x);for(let t=0;t<=1;t+=.07692307692307693)ne=AI(yI(s,e),s,II*t),v.push(ne),re=AI(vI(s,e),s,II*-t),y.push(re);ee=ne,te=re,le&&(ie=!0);continue}if(ie=!1,t===e.length-1){let e=bI(SI(c),x);v.push(yI(s,e)),y.push(vI(s,e));continue}let ue=bI(SI(jI(oe,c,se)),x);ne=yI(s,ue),(t<=1||DI(ee,ne)>_)&&(v.push(ne),ee=ne),re=vI(s,ue),(t<=1||DI(te,re)>_)&&(y.push(re),te=re),b=r,C=c}let ae=e[0].point.slice(0,2),oe=e.length>1?e[e.length-1].point.slice(0,2):vI(e[0].point,[1,1]),se=[],ce=[];if(e.leLine truncated
`:n(e)).join(``),r=(e,i)=>{for(let a of e)if(a.type===`heading`){let e=Number(a.attrs?.level)||1;t.push({text:n(a),size:[0,26,21,18,16,16,16][e]??16,weight:650})}else if(a.type===`paragraph`)t.push({text:i+n(a),size:15,weight:400});else if(a.type===`listItem`||a.type===`taskItem`){let e=a.type===`taskItem`?a.attrs?.checked?`☑ `:`☐ `:`• `,[i,...o]=a.content??[];i&&t.push({text:e+n(i),size:15,weight:400}),r(o,` `)}else a.type===`codeBlock`?t.push({text:n(a),size:13,weight:400}):a.content?.length&&r(a.content,i)};return r(e,``),t}function xR(e,t,n,r,i,a,o=400,s=`start`){let c=Math.round(r*1.35);return n.map((n,l)=>`<text x="${e}" y="${t+r+l*c}" font-size="${r}" font-family="${WL(a)}" font-weight="${o}" fill="${i}" text-anchor="${s}" xml:space="preserve">${WL(n)}</text>`).join(``)}async function SR(e){if(e.startsWith(`data:`))return e;try{let t=await fetch(e,{credentials:`include`});if(!t.ok)return null;let n=await t.blob();return await new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:null),t.onerror=()=>e(null),t.readAsDataURL(n)})}catch{return null}}async function CR(e){let t=yR(e.root),n=e.elements.filter(e=>e.type!==`group`),r=QP(ZP(n.map(t=>e.boxOf(t)))??{x:0,y:0,w:400,h:300},32),i=t(`ink`,`line`),a=[];for(let r of n){let n=e.boxOf(r),o=r.rotate?` rotate(${r.rotate} ${n.w/2} ${n.h/2})`:``,s=e=>`<g transform="translate(${n.x} ${n.y})${o}">${e}</g>`;switch(r.type){case`shape`:{let e=sI(r.text,r.fontSize,Math.max(20,n.w-16)),i=Math.round(r.fontSize*1.35),o=n.h/2-e.length*i/2-r.fontSize*.25;a.push(s(QL(r,t)+(r.text?xR(n.w/2,o,e,r.fontSize,t(r.textColor,`line`),nI,400,`middle`):``)));break}case`text`:{let e=aI(r.font),i=r.w?sI(r.text,r.fontSize,r.w,e):r.text.split(`
`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(xR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push(eR(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(`<rect x="${n.mid[0]-e/2}" y="${n.mid[1]-12}" width="${e}" height="24" rx="4" fill="${t(`paper`,`line`)}"/>`+xR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,nI,400,`middle`))}break}case`brush`:a.push(s(nR(r,t)));break;case`frame`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)===`none`?`none`:t(r.background,`fill`)}" stroke="${t(`gray`,`line`)}" stroke-width="1.5"/>`+xR(4,-24,[r.title],13,t(`gray`,`line`),nI,600)));break;case`note`:{let o=e.noteBody(r),c=o?bR(rR(o)):[],l=18,u=`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`;if(r.page&&e.pageTitle){let t=sI(e.pageTitle,26,n.w-48,nI,650);u+=xR(24,l-4,t,26,i,nI,650),l+=t.length*35+8}for(let e of c){let t=sI(e.text,e.size,n.w-48,nI,e.weight);if(u+=xR(24,l,t,e.size,i,nI,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await SR(e.resolve(r.src));a.push(s(i?`<image href="${WL(i)}" width="${n.w}" height="${n.h}" preserveAspectRatio="xMidYMid meet"/>`:`<rect width="${n.w}" height="${n.h}" fill="${t(`ink`,`fill`)}"/>`));break}case`embed`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(`paper`,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`+xR(16,16,sI(r.url,13,n.w-32),13,t(`blue`,`line`),nI)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>`<path d="${hI(e.from,e.to)}" fill="none" stroke="${o}" stroke-width="2"/>`).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="${e.depth===0?10:8}" fill="${l}" stroke="${o}" stroke-width="${e.depth===0?0:1.5}"/>`;let d=sI(r.nodes[e.id]?.text||` `,n,260,nI,a);c+=xR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,nI,a,`middle`)}a.push(`<g transform="translate(${r.x} ${r.y})">${c}</g>`);break}}}return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(r.w)}" height="${Math.ceil(r.h)}" viewBox="${r.x} ${r.y} ${r.w} ${r.h}"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${t(`paper`,`line`)}"/>${a.join(``)}</svg>`,box:r}}async function wR(e,t){let{svg:n,box:r}=await CR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var TR=.1,ER=4,DR=`http://www.w3.org/2000/svg`,OR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),kR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??xF,this.editable=t.editable,this.styles=WF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new dR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(DR,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new vR(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.roLine truncated
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=uP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>zM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>BM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=_u(e.selection.$from,e=>e.type.name===`table`);return HM(e,t&&(e=>{n&&pP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>GM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>KM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=_u(e.selection.$from,e=>e.type.name===`table`);return JM(e,t&&(e=>{n&&pP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>sN(e,t),mergeCells:()=>({state:e,dispatch:t})=>ZM(e,t),splitCell:()=>({state:e,dispatch:t})=>QM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>rN(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>rN(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>iN(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>ZM(e,t)?!0:QM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>eN(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>oN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>oN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&FM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=DM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:fP,"Mod-Backspace":fP,Delete:fP,"Mod-Delete":fP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[AN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],WN({allowTableNodeSelection:this.options.allowTableNodeSelection}),CP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=j(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Mu(A(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),TP=wp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(wP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(tP.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(nP.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(rP.configure(this.options.tableRow)),e}}),EP=wp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Nf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function DP(){return[zk.configure({HTMLAttributes:{class:`dw-tasks`}}),Rk.configure({nested:!0})]}function OP(){return[TP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var kP=EP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),AP=wp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),jP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,MP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,NP=gp.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||kf(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Nf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`)){if(!o){a.push(``);continue}let e=``;for(let s of o.split(/(\s+)/)){let o=e+s;if(!e||aI(o,t,r,i)<=n)e=o;else for(a.push(e.trimEnd()),e=s.trimStart();e&&aI(e,t,r,i)>n;){let o=e.length-1;for(;o>1&&aI(e.slice(0,o),t,r,i)>n;)o--;a.push(e.slice(0,o)),e=e.slice(o)}}a.push(e)}return a}function sI(e,t){let n=t===0?18:15,r=t===0?600:400,i=oI(e||` `,n,260,tI,r),a=Math.max(...i.map(e=>aI(e,n,tI,r)),t===0?60:40);return{w:Math.ceil(a)+(t===0?32:24),h:i.length*Math.round(n*1.4)+(t===0?20:14)}}var cI=56,lI=14;function uI(e){let t=Object.entries(e).filter(([,t])=>!t.parent||!e[t.parent]);return t.sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)),t[0]?.[0]??null}function dI(e,t){return Object.entries(e).filter(([e,n])=>n.parent===t&&e!==t).sort((e,t)=>e[1].pos-t[1].pos||(e[0]<t[0]?-1:1)).map(([e])=>e)}function fI(e,t,n){let r=uI(e),i=new Map,a=[];if(!r)return{root:``,boxes:i,edges:a,bounds:{x:0,y:0,w:0,h:0}};let o=new Map,s=new Set,c=(t,r)=>{if(!(s.has(t)||r>50)){s.add(t),o.set(t,n(e[t].text,r));for(let n of dI(e,t))c(n,r+1)}};c(r,0);let l=t=>dI(e,t).filter(e=>o.has(e)),u=new Map,d=e=>{let t=u.get(e);if(t!==void 0)return t;let n=l(e),r=n.reduce((e,t)=>e+d(t),0)+lI*Math.max(0,n.length-1),i=Math.max(o.get(e).h,r);return u.set(e,i),i},f=(e,t,n,r,a,s)=>{let c=o.get(e),u=a===1?t:t-c.w;i.set(e,{id:e,x:u,y:n-c.h/2,w:c.w,h:c.h,depth:r,dir:a,parent:s}),p(e,l(e),a===1?u+c.w+cI:u-cI,n,r+1,a)},p=(e,t,n,r,i,a)=>{let o=r-(t.reduce((e,t)=>e+d(t),0)+lI*Math.max(0,t.length-1))/2;for(let r of t){let t=d(r);f(r,n,o+t/2,i,a,e),o+=t+lI}},m=o.get(r);i.set(r,{id:r,x:0,y:0,w:m.w,h:m.h,depth:0,dir:1,parent:``});let h=m.h/2,g=l(r);if(t===`right`)p(r,g,m.w+cI,h,1,1);else if(t===`left`)p(r,g,-56,h,1,-1);else{let e=Math.ceil(g.length/2);p(r,g.slice(0,e),m.w+cI,h,1,1),p(r,g.slice(e),-56,h,1,-1)}for(let e of i.values()){if(!e.parent)continue;let t=i.get(e.parent),n=e.dir===1?[t.x+t.w,t.y+t.h/2]:[t.x,t.y+t.h/2],r=e.dir===1?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2];a.push({from:n,to:r,child:e.id})}let _=1/0,v=1/0,y=-1/0,b=-1/0;for(let e of i.values())_=Math.min(_,e.x),v=Math.min(v,e.y),y=Math.max(y,e.x+e.w),b=Math.max(b,e.y+e.h);return{root:r,boxes:i,edges:a,bounds:{x:_,y:v,w:y-_,h:b-v}}}function pI(e,t,n,r){let i=e.boxes.get(n);if(!i)return null;if(r===`ArrowUp`||r===`ArrowDown`){let a=i.parent?dI(t,i.parent).filter(t=>e.boxes.get(t)?.dir===i.dir):[];return a[a.indexOf(n)+(r===`ArrowUp`?-1:1)]??null}let a=r===`ArrowRight`?1:-1;return i.parent?a===i.dir?dI(t,n)[0]??null:i.parent:dI(t,n).find(t=>e.boxes.get(t)?.dir===a)??null}function mI(e,t){let n=(e[0]+t[0])/2;return`M${e[0]} ${e[1]} C${n} ${e[1]} ${n} ${t[1]} ${t[0]} ${t[1]}`}function hI(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function gI(e){return[-e[0],-e[1]]}function _I(e,t){return[e[0]+t[0],e[1]+t[1]]}function vI(e,t){return[e[0]-t[0],e[1]-t[1]]}function yI(e,t){return[e[0]*t,e[1]*t]}function bI(e,t){return[e[0]/t,e[1]/t]}function xI(e){return[e[1],-e[0]]}function SI(e,t){return e[0]*t[0]+e[1]*t[1]}function CI(e,t){return e[0]===t[0]&&e[1]===t[1]}function wI(e){return Math.hypot(e[0],e[1])}function TI(e){return e[0]*e[0]+e[1]*e[1]}function EI(e,t){return TI(vI(e,t))}function DI(e){return bI(e,wI(e))}function OI(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function kI(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function AI(e,t,n){return _I(e,yI(vI(t,e),n))}function jI(e,t,n){return _I(e,yI(t,n))}var{min:MI,PI:NI}=Math,PI=.275,FI=NI+1e-4;function II(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=MI(1,t.distance/n);r=MI(1,e+(MI(1,1-i)-e)*(i*PI))}return(e+r)/2},e[0].pressure),x=hI(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,ee=e[0].point,te=ee,ne=ee,re=te,ie=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=MI(1,l/n),t=MI(1,1-e);r=MI(1,b+(t-b)*(e*PI))}x=hI(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,ae=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,ae));let oe=(t<e.length-1?e[t+1]:e[t]).vector,se=t<e.length-1?SI(c,oe):1,ce=SI(c,C)<0&&!ie,le=se!==null&&se<0;if(ce||le){let e=yI(xI(C),x);for(let t=0;t<=1;t+=.07692307692307693)ne=kI(vI(s,e),s,FI*t),v.push(ne),re=kI(_I(s,e),s,FI*-t),y.push(re);ee=ne,te=re,le&&(ie=!0);continue}if(ie=!1,t===e.length-1){let e=yI(xI(c),x);v.push(vI(s,e)),y.push(_I(s,e));continue}let ue=yI(xI(AI(oe,c,se)),x);ne=vI(s,ue),(t<=1||EI(ee,ne)>_)&&(v.push(ne),ee=ne),re=_I(s,ue),(t<=1||EI(te,re)>_)&&(y.push(re),te=re),b=r,C=c}let ae=e[0].point.slice(0,2),oe=e.length>1?e[e.length-1].point.slice(0,2):_I(e[0].point,[1,1]),se=[],ce=[];if(eLine truncated
`:n(e)).join(``),r=(e,i)=>{for(let a of e)if(a.type===`heading`){let e=Number(a.attrs?.level)||1;t.push({text:n(a),size:[0,26,21,18,16,16,16][e]??16,weight:650})}else if(a.type===`paragraph`)t.push({text:i+n(a),size:15,weight:400});else if(a.type===`listItem`||a.type===`taskItem`){let e=a.type===`taskItem`?a.attrs?.checked?`☑ `:`☐ `:`• `,[i,...o]=a.content??[];i&&t.push({text:e+n(i),size:15,weight:400}),r(o,` `)}else a.type===`codeBlock`?t.push({text:n(a),size:13,weight:400}):a.content?.length&&r(a.content,i)};return r(e,``),t}function bR(e,t,n,r,i,a,o=400,s=`start`){let c=Math.round(r*1.35);return n.map((n,l)=>`<text x="${e}" y="${t+r+l*c}" font-size="${r}" font-family="${UL(a)}" font-weight="${o}" fill="${i}" text-anchor="${s}" xml:space="preserve">${UL(n)}</text>`).join(``)}async function xR(e){if(e.startsWith(`data:`))return e;try{let t=await fetch(e,{credentials:`include`});if(!t.ok)return null;let n=await t.blob();return await new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:null),t.onerror=()=>e(null),t.readAsDataURL(n)})}catch{return null}}async function SR(e){let t=vR(e.root),n=e.elements.filter(e=>e.type!==`group`),r=ZP(XP(n.map(t=>e.boxOf(t)))??{x:0,y:0,w:400,h:300},32),i=t(`ink`,`line`),a=[];for(let r of n){let n=e.boxOf(r),o=r.rotate?` rotate(${r.rotate} ${n.w/2} ${n.h/2})`:``,s=e=>`<g transform="translate(${n.x} ${n.y})${o}">${e}</g>`;switch(r.type){case`shape`:{let e=oI(r.text,r.fontSize,Math.max(20,n.w-16)),i=Math.round(r.fontSize*1.35),o=n.h/2-e.length*i/2-r.fontSize*.25;a.push(s(ZL(r,t)+(r.text?bR(n.w/2,o,e,r.fontSize,t(r.textColor,`line`),tI,400,`middle`):``)));break}case`text`:{let e=iI(r.font),i=r.w?oI(r.text,r.fontSize,r.w,e):r.text.split(`
`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(bR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push($L(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(`<rect x="${n.mid[0]-e/2}" y="${n.mid[1]-12}" width="${e}" height="24" rx="4" fill="${t(`paper`,`line`)}"/>`+bR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,tI,400,`middle`))}break}case`brush`:a.push(s(tR(r,t)));break;case`frame`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)===`none`?`none`:t(r.background,`fill`)}" stroke="${t(`gray`,`line`)}" stroke-width="1.5"/>`+bR(4,-24,[r.title],13,t(`gray`,`line`),tI,600)));break;case`note`:{let o=e.noteBody(r),c=o?yR(nR(o)):[],l=18,u=`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(r.background,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`;if(r.page&&e.pageTitle){let t=oI(e.pageTitle,26,n.w-48,tI,650);u+=bR(24,l-4,t,26,i,tI,650),l+=t.length*35+8}for(let e of c){let t=oI(e.text,e.size,n.w-48,tI,e.weight);if(u+=bR(24,l,t,e.size,i,tI,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await xR(e.resolve(r.src));a.push(s(i?`<image href="${UL(i)}" width="${n.w}" height="${n.h}" preserveAspectRatio="xMidYMid meet"/>`:`<rect width="${n.w}" height="${n.h}" fill="${t(`ink`,`fill`)}"/>`));break}case`embed`:a.push(s(`<rect width="${n.w}" height="${n.h}" rx="8" fill="${t(`paper`,`fill`)}" stroke="${t(`gray`,`fill`)}"/>`+bR(16,16,oI(r.url,13,n.w-32),13,t(`blue`,`line`),tI)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>`<path d="${mI(e.from,e.to)}" fill="none" stroke="${o}" stroke-width="2"/>`).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="${e.depth===0?10:8}" fill="${l}" stroke="${o}" stroke-width="${e.depth===0?0:1.5}"/>`;let d=oI(r.nodes[e.id]?.text||` `,n,260,tI,a);c+=bR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,tI,a,`middle`)}a.push(`<g transform="translate(${r.x} ${r.y})">${c}</g>`);break}}}return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(r.w)}" height="${Math.ceil(r.h)}" viewBox="${r.x} ${r.y} ${r.w} ${r.h}"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${t(`paper`,`line`)}"/>${a.join(``)}</svg>`,box:r}}async function CR(e,t){let{svg:n,box:r}=await SR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var wR=.1,TR=4,ER=`http://www.w3.org/2000/svg`,DR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),OR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??bF,this.editable=t.editable,this.styles=UF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new uR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(ER,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new _R(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.roLine truncated
`:e[i]):r+=e[i];if(i>=e.length)throw new Uz(`Text starting at ${n+1} has no closing quote`);t.push({t:`str`,v:r,at:n}),n=i+1;continue}if(/[A-Za-z_]/.test(r)){let r=/^[A-Za-z_][A-Za-z0-9_]*/.exec(e.slice(n));t.push({t:`id`,v:r[0],at:n}),n+=r[0].length;continue}let i=e.slice(n,n+2);if([`<=`,`>=`,`==`,`!=`,`&&`,`||`].includes(i))t.push({t:`op`,v:i,at:n}),n+=2;else if(`+-*/%<>(),!`.includes(r))t.push({t:`op`,v:r,at:n}),n++;else throw new Uz(`Unexpected "${r}" at ${n+1}`)}return t.push({t:`end`,v:``,at:e.length}),t}function qz(e){if(e.length>Wz)throw new Uz(`A formula can have at most ${Wz} characters`);if(!e.trim())throw new Uz(`The formula is empty`);let t=Kz(e),n=0,r=0,i=()=>t[n],a=(...e)=>i().t===`op`&&e.includes(i().v),o=(...e)=>i().t===`id`&&e.includes(i().v.toLowerCase()),s=e=>{if(!a(e))throw new Uz(`Expected "${e}" at ${i().at+1}`);n++},c=()=>{if(++r>Gz)throw new Uz(`The formula is nested too deeply`)},l=(e,t)=>{let n=e();for(let r=t();r;r=t())n={k:`bin`,op:r,a:n,b:e()};return n},u=()=>l(d,()=>a(`||`)||o(`or`)?(n++,`or`):null),d=()=>l(f,()=>a(`&&`)||o(`and`)?(n++,`and`):null),f=()=>l(p,()=>a(`==`,`!=`)?t[n++].v:null),p=()=>l(m,()=>a(`<`,`<=`,`>`,`>=`)?t[n++].v:null),m=()=>l(h,()=>a(`+`,`-`)?t[n++].v:null),h=()=>l(g,()=>a(`*`,`/`,`%`)?t[n++].v:null),g=()=>{if(a(`-`)){n++,c();let e=g();return r--,{k:`un`,op:`-`,a:e}}if(a(`!`)||o(`not`)){n++,c();let e=g();return r--,{k:`un`,op:`not`,a:e}}return _()},_=()=>{let e=i();if(e.t===`num`)return n++,{k:`num`,v:Number(e.v)};if(e.t===`str`)return n++,{k:`str`,v:e.v};if(a(`(`)){n++,c();let e=u();return r--,s(`)`),e}if(e.t===`id`){n++;let t=e.v.toLowerCase();if(t===`true`||t===`false`)return{k:`bool`,v:t===`true`};if(!a(`(`))throw new Uz(`Unknown name "${e.v}" at ${e.at+1}; write prop("${e.v}") for a property`);n++,c();let i=[];if(!a(`)`))for(i.push(u());a(`,`);)n++,i.push(u());if(r--,s(`)`),t===`prop`){if(i.length!==1||i[0].k!==`str`)throw new Uz(`prop() takes a property name in quotes, at ${e.at+1}`);return{k:`prop`,name:i[0].v}}let o=Jz[t];if(!o)throw new Uz(`Unknown function "${e.v}" at ${e.at+1}`);if(i.length<o[0]||i.length>o[1])throw new Uz(`${e.v}() takes ${o[0]===o[1]?o[0]:`${o[0]} to ${o[1]===1/0?`any number of`:o[1]}`} arguments`);return{k:`call`,fn:t,args:i}}throw new Uz(e.t===`end`?`The formula ends too early`:`Unexpected "${e.v}" at ${e.at+1}`)},v=u();if(i().t!==`end`)throw new Uz(`Unexpected "${i().v}" at ${i().at+1}`);return v}var Jz={if:[3,3],abs:[1,1],round:[1,2],floor:[1,1],ceil:[1,1],min:[1,1/0],max:[1,1/0],length:[1,1],lower:[1,1],upper:[1,1],contains:[2,2],concat:[1,1/0],empty:[1,1],tonumber:[1,1],format:[1,1],today:[0,0],now:[0,0],dateadd:[3,3],datebetween:[3,3],year:[1,1],month:[1,1],day:[1,1]},Yz=e=>typeof e==`object`&&!!e;function Xz(e){return e===null?``:typeof e==`number`?Number.isFinite(e)?String(Math.round(e*1e10)/1e10):``:typeof e==`boolean`?e?`true`:`false`:Yz(e)?e.day:e}function Zz(e,t){if(typeof e==`number`)return e;if(e===null||e===``)return 0;if(typeof e==`boolean`)return+!!e;if(typeof e==`string`){let t=Number(e.trim().replace(`,`,`.`));if(Number.isFinite(t))return t}throw new Uz(`${t} needs a number, not "${Xz(e)}"`)}function Qz(e,t){if(Yz(e))return e.day;if(typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e))return e;throw new Uz(`${t} needs a date`)}var $z=e=>typeof e==`boolean`?e:typeof e==`number`?e!==0:Yz(e)?!0:!!e;function eB(e){return Date.UTC(+e.slice(0,4),e.slice(5,7)-1,+e.slice(8,10))}function tB(e,t,n){let r=+e.slice(0,4),i=e.slice(5,7)-1,a=+e.slice(8,10),o=Math.trunc(t),s;switch(n){case`days`:s=new Date(Date.UTC(r,i,a+o));break;case`weeks`:s=new Date(Date.UTC(r,i,a+o*7));break;case`months`:case`years`:{let e=n===`years`?o*12:o,t=new Date(Date.UTC(r,i+e+1,0)).getUTCDate();s=new Date(Date.UTC(r,i+e,Math.min(a,t)));break}default:throw new Uz(`Unknown unit "${n}"; use days, weeks, months or years`)}return s.toISOString().slice(0,10)}function nB(e,t,n){let r=Math.round((eB(e)-eB(t))/864e5);switch(n){case`days`:return r;case`weeks`:return Math.trunc(r/7);case`months`:case`years`:{let r=(+e.slice(0,4)-t.slice(0,4))*12+(+e.slice(5,7)-t.slice(5,7));return r>0&&+e.slice(8,10)<+t.slice(8,10)&&r--,r<0&&+e.slice(8,10)>+t.slice(8,10)&&r++,n===`years`?Math.trunc(r/12):r}default:throw new Uz(`Unknown unit "${n}"; use days, weeks, months or years`)}}function rB(e,t){if(Yz(e)||Yz(t))return Xz(e)===Xz(t);if(typeof e==`number`||typeof t==`number`){if(e===null||t===null)return e===t;try{return Zz(e,`==`)===Zz(t,`==`)}catch{return!1}}return(e??``)===(t??``)}function iB(e,t){return Yz(e)||Yz(t)?Xz(e).localeCompare(Xz(t)):typeof e==`string`&&typeof t==`string`?e.localeCompare(t):Zz(e,`Comparing`)-Zz(t,`Comparing`)}function aB(e,t){let n=e=>aB(e,t);switch(e.k){case`num`:return e.v;case`str`:return e.v;case`bool`:return e.v;case`prop`:return t.prop(e.name);case`un`:{let t=n(e.a);return e.op===`-`?-Zz(t,`-`):!$z(t)}case`bin`:{if(e.op===`and`)return $z(n(e.a))&&$z(n(e.b));if(e.op===`or`)return $z(n(e.a))||$z(n(e.b));let t=n(e.a),r=n(e.b);switch(e.opLine truncated
`||e===`\r`?(r.push(i),n.push(r),r=[],i=``,e===`\r`&&s[o+1]===`
`&&o++):i+=e,o++}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function xB(e,t){return e.includes(t)||/["\r\n]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function SB(e,t=`,`){return e.map(e=>e.map(e=>xB(e,t)).join(t)).join(`\r
`)}function CB(e,t,n){return SB([t.map(e=>e.name),...n.map(e=>t.map(t=>iz(e,t)))])}function wB(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>nz(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function TB(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:WR(),name:e,color:hz(n)},n.push(t)),t.id};switch(t.type){case`number`:return nz(r);case`progress`:{let e=nz(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return ez(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function EB(e,t=`,`){let n=bB(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:WR(),name:e.trim()||`${t+1}`,type:t===0?`title`:wB(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=TB(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function DB(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function OB(e,t,n,r){let i=I(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=I(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var kB=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function AB(e,t,n,r){let i=e.labels;if(!oz(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return OB(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=I(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function jB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(OB(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=az(l.type),d=I(`div`,{class:`dw-db-pop__line`},OB(n.column,kB(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:az(t.type)[0]},s(),c()}),OB(n.op,u.map(e=>({value:e,label:FR(i,e)})),i.filter,e=>{o[r]={...n,op:e},oz(e)||delete o[r].value,s(),c()}),AB(e,l,n,e=>{o[r]={...o[r],value:e},s()}),IB(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(LB(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:az(e.type)[0]}),s(),c()}))};c()}function MB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(I(`div`,{class:`dw-db-pop__line`},OB(e.column,kB(a),i.sort,t=>{o[n]={...e,column:t},s()}),OB(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),IB(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(LB(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function NB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>KR.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||NR(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(I(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?OB(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function PB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(I(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?OB(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||NR(i,e.tyLine truncated
`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(IS.getState(this.editor.state)?.undoManager)?.addToScope(iB(e))},addCommands(){let e=e=>{let t=WR(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(yB(n,t,e,(e,t)=>iV(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??mB($B(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=sV(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=QB(this.options.labels),o={id:WR(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:WR(),name:a.done,type:`checkbox`}:null;c&&s.push(c);let l=Date.now(),u={title:``,columns:s,rows:i.items.map((e,t)=>({id:WR(),cells:{[o.id]:e.text,...c&&e.checked?{[c.id]:!0}:{}},createdAt:l+t,createdBy:this.options.me?.()??null,body:e.rest.length?e.rest:void 0})),views:[GR(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(E.create(e.doc,i.from)),!0))}}},addKeyboardShortcuts(){return{"Mod-g":()=>this.editor.commands.groupAsDatabase()}},addProseMirrorPlugins(){let{doc:e,readOnlyDoc:t}=this.options,n=e&&!t?e:null,r=this.editor;return[new D({key:new Un(`databaseClipboard`),props:{transformCopied:t=>!e||!nV(t.content)?t:new p(tV(t.content,t=>{let n=iB(e).get(String(t.attrs.id));return n instanceof Bb?t.type.create({...t.attrs,data:vB(n,eV)}):t}),t.openStart,t.openEnd),transformPasted:e=>nV(e.content)?new p(tV(e.content,e=>{let t=WR();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?qR(e.attrs.data):null,a=iB(n).get(String(e.attrs.id)),o=i??(a instanceof Bb?vB(a,eV):mB($B(this.options.labels)));return yB(n,t,oV(o),(e,t)=>iV(r,e,t)),e.type.create({id:t,data:null})}),e.openStart,e.openEnd):e},appendTransaction:(e,t,i)=>{if(!n||!e.some(e=>e.docChanged&&!e.getMeta(FS))||!e.some(e=>e.steps.some(e=>nV(e.slice?.content??s.empty))))return null;let a=new Set,o=[];if(i.doc.descendants((e,t)=>{if(e.type.name!==`database`)return;let n=String(e.attrs.id);return n&&a.has(n)&&o.push({pos:t,node:e}),a.add(n),!1}),!o.length)return null;let c=i.tr;for(let{pos:e,node:t}of o){let i=iB(n).get(String(t.attrs.id)),a=WR();i instanceof Bb&&yB(n,a,oV(vB(i,eV)),(e,t)=>iV(r,e,t)),c.setNodeMarkup(e,void 0,{...t.attrs,id:a,data:null})}return c}})]},addNodeView(){let e=this.options;return({node:t,editor:n,getPos:r})=>{let i=t,a=e.labels??BR,o=e.doc,s=()=>n.isEditable&&!!o&&!e.readOnlyDoc,c=null,l=null,u=null,d=null,f=I(`div`,{class:`dw-db-node`}),p=()=>String(i.attrs.id),m=()=>{let e=o?iB(o).get(p()):void 0;return e instanceof Bb?e:null},h=()=>{let t=m();return t?pB(t):i.attrs.data?qR(i.attrs.data):mB($B(e.labels))},g=e=>{let t=o?iB(o).get(e):void 0;if(t instanceof Bb)return pB(t);let r=null;return n.state.doc.descendants(t=>!r&&(t.type.name===`database`&&t.attrs.id===e&&t.attrs.data&&(r=qR(t.attrs.data)),!0)),r},_=new Map,v=t=>{let n=e.linkedPages;if(!n)return null;let r=_.get(t);if(!r){let e=n.open(t),i=e.onChange(re);e.doc.on(`update`,re),r={provider:e,stop:()=>{i(),e.doc.off(`update`,re),e.destroy()}},_.set(t,r)}return r.provider},y=t=>!t||t===e.linkedPages?.self,b=new Set,x=e=>{if(y(e.page))return b.add(e.database),e.database===p()?h():g(e.database);let t=v(e.page);if(!t?.synced)return null;let n=iB(t.doc).get(e.database);return n instanceof Bb?pB(n):null},S=(e,t,n)=>{let r=[],i=e=>{for(let a of e.toArray())if(a instanceof lx){if(a.nodeName===`database`){let e=String(a.getAttribute(`id`)??``);e&&r.push({page:t,database:e,title:n(e)?.title??``})}else i(a)}};return i(e),r},C=t=>{if(!s()||!o||!y(t.page))return null;if(t.database===p())return c;let n=iB(o).get(t.database);return n instanceof Bb?new gB(o,n,()=>e.me?.()??null):null},ee={local:()=>{let e=[];return n.state.doc.descendants(t=>(t.type.name===`database`&&t.attrs.id&&t.attrs.id!==p()&&e.push({page:``,database:String(t.attrs.id),title:g(String(t.attrs.id))?.title??``}),!0)),e},searchPages:e.pages?t=>e.pages.search(t).then(e=>e.filter(e=>!y(e.id)).map(e=>({id:e.id,title:e.title}))):void 0,databasesOn:e.linkedPages?e=>new Promise(t=>{let n=v(e),r=()=>{t(S(n.doc.getXmlFragment(`default`),e,e=>{let t=iB(n.doc).get(e);return t instanceof Bb?pB(t):null}))};if(n.synced)return r();let i=setTimeout(()=>{a(),t([])},8e3),a=n.onChange(()=>{n.synced&&(clearTimeout(i),a(),r())})}):void 0,read:x,pointsHere:(t,n)=>n.database===p()?y(t.page)?y(n.page):!!e.linkedPages?.self&&n.page===e.linkedPages.self:!1,writable:e=>!!C(e),link:(e,t,n,r)=>{let i=C(e),a=e.back;if(!i||!a)return!1;let o=i.snapshot().rows.find(e=>e.id===n);if(!o)return!1;let s=Cz(o.cells[a]).filter(e=>e!==t);return r&&s.push(t),i.setCell(n,a,s.length?s:null),!0},addBack:(e,t,n)=>{let r=C(e);return r?(r.tx(()=>{let e=r.addColumn(`relation`,n);r.setRelation(e,{page:``,database:p(),back:t})}),!0):!1},openRecord:(t,r)=>{y(t.page)?XB(n,t.database,r):e.onNavigate?.(`/p/${encodeURIComponent(t.page)}${qB(t.database,r)}Line truncated
`);return/\s/.test(n)}):!1}function OV(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function kV(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:OV(e)}function AV({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!DV(r)}function jV({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function MV({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),xs.create(a.doc,[vs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function NV({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function PV({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function FV({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Mj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Pj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function IV(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function LV({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&IV(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=jj(c,o,()=>{Fj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function RV({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=PV({editor:e,items:n}),v=FV({placLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=jj(e.anchor,t,()=>{Fj(e.anchor,t,{placement:`bottom-start`,middleware:[Mj(6),Pj(),Nj({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),sH===d&&(sH=null),n||e.onCancel?.())}let d=()=>u();return sH=d,n.focus(),e.multiline||n.select(),d}var lH={open:`green`,started:`yellow`,draft:`gray`,merged:`purple`,done:`blue`,closed:`red`,canceled:`gray`},uH=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function dH(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of uH){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function fH(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var pH=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function mH(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;cH({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(fH(t)),onCancel:()=>e(``)})})}async function hH(e,t,n,r){let i=await mH(e,t,t.blocks.embedUrl);i&&(dH(i)?e.chain().focus().insertEmbed(i).run():await _H(e,i,n,r))}async function gH(e,t,n,r){let i=await mH(e,t,t.blocks.linkUrl);i&&await _H(e,i,n,r)}async function _H(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var vH=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=fH(String(e.attrs.url));return[`div`,A(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=fH(e),i=dH(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${pH(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.creatLine truncated
`&&o++):i+=e,o++}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function nV(e,t){return e.includes(t)||/["\r\n]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function rV(e,t=`,`){return e.map(e=>e.map(e=>nV(e,t)).join(t)).join(`\r
`)}function iV(e,t,n){return rV([t.map(e=>e.name),...n.map(e=>t.map(t=>uz(e,t)))])}function aV(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>cz(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function oV(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:qR(),name:e,color:xz(n)},n.push(t)),t.id};switch(t.type){case`number`:return cz(r);case`progress`:{let e=cz(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return oz(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function sV(e,t=`,`){let n=tV(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:qR(),name:e.trim()||`${t+1}`,type:t===0?`title`:aV(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=oV(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function cV(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function lV(e,t,n,r){let i=L(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=L(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var uV=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function dV(e,t,n,r){let i=e.labels;if(!fz(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return lV(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=L(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function fV(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(lV(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(L(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=dz(l.type),d=L(`div`,{class:`dw-db-pop__line`},lV(n.column,uV(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:dz(t.type)[0]},s(),c()}),lV(n.op,u.map(e=>({value:e,label:PR(i,e)})),i.filter,e=>{o[r]={...n,op:e},fz(e)||delete o[r].value,s(),c()}),dV(e,l,n,e=>{o[r]={...o[r],value:e},s()}),bV(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(xV(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:dz(e.type)[0]}),s(),c()}))};c()}function pV(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(L(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(L(`div`,{class:`dw-db-pop__line`},lV(e.column,uV(a),i.sort,t=>{o[n]={...e,column:t},s()}),lV(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),bV(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(xV(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function mV(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>QR.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||MR(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(L(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?lV(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):L(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function hV(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(L(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?lV(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||MR(i,e.tyLine truncated
`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(FS.getState(this.editor.state)?.undoManager)?.addToScope(zB(e))},addCommands(){let e=e=>{let t=qR(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(eV(n,t,e,(e,t)=>KV(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??YB(VV(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=YV(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=BV(this.options.labels),o={id:qR(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:qR(),name:a.done,type:`checkbox`}:null;c&&s.push(c);let l=Date.now(),u={title:``,columns:s,rows:i.items.map((e,t)=>({id:qR(),cells:{[o.id]:e.text,...c&&e.checked?{[c.id]:!0}:{}},createdAt:l+t,createdBy:this.options.me?.()??null,body:e.rest.length?e.rest:void 0})),views:[JR(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(E.create(e.doc,i.from)),!0))}}},addKeyboardShortcuts(){return{"Mod-g":()=>this.editor.commands.groupAsDatabase()}},addProseMirrorPlugins(){let{doc:e,readOnlyDoc:t}=this.options,n=e&&!t?e:null,r=this.editor;return[new D({key:new O(`databaseClipboard`),props:{transformCopied:t=>!e||!WV(t.content)?t:new p(UV(t.content,t=>{let n=zB(e).get(String(t.attrs.id));return n instanceof zb?t.type.create({...t.attrs,data:$B(n,HV)}):t}),t.openStart,t.openEnd),transformPasted:e=>WV(e.content)?new p(UV(e.content,e=>{let t=qR();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?$R(e.attrs.data):null,a=zB(n).get(String(e.attrs.id)),o=i??(a instanceof zb?$B(a,HV):YB(VV(this.options.labels)));return eV(n,t,JV(o),(e,t)=>KV(r,e,t)),e.type.create({id:t,data:null})}),e.openStart,e.openEnd):e},appendTransaction:(e,t,i)=>{if(!n||!e.some(e=>e.docChanged&&!e.getMeta(PS))||!e.some(e=>e.steps.some(e=>WV(e.slice?.content??s.empty))))return null;let a=new Set,o=[];if(i.doc.descendants((e,t)=>{if(e.type.name!==`database`)return;let n=String(e.attrs.id);return n&&a.has(n)&&o.push({pos:t,node:e}),a.add(n),!1}),!o.length)return null;let c=i.tr;for(let{pos:e,node:t}of o){let i=zB(n).get(String(t.attrs.id)),a=qR();i instanceof zb&&eV(n,a,JV($B(i,HV)),(e,t)=>KV(r,e,t)),c.setNodeMarkup(e,void 0,{...t.attrs,id:a,data:null})}return c}})]},addNodeView(){let e=this.options;return({node:t,editor:n,getPos:r})=>{let i=t,a=e.labels??BR,o=e.doc,s=()=>n.isEditable&&!!o&&!e.readOnlyDoc,c=null,l=null,u=null,d=null,f=L(`div`,{class:`dw-db-node`}),p=()=>String(i.attrs.id),m=()=>{let e=o?zB(o).get(p()):void 0;return e instanceof zb?e:null},h=()=>{let t=m();return t?JB(t):i.attrs.data?$R(i.attrs.data):YB(VV(e.labels))},g=e=>{let t=o?zB(o).get(e):void 0;if(t instanceof zb)return JB(t);let r=null;return n.state.doc.descendants(t=>!r&&(t.type.name===`database`&&t.attrs.id===e&&t.attrs.data&&(r=$R(t.attrs.data)),!0)),r},_=new Map,v=t=>{let n=e.linkedPages;if(!n)return null;let r=_.get(t);if(!r){let e=n.open(t),i=e.onChange(re);e.doc.on(`update`,re),r={provider:e,stop:()=>{i(),e.doc.off(`update`,re),e.destroy()}},_.set(t,r)}return r.provider},y=t=>!t||t===e.linkedPages?.self,b=new Set,x=e=>{if(y(e.page))return b.add(e.database),e.database===p()?h():g(e.database);let t=v(e.page);if(!t?.synced)return null;let n=zB(t.doc).get(e.database);return n instanceof zb?JB(n):null},S=(e,t,n)=>{let r=[],i=e=>{for(let a of e.toArray())if(a instanceof cx){if(a.nodeName===`database`){let e=String(a.getAttribute(`id`)??``);e&&r.push({page:t,database:e,title:n(e)?.title??``})}else i(a)}};return i(e),r},C=t=>{if(!s()||!o||!y(t.page))return null;if(t.database===p())return c;let n=zB(o).get(t.database);return n instanceof zb?new ZB(o,n,()=>e.me?.()??null):null},ee={local:()=>{let e=[];return n.state.doc.descendants(t=>(t.type.name===`database`&&t.attrs.id&&t.attrs.id!==p()&&e.push({page:``,database:String(t.attrs.id),title:g(String(t.attrs.id))?.title??``}),!0)),e},searchPages:e.pages?t=>e.pages.search(t).then(e=>e.filter(e=>!y(e.id)).map(e=>({id:e.id,title:e.title}))):void 0,databasesOn:e.linkedPages?e=>new Promise(t=>{let n=v(e),r=()=>{t(S(n.doc.getXmlFragment(`default`),e,e=>{let t=zB(n.doc).get(e);return t instanceof zb?JB(t):null}))};if(n.synced)return r();let i=setTimeout(()=>{a(),t([])},8e3),a=n.onChange(()=>{n.synced&&(clearTimeout(i),a(),r())})}):void 0,read:x,pointsHere:(t,n)=>n.database===p()?y(t.page)?y(n.page):!!e.linkedPages?.self&&n.page===e.linkedPages.self:!1,writable:e=>!!C(e),link:(e,t,n,r)=>{let i=C(e),a=e.back;if(!i||!a)return!1;let o=i.snapshot().rows.find(e=>e.id===n);if(!o)return!1;let s=Lz(o.cells[a]).filter(e=>e!==t);return r&&s.push(t),i.setCell(n,a,s.length?s:null),!0},addBack:(e,t,n)=>{let r=C(e);return r?(r.tx(()=>{let e=r.addColumn(`relation`,n);r.setRelation(e,{page:``,database:p(),back:t})}),!0):!1},openRecord:(t,r)=>{y(t.page)?RV(n,t.database,r):e.onNavigate?.(`/p/${encodeURIComponent(t.page)}${FV(t.database,r)}`Line truncated
`);return/\s/.test(n)}):!1}function gH(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function _H(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:gH(e)}function vH({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!hH(r)}function yH({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function bH({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),bs.create(a.doc,[_s.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function xH({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function SH({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function CH({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[jj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Nj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function wH(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function TH({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&wH(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Aj(c,o,()=>{Pj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function EH({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=SH({editor:e,items:n}),v=CH({placLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=Aj(e.anchor,t,()=>{Pj(e.anchor,t,{placement:`bottom-start`,middleware:[jj(6),Nj(),Mj({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),eU===d&&(eU=null),n||e.onCancel?.())}let d=()=>u();return eU=d,n.focus(),e.multiline||n.select(),d}var nU={open:`green`,started:`yellow`,draft:`gray`,merged:`purple`,done:`blue`,closed:`red`,canceled:`gray`},rU=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function iU(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of rU){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function aU(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var oU=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function sU(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;tU({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(aU(t)),onCancel:()=>e(``)})})}async function cU(e,t,n,r){let i=await sU(e,t,t.blocks.embedUrl);i&&(iU(i)?e.chain().focus().insertEmbed(i).run():await uU(e,i,n,r))}async function lU(e,t,n,r){let i=await sU(e,t,t.blocks.linkUrl);i&&await uU(e,i,n,r)}async function uU(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var dU=qp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=aU(String(e.attrs.url));return[`div`,j(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=aU(e),i=iU(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${oU(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.creatLine truncated
`:e.text??``).join(``))}var RU={bold:`strong`,italic:`em`,strike:`s`,code:`code`,underline:`u`};function zU(e,t){let n=document.createDocumentFragment();if(!e)return n.append(t),n;for(let t of e){if(t.type===`hardBreak`){n.append(document.createElement(`br`));continue}let e=document.createTextNode(t.text??``);for(let n of t.marks??[]){let t;if(n.type===`link`){let e=document.createElement(`a`);e.href=String(n.attrs?.href??``),e.rel=`noopener noreferrer`,e.target=`_blank`,t=e}else{let e=RU[n.type];if(!e)continue;t=document.createElement(e)}t.append(e),e=t}n.append(e)}return n}function BU(e){return IU(e.attrs.content)}function VU(e){let t=[];return e.descendants((e,n)=>(e.type.name===`footnote`&&t.push({pos:n,text:NU(e.attrs.text),content:BU(e)}),!0)),t}var HU=new O(`footnotes`),UU=qp.create({name:`doc`,topNode:!0,content:`paragraph`});function WU(e,t,n,r){let i=e.state.doc.nodeAt(t);if(!i||i.type.name!==`footnote`)return;let a=r?.blocks.footnoteText??`Footnote text`,o=null;pB(n,(n,s)=>{let c=BU(i)??(i.attrs.text?[{type:`text`,text:NU(i.attrs.text)}]:[]);if(!e.editable){n.append(L(`div`,{class:`dw-footnote-pop__read`},zU(BU(i),NU(i.attrs.text))));return}let l=n=>{let r=e.state.doc.nodeAt(t);if(!r||r.type.name!==`footnote`)return;let i=IU(n.getJSON().content?.[0]?.content??[]),a=LU(i);(a!==r.attrs.text||JSON.stringify(i)!==JSON.stringify(r.attrs.content??null))&&e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...r.attrs,text:a,content:i}))},u=()=>{s(),e.focus()},d=L(`div`,{class:`dw-footnote-pop__text`}),f=e=>{let t=String(e.getAttributes(`link`).href??``),n=window.prompt(r?.format.linkPrompt??`Link address`,t);n!==null&&(n.trim()?FU.test(n.trim())&&e.chain().focus().extendMarkRange(`link`).setLink({href:n.trim()}).run():e.chain().focus().extendMarkRange(`link`).unsetLink().run())};o=new Bp({element:d,extensions:[UU,Jk.configure({document:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,listKeymap:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1,gapcursor:!1,trailingNode:!1,link:{openOnClick:!1,autolink:!0}}),wp.create({name:`footnoteKeys`,addKeyboardShortcuts:()=>({Enter:()=>(u(),!0),"Mod-k":({editor:e})=>(f(e),!0)})})],content:{type:`doc`,content:[{type:`paragraph`,content:c}]},editorProps:{attributes:{class:`dw-footnote-pop__field`,"aria-label":a,role:`textbox`}},onUpdate:({editor:e})=>l(e)});let p=(e,t,n)=>{let r=L(`button`,{type:`button`,class:`dw-footnote-pop__tool`,title:t,"aria-label":t});return r.append(Vj(e,15)),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,()=>o&&n(o)),r},m=r?.format,h=L(`div`,{class:`dw-footnote-pop__tools`,role:`toolbar`},p(`bold`,m?.bold??`Bold`,e=>e.chain().focus().toggleBold().run()),p(`italic`,m?.italic??`Italic`,e=>e.chain().focus().toggleItalic().run()),p(`code`,m?.code??`Inline code`,e=>e.chain().focus().toggleCode().run()),p(`link`,m?.link??`Link`,f));n.append(h,d),o.commands.focus(`end`)},{class:`dw-footnote-pop`,label:a,onClose:()=>{o?.destroy(),o=null}})}var GU=qp.create({name:`footnote`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{labels:null}},addAttributes(){return{text:{default:``,parseHTML:e=>NU(e.getAttribute(`data-text`)??e.getAttribute(`title`)??``),renderHTML:e=>({"data-text":e.text,title:e.text})},content:{default:null,parseHTML:e=>{try{return IU(JSON.parse(e.getAttribute(`data-content`)??`null`))}catch{return null}},renderHTML:e=>{let t=IU(e.content);return t?{"data-content":JSON.stringify(t)}:{}}}}},parseHTML(){return[{tag:`sup[data-type=footnote]`}]},renderHTML({HTMLAttributes:e}){return[`sup`,j(e,{"data-type":`footnote`,class:`dw-footnote`})]},renderText({node:e}){return` (${NU(e.attrs.text)})`},addCommands(){return{insertFootnote:(e=``)=>({editor:t,tr:n,dispatch:r})=>{let i=t.schema.nodes.footnote;if(!r)return!0;let a=n.selection.from;n.replaceSelectionWith(i.create({text:NU(e)}),!1);let o=this.options.labels;return setTimeout(()=>{if(t.isDestroyed)return;let e=t.view.nodeDOM(a);e instanceof Element&&WU(t.view,a,e,o)}),!0}}},addProseMirrorPlugins(){let e=this.options.labels,t=t=>{let n=VU(t);if(!n.length)return bs.empty;let r=n.map((t,n)=>_s.node(t.pos,t.pos+1,{"data-n":String(n+1),id:`fnref-${n+1}`,"aria-label":(e?.blocks.footnote??`Footnote {n}`).replace(`{n}`,String(n+1))})),i=JSON.stringify(n.map(e=>e.content??e.text)),a=_s.widget(t.content.size,t=>{let r=L(`ol`,{});return n.forEach((n,i)=>{let a=L(`a`,{href:`#fnref-${i+1}`,class:`dw-footnotes__back`,title:e?.blocks.footnoteBack??`Back to the text`,"aria-label":e?.blocks.footnoteBack??`Back to the text`},`↩`);a.addEventListener(`click`,e=>{e.preventDefault(),t.dom.querySelector(`[id="fnref-${i+1}"]`)?.scrollIntoView({block:`center`})});let o=L(`span`,{class:`dw-footnotes__text`});o.append(n.text||n.content?zU(n.content,n.text):`…`),t.editable&&o.addEventListener(`click`,n=>{if(n.target?.closest?.(`a`))return;let r=VU(t.state.doc)[i],a=t.dom.querySelector(`[id="fnref-${i+1}"]`);r&&a&&WU(t,r.pos,a,e)}),r.append(L(`li`,{id:`fnLine truncated
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
@@ -178,7 +180,7 @@ c5.3,-9.3,12,-14,20,-14
H400000v`+(40+e)+`H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},vU=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},YW=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l`+e/2.084+` -`+e+`
@@ -188,7 +190,7 @@ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},yU=function(e,t){return`M983 `+(10+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},XW=function(e,t){return`M983 `+(10+e+t)+`
l`+e/3.13+` -`+e+`
c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+`
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
@@ -197,7 +199,7 @@ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},bU=function(e,t){return`M424,`+(2398+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},ZW=function(e,t){return`M424,`+(2398+e+t)+`
c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
@@ -207,18 +209,18 @@ v`+(40+e)+`H1014.6
s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+` `+t+`
h400000v`+(40+e)+`h-400000z`},xU=function(e,t){return`M473,`+(2713+e+t)+`
h400000v`+(40+e)+`h-400000z`},QW=function(e,t){return`M473,`+(2713+e+t)+`
c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+` -`+e+`
c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7
s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},SU=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},CU=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},$W=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},eG=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
H742v`+r+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},wU=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=_U(t,gU);break;case`sqrtSize1`:r=vU(t,gU);break;case`sqrtSize2`:r=yU(t,gU);break;case`sqrtSize3`:r=bU(t,gU);break;case`sqrtSize4`:r=xU(t,gU);break;case`sqrtTall`:r=CU(t,gU,n)}return r},TU=function(e,t){switch(e){case`⎜`:return hU(`M291 0 H417 V`+t+` H291z`);case`∣`:return hU(`M145 0 H188 V`+t+` H145z`);case`∥`:return hU(`M145 0 H188 V`+t+` H145z`)+hU(`M367 0 H410 V`+t+` H367z`);case`⎟`:return hU(`M457 0 H583 V`+t+` H457z`);case`⎢`:return hU(`M319 0 H403 V`+t+` H319z`);case`⎥`:return hU(`M263 0 H347 V`+t+` H263z`);case`⎪`:return hU(`M384 0 H504 V`+t+` H384z`);case`⏐`:return hU(`M312 0 H355 V`+t+` H312z`);case`‖`:return hU(`M257 0 H300 V`+t+` H257z`)+hU(`M478 0 H521 V`+t+` H478z`);default:return``}},EU={doubleleftarrow:`M262 157
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},tG=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=JW(t,qW);break;case`sqrtSize1`:r=YW(t,qW);break;case`sqrtSize2`:r=XW(t,qW);break;case`sqrtSize3`:r=ZW(t,qW);break;case`sqrtSize4`:r=QW(t,qW);break;case`sqrtTall`:r=eG(t,qW,n)}return r},nG=function(e,t){switch(e){case`⎜`:return KW(`M291 0 H417 V`+t+` H291z`);case`∣`:return KW(`M145 0 H188 V`+t+` H145z`);case`∥`:return KW(`M145 0 H188 V`+t+` H145z`)+KW(`M367 0 H410 V`+t+` H367z`);case`⎟`:return KW(`M457 0 H583 V`+t+` H457z`);case`⎢`:return KW(`M319 0 H403 V`+t+` H319z`);case`⎥`:return KW(`M263 0 H347 V`+t+` H263z`);case`⎪`:return KW(`M384 0 H504 V`+t+` H384z`);case`⏐`:return KW(`M312 0 H355 V`+t+` H312z`);case`‖`:return KW(`M257 0 H300 V`+t+` H257z`)+KW(`M478 0 H521 V`+t+` H478z`);default:return``}},rG={doubleleftarrow:`M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
@@ -264,10 +266,10 @@ m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:hU(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:hU(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:hU(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:hU(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:KW(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:KW(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:KW(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:KW(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:hU(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:KW(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
@@ -316,7 +318,7 @@ m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:hU(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:hU(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:hU(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:KW(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:KW(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:KW(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
@@ -389,7 +391,7 @@ M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},DU=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},iG=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
H403z M403 1759 V0 H319 V1759 v`+t+` v1759 v84 h84z`;case`rbrack`:return`M347 1759 V0 H0 V84 H263 V1759 v`+t+` v1759 H0 v84 H347z
M347 1759 V0 H263 V1759 v`+t+` v1759 h84z`;case`vert`:return`M145 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
@@ -417,20 +419,20 @@ c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function OU(e){return`toText`in e}var kU=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(OU(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},AU={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},jU={ex:!0,em:!0,mu:!0},MU=function(e){return typeof e!=`string`&&(e=e.unit),e in AU||e in jU||e===`ex`},NU=function(e,t){var n;if(e.unit in AU)n=AU[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new L(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},PU=function(e){return e.filter(e=>e).join(` `)},FU=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=IH(n)+`:`+r+`;`)}return t},IU=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},LU=function(e){var t=document.createElement(e);t.className=PU(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},RU=/[\s"'>/=\x00-\x1f]/,zU=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+zH(PU(this.classes))+`"`);var n=FU(this.style);n&&(t+=` style="`+zH(n)+`"`);for(var r of Object.keys(this.attributes)){if(RU.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+zH(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},BU=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,IU.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return LU.call(this,`span`)}toMarkup(){return zU.call(this,`span`)}},VU=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,IU.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return LU.call(this,`a`)}toMarkup(){return zU.call(this,`a`)}},HU=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+zH(this.src)+`"`+(` alt="`+zH(this.alt)+`"`),t=FU(this.style);return t&&(e+=` style="`+zH(t)+`"`),e+=`'/>`,e}},UU={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},WU=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=fU(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=UU[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=PU(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=zH(PU(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new GU([new KU(d[v])],{width:`400em`,height:z(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=QW([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=z(m),l.push(b)}return{span:X([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=z(o),a>0&&(i.style.minWidth=z(a)),i},sK=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=X([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new qU({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new qU({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=QW([],[new GU(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},cK=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],lK=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],uK=new Set(cK),dK=new Set(lK);function fK(e){return uK.has(e)}function pK(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function mK(e){var t=hK(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function hK(e){return e.type===`atom`||dK.has(e.type)?e:null}function gK(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new L(t,e);return r}var _K=e=>{if(e instanceof WU)return e;if(XU(e)&&e.children.length===1)return _K(e.children[0])},vK=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=pK(e.base,`accent`),n=r.base,e.base=n,i=YU(jG(e,t)),e.base=r):(r=pK(e,`accent`),n=r.base);var a=jG(n,t.havingCrampedStyle()),o=r.isShifty&&HH(n),s=0;o&&(s=_K(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=oK(r,t),u=iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=lG(`vec`,t),f=cG.vec[1]):(d=JW({type:`textord`,mode:r.mode,text:r.label},t),d=JU(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=X([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=X([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},yK=(e,t)=>{var n=e.isStretchy?rK(e.label):new Q(`mo`,[zG(e.label,e.mode)]),r=new Q(`mover`,[KG(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},bK=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));Z({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=yG(t[0]),r=!bK.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:vK,mathmlBuilder:yK}),Z({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),Z({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=jG(e.base,t),r=oK(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[iG({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=rK(e.label),r=new Q(`munder`,[KG(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var xK=e=>{var t=new Q(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};Z({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrighLine truncated
]`,fJ=`\\\\[a-zA-Z@]+`,pJ=`\\\\[^\ud800-\udfff]`,mJ=`(`+fJ+`)`+dJ+`*`,hJ=`\\\\(
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function aG(e){return`toText`in e}var oG=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(aG(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},sG={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},cG={ex:!0,em:!0,mu:!0},lG=function(e){return typeof e!=`string`&&(e=e.unit),e in sG||e in cG||e===`ex`},uG=function(e,t){var n;if(e.unit in sG)n=sG[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new R(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},dG=function(e){return e.filter(e=>e).join(` `)},fG=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=fW(n)+`:`+r+`;`)}return t},pG=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},mG=function(e){var t=document.createElement(e);t.className=dG(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},hG=/[\s"'>/=\x00-\x1f]/,gG=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+hW(dG(this.classes))+`"`);var n=fG(this.style);n&&(t+=` style="`+hW(n)+`"`);for(var r of Object.keys(this.attributes)){if(hG.test(r))throw new R(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+hW(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},_G=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,pG.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return mG.call(this,`span`)}toMarkup(){return gG.call(this,`span`)}},vG=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,pG.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return mG.call(this,`a`)}toMarkup(){return gG.call(this,`a`)}},yG=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+hW(this.src)+`"`+(` alt="`+hW(this.alt)+`"`),t=fG(this.style);return t&&(e+=` style="`+hW(t)+`"`),e+=`'/>`,e}},bG={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},xG=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=UW(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=bG[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=dG(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=hW(dG(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new SG([new CG(d[v])],{width:`400em`,height:z(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=kK([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=z(m),l.push(b)}return{span:X([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=z(o),a>0&&(i.style.minWidth=z(a)),i},Rq=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=X([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new wG({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new wG({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=kK([],[new SG(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},zq=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],Bq=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],Vq=new Set(zq),Hq=new Set(Bq);function Uq(e){return Vq.has(e)}function Wq(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function Gq(e){var t=Kq(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function Kq(e){return e.type===`atom`||Hq.has(e.type)?e:null}function qq(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new R(t,e);return r}var Jq=e=>{if(e instanceof xG)return e;if(DG(e)&&e.children.length===1)return Jq(e.children[0])},Yq=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Wq(e.base,`accent`),n=r.base,e.base=n,i=EG(cq(e,t)),e.base=r):(r=Wq(e,`accent`),n=r.base);var a=cq(n,t.havingCrampedStyle()),o=r.isShifty&&vW(n),s=0;o&&(s=Jq(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=Lq(r,t),u=FK({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=BK(`vec`,t),f=zK.vec[1]):(d=TK({type:`textord`,mode:r.mode,text:r.label},t),d=TG(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=X([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=FK({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=X([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},Xq=(e,t)=>{var n=e.isStretchy?Pq(e.label):new Q(`mo`,[gq(e.label,e.mode)]),r=new Q(`mover`,[Cq(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},Zq=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));Z({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=XK(t[0]),r=!Zq.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:Yq,mathmlBuilder:Xq}),Z({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),Z({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=cq(e.base,t),r=Lq(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[FK({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=Pq(e.label),r=new Q(`munder`,[Cq(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var Qq=e=>{var t=new Q(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};Z({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrighLine truncated
]`,UY=`\\\\[a-zA-Z@]+`,WY=`\\\\[^\ud800-\udfff]`,GY=`(`+UY+`)`+HY+`*`,KY=`\\\\(
|[ \r ]+
?)[ \r ]*`,gJ=`[̀-ͯ]`,_J=RegExp(gJ+`+$`),vJ=`(`+dJ+`+)|`+(hJ+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(gJ+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(gJ+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+mJ)+(`|`+pJ+`)`),yJ=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(vJ,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new yq(`EOF`,new vq(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new yq(e[t],new vq(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new yq(r,new vq(this,t,this.tokenRegex.lastIndex))}},bJ=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new L(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},xJ=_q;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var SJ={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new L("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=SJ[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=SJ[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var CJ=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new L(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new L(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new L(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new L(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>CJ(e,!1,!0,!1)),$(`\\renewcommand`,e=>CJ(e,!0,!1,!1)),$(`\\providecommand`,e=>CJ(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),uJ[n],iW.math[n],iW.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(PJ,t[0])&&!iW[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=PJ[t[0]]+t.slice(1));var i=_J.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(iW[this.mode][t]){this.settings.strict&&this.mode===`math`&&EW.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=iW[this.mode][t].group,s=vq.range(e);a=fK(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(mU(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:vq.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!NJ[l])throw new L(`Unknown accent ' `+l+`'`,e);var u=NJ[l][this.mode]||NJ[l].text;if(!u)throw new L(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:vq.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};FJ.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var IJ=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new FJ(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new L(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new yq(`\\df@tag`)])}]}return r},LJ=function(e,t,n){t.textContent=``;var r=VJ(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),LJ=function(){throw new L(`KaTeX doesn't work in quirks mode.`)});var RJ=function(e,t){return VJ(e,t).toMarkup()},zJ=function(e,t){return IJ(e,new JH(t))},BJ=function(e,t,n){if(n.throwOnError||!(e instanceof L))throw e;var r=X([`katex-error`],[new WU(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},VJ=function(e,t){var n=new JH(t);try{return eK(IJ(e,n),e,n)}catch(t){return BJ(t,e,n)}},HJ={version:`0.18.10`,render:LJ,renderToString:RJ,ParseError:L,SETTINGS_SCHEMA:WH,__parse:zJ,__renderToDomTree:VJ,__renderToHTMLTree:function(e,t){var n=new JH(t);try{return tK(IJ(e,n),e,n)}catch(t){return BJ(t,e,n)}},__setFontMetrics:eW,__defineSymbol:B,__defineFunction:Z,__defineMacro:$,__domTree:{Span:BU,Anchor:VU,SymbolNode:WU,SvgNode:GU,PathNode:KU,LineNode:qU}},UJ=Jp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{HJ.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),WJ=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},GJ=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:WJ,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{HJ.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),KJ=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[UJ.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),GJ.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function qJ(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;cH({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return KJ.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function JJ({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new Un,command:({editor:e,range:t,props:i})=>{var a,o;let sLine truncated
Idea --> Draft --> Review --> Published`,eY=null;function tY(e){return eY??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),eY}var nY=0;async function rY(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await tY(r)).render(`dw-mermaid-${++nY}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var iY=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=$J)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return rY(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;cH({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void rY(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),rY(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void rY(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),rY(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function aY(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function oY(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...o(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),{...o(`columns`,`columns`,[`layout`,`side by side`,`split`,`grid`,`multi-column`],()=>{}),children:[2,3,4].map(e=>o(`columns${e}`,`columns`,[`columns`,`layout`,`side by side`,String(e)],(t,n)=>t.chain().focus().deleteRange(n).insertColumns(e).run()))},o(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),o(`database`,`database`,[`kanban`,`board`,`calendar`,`records`,`tracker`,`notion`],(e,t)=>e.chain().focus().deleteRange(t).insertDatabase().run()),o(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),o(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),o(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),o(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),o(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),o(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),o(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focus().deleteRange(t).insertInlineMath(Line truncated
]`).replace(`lheading`,aX).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},bX=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xX=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,SX=/^( {2,}|\\)\n(?!\s*$)/,CX=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wX=/[\p{P}\p{S}]/u,TX=/[\s\p{P}\p{S}]/u,EX=/[^\s\p{P}\p{S}]/u,DX=YY(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,TX).getRegex(),OX=/(?!~)[\p{P}\p{S}]/u,kX=/(?!~)[\s\p{P}\p{S}]/u,AX=/(?:[^\s\p{P}\p{S}]|~)/u,jX=YY(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,XY?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),MX=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,NX=YY(MX,`u`).replace(/punct/g,wX).getRegex(),PX=YY(MX,`u`).replace(/punct/g,OX).getRegex(),FX=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,IX=YY(FX,`gu`).replace(/notPunctSpace/g,EX).replace(/punctSpace/g,TX).replace(/punct/g,wX).getRegex(),LX=YY(FX,`gu`).replace(/notPunctSpace/g,AX).replace(/punctSpace/g,kX).replace(/punct/g,OX).getRegex(),RX=YY(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,EX).replace(/punctSpace/g,TX).replace(/punct/g,wX).getRegex(),zX=YY(/\\(punct)/,`gu`).replace(/punct/g,wX).getRegex(),BX=YY(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),VX=YY(pX).replace(`(?:-->|$)`,`-->`).getRegex(),HX=YY(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,VX).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),UX=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,WX=YY(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,UX).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),GX=YY(/^!?\[(label)\]\[(ref)\]/).replace(`label`,UX).replace(`ref`,lX).getRegex(),KX=YY(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,lX).getRegex(),qX=YY(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,GX).replace(`nolink`,KX).getRegex(),JX=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,YX={_backpedal:JY,anyPunctuation:zX,autolink:BX,blockSkip:jX,br:SX,code:xX,del:JY,emStrongLDelim:NX,emStrongRDelimAst:IX,emStrongRDelimUnd:RX,escape:bX,link:WX,nolink:KX,punctuation:DX,reflink:GX,reflinkSearch:qX,tag:HX,text:CX,url:JY},XX={...YX,link:YY(/^!?\[(label)\]\((.*?)\)/).replace(`label`,UX).getRegex(),reflink:YY(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,UX).getRegex()},ZX={...YX,emStrongRDelimAst:LX,emStrongLDelim:PX,url:YY(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,JX).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:YY(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,JX).getRegex()},QX={...ZX,br:YY(SX).replace(`{2,}`,`*`).getRegex(),text:YY(ZX.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},$X={normal:gX,gfm:vX,pedantic:yX},eZ={normal:YX,gfm:ZX,breaks:QX,pedantic:XX},tZ={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},nZ=e=>tZ[e];function rZ(e,t){if(t){if(ZY.escapeTest.test(e))return e.replace(ZY.escapeReplace,nZ)}else if(ZY.escapeTestNoEncode.test(e))return e.replace(ZY.escapeReplaceNoEncode,nZ);return e}function iZ(e){try{e=encodeURI(e).replace(ZY.percentDecode,`%`)}catch{return null}return e}function aZ(e,t){let n=e.replace(ZY.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(ZY.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(ZY.slLine truncated
?)[ \r ]*`,qY=`[̀-ͯ]`,JY=RegExp(qY+`+$`),YY=`(`+HY+`+)|`+(KY+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(qY+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(qY+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+GY)+(`|`+WY+`)`),XY=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(YY,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new XJ(`EOF`,new YJ(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new R(`Unexpected character: '`+e[t]+`'`,new XJ(e[t],new YJ(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new XJ(r,new YJ(this,t,this.tokenRegex.lastIndex))}},ZY=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new R(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},QY=JJ;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var $Y={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new R("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=$Y[t.text],r==null||r>=n)throw new R(`Invalid base-`+n+` digit `+t.text);for(var i;(i=$Y[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var eX=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new R(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new R(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new R(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new R(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>eX(e,!1,!0,!1)),$(`\\renewcommand`,e=>eX(e,!0,!1,!1)),$(`\\providecommand`,e=>eX(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),VY[n],FG.math[n],FG.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(dX,t[0])&&!FG[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=dX[t[0]]+t.slice(1));var i=JY.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(FG[this.mode][t]){this.settings.strict&&this.mode===`math`&&rK.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=FG[this.mode][t].group,s=YJ.range(e);a=Uq(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(GW(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:YJ.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!uX[l])throw new R(`Unknown accent ' `+l+`'`,e);var u=uX[l][this.mode]||uX[l].text;if(!u)throw new R(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:YJ.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};fX.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var pX=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new fX(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new R(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new XJ(`\\df@tag`)])}]}return r},mX=function(e,t,n){t.textContent=``;var r=vX(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),mX=function(){throw new R(`KaTeX doesn't work in quirks mode.`)});var hX=function(e,t){return vX(e,t).toMarkup()},gX=function(e,t){return pX(e,new wW(t))},_X=function(e,t,n){if(n.throwOnError||!(e instanceof R))throw e;var r=X([`katex-error`],[new xG(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},vX=function(e,t){var n=new wW(t);try{return jq(pX(e,n),e,n)}catch(t){return _X(t,e,n)}},yX={version:`0.18.10`,render:mX,renderToString:hX,ParseError:R,SETTINGS_SCHEMA:bW,__parse:gX,__renderToDomTree:vX,__renderToHTMLTree:function(e,t){var n=new wW(t);try{return Mq(pX(e,n),e,n)}catch(t){return _X(t,e,n)}},__setFontMetrics:jG,__defineSymbol:B,__defineFunction:Z,__defineMacro:$,__domTree:{Span:_G,Anchor:vG,SymbolNode:xG,SvgNode:SG,PathNode:CG,LineNode:wG}},bX=qp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,j(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new cp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{yX.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),xX=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},SX=qp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,j(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new cp({find:xX,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{yX.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),CX=wp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[bX.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),SX.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function wX(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;tU({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return CX.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function TX({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new O,command:({editor:e,range:t,props:i})=>{var a,o;let s=Line truncated
Idea --> Draft --> Review --> Published`,jX=null;function MX(e){return jX??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),jX}var NX=0;async function PX(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await MX(r)).render(`dw-mermaid-${++NX}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var FX=qp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,j(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=AX)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return PX(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;tU({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void PX(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),PX(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void PX(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),PX(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function IX(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function LX(e,t,n,r,i=!1,a,o=!!r?.children){let s=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),c=[s(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),s(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),s(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),s(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...s(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>s(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},s(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),s(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),s(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),s(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),{...s(`columns`,`columns`,[`layout`,`side by side`,`split`,`grid`,`multi-column`],()=>{}),children:[2,3,4,5].map(e=>s(`columns${e}`,`columns`,[`columns`,`layout`,`side by side`,String(e)],(t,n)=>t.chain().focus().deleteRange(n).insertColumns(e).run()))},s(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),s(`database`,`database`,[`kanban`,`board`,`calendar`,`records`,`tracker`,`notion`],(e,t)=>e.chain().focus().deleteRange(t).insertDatabase().run()),s(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),s(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),s(`tabs`,`tabs`,[`tab`,`tabbed`,`switch`,`panes`],(e,t)=>e.chain().focus().deleteRange(t).insertTabs().run()),s(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),s(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),s(`pageBreak`,`page-break`,[`print`,`new page`,`break`,`pdf`],(e,t)=>e.chain().focus().deleteRange(t).setPageBreak().run()),s(`footnote`,`footnote`,[`note`,`reference`,`citation`,`source`,`fn`],(e,t)=>e.chain().focus().deleteRange(t).insertFootnote().run()),sLine truncated
]`).replace(`lheading`,LZ).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},QZ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$Z=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,eQ=/^( {2,}|\\)\n(?!\s*$)/,tQ=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,nQ=/[\p{P}\p{S}]/u,rQ=/[\s\p{P}\p{S}]/u,iQ=/[^\s\p{P}\p{S}]/u,aQ=DZ(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,rQ).getRegex(),oQ=/(?!~)[\p{P}\p{S}]/u,sQ=/(?!~)[\s\p{P}\p{S}]/u,cQ=/(?:[^\s\p{P}\p{S}]|~)/u,lQ=DZ(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,OZ?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),uQ=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,dQ=DZ(uQ,`u`).replace(/punct/g,nQ).getRegex(),fQ=DZ(uQ,`u`).replace(/punct/g,oQ).getRegex(),pQ=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,mQ=DZ(pQ,`gu`).replace(/notPunctSpace/g,iQ).replace(/punctSpace/g,rQ).replace(/punct/g,nQ).getRegex(),hQ=DZ(pQ,`gu`).replace(/notPunctSpace/g,cQ).replace(/punctSpace/g,sQ).replace(/punct/g,oQ).getRegex(),gQ=DZ(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,iQ).replace(/punctSpace/g,rQ).replace(/punct/g,nQ).getRegex(),_Q=DZ(/\\(punct)/,`gu`).replace(/punct/g,nQ).getRegex(),vQ=DZ(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),yQ=DZ(GZ).replace(`(?:-->|$)`,`-->`).getRegex(),bQ=DZ(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,yQ).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xQ=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,SQ=DZ(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,xQ).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),CQ=DZ(/^!?\[(label)\]\[(ref)\]/).replace(`label`,xQ).replace(`ref`,VZ).getRegex(),wQ=DZ(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,VZ).getRegex(),TQ=DZ(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,CQ).replace(`nolink`,wQ).getRegex(),EQ=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,DQ={_backpedal:EZ,anyPunctuation:_Q,autolink:vQ,blockSkip:lQ,br:eQ,code:$Z,del:EZ,emStrongLDelim:dQ,emStrongRDelimAst:mQ,emStrongRDelimUnd:gQ,escape:QZ,link:SQ,nolink:wQ,punctuation:aQ,reflink:CQ,reflinkSearch:TQ,tag:bQ,text:tQ,url:EZ},OQ={...DQ,link:DZ(/^!?\[(label)\]\((.*?)\)/).replace(`label`,xQ).getRegex(),reflink:DZ(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,xQ).getRegex()},kQ={...DQ,emStrongRDelimAst:hQ,emStrongLDelim:fQ,url:DZ(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,EQ).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:DZ(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,EQ).getRegex()},AQ={...kQ,br:DZ(eQ).replace(`{2,}`,`*`).getRegex(),text:DZ(kQ.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},jQ={normal:JZ,gfm:XZ,pedantic:ZZ},MQ={normal:DQ,gfm:kQ,breaks:AQ,pedantic:OQ},NQ={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},PQ=e=>NQ[e];function FQ(e,t){if(t){if(kZ.escapeTest.test(e))return e.replace(kZ.escapeReplace,PQ)}else if(kZ.escapeTestNoEncode.test(e))return e.replace(kZ.escapeReplaceNoEncode,PQ);return e}function IQ(e){try{e=encodeURI(e).replace(kZ.percentDecode,`%`)}catch{return null}return e}function LQ(e,t){let n=e.replace(kZ.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(kZ.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(kZ.slLine truncated
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
`)}var uZ=class{options;rules;lexer;constructor(e){this.options=e||KY}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:oZ(e,`
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=lZ(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=oZ(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:oZ(t[0],`
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=oZ(t[0],`
`)}var HQ=class{options;rules;lexer;constructor(e){this.options=e||wZ}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:RQ(e,`
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=VQ(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=RQ(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:RQ(t[0],`
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=RQ(t[0],`
`).split(`
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -448,10 +450,10 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
`,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
`+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=aZ(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(aZ(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=oZ(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=sZ(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),cZ(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return cZ(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},dZ=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||KY,this.options.tokenizer=this.options.tokenizer||new uZ,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:ZY,block:$X.normal,inline:eZ.normal};this.options.pedantic?(t.block=$X.pedantic,t.inline=eZ.pedantic):this.options.gfm&&(t.block=$X.gfm,t.inline=this.options.breaks?eZ.breaks:eZ.gfm),this.tokenizer.rules=t}static get rules(){return{block:$X,inline:eZ}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(ZY.carriageReturn,`
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(ZY.tabCharGlobal,` `).replace(ZY.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=LQ(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(LQ(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=RQ(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=zQ(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),BQ(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return BQ(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},UQ=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wZ,this.options.tokenizer=this.options.tokenizer||new HQ,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:kZ,block:jQ.normal,inline:MQ.normal};this.options.pedantic?(t.block=jQ.pedantic,t.inline=MQ.pedantic):this.options.gfm&&(t.block=jQ.gfm,t.inline=this.options.breaks?MQ.breaks:MQ.gfm),this.tokenizer.rules=t}static get rules(){return{block:jQ,inline:MQ}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(kZ.carriageReturn,`
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(kZ.tabCharGlobal,` `).replace(kZ.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
`)?``:`
`)+r.raw,n.text+=`
@@ -464,16 +466,16 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
`)?``:`
`)+r.raw,n.text+=`
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if((r=this.tokenizer.escape(e))||(r=this.tokenizer.tag(e))||(r=this.tokenizer.link(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if((r=this.tokenizer.emStrong(e,n,o))||(r=this.tokenizer.codespan(e))||(r=this.tokenizer.br(e))||(r=this.tokenizer.del(e))||(r=this.tokenizer.autolink(e))||!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},fZ=class{options;parser;constructor(e){this.options=e||KY}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(ZY.notSpaceStart)?.[0],i=e.replace(ZY.endingNewline,``)+`
`;return r?`<pre><code class="language-`+rZ(r)+`">`+(n?i:rZ(i,!0))+`</code></pre>
`:`<pre><code>`+(n?i:rZ(i,!0))+`</code></pre>
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if((r=this.tokenizer.escape(e))||(r=this.tokenizer.tag(e))||(r=this.tokenizer.link(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if((r=this.tokenizer.emStrong(e,n,o))||(r=this.tokenizer.codespan(e))||(r=this.tokenizer.br(e))||(r=this.tokenizer.del(e))||(r=this.tokenizer.autolink(e))||!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},WQ=class{options;parser;constructor(e){this.options=e||wZ}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(kZ.notSpaceStart)?.[0],i=e.replace(kZ.endingNewline,``)+`
`;return r?`<pre><code class="language-`+FQ(r)+`">`+(n?i:FQ(i,!0))+`</code></pre>
`:`<pre><code>`+(n?i:FQ(i,!0))+`</code></pre>
`}blockquote({tokens:e}){return`<blockquote>
${this.parser.parse(e)}</blockquote>
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
`}hr(e){return`<hr>
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
`+r+`</`+i+`>
`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+rZ(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+FQ(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
<thead>
@@ -482,15 +484,15 @@ ${this.parser.parse(e)}</blockquote>
`}tablerow({text:e}){return`<tr>
${e}</tr>
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${rZ(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=iZ(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+rZ(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=iZ(e);if(i===null)return rZ(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${rZ(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:rZ(e.text)}},pZ=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},mZ=class e{options;renderer;textRenderer;constructor(e){this.options=e||KY,this.options.renderer=this.options.renderer||new fZ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new pZ}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`def`:n+=this.renderer.def(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},hZ=class{options;block;constructor(e){this.options=e||KY}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?dZ.lex:dZ.lexInline}provideParser(){return this.block?mZ.parse:mZ.parseInline}},gZ=new class{defaults=GY();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=mZ;Renderer=fZ;TextRenderer=pZ;Lexer=dZ;Tokenizer=uZ;Hooks=hZ;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new fZ(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new uZ(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new hZ;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=hZ.passThroughHooks.has(n)?e=>{if(this.defaults.async&&hZ.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return dZ.lex(e,t??this.defaults)}parser(e,t){return mZ.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async:Line truncated
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+rZ(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function _Z(e,t){return gZ.parse(e,t)}_Z.options=_Z.setOptions=function(e){return gZ.setOptions(e),_Z.defaults=gZ.defaults,qY(_Z.defaults),_Z},_Z.getDefaults=GY,_Z.defaults=KY,_Z.use=function(...e){return gZ.use(...e),_Z.defaults=gZ.defaults,qY(_Z.defaults),_Z},_Z.walkTokens=function(e,t){return gZ.walkTokens(e,t)},_Z.parseInline=gZ.parseInline,_Z.Parser=mZ,_Z.parser=mZ.parse,_Z.Renderer=fZ,_Z.TextRenderer=pZ,_Z.Lexer=dZ,_Z.lexer=dZ.lex,_Z.Tokenizer=uZ,_Z.Hooks=hZ,_Z.parse=_Z,_Z.options,_Z.setOptions,_Z.use,_Z.walkTokens,_Z.parseInline,mZ.parse,dZ.lex;function vZ(e){let t=e??BR;return{...xF,...t.edgeless,colors:{...xF.colors,...t.colors}}}function yZ(e){let t=e?.surface;return Array.isArray(t?.elements)?t.elements:[]}function bZ(e,t,n){let r={...n,placeholder:n.placeholder??``},i=new Vp({element:e,editable:t.kind!==`json`&&t.editable,content:t.kind===`json`?t.content:void 0,extensions:t.kind===`page`?UY({...r,collab:{provider:t.provider,user:t.user}}):t.kind===`body`?UY({...r,rowBody:{doc:t.doc,fragment:t.fragment}}):UY(r),editorProps:{attributes:{class:`dw-prose`}}});return{destroy:()=>i.destroy(),focus:()=>i.commands.focus(`end`),setEditable:e=>i.setEditable(e&&t.kind!==`json`)}}function xZ(e,t){let n=!!t.provider,r,i=null;if(t.provider)r=t.provider.doc;else{i=new Cv,r=i;let e=t.content;i.transact(()=>iR(i.getXmlFragment(`default`),e?.content??[]));let n=yZ(e);if(n.length){let e=new dR(i,{undo:!1});e.load(n),e.destroy()}}let a={...t};delete a.provider,delete a.content;let o=new kR(e,{doc:r,editable:n&&t.editable,notes:{mount:(e,r)=>{let i=n?r.page?{kind:`page`,provider:t.provider,user:t.user??{name:`?`,color:`#888`},editable:r.editable}:{kind:`body`,doc:r.doc,fragment:r.fragment,editable:r.editable}:{kind:`json`,content:r.page&&t.content?t.content:{type:`doc`,content:rR(r.fragment)}};return t.mountNote?t.mountNote(e,i):bZ(e,i,a)}},labels:vZ(t.labels),files:t.files,links:t.links,embedSource:dH,styles:t.styles,onStyles:t.onStyles,viewKey:t.viewKey,pageTitle:t.pageTitle,undo:n,onError:t.onError,onComment:t.onComment,onCommentSelect:t.onCommentSelect});return{view:o,setEditable:e=>o.setEditable(n&&e),destroy:()=>{o.destroy(),i?.destroy()}}}function SZ(e,t,n){let r=Yj(t),i=JB(t);if(!r&&!i)return()=>{};let a=()=>i?XB(e,i.database,i.row):tM(e,r),o=!1,s,c=()=>{clearTimeout(s),s=setTimeout(()=>{o||e.isDestroyed||!a()||(o=!0,l(),n?.())},50)},l=()=>{e.off(`transaction`,c),clearTimeout(u)},u=setTimeout(l,5e3);return e.on(`transaction`,c),c(),()=>{l(),clearTimeout(s)}}var CZ=3e4,wZ=class extends pm{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Fh();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&TZ(this,t,`timeout`)},mm(CZ/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Fh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),tg(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},TZ=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Fh()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},EZ=(e,t,n=e.states)=>{let r=t.length,i=Fm();j(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;j(i,r),j(i,s),Gm(i,JSON.stringify(o))}return Rm(i)},DZ=(e,t,n)=>{let r=hh(t),i=Fh(),a=[],o=[],s=[],c=[],l=M(r);for(let t=0;t<l;t++){let t=M(r),n=M(r),l=JSON.parse(xh(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(tg(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},nLine truncated
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${FQ(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=IQ(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+FQ(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=IQ(e);if(i===null)return FQ(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${FQ(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:FQ(e.text)}},GQ=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},KQ=class e{options;renderer;textRenderer;constructor(e){this.options=e||wZ,this.options.renderer=this.options.renderer||new WQ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new GQ}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`def`:n+=this.renderer.def(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},qQ=class{options;block;constructor(e){this.options=e||wZ}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?UQ.lex:UQ.lexInline}provideParser(){return this.block?KQ.parse:KQ.parseInline}},JQ=new class{defaults=CZ();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=KQ;Renderer=WQ;TextRenderer=GQ;Lexer=UQ;Tokenizer=HQ;Hooks=qQ;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new WQ(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new HQ(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new qQ;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=qQ.passThroughHooks.has(n)?e=>{if(this.defaults.async&&qQ.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return UQ.lex(e,t??this.defaults)}parser(e,t){return KQ.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async:Line truncated
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+FQ(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function YQ(e,t){return JQ.parse(e,t)}YQ.options=YQ.setOptions=function(e){return JQ.setOptions(e),YQ.defaults=JQ.defaults,TZ(YQ.defaults),YQ},YQ.getDefaults=CZ,YQ.defaults=wZ,YQ.use=function(...e){return JQ.use(...e),YQ.defaults=JQ.defaults,TZ(YQ.defaults),YQ},YQ.walkTokens=function(e,t){return JQ.walkTokens(e,t)},YQ.parseInline=JQ.parseInline,YQ.Parser=KQ,YQ.parser=KQ.parse,YQ.Renderer=WQ,YQ.TextRenderer=GQ,YQ.Lexer=UQ,YQ.lexer=UQ.lex,YQ.Tokenizer=HQ,YQ.Hooks=qQ,YQ.parse=YQ,YQ.options,YQ.setOptions,YQ.use,YQ.walkTokens,YQ.parseInline,KQ.parse,UQ.lex;function XQ(e){let t=e??BR;return{...bF,...t.edgeless,colors:{...bF.colors,...t.colors}}}function ZQ(e){let t=e?.surface;return Array.isArray(t?.elements)?t.elements:[]}function QQ(e,t,n){let r={...n,placeholder:n.placeholder??``},i=new Bp({element:e,editable:t.kind!==`json`&&t.editable,content:t.kind===`json`?t.content:void 0,extensions:t.kind===`page`?bZ({...r,collab:{provider:t.provider,user:t.user}}):t.kind===`body`?bZ({...r,rowBody:{doc:t.doc,fragment:t.fragment}}):bZ(r),editorProps:{attributes:{class:`dw-prose`}}});return{destroy:()=>i.destroy(),focus:()=>i.commands.focus(`end`),setEditable:e=>i.setEditable(e&&t.kind!==`json`)}}function $Q(e,t){let n=!!t.provider,r,i=null;if(t.provider)r=t.provider.doc;else{i=new Sv,r=i;let e=t.content;i.transact(()=>rR(i.getXmlFragment(`default`),e?.content??[]));let n=ZQ(e);if(n.length){let e=new uR(i,{undo:!1});e.load(n),e.destroy()}}let a={...t};delete a.provider,delete a.content;let o=new OR(e,{doc:r,editable:n&&t.editable,notes:{mount:(e,r)=>{let i=n?r.page?{kind:`page`,provider:t.provider,user:t.user??{name:`?`,color:`#888`},editable:r.editable}:{kind:`body`,doc:r.doc,fragment:r.fragment,editable:r.editable}:{kind:`json`,content:r.page&&t.content?t.content:{type:`doc`,content:nR(r.fragment)}};return t.mountNote?t.mountNote(e,i):QQ(e,i,a)}},labels:XQ(t.labels),files:t.files,links:t.links,embedSource:iU,styles:t.styles,onStyles:t.onStyles,viewKey:t.viewKey,pageTitle:t.pageTitle,undo:n,onError:t.onError,onComment:t.onComment,onCommentSelect:t.onCommentSelect});return{view:o,setEditable:e=>o.setEditable(n&&e),destroy:()=>{o.destroy(),i?.destroy()}}}function e$(e,t,n){let r=Jj(t),i=IV(t);if(!r&&!i)return()=>{};let a=()=>i?RV(e,i.database,i.row):eM(e,r),o=!1,s,c=()=>{clearTimeout(s),s=setTimeout(()=>{o||e.isDestroyed||!a()||(o=!0,l(),n?.())},50)},l=()=>{e.off(`transaction`,c),clearTimeout(u)},u=setTimeout(l,5e3);return e.on(`transaction`,c),c(),()=>{l(),clearTimeout(s)}}var t$=3e4,n$=class extends fm{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Ph();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&r$(this,t,`timeout`)},pm(t$/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Ph()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),eg(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},r$=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Ph()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},i$=(e,t,n=e.states)=>{let r=t.length,i=Pm();M(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;M(i,r),M(i,s),Wm(i,JSON.stringify(o))}return Lm(i)},a$=(e,t,n)=>{let r=mh(t),i=Ph(),a=[],o=[],s=[],c=[],l=N(r);for(let t=0;t<l;t++){let t=N(r),n=N(r),l=JSON.parse(bh(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(eg(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},nLine truncated
`),before:e.state.doc.textBetween(Math.max(0,t-4e3),t,`
`)});return}case`insertMarkdown`:this.insertMarkdown(e.markdown,e.mode);return;case`transcribed`:{let t=this.pendingTranscripts.get(e.id);if(!t)return;this.pendingTranscripts.delete(e.id),e.result&&this.words?t.resolve(Qp(e.result,this.words,GZ)):t.reject(Error(e.error||this.labels.blocks.transcribeFailed));return}default:throw Error(`unknown message ${e.type}`)}}requestTranscript(e,t){let n=this.nextTranscript++;return new Promise((r,i)=>{this.pendingTranscripts.set(n,{resolve:r,reject:i}),this.send({type:`transcribe`,id:n,src:e,name:t})})}insertMarkdown(e,t){let n=this.picked,r=n&&!n.editor.isDestroyed?n.editor:this.target,i=GZ(e);if(!i.trim())return;let a=r.state.doc.content.size,o=Math.min(n?.from??r.state.selection.from,a),s=Math.min(n?.to??r.state.selection.to,a);if(t===`replace`)r.chain().focus().insertContentAt({from:o,to:s},i).run();else{let e=r.state.doc.resolve(s);r.chain().focus().insertContentAt(e.depth>=1?e.after(1):s,i).run()}this.picked=null}connect(e){this.provider?.destroy();let t=new BZ({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}}),this.mode===`edgeless`&&this.openCanvas()}openCanvas(){this.closeCanvas();let e=document.createElement(`div`);e.className=`dw-bridge-canvas`,document.body.append(e),this.canvasEl=e,this.el.hidden=!0,this.canvas=xZ(e,{provider:this.provider??void 0,content:this.provider?void 0:this.lastContent??this.editor.getJSON(),editable:this.editable&&!!this.provider,pageTitle:()=>this.title,onNavigate:e=>this.send({type:`navigate`,path:e}),onError:e=>this.send({type:`error`,message:e instanceof Error?e.message:String(e)})})}closeCanvas(){this.canvas?.destroy(),this.canvas=null,this.canvasEl?.remove(),this.canvasEl=null,this.el.hidden=!1}create(e){return this.el.replaceChildren(),new Vp({element:this.el,editable:this.editable,extensions:UY({...e,files:this.files,labels:this.labels,onNavigate:e=>this.send({type:`navigate`,path:e})}),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:()=>this.reportState(),onTransaction:()=>this.reportState(),onFocus:()=>this.reportState(),onBlur:()=>this.reportState()})}get target(){return this.inner&&!this.inner.isDestroyed?this.inner:this.editor}track(e){let t=(e instanceof Element?e.closest(`.ProseMirror`):null)?.editor;t&&(this.setInner(t===this.editor?null:t),this.reportState())}innerChanged=()=>this.reportState();innerGone=()=>{this.setInner(null),this.reportState()};setInner(e){if(e!==this.inner){if(this.inner){for(let e of[`selectionUpdate`,`transaction`,`focus`,`blur`])this.inner.off(e,this.innerChanged);this.inner.off(`destroy`,this.innerGone)}if(this.inner=e,e){for(let t of[`selectionUpdate`,`transaction`,`focus`,`blur`])e.on(t,this.innerChanged);e.on(`destroy`,this.innerGone)}}}reportOverlay(){let e=document.querySelector(VZ)!==null;e!==this.overlay&&(this.overlay=e,this.send({type:`overlay`,open:e}))}reportState(){let e=this.target;if(e.isDestroyed)return;let t={active:UZ.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function GZ(e){return _Z.parse(e.trim(),{async:!1,gfm:!0})}function KZ(e){if(e.isDestroyed)return;let t=e.view.props.nodeViews??{},n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)]));e.view.setProps({nodeViews:n})}function qZ(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var JZ=new WZ(document.getElementById(`editor`),qZ);window.docwell={receive:e=>JZ.receive(e)};</script>
`)});return}case`insertMarkdown`:this.insertMarkdown(e.markdown,e.mode);return;case`transcribed`:{let t=this.pendingTranscripts.get(e.id);if(!t)return;this.pendingTranscripts.delete(e.id),e.result&&this.words?t.resolve(Zp(e.result,this.words,C$)):t.reject(Error(e.error||this.labels.blocks.transcribeFailed));return}case`subpageList`:{let t=this.pendingSubpages.get(e.id);this.pendingSubpages.delete(e.id),t?.(Array.isArray(e.pages)?e.pages:[]);return}default:throw Error(`unknown message ${e.type}`)}}requestSubpages(){let e=this.nextSubpages++;return new Promise(t=>{let n=setTimeout(()=>{this.pendingSubpages.delete(e),t([])},1e4);this.pendingSubpages.set(e,e=>{clearTimeout(n),t(e)}),this.send({type:`subpages`,id:e})})}requestTranscript(e,t){let n=this.nextTranscript++;return new Promise((r,i)=>{this.pendingTranscripts.set(n,{resolve:r,reject:i}),this.send({type:`transcribe`,id:n,src:e,name:t})})}insertMarkdown(e,t){let n=this.picked,r=n&&!n.editor.isDestroyed?n.editor:this.target,i=C$(e);if(!i.trim())return;let a=r.state.doc.content.size,o=Math.min(n?.from??r.state.selection.from,a),s=Math.min(n?.to??r.state.selection.to,a);if(t===`replace`)r.chain().focus().insertContentAt({from:o,to:s},i).run();else{let e=r.state.doc.resolve(s);r.chain().focus().insertContentAt(e.depth>=1?e.after(1):s,i).run()}this.picked=null}connect(e){this.provider?.destroy();let t=new v$({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}}),this.mode===`edgeless`&&this.openCanvas()}openCanvas(){this.closeCanvas();let e=document.createElement(`div`);e.className=`dw-bridge-canvas`,document.body.append(e),this.canvasEl=e,this.el.hidden=!0,this.canvas=$Q(e,{provider:this.provider??void 0,content:this.provider?void 0:this.lastContent??this.editor.getJSON(),editable:this.editable&&!!this.provider,pageTitle:()=>this.title,onNavigate:e=>this.send({type:`navigate`,path:e}),onError:e=>this.send({type:`error`,message:e instanceof Error?e.message:String(e)})})}closeCanvas(){this.canvas?.destroy(),this.canvas=null,this.canvasEl?.remove(),this.canvasEl=null,this.el.hidden=!1}create(e){return this.el.replaceChildren(),new Bp({element:this.el,editable:this.editable,extensions:bZ({...e,files:this.files,labels:this.labels,children:()=>this.requestSubpages(),onNavigate:e=>this.send({type:`navigate`,path:e})}),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:()=>this.reportState(),onTransaction:()=>this.reportState(),onFocus:()=>this.reportState(),onBlur:()=>this.reportState()})}get target(){return this.inner&&!this.inner.isDestroyed?this.inner:this.editor}track(e){let t=(e instanceof Element?e.closest(`.ProseMirror`):null)?.editor;t&&(this.setInner(t===this.editor?null:t),this.reportState())}innerChanged=()=>this.reportState();innerGone=()=>{this.setInner(null),this.reportState()};setInner(e){if(e!==this.inner){if(this.inner){for(let e of[`selectionUpdate`,`transaction`,`focus`,`blur`])this.inner.off(e,this.innerChanged);this.inner.off(`destroy`,this.innerGone)}if(this.inner=e,e){for(let t of[`selectionUpdate`,`transaction`,`focus`,`blur`])e.on(t,this.innerChanged);e.on(`destroy`,this.innerGone)}}}reportOverlay(){let e=document.querySelector(y$)!==null;e!==this.overlay&&(this.overlay=e,this.send({type:`overlay`,open:e}))}reportState(){let e=this.target;if(e.isDestroyed)return;let t={active:x$.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function C$(e){return YQ.parse(e.trim(),{async:!1,gfm:!0})}function w$(e){if(e.isDestroyed)return;let t=e.view.props.nodeViews??{},n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)]));e.view.setProps({nodeViews:n})}function T$(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var E$=new S$(document.getElementById(`editor`),T$);window.docwell={receive:e=>E$.receive(e)};</script>
<style rel="stylesheet" crossorigin>/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--font-serif:"Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style", Georgia, serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--dw-surface);--color-surface-sunken:var(--dw-surface-sunken);--color-surface-raised:var(--dw-surface-raised);--color-surface-hover:var(--dw-surface-hover);--color-line:var(--dw-line);--color-line-strong:var(--dw-line-strong);--color-ink:var(--dw-ink);--color-ink-muted:var(--dw-ink-muted);--color-ink-faint:var(--dw-ink-faint);--color-primary:var(--dw-primary);--color-primary-hover:var(--dw-primary-hover);--color-on-primary:var(--dw-on-primary);--color-accent:var(--dw-accent);--color-accent-soft:var(--dw-accent-soft);--color-selection:var(--dw-selection);--color-focus-ring:var(--dw-focus-ring);--color-success:var(--dw-success);--color-success-soft:var(--dw-success-soft);--color-warning:var(--dw-warning);--color-warning-soft:var(--dw-warning-soft);--color-danger:var(--dw-danger);--color-danger-soft:var(--dw-danger-soft);--color-on-danger:var(--dw-on-danger);--color-info:var(--dw-info);--color-info-soft:var(--dw-info-soft);--color-code-bg:var(--dw-code-bg);--text-ui-xs:12px;--text-ui-xs--line-height:16px;--text-ui-xs--letter-spacing:.01em;--text-ui-xs--font-weight:500;--text-ui-sm:13px;--text-ui-sm--line-height:18px;--text-ui-md:14px;--text-ui-md--line-height:20px;--text-doc-h1:30px;--text-doc-h1--line-height:38px;--text-doc-h2:24px;--text-doc-h2--line-height:32px;--text-doc-h3:18px;--text-doc-h3--line-height:28px;--text-doc-body:16px;--text-doc-body--line-height:27px;--text-code:14px;--text-code--line-height:22px;--shadow-menu:var(--dw-shadow-menu);--shadow-dialog:var(--dw-shadow-dialog);--container-doc:720px;--container-doc-wide:1040px;--spacing-control-sm:28px;--spacing-control-md:34px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-varLine truncated
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--font-serif:"Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style", Georgia, serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--dw-surface);--color-surface-sunken:var(--dw-surface-sunken);--color-surface-raised:var(--dw-surface-raised);--color-surface-hover:var(--dw-surface-hover);--color-line:var(--dw-line);--color-line-strong:var(--dw-line-strong);--color-ink:var(--dw-ink);--color-ink-muted:var(--dw-ink-muted);--color-ink-faint:var(--dw-ink-faint);--color-primary:var(--dw-primary);--color-primary-hover:var(--dw-primary-hover);--color-on-primary:var(--dw-on-primary);--color-accent:var(--dw-accent);--color-accent-soft:var(--dw-accent-soft);--color-selection:var(--dw-selection);--color-focus-ring:var(--dw-focus-ring);--color-success:var(--dw-success);--color-success-soft:var(--dw-success-soft);--color-warning:var(--dw-warning);--color-warning-soft:var(--dw-warning-soft);--color-danger:var(--dw-danger);--color-danger-soft:var(--dw-danger-soft);--color-on-danger:var(--dw-on-danger);--color-info:var(--dw-info);--color-info-soft:var(--dw-info-soft);--color-code-bg:var(--dw-code-bg);--text-ui-xs:12px;--text-ui-xs--line-height:16px;--text-ui-xs--letter-spacing:.01em;--text-ui-xs--font-weight:500;--text-ui-sm:13px;--text-ui-sm--line-height:18px;--text-ui-md:14px;--text-ui-md--line-height:20px;--text-doc-h1:30px;--text-doc-h1--line-height:38px;--text-doc-h2:24px;--text-doc-h2--line-height:32px;--text-doc-h3:18px;--text-doc-h3--line-height:28px;--text-doc-body:16px;--text-doc-body--line-height:27px;--text-code:14px;--text-code--line-height:22px;--shadow-menu:var(--dw-shadow-menu);--shadow-dialog:var(--dw-shadow-dialog);--container-doc:clamp(720px, 40vw, 960px);--container-doc-wide:clamp(1040px, 55vw, 1440px);--spacing-control-sm:28px;--spacing-control-md:34px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-moLine truncated
/*$vite$:1*/</style>
</head>
<body>
+45
View File
@@ -248,4 +248,49 @@ describe("EditorBridge AI", () => {
bridge.receive({ type: "setAi", transcribe: false, words });
expect(el.querySelector("[data-testid=file-transcribe]")).toBeNull();
});
it("inserts footnotes, status badges, tabs, page breaks and subpages from the toolbar", () => {
const { bridge, sent } = setup();
bridge.receive({ type: "setEditable", editable: true });
bridge.receive({ type: "setContent", content: doc });
bridge.receive({ type: "command", command: "footnote" });
bridge.receive({ type: "command", command: "status" });
const inline = JSON.stringify(bridge.content);
expect(inline).toContain('"type":"footnote"');
expect(inline).toContain('"type":"status"');
for (const command of ["pageBreak", "subpages", "tabs"] as const) {
bridge.receive({ type: "command", command });
}
const types = (bridge.content.content ?? []).map((n) => n.type);
expect(types).toEqual(expect.arrayContaining(["pageBreak", "subpages", "tabs"]));
const state = sent.filter((m) => m.type === "state").at(-1);
expect(state?.type === "state" && state.state.active).toContain("tabs");
});
it("opens the emoji list after a space", () => {
// jsdom draws no layout; the list scrolls its active row into view.
Element.prototype.scrollIntoView ??= () => {};
const { bridge } = setup();
bridge.receive({ type: "setEditable", editable: true });
bridge.receive({ type: "setContent", content: doc });
bridge.receive({ type: "command", command: "emoji" });
expect(JSON.stringify(bridge.content)).toContain("Hello :");
});
it("asks the app for the page's subpages and lists them", async () => {
const { bridge, sent, el } = setup();
bridge.receive({ type: "setContent", content: { type: "doc", content: [{ type: "subpages" }] } });
const ask = sent.find((m) => m.type === "subpages");
expect(ask).toBeDefined();
bridge.receive({
type: "subpageList",
id: ask!.type === "subpages" ? ask!.id : 0,
pages: [{ id: "c1", title: "Setup", icon: "🛠" }],
});
await Promise.resolve();
await Promise.resolve();
expect(el.querySelector(".dw-subpages a")?.getAttribute("href")).toBe("/p/c1");
expect(el.querySelector(".dw-subpages")?.textContent).toContain("Setup");
});
});
+43
View File
@@ -15,6 +15,7 @@ import {
type EditorMessage,
type EditorState,
type HostMessage,
type SubpageRef,
type TranscribeWords,
} from "./protocol";
@@ -39,6 +40,21 @@ const commands: Record<Command, (e: Editor) => boolean> = {
callout: (e) =>
e.isActive("callout") ? e.chain().focus().unsetCallout().run() : e.chain().focus().setCallout().run(),
table: (e) => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
footnote: (e) => e.chain().focus().insertFootnote().run(),
status: (e) => e.chain().focus().insertStatus().run(),
tabs: (e) => e.chain().focus().insertTabs().run(),
pageBreak: (e) => e.chain().focus().setPageBreak().run(),
// Opens the ":" emoji list, which starts after a space or at the start of a line.
emoji: (e) => {
const { $from } = e.state.selection;
const before = $from.parent.textBetween(Math.max(0, $from.parentOffset - 1), $from.parentOffset, "", " ");
return e
.chain()
.focus()
.insertContent(before && before !== " " ? " :" : ":")
.run();
},
subpages: (e) => e.chain().focus().insertSubpages().run(),
undo: (e) => e.chain().focus().undo().run(),
redo: (e) => e.chain().focus().redo().run(),
};
@@ -60,6 +76,7 @@ const activeChecks: [Command, (e: Editor) => boolean][] = [
["taskList", (e) => e.isActive("taskList")],
["callout", (e) => e.isActive("callout")],
["table", (e) => e.isActive("table")],
["tabs", (e) => e.isActive("tabs")],
];
/**
@@ -99,6 +116,9 @@ export class EditorBridge {
{ resolve: (html: string) => void; reject: (e: Error) => void }
>();
private nextTranscript = 1;
/** Subpage lists the app is looking up, by request id. */
private readonly pendingSubpages = new Map<number, (pages: SubpageRef[]) => void>();
private nextSubpages = 1;
/** The range "getSelection" reported, for "insertMarkdown". */
private picked: { editor: Editor; from: number; to: number } | null = null;
/**
@@ -237,11 +257,33 @@ export class EditorBridge {
else p.reject(new Error(msg.error || this.labels.blocks.transcribeFailed));
return;
}
case "subpageList": {
const done = this.pendingSubpages.get(msg.id);
this.pendingSubpages.delete(msg.id);
done?.(Array.isArray(msg.pages) ? msg.pages : []);
return;
}
default:
throw new Error(`unknown message ${(msg as { type: string }).type}`);
}
}
/** Asks the app for the page's subpages; an app that does not answer in 10 s lists none. */
private requestSubpages(): Promise<SubpageRef[]> {
const id = this.nextSubpages++;
return new Promise((resolve) => {
const timer = setTimeout(() => {
this.pendingSubpages.delete(id);
resolve([]);
}, 10_000);
this.pendingSubpages.set(id, (pages) => {
clearTimeout(timer);
resolve(pages);
});
this.send({ type: "subpages", id });
});
}
/** Asks the app to transcribe a file; resolves with the HTML to insert. */
private requestTranscript(src: string, name: string): Promise<string> {
const id = this.nextTranscript++;
@@ -319,6 +361,7 @@ export class EditorBridge {
...opts,
files: this.files,
labels: this.labels,
children: () => this.requestSubpages(),
onNavigate: (path) => this.send({ type: "navigate", path }),
}),
editorProps: { attributes: { class: "dw-prose" } },
+19 -2
View File
@@ -22,6 +22,12 @@ export type Command =
| "taskList"
| "callout"
| "table"
| "footnote"
| "status"
| "tabs"
| "pageBreak"
| "emoji"
| "subpages"
| "undo"
| "redo";
@@ -70,7 +76,16 @@ export type HostMessage =
id: number;
error?: string;
result?: { name: string; text: string; summary: string; summaryError?: string };
};
}
/** The answer to a "subpages" request: the page's child pages, in order. */
| { type: "subpageList"; id: number; pages: SubpageRef[] };
/** A child page the subpages block lists. */
export interface SubpageRef {
id: string;
title: string;
icon?: string;
}
/** The words of the Transcribe button and of what it inserts. */
export interface TranscribeWords {
@@ -109,7 +124,9 @@ export type EditorMessage =
| { type: "selection"; text: string; before: string }
/** The user asked to transcribe a file (src is its /api/v1/files/<id> path); answer with "transcribed". */
| { type: "transcribe"; id: number; src: string; name: string }
/** A subpages block wants the page's child pages; answer with "subpageList". */
| { type: "subpages"; id: number }
| { type: "error"; message: string };
/** Bumped when a message changes shape, so the app can refuse a stale bundle. */
export const PROTOCOL_VERSION = 4;
export const PROTOCOL_VERSION = 5;
+2 -1
View File
@@ -14,7 +14,8 @@
"./edgeless": "./src/edgeless.ts",
"./ai": "./src/ai.ts",
"./files": "./src/files.ts",
"./labels": "./src/labels.ts"
"./labels": "./src/labels.ts",
"./emoji": "./src/emoji.ts"
},
"scripts": {
"test": "vitest run"
+4 -3
View File
@@ -29,7 +29,7 @@ function inColumn(e: Editor, i: number): number {
}
describe("columns", () => {
it("inserts two to four columns from the slash menu and puts the caret in the first", () => {
it("inserts two to five columns from the slash menu and puts the caret in the first", () => {
const e = setup("<p></p>");
const cmd = filterCommands(slashCommands(englishLabels), "3 columns")[0];
expect(cmd?.id).toBe("columns3");
@@ -63,9 +63,10 @@ describe("columns", () => {
expect(row(e)?.content?.[2]?.content?.[0]?.content?.[0]?.text).toBe("B");
});
it("stops at four columns", () => {
it("stops at five columns", () => {
const e = setup("<p></p>");
e.commands.insertColumns(4);
e.commands.insertColumns(5);
expect(row(e)?.content).toHaveLength(5);
e.commands.setTextSelection(inColumn(e, 0));
expect(e.commands.addColumn()).toBe(false);
});
+2 -2
View File
@@ -19,7 +19,7 @@ declare module "@tiptap/core" {
}
export const minColumns = 2;
export const maxColumns = 4;
export const maxColumns = 5;
/** No column gets narrower than this share of the row (percent). */
const minWidth = 10;
@@ -60,7 +60,7 @@ function isEmptyColumn(col: PMNode): boolean {
}
/**
* Side-by-side columns: a row ("columns") of two to four columns, each
* Side-by-side columns: a row ("columns") of two to five columns, each
* holding ordinary blocks. Columns share the width equally until someone
* drags the line between two of them. On narrow screens they stack.
* Backspace in an empty column removes it, and a row left with one column
+182
View File
@@ -0,0 +1,182 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Editor, type JSONContent } from "@tiptap/core";
import { afterEach, describe, expect, it } from "vitest";
import { emojiMatches } from "./emojipicker";
import { docwellExtensions } from "./extensions";
import { cleanNoteContent, footnotesOf, noteText } from "./footnotes";
import { englishLabels } from "./labels";
import { mediaKind } from "./media";
import { filterCommands, slashCommands } from "./slash";
import { parseBlockLink, syncedPath } from "./syncedpage";
let editor: Editor | undefined;
afterEach(() => editor?.destroy());
function setup(content: string | JSONContent, opts: Parameters<typeof docwellExtensions>[0] = {}) {
editor = new Editor({ extensions: docwellExtensions(opts), content });
return editor;
}
const json = (e: Editor) => e.getJSON().content as JSONContent[];
describe("page breaks, status badges and footnotes", () => {
it("inserts a page break and reads it back from HTML", () => {
const e = setup("<p></p>");
e.commands.setPageBreak();
expect(json(e)[0]?.type).toBe("pageBreak");
const again = setup(e.getHTML());
expect(json(again)[0]?.type).toBe("pageBreak");
});
it("keeps a status badge's words and colour through HTML", () => {
const e = setup('<p>Plan <span data-type="status" data-color="green"> In review </span></p>');
expect(json(e)[0]?.content?.[1]).toMatchObject({ type: "status", attrs: { text: "In review", color: "green" } });
expect(e.getHTML()).toContain(">In review</span>");
expect(e.getText()).toBe("Plan In review");
});
it("gives a new status badge the default words", () => {
const e = setup("<p></p>");
e.commands.insertStatus();
expect(json(e)[0]?.content?.[0]).toMatchObject({ type: "status", attrs: { text: "To do", color: "gray" } });
});
it("numbers footnotes in reading order and keeps their text", () => {
const e = setup(
'<p>One<sup data-type="footnote" data-text="First"></sup> two<sup data-type="footnote" data-text="Second"></sup></p>',
);
expect(footnotesOf(e.state.doc).map((f) => f.text)).toEqual(["First", "Second"]);
expect(e.getHTML()).toContain('data-text="Second"');
});
});
describe("tabs", () => {
it("inserts two named tabs and puts the caret in the first", () => {
const e = setup("<p></p>");
e.commands.insertTabs();
const tabs = json(e)[0];
expect(tabs?.type).toBe("tabs");
expect(tabs?.content?.map((t) => t.attrs?.title)).toEqual(["Tab 1", "Tab 2"]);
expect(e.state.selection.$from.node(-1).type.name).toBe("tab");
});
it("reads tabs back from HTML", () => {
const e = setup(
'<div data-type="tabs"><div data-type="tab" data-title="Mac"><p>⌘</p></div>' +
'<div data-type="tab" data-title="Windows"><p>Ctrl</p></div></div>',
);
expect(json(e)[0]?.content?.[1]).toMatchObject({ type: "tab", attrs: { title: "Windows" } });
});
});
describe("video and audio", () => {
it("tells video from audio", () => {
expect(mediaKind("video/mp4", "a.mp4")).toBe("video");
expect(mediaKind("", "talk.m4a")).toBe("audio");
expect(mediaKind("application/pdf", "a.pdf")).toBeNull();
});
it("keeps a player's file through HTML", () => {
const e = setup(
'<video src="/api/v1/files/abc" data-name="demo.mp4"></video><audio src="/api/v1/files/def"></audio>',
);
expect(json(e)[0]).toMatchObject({ type: "video", attrs: { src: "/api/v1/files/abc", name: "demo.mp4" } });
expect(json(e)[1]).toMatchObject({ type: "audio", attrs: { src: "/api/v1/files/def" } });
});
});
describe("synced blocks", () => {
it("reads the page and block from a copied block link", () => {
expect(parseBlockLink("https://docs.example.com/p/Ab12_x#b-k3j9x2a1")).toEqual({
page: "Ab12_x",
block: "k3j9x2a1",
});
expect(parseBlockLink("/p/Ab12_x")).toBeNull();
expect(parseBlockLink("just text")).toBeNull();
});
it("stores the block on the synced page and links to it", () => {
const e = setup('<div data-type="syncedPage" data-page="Ab12" data-block="k3j9x2a1"></div>');
expect(json(e)[0]).toMatchObject({ type: "syncedPage", attrs: { page: "Ab12", block: "k3j9x2a1" } });
expect(e.getHTML()).toContain(`href="${syncedPath("Ab12", "k3j9x2a1")}"`);
});
});
describe("the slash menu", () => {
const all = slashCommands(
englishLabels,
{ resolve: (s) => s, upload: async () => ({ url: "", name: "", mime: "", size: 0 }) },
undefined,
{ search: async () => [], children: async () => [] },
);
const ids = (cmds: typeof all) => cmds.flatMap((c) => [c.id, ...(c.children ?? []).map((k) => k.id)]);
it("offers the blocks Docmost has", () => {
for (const id of [
"columns5",
"video",
"audio",
"pageBreak",
"footnote",
"tabs",
"status",
"emoji",
"subpages",
"syncedBlock",
]) {
expect(ids(all)).toContain(id);
}
});
it("finds them by name", () => {
expect(filterCommands(all, "page break")[0]?.id).toBe("pageBreak");
expect(filterCommands(all, "5 col")[0]?.id).toBe("columns5");
});
it("puts five columns in a row", () => {
const e = setup("<p></p>");
filterCommands(all, "5 columns")[0]!.run(e, { from: 1, to: 1 });
expect(json(e)[0]?.content).toHaveLength(5);
});
});
describe("emoji", () => {
it("finds emoji by word and offers some before a word is typed", () => {
expect(emojiMatches("thumbs")[0]?.char).toBe("👍");
expect(emojiMatches("").length).toBeGreaterThan(0);
});
});
describe("formatted footnotes", () => {
it("keeps text runs, marks and safe links, and drops anything else", () => {
const content = cleanNoteContent([
{ type: "text", text: "See " },
{ type: "text", text: "docs", marks: [{ type: "bold" }, { type: "link", attrs: { href: "https://x.dev" } }] },
{
type: "text",
text: "!",
marks: [{ type: "link", attrs: { href: "javascript:alert(1)" } }, { type: "heading" }],
},
{ type: "paragraph", content: [{ type: "text", text: "no" }] },
{ type: "hardBreak" },
]);
expect(content).toEqual([
{ type: "text", text: "See " },
{ type: "text", text: "docs", marks: [{ type: "bold" }, { type: "link", attrs: { href: "https://x.dev" } }] },
{ type: "text", text: "!" },
]);
expect(noteText(content)).toBe("See docs!");
expect(cleanNoteContent("text")).toBeNull();
});
it("keeps a footnote's formatted text through HTML", () => {
const content = [{ type: "text", text: "Bold", marks: [{ type: "bold" }] }];
const e = setup(
`<p>A<sup data-type="footnote" data-text="Bold" data-content='${JSON.stringify(content)}'></sup></p>`,
);
expect(footnotesOf(e.state.doc)[0]).toMatchObject({ text: "Bold", content });
const again = setup(e.getHTML());
expect(footnotesOf(again.state.doc)[0]?.content).toEqual(content);
});
});
+317
View File
@@ -2969,3 +2969,320 @@
.dark .dw-suggest-del {
--dw-suggest-del: #ff8a7a;
}
/* ---- Page break (pagebreak.ts): a labelled dashed line on screen, a new page in print ---- */
.dw-prose .dw-page-break {
position: relative;
height: 24px;
margin: 12px 0;
break-after: page;
}
.dw-prose .dw-page-break::before {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
border-top: 1px dashed var(--color-line-strong, var(--color-line));
}
.dw-prose .dw-page-break::after {
content: attr(data-label);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 0 8px;
background: var(--color-surface);
font-family: var(--font-sans);
font-size: 11px;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--color-ink-faint);
}
.dw-prose .dw-page-break.ProseMirror-selectednode::before {
border-top-color: var(--color-accent);
}
@media print {
.dw-prose .dw-page-break {
height: 0;
margin: 0;
}
.dw-prose .dw-page-break::before,
.dw-prose .dw-page-break::after {
display: none;
}
}
/* ---- Status badges (status.ts) ---- */
.dw-prose .dw-status {
display: inline-block;
padding: 0 6px;
border-radius: var(--radius-xs, 4px);
background: var(--dw-bg, var(--dw-bg-gray));
color: var(--dw-c, var(--dw-c-gray));
font-family: var(--font-sans);
font-size: 0.75em;
font-weight: 600;
line-height: 1.6;
letter-spacing: 0.02em;
text-transform: uppercase;
vertical-align: 0.1em;
white-space: nowrap;
cursor: default;
}
.dw-prose[contenteditable="true"] .dw-status {
cursor: pointer;
}
.dw-prose .dw-status.ProseMirror-selectednode {
outline: 2px solid var(--color-focus-ring);
outline-offset: 1px;
}
.dw-status-pop {
display: grid;
gap: 8px;
padding: 8px;
/* Room for all nine colours on one line. */
width: 240px;
}
.dw-status-pop__colors {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.dw-status-pop__swatch {
width: 20px;
height: 20px;
border: 1px solid var(--color-line);
border-radius: var(--radius-xs, 4px);
background: var(--dw-bg);
cursor: pointer;
}
.dw-status-pop__swatch[aria-checked="true"],
.dw-status-pop__swatch:hover {
outline: 2px solid var(--dw-c);
outline-offset: 1px;
}
/* ---- Emoji in the ":" list (emojipicker.ts) ---- */
.dw-suggest__icon--glyph {
font-size: 20px;
line-height: 1;
}
/* ---- Video and audio (media.ts) ---- */
.dw-prose .dw-media {
margin: 8px 0;
}
.dw-prose .dw-media video {
display: block;
width: 100%;
max-height: 70vh;
border-radius: var(--radius-md);
background: #000;
}
.dw-prose .dw-media audio {
display: block;
width: 100%;
}
.dw-prose .dw-media.ProseMirror-selectednode {
outline: 2px solid var(--color-focus-ring);
outline-offset: 2px;
border-radius: var(--radius-md);
}
/* ---- Footnotes (footnotes.ts): numbers in the text, notes at the end ---- */
.dw-prose sup.dw-footnote {
cursor: pointer;
font-family: var(--font-sans);
font-size: 0.7em;
font-weight: 600;
color: var(--color-accent);
}
.dw-prose sup.dw-footnote::after {
content: "[" attr(data-n) "]";
}
.dw-prose sup.dw-footnote.ProseMirror-selectednode {
outline: 2px solid var(--color-focus-ring);
border-radius: 2px;
}
.dw-prose .dw-footnotes {
margin-top: 32px;
padding-top: 8px;
border-top: 1px solid var(--color-line);
font-size: 0.875em;
color: var(--color-ink-muted);
}
.dw-prose .dw-footnotes ol {
margin: 0;
padding-left: 1.5em;
}
.dw-prose .dw-footnotes li {
margin: 2px 0;
}
.dw-prose[contenteditable="true"] .dw-footnotes__text {
cursor: text;
}
.dw-prose .dw-footnotes__back {
text-decoration: none;
color: var(--color-accent);
}
.dw-footnote-pop {
padding: 8px;
width: 300px;
}
.dw-footnote-pop__tools {
display: flex;
gap: 2px;
margin-bottom: 6px;
}
.dw-footnote-pop__tool {
display: grid;
place-items: center;
width: 26px;
height: 26px;
border: none;
border-radius: var(--radius-sm);
background: none;
color: var(--color-ink-muted);
cursor: pointer;
}
.dw-footnote-pop__tool:hover {
background: var(--color-surface-hover);
color: var(--color-ink);
}
.dw-footnote-pop__text .dw-footnote-pop__field {
min-height: 64px;
max-height: 40vh;
overflow-y: auto;
padding: 6px 8px;
border: 1px solid var(--color-line);
border-radius: var(--radius-sm);
background: var(--color-surface);
font-family: var(--font-sans);
font-size: 14px;
line-height: 1.5;
outline: none;
}
.dw-footnote-pop__text .dw-footnote-pop__field:focus {
border-color: var(--color-accent);
}
.dw-footnote-pop__field p {
margin: 0;
}
.dw-footnote-pop__field code,
.dw-prose .dw-footnotes code {
padding: 0 3px;
border-radius: 3px;
background: var(--color-surface-hover);
font-family: var(--font-mono);
font-size: 0.9em;
}
.dw-footnote-pop__field a,
.dw-footnote-pop__read a {
color: var(--color-accent);
}
.dw-footnote-pop__read {
font-family: var(--font-sans);
font-size: 14px;
line-height: 1.5;
}
/* ---- Tabs (tabs.ts) ---- */
.dw-prose .dw-tabs {
margin: 8px 0;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
}
.dw-tabs__strip {
display: flex;
align-items: center;
gap: 2px;
padding: 4px 4px 0;
border-bottom: 1px solid var(--color-line);
overflow-x: auto;
font-family: var(--font-sans);
font-size: var(--text-ui-md, 14px);
}
.dw-tabs__tab {
padding: 6px 12px;
border: none;
border-bottom: 2px solid transparent;
background: none;
color: var(--color-ink-muted);
font: inherit;
white-space: nowrap;
cursor: pointer;
}
.dw-tabs__tab:hover {
color: var(--color-ink);
}
.dw-tabs__tab.is-active {
border-bottom-color: var(--color-accent);
color: var(--color-ink);
font-weight: 600;
}
.dw-tabs__action {
display: grid;
place-items: center;
width: 24px;
height: 24px;
border: none;
border-radius: var(--radius-sm);
background: none;
color: var(--color-ink-muted);
font-size: 16px;
line-height: 1;
cursor: pointer;
}
.dw-tabs__action:hover {
background: var(--color-surface-hover);
}
.dw-tabs__delete {
margin-left: auto;
}
.dw-tabs__body {
padding: 4px 16px;
}
.dw-tabs__body > [hidden] {
display: none;
}
/* ---- Subpages (subpages.ts) ---- */
.dw-prose .dw-subpages {
margin: 8px 0;
font-family: var(--font-sans);
}
.dw-prose .dw-subpages ul {
margin: 0;
padding: 0;
list-style: none;
}
.dw-prose .dw-subpages__link {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 6px;
border-radius: var(--radius-sm);
color: var(--color-ink);
text-decoration: none;
}
.dw-prose .dw-subpages__link:hover {
background: var(--color-surface-hover);
}
.dw-prose .dw-subpages__link span:last-child {
border-bottom: 1px solid var(--color-line);
}
.dw-prose .dw-subpages__icon {
width: 16px;
text-align: center;
}
.dw-prose .dw-subpages__note {
margin: 0;
font-size: 13px;
color: var(--color-ink-muted);
}
/* ---- Synced blocks (syncedpage.ts): one block of another page ---- */
.dw-prose .dw-synced-hidden {
display: none !important;
}
+81
View File
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// The emoji the page icon picker and the editor's ":" picker offer, by group,
// each with English words to find it by. Any other emoji can still be typed
// or pasted into the search.
export type EmojiGroup = "smileys" | "people" | "nature" | "food" | "activity" | "travel" | "objects" | "symbols";
export interface Emoji {
char: string;
words: string;
}
const raw: Record<EmojiGroup, string> = {
smileys: `😀 grinning smile happy|😃 smiley happy|😄 smile laugh|😁 grin beam|😆 laughing|😅 sweat smile|🤣 rofl rolling laugh|😂 joy tears laugh|🙂 slight smile|🙃 upside down|😉 wink|😊 blush happy|😇 innocent halo angel|🥰 love hearts|😍 heart eyes love|🤩 star struck|😘 kiss blow|😋 yum tasty|😛 tongue|😜 wink tongue|🤪 zany crazy|🤑 money|🤗 hug|🤭 oops giggle|🤫 shush quiet|🤔 thinking|🤐 zipper mouth|😐 neutral|😑 expressionless|😶 no mouth|😏 smirk|😒 unamused|🙄 eye roll|😬 grimace|😌 relieved|😔 pensive sad|😪 sleepy|😴 sleeping|😷 mask sick|🤒 thermometer ill|🤯 mind blown exploding|🥳 party celebrate|😎 cool sunglasses|🤓 nerd geek|🧐 monocle|😕 confused|😟 worried|😮 surprised open mouth|😲 astonished|😳 flushed|🥺 pleading|😢 cry tear|😭 sob crying|😱 scream fear|😤 triumph steam|😡 angry rage|🤬 cursing|😈 devil|💀 skull dead|💩 poop|🤡 clown|👻 ghost|👽 alien|🤖 robot|😺 cat smile|❤️ heart love red`,
people: `👋 wave hello hi|🤚 raised back hand|✋ hand stop|👌 ok okay|✌️ victory peace|🤞 crossed fingers luck|🤟 love you|🤘 rock horns|👈 point left|👉 point right|👆 point up|👇 point down|☝️ index up|👍 thumbs up like yes|👎 thumbs down no|✊ fist|👊 punch|👏 clap applause|🙌 raised hands hooray|🤝 handshake deal|🙏 pray thanks please|✍️ writing|💪 muscle strong|🧠 brain|👀 eyes look|👁️ eye|👤 person user|👥 people users team|🧑‍💻 developer coder technologist|🧑‍🏫 teacher|🧑‍🎓 student|🧑‍🔬 scientist|🧑‍🎨 artist|🧑‍🍳 cook chef|🧑‍🔧 mechanic|🧑‍⚕️ doctor health|🧑‍💼 office worker business|🕵️ detective|👷 construction worker|🦸 superhero|🧙 wizard mage|🏃 running|🚶 walking|🧘 yoga meditation|👪 family|👶 baby`,
nature: `🐶 dog puppy|🐱 cat kitten|🐭 mouse|🐰 rabbit bunny|🦊 fox|🐻 bear|🐼 panda|🐨 koala|🐯 tiger|🦁 lion|🐮 cow|🐷 pig|🐸 frog|🐵 monkey|🐔 chicken|🐧 penguin|🐦 bird|🦉 owl|🦄 unicorn|🐝 bee|🐛 bug|🦋 butterfly|🐢 turtle|🐍 snake|🐙 octopus|🐬 dolphin|🐳 whale|🐟 fish|🦈 shark|🌵 cactus|🎄 christmas tree|🌲 evergreen tree|🌳 tree|🌴 palm|🌱 seedling sprout|🌿 herb|🍀 clover luck|🍁 maple leaf|🍂 fallen leaves autumn|🌷 tulip|🌹 rose|🌻 sunflower|🌸 blossom|💐 bouquet flowers|🍄 mushroom|🌍 earth world globe|🌙 moon night|⭐ star|🌟 glowing star|✨ sparkles|⚡ lightning zap|🔥 fire hot|🌈 rainbow|☀️ sun|⛅ cloud sun|☁️ cloud|🌧️ rain|❄️ snow snowflake|💧 droplet water|🌊 wave ocean sea`,
food: `🍏 green apple|🍎 apple red|🍐 pear|🍊 orange|🍋 lemon|🍌 banana|🍉 watermelon|🍇 grapes|🍓 strawberry|🫐 blueberries|🍒 cherries|🍑 peach|🥭 mango|🍍 pineapple|🥥 coconut|🥝 kiwi|🍅 tomato|🥑 avocado|🥦 broccoli|🥕 carrot|🌽 corn|🌶️ pepper hot|🥔 potato|🍞 bread|🥐 croissant|🧀 cheese|🥚 egg|🍳 cooking|🥞 pancakes|🥓 bacon|🍔 burger|🍟 fries|🍕 pizza|🌭 hot dog|🌮 taco|🌯 burrito|🥗 salad|🍝 pasta spaghetti|🍜 ramen noodles|🍣 sushi|🍱 bento|🍦 ice cream|🍩 doughnut|🍪 cookie|🎂 birthday cake|🍰 cake|🧁 cupcake|🍫 chocolate|🍬 candy|🍿 popcorn|☕ coffee|🍵 tea|🧃 juice|🥤 drink|🍺 beer|🍷 wine|🍸 cocktail|🥂 cheers champagne|🍽️ dinner plate`,
activity: `⚽ soccer football|🏀 basketball|🏈 american football|⚾ baseball|🎾 tennis|🏐 volleyball|🏉 rugby|🎱 billiards|🏓 ping pong|🏸 badminton|🥅 goal|⛳ golf|🏹 archery|🎣 fishing|🥊 boxing|🎽 running shirt|⛸️ ice skate|🎿 ski|🏂 snowboard|🏋️ weights gym|🚴 cycling bike|🏆 trophy win|🥇 gold medal first|🥈 silver medal|🥉 bronze medal|🏅 medal|🎖️ military medal|🎫 ticket|🎪 circus|🎭 theatre drama|🎨 art palette paint|🎬 movie clapper film|🎤 microphone sing|🎧 headphones music|🎼 score|🎹 piano|🥁 drum|🎷 saxophone|🎺 trumpet|🎸 guitar|🎻 violin|🎲 dice game|♟️ chess|🎯 target goal dart|🎳 bowling|🎮 video game|🧩 puzzle|🎉 party popper tada|🎊 confetti|🎈 balloon|🎁 gift present`,
travel: `🚗 car|🚕 taxi|🚌 bus|🚎 trolleybus|🏎️ race car|🚓 police car|🚑 ambulance|🚒 fire engine|🚚 truck delivery|🚜 tractor|🛵 scooter|🚲 bicycle|🛴 kick scooter|🚂 train locomotive|🚆 train|🚇 metro subway|✈️ airplane flight|🛫 departure|🛬 arrival|🚀 rocket launch|🛸 ufo|🚁 helicopter|⛵ sailboat|🚤 speedboat|🚢 ship|⚓ anchor|🗺️ map|🧭 compass|🏔️ mountain snow|⛰️ mountain|🌋 volcano|🏕️ camping|🏖️ beach|🏝️ island|🏠 house home|🏡 garden home|🏢 office building|🏬 department store|🏭 factory|🏥 hospital|🏦 bank|🏨 hotel|🏪 shop store|🏫 school|🏛️ classical building|⛪ church|🏰 castle|🗼 tower|🗽 statue liberty|⛲ fountain|🌆 city|🌃 night city|🌉 bridge|🎡 ferris wheel|🎢 roller coaster|🚦 traffic light|🚧 construction|⛽ fuel`,
objects: `📄 page document|📃 curl page|📑 bookmark tabs|📝 memo note write|📋 clipboard|📌 pushpin pin|📍 location pin|📎 paperclip|🖇️ paperclips|📏 ruler|📐 triangle ruler|✂️ scissors|🗂️ dividers index|📁 folder|📂 open folder|🗃️ card box|🗄️ cabinet|🗑️ trash wastebasket|📅 calendar date|📆 tear off calendar|🗓️ spiral calendar|📇 card index|📈 chart up growth|📉 chart down|📊 bar chart stats|📒 ledger|📓 notebook|📔 notebook decorative|📕 book closed|📗 green book|📘 blue book|📙 orange book|📚 books library|📖 open book read|🔖 bookmark|🏷️ label tag|💼 briefcase work|💻 laptop computer|🖥️ desktop computer|⌨️ keyboard|🖱️ mouse computer|📱 phone mobile|☎️ telephone|📞 receiver call|📠 fax|🔋 battery|🔌 plug|💡 bulb idea|🔦 flashlight|🕯️ candle|💰 money bag|💳 card credit|🧾 receipt|✉️ envelope mail|📧 email|📨 incoming mail|📦 package box|📮 postbox|🔒 lock locked|🔓 unlocked|🔑 key|🗝️ old key|🔨 hammer|🛠️ tools|🔧 wrench|🔩 nut bolt|⚙️ gear settings|🧰 toolbox|🧲 magnet|🧪 test tube|🔬 microscope|🔭 telescope|📡 satellite|💊 pill|🩺 stethoscope|🛒 cart shopping|🎓 graduation cap|👑 crown|💎 gem diamond|⏰ alarm clock|⏳ hourglass|⌛ hourglass done|🕐 clock time|📷 camera photo|🎥 video camera|📺 television tv|📻 radio|🔔 bell notification|📣 megaphone announce|📢 loudspeaker|🔍 search magnifier|🧭 compass direction`,
symbols: `✅ check done yes|☑️ ballot check|✔️ check mark|❌ cross no|❎ cross button|➕ plus add|➖ minus|➗ divide|✖️ multiply|❓ question|❔ white question|❗ exclamation important|‼️ double exclamation|⚠️ warning|🚫 prohibited|⛔ no entry|🛑 stop|💯 hundred|🔴 red circle|🟠 orange circle|🟡 yellow circle|🟢 green circle|🔵 blue circle|🟣 purple circle|⚫ black circle|⚪ white circle|🟥 red square|🟧 orange square|🟨 yellow square|🟩 green square|🟦 blue square|🟪 purple square|⬛ black square|⬜ white square|🔶 orange diamond|🔷 blue diamond|♻️ recycle|⚛️ atom|☮️ peace|☯️ yin yang|♾️ infinity|💲 dollar|💱 exchange|©️ copyright|®️ registered|™️ trademark|🔝 top|🔜 soon|🆕 new|🆓 free|🆗 ok|🆙 up|🆒 cool|ℹ️ info information|🔤 abc letters|🔢 numbers|#️⃣ hash|➡️ right arrow|⬅️ left arrow|⬆️ up arrow|⬇️ down arrow|🔄 refresh sync|🔁 repeat|▶️ play|⏸️ pause|⏹️ stop|⏩ fast forward|💬 speech chat comment|💭 thought|🗯️ anger bubble|💤 sleep zzz|💥 boom collision|💫 dizzy|🎵 music note|🔗 link|🏁 finish flag|🚩 red flag|🏳️ white flag|🏴 black flag|💜 purple heart|💙 blue heart|💚 green heart|💛 yellow heart|🧡 orange heart|🖤 black heart|💔 broken heart`,
};
export const emojiGroups = Object.keys(raw) as EmojiGroup[];
export const emojiByGroup: Record<EmojiGroup, Emoji[]> = Object.fromEntries(
emojiGroups.map((g) => [
g,
raw[g].split("|").map((entry) => {
const [char = "", ...words] = entry.trim().split(" ");
return { char, words: words.join(" ") };
}),
]),
) as Record<EmojiGroup, Emoji[]>;
/** The emoji whose words start with every word of the query, in group order. */
export function searchEmoji(query: string): Emoji[] {
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
if (!terms.length) return [];
const seen = new Set<string>();
const out: Emoji[] = [];
for (const g of emojiGroups) {
for (const e of emojiByGroup[g]) {
if (seen.has(e.char)) continue;
const words = e.words.split(" ");
if (terms.every((t) => words.some((w) => w.startsWith(t)))) {
seen.add(e.char);
out.push(e);
}
}
}
return out;
}
/** Text that is itself an icon: a few characters with no letters or digits, as the server keeps at most 32 bytes. */
export function typedEmoji(text: string): string | null {
const t = text.trim();
if (!t || /[\p{L}\p{N}]/u.test(t) || new TextEncoder().encode(t).length > 32) return null;
return /\p{Extended_Pictographic}/u.test(t) ? t : null;
}
const recentKey = "docwell.recentEmoji";
/** The emoji this browser picked last, newest first. */
export function recentEmoji(): string[] {
try {
const list = JSON.parse(localStorage.getItem(recentKey) ?? "[]");
return Array.isArray(list) ? list.filter((x) => typeof x === "string").slice(0, 16) : [];
} catch {
return [];
}
}
export function rememberEmoji(char: string) {
try {
localStorage.setItem(recentKey, JSON.stringify([char, ...recentEmoji().filter((c) => c !== char)].slice(0, 16)));
} catch {
// Private windows may refuse storage; the picker works without it.
}
}
+58
View File
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Extension } from "@tiptap/core";
import { PluginKey } from "@tiptap/pm/state";
import Suggestion from "@tiptap/suggestion";
import { emojiByGroup, recentEmoji, rememberEmoji, searchEmoji, type Emoji } from "./emoji";
import type { EditorLabels } from "./labels";
import { floatingList } from "./suggestion";
/** What ":" offers before anything is typed: recent picks, then the first smileys and hands. */
function startingEmoji(): Emoji[] {
const recent = recentEmoji().map((char) => ({ char, words: "" }));
const seen = new Set(recent.map((e) => e.char));
const more = [...emojiByGroup.smileys.slice(0, 8), ...emojiByGroup.people.slice(12, 16)].filter(
(e) => !seen.has(e.char),
);
return [...recent, ...more].slice(0, 10);
}
/** The emoji ":" + query finds, at most ten. */
export function emojiMatches(query: string): Emoji[] {
return query.trim() ? searchEmoji(query).slice(0, 10) : startingEmoji();
}
/**
* Typing ":" after a space (or at the start of a line) and a word opens a
* list of emoji; picking one puts it in place of ":word".
*/
export const EmojiPicker = Extension.create<{ labels: EditorLabels | null }>({
name: "emojiPicker",
addOptions() {
return { labels: null };
},
addProseMirrorPlugins() {
const labels = this.options.labels;
return [
Suggestion<Emoji>({
editor: this.editor,
pluginKey: new PluginKey("emojiPicker"),
char: ":",
allowSpaces: false,
allow: ({ state, range }) => !state.doc.resolve(range.from).parent.type.spec.code,
items: ({ query }) => emojiMatches(query),
render: floatingList<Emoji>({
label: labels?.blocks.emoji ?? "Emoji",
empty: labels?.blocks.noEmoji ?? "No emoji found",
toItem: (e) => ({ label: e.words || e.char, glyph: e.char }),
pick: (p, e) => {
rememberEmoji(e.char);
p.editor.chain().focus().insertContentAt(p.range, e.char).run();
},
}),
}),
];
},
});
+44 -4
View File
@@ -15,17 +15,24 @@ import { DocwellCodeBlock } from "./codeblock";
import { DocwellHighlight, TextColor } from "./colors";
import { CommentHighlights } from "./comments";
import { DateMention } from "./dates";
import { SyncedPage, type SyncedPageHost } from "./syncedpage";
import { SyncedBlockFilter, SyncedPage, type SyncedPageHost } from "./syncedpage";
import type * as Y from "yjs";
import { DrawioBlock, ExcalidrawBlock, type ExcalidrawLoader } from "./diagrams";
import { Embed, LinkCard, type LinkHost } from "./embeds";
import { DocwellImage, FileAttachment, FileDrop, type FileHost } from "./files";
import { EmojiPicker } from "./emojipicker";
import { Footnote } from "./footnotes";
import { Audio, Video } from "./media";
import { PageBreak } from "./pagebreak";
import { Status } from "./status";
import { Subpages } from "./subpages";
import { Tab, Tabs } from "./tabs";
import { FindReplace } from "./find";
import { englishLabels, type EditorLabels } from "./labels";
import { docwellMath } from "./math";
import { docwellMention, type MentionHost } from "./mention";
import { MermaidBlock, type MermaidLoader } from "./mermaid";
import { PageLinks, type PageHost } from "./pagelinks";
import { PageLinks, type PageHost, type PageRef } from "./pagelinks";
import type { PdfLoader } from "./pdf";
import { SlashMenu, slashCommands } from "./slash";
import { Suggestions } from "./suggest";
@@ -49,6 +56,11 @@ export interface ExtensionOptions {
mentions?: MentionHost;
/** Finds pages for "[[" links. */
pages?: PageHost;
/**
* Lists the page's subpages for the subpages block, where the host has no
* PageHost (the mobile bridge); otherwise PageHost.children does.
*/
children?: () => Promise<PageRef[]>;
/** Fetches previews for link cards; without it cards show the address only. */
links?: LinkHost;
/**
@@ -69,6 +81,8 @@ export interface ExtensionOptions {
* without carets, undo or synced pages of its own.
*/
syncedDoc?: Y.Doc;
/** With syncedDoc: shows only the block with this id (a synced block). */
syncedBlock?: string;
/** Edits a database row's body (database/peek.ts): bound to this fragment of doc, without carets. */
rowBody?: { doc: Y.Doc; fragment: Y.XmlFragment };
/** The Draw.io embed address (default https://embed.diagrams.net). */
@@ -126,6 +140,15 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
Placeholder.configure({ placeholder: opts.placeholder ?? "Type '/' for commands…" }),
DocwellImage.configure({ host: opts.files }),
FileAttachment.configure({ host: opts.files, loadPdf: opts.loadPdf, labels }),
Video.configure({ host: opts.files }),
Audio.configure({ host: opts.files }),
PageBreak.configure({ labels }),
Status.configure({ labels }),
Footnote.configure({ labels }),
Tabs.configure({ labels }),
Tab,
Subpages.configure({ children: subpagesOf(opts), labels, onNavigate: opts.onNavigate }),
EmojiPicker.configure({ labels }),
DocwellCodeBlock.configure({ lineNumbers: opts.codeLineNumbers ?? false }),
HeadingShortcuts,
docwellAlign,
@@ -141,7 +164,15 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
docwellMention(labels, opts.mentions),
DateMention.configure({ labels, me: () => opts.mentions?.me, onOpen: opts.onOpenDate }),
SlashMenu.configure({
commands: slashCommands(labels, opts.files, opts.onError, opts.pages, !!opts.loadExcalidraw, opts.links),
commands: slashCommands(
labels,
opts.files,
opts.onError,
opts.pages,
!!opts.loadExcalidraw,
opts.links,
!!subpagesOf(opts),
),
labels,
}),
CommentHighlights.configure({ onSelect: opts.onCommentSelect }),
@@ -158,9 +189,10 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
labels,
onNavigate: opts.onNavigate,
// One level deep: a synced page's own synced pages show as links.
nested: (doc) =>
nested: (doc, block) =>
docwellExtensions({
syncedDoc: doc,
syncedBlock: block,
files: opts.files,
links: opts.links,
onNavigate: opts.onNavigate,
@@ -220,6 +252,7 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
];
// Database edits (DB_ORIGIN) are undone with the text they were made with.
const yUndoOptions = { trackedOrigins: [DB_ORIGIN] };
if (opts.syncedDoc && opts.syncedBlock) list.push(SyncedBlockFilter.configure({ block: opts.syncedBlock }));
if (opts.rowBody) {
list.push(Collaboration.configure({ document: opts.rowBody.doc, fragment: opts.rowBody.fragment, yUndoOptions }));
} else if (opts.rowFragmentReadOnly) {
@@ -235,6 +268,13 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
return list;
}
/** Where the subpages block reads the page's subpages, if anywhere. */
function subpagesOf(opts: ExtensionOptions): (() => Promise<PageRef[]>) | undefined {
if (opts.children) return opts.children;
const pages = opts.pages;
return pages?.children ? () => pages.children!() : undefined;
}
/**
* Another editor's caret with their name. The name is hidden from assistive
* tech, which would otherwise read it as part of the text.
+396
View File
@@ -0,0 +1,396 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Editor, Extension, mergeAttributes, Node, type JSONContent } from "@tiptap/core";
import type { Node as PMNode } from "@tiptap/pm/model";
import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state";
import { Decoration, DecorationSet, type EditorView } from "@tiptap/pm/view";
import StarterKit from "@tiptap/starter-kit";
import { h, popover } from "./database/dom";
import type { EditorLabels } from "./labels";
import { svgIcon } from "./suggestion";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
footnote: {
/** Inserts a footnote mark at the selection and opens it for its text. */
insertFootnote: (text?: string) => ReturnType;
};
}
}
/** The most text a footnote holds. */
const MAX_NOTE = 2000;
/** A footnote's plain text: at most 2000 characters. */
export function cleanFootnote(s: unknown): string {
return typeof s === "string" ? s.trim().slice(0, MAX_NOTE) : "";
}
/** The marks a footnote's text can carry. */
const noteMarks = new Set(["bold", "italic", "strike", "code", "underline", "link"]);
/** Link addresses a note may hold: the web, mail, and the app's own paths. */
const SAFE_HREF = /^(https?:\/\/|mailto:|\/(?!\/)|#)/i;
/**
* A footnote's formatted text: text runs (with bold, italic, strikethrough,
* code, underline and links) and line breaks. Anything else is dropped, and
* the text is cut at 2000 characters. Null when nothing is left.
*/
export function cleanNoteContent(v: unknown): JSONContent[] | null {
if (!Array.isArray(v)) return null;
const out: JSONContent[] = [];
let room = MAX_NOTE;
for (const raw of v) {
if (room <= 0 || !raw || typeof raw !== "object") continue;
const n = raw as JSONContent;
if (n.type === "hardBreak") {
out.push({ type: "hardBreak" });
continue;
}
if (n.type !== "text" || typeof n.text !== "string" || !n.text) continue;
const text = n.text.slice(0, room);
room -= text.length;
const marks = (n.marks ?? []).flatMap((m) => {
if (!m || !noteMarks.has(m.type)) return [];
if (m.type !== "link") return [{ type: m.type }];
const href = typeof m.attrs?.href === "string" ? m.attrs.href.trim() : "";
return SAFE_HREF.test(href) ? [{ type: "link", attrs: { href } }] : [];
});
out.push(marks.length ? { type: "text", text, marks } : { type: "text", text });
}
while (out.at(-1)?.type === "hardBreak") out.pop();
return out.length ? out : null;
}
/** The plain text of a footnote's formatted text. */
export function noteText(content: JSONContent[] | null): string {
return cleanFootnote((content ?? []).map((n) => (n.type === "hardBreak" ? "\n" : (n.text ?? ""))).join(""));
}
const markTags: Record<string, keyof HTMLElementTagNameMap> = {
bold: "strong",
italic: "em",
strike: "s",
code: "code",
underline: "u",
};
/** A footnote's text as DOM: its formatted text, or its plain text for notes without. */
export function noteDOM(content: JSONContent[] | null, text: string): DocumentFragment {
const frag = document.createDocumentFragment();
if (!content) {
frag.append(text);
return frag;
}
for (const n of content) {
if (n.type === "hardBreak") {
frag.append(document.createElement("br"));
continue;
}
let el: globalThis.Node = document.createTextNode(n.text ?? "");
for (const m of n.marks ?? []) {
let wrap: HTMLElement;
if (m.type === "link") {
const a = document.createElement("a");
a.href = String(m.attrs?.href ?? "");
a.rel = "noopener noreferrer";
a.target = "_blank";
wrap = a;
} else {
const tag = markTags[m.type];
if (!tag) continue;
wrap = document.createElement(tag);
}
wrap.append(el);
el = wrap;
}
frag.append(el);
}
return frag;
}
/** A footnote node's formatted text: its content, or its plain text as one run. */
function contentOf(node: PMNode): JSONContent[] | null {
return cleanNoteContent(node.attrs.content);
}
/** The footnotes of a document in reading order, with their positions. */
export function footnotesOf(doc: PMNode): { pos: number; text: string; content: JSONContent[] | null }[] {
const out: { pos: number; text: string; content: JSONContent[] | null }[] = [];
doc.descendants((node, pos) => {
if (node.type.name === "footnote")
out.push({ pos, text: cleanFootnote(node.attrs.text), content: contentOf(node) });
return true;
});
return out;
}
const key = new PluginKey<DecorationSet>("footnotes");
/** The schema of a footnote's text: one paragraph of formatted text. */
const NoteDoc = Node.create({ name: "doc", topNode: true, content: "paragraph" });
/** Opens the panel that shows a footnote and, while editing, changes it. */
function editFootnote(view: EditorView, pos: number, anchor: Element, labels: EditorLabels | null) {
const node = view.state.doc.nodeAt(pos);
if (!node || node.type.name !== "footnote") return;
const label = labels?.blocks.footnoteText ?? "Footnote text";
let mini: Editor | null = null;
popover(
anchor,
(box, close) => {
const initial =
contentOf(node) ?? (node.attrs.text ? [{ type: "text", text: cleanFootnote(node.attrs.text) }] : []);
if (!view.editable) {
box.append(
h("div", { class: "dw-footnote-pop__read" }, noteDOM(contentOf(node), cleanFootnote(node.attrs.text))),
);
return;
}
const save = (e: Editor) => {
const at = view.state.doc.nodeAt(pos);
if (!at || at.type.name !== "footnote") return;
const content = cleanNoteContent(e.getJSON().content?.[0]?.content ?? []);
const text = noteText(content);
if (text === at.attrs.text && JSON.stringify(content) === JSON.stringify(at.attrs.content ?? null)) return;
view.dispatch(view.state.tr.setNodeMarkup(pos, undefined, { ...at.attrs, text, content }));
};
const finish = () => {
close();
view.focus();
};
const field = h("div", { class: "dw-footnote-pop__text" });
const link = (e: Editor) => {
const now = String(e.getAttributes("link").href ?? "");
const href = window.prompt(labels?.format.linkPrompt ?? "Link address", now);
if (href === null) return;
if (!href.trim()) e.chain().focus().extendMarkRange("link").unsetLink().run();
else if (SAFE_HREF.test(href.trim()))
e.chain().focus().extendMarkRange("link").setLink({ href: href.trim() }).run();
};
mini = new Editor({
element: field,
extensions: [
NoteDoc,
StarterKit.configure({
document: false,
heading: false,
blockquote: false,
bulletList: false,
orderedList: false,
listItem: false,
listKeymap: false,
codeBlock: false,
horizontalRule: false,
dropcursor: false,
gapcursor: false,
trailingNode: false,
link: { openOnClick: false, autolink: true },
}),
Extension.create({
name: "footnoteKeys",
addKeyboardShortcuts: () => ({
// Enter closes the note; Shift+Enter breaks the line.
Enter: () => {
finish();
return true;
},
"Mod-k": ({ editor }) => {
link(editor);
return true;
},
}),
}),
],
content: { type: "doc", content: [{ type: "paragraph", content: initial }] },
editorProps: { attributes: { class: "dw-footnote-pop__field", "aria-label": label, role: "textbox" } },
onUpdate: ({ editor }) => save(editor),
});
const tool = (icon: "bold" | "italic" | "code" | "link", title: string, run: (e: Editor) => void) => {
const b = h("button", { type: "button", class: "dw-footnote-pop__tool", title, "aria-label": title });
b.append(svgIcon(icon, 15));
b.addEventListener("mousedown", (e) => e.preventDefault());
b.addEventListener("click", () => mini && run(mini));
return b;
};
const f = labels?.format;
const tools = h(
"div",
{ class: "dw-footnote-pop__tools", role: "toolbar" },
tool("bold", f?.bold ?? "Bold", (e) => e.chain().focus().toggleBold().run()),
tool("italic", f?.italic ?? "Italic", (e) => e.chain().focus().toggleItalic().run()),
tool("code", f?.code ?? "Inline code", (e) => e.chain().focus().toggleCode().run()),
tool("link", f?.link ?? "Link", link),
);
box.append(tools, field);
// Focus now, with the caret at the end: the panel is already in the page.
mini.commands.setTextSelection(mini.state.doc.content.size - 1);
mini.view.focus();
},
{
class: "dw-footnote-pop",
label,
onClose: () => {
mini?.destroy();
mini = null;
},
},
);
}
/**
* A footnote: a small number in the text that holds its note. Footnotes are
* numbered in reading order, and their notes are listed at the end of the
* page, each linking back to its number. Clicking a number opens its note.
* The note's formatted text is in content; text keeps it as plain text for
* search and for readers that only know plain notes.
*/
export const Footnote = Node.create<{ labels: EditorLabels | null }>({
name: "footnote",
group: "inline",
inline: true,
atom: true,
selectable: true,
addOptions() {
return { labels: null };
},
addAttributes() {
return {
text: {
default: "",
parseHTML: (el) => cleanFootnote(el.getAttribute("data-text") ?? el.getAttribute("title") ?? ""),
renderHTML: (a) => ({ "data-text": a.text, title: a.text }),
},
content: {
default: null,
parseHTML: (el) => {
try {
return cleanNoteContent(JSON.parse(el.getAttribute("data-content") ?? "null"));
} catch {
return null;
}
},
renderHTML: (a) => {
const c = cleanNoteContent(a.content);
return c ? { "data-content": JSON.stringify(c) } : {};
},
},
};
},
parseHTML() {
return [{ tag: "sup[data-type=footnote]" }];
},
renderHTML({ HTMLAttributes }) {
return ["sup", mergeAttributes(HTMLAttributes, { "data-type": "footnote", class: "dw-footnote" })];
},
renderText({ node }) {
return ` (${cleanFootnote(node.attrs.text)})`;
},
addCommands() {
return {
insertFootnote:
(text = "") =>
({ editor, tr, dispatch }) => {
const type = editor.schema.nodes.footnote!;
if (!dispatch) return true;
const from = tr.selection.from;
tr.replaceSelectionWith(type.create({ text: cleanFootnote(text) }), false);
// The new footnote opens for its text once it is drawn.
const labels = this.options.labels;
setTimeout(() => {
if (editor.isDestroyed) return;
const el = editor.view.nodeDOM(from);
if (el instanceof Element) editFootnote(editor.view, from, el, labels);
});
return true;
},
};
},
addProseMirrorPlugins() {
const labels = this.options.labels;
const decorate = (doc: PMNode) => {
const notes = footnotesOf(doc);
if (!notes.length) return DecorationSet.empty;
const marks = notes.map((n, i) =>
Decoration.node(n.pos, n.pos + 1, {
"data-n": String(i + 1),
id: `fnref-${i + 1}`,
"aria-label": (labels?.blocks.footnote ?? "Footnote {n}").replace("{n}", String(i + 1)),
}),
);
// The list at the end; its key changes with the notes so it is drawn again.
const sig = JSON.stringify(notes.map((n) => n.content ?? n.text));
const list = Decoration.widget(
doc.content.size,
(view) => {
const ol = h("ol", {});
notes.forEach((n, i) => {
const back = h(
"a",
{
href: `#fnref-${i + 1}`,
class: "dw-footnotes__back",
title: labels?.blocks.footnoteBack ?? "Back to the text",
"aria-label": labels?.blocks.footnoteBack ?? "Back to the text",
},
"↩",
);
back.addEventListener("click", (e) => {
e.preventDefault();
const target = view.dom.querySelector(`[id="fnref-${i + 1}"]`);
target?.scrollIntoView({ block: "center" });
});
const text = h("span", { class: "dw-footnotes__text" });
text.append(n.text || n.content ? noteDOM(n.content, n.text) : "…");
if (view.editable) {
text.addEventListener("click", (e) => {
// Links in the note open; a click elsewhere edits it.
if ((e.target as Element | null)?.closest?.("a")) return;
const at = footnotesOf(view.state.doc)[i];
const ref = view.dom.querySelector(`[id="fnref-${i + 1}"]`);
if (at && ref) editFootnote(view, at.pos, ref, labels);
});
}
ol.append(h("li", { id: `fn-${i + 1}` }, text, " ", back));
});
return h(
"section",
{ class: "dw-footnotes", contenteditable: "false", "aria-label": labels?.blocks.footnotes ?? "Footnotes" },
ol,
);
},
{ side: 1, key: `footnotes:${sig}`, ignoreSelection: true, stopEvent: () => true },
);
return DecorationSet.create(doc, [...marks, list]);
};
return [
new Plugin<DecorationSet>({
key,
state: {
init: (_c, state) => decorate(state.doc),
apply: (tr, old) => (tr.docChanged ? decorate(tr.doc) : old),
},
props: {
decorations: (state) => key.getState(state),
handleClickOn: (view, _pos, node, nodePos, event) => {
if (node.type.name !== "footnote") return false;
const el = view.nodeDOM(nodePos);
if (!(el instanceof Element)) return false;
event.preventDefault();
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, nodePos)));
editFootnote(view, nodePos, el, labels);
return true;
},
},
}),
];
},
});
+61
View File
@@ -129,6 +129,35 @@ export interface EditorLabels {
syncedLoading: string;
syncedDenied: string;
syncedSelf: string;
/** Synced blocks: a syncedPage that shows one block of another page. */
syncedBlock: string;
syncedBlockUrl: string;
syncedBlockInvalid: string;
syncedBlockMissing: string;
/** The dashed line where printing starts a new page. */
pageBreak: string;
/** An inline status badge and the panel that changes it. */
status: string;
statusDefault: string;
statusText: string;
statusColor: string;
/** Footnotes: the list at the end of the page and the panel that edits one. */
footnotes: string;
footnote: string;
footnoteText: string;
footnoteBack: string;
/** The tabs block. {n} in tabName is the tab's number. */
tabName: string;
addTab: string;
renameTab: string;
deleteTab: string;
/** The list of the page's subpages. */
subpages: string;
subpagesEmpty: string;
subpagesLoading: string;
/** ":" emoji. */
emoji: string;
noEmoji: string;
};
/** Suggesting mode (suggest.ts): the bar above the page and the card on a suggestion. count has {n} in it. */
suggest: {
@@ -218,6 +247,7 @@ export const englishLabels: EditorLabels = {
columns2: { label: "2 columns", description: "Two blocks side by side" },
columns3: { label: "3 columns", description: "Three blocks side by side" },
columns4: { label: "4 columns", description: "Four blocks side by side" },
columns5: { label: "5 columns", description: "Five blocks side by side" },
table: { label: "Table", description: "Rows and columns" },
quote: { label: "Quote", description: "Set text apart as a quote" },
code: { label: "Code block", description: "Monospaced code" },
@@ -241,6 +271,15 @@ export const englishLabels: EditorLabels = {
tomorrow: { label: "Tomorrow", description: "Insert tomorrow's date" },
yesterday: { label: "Yesterday", description: "Insert yesterday's date" },
now: { label: "Now", description: "Insert the date and time" },
video: { label: "Video", description: "Upload a video that plays on the page" },
audio: { label: "Audio", description: "Upload a recording that plays on the page" },
pageBreak: { label: "Page break", description: "Start a new page when printing" },
footnote: { label: "Footnote", description: "A numbered note at the end of the page" },
tabs: { label: "Tabs", description: "Content on several tabs" },
status: { label: "Status", description: "A coloured badge in the text" },
emoji: { label: "Emoji", description: "Pick an emoji (or type :)" },
subpages: { label: "Subpages", description: "List this page's subpages" },
syncedBlock: { label: "Synced block", description: "Show a block of another page, always up to date" },
},
format: {
bold: "Bold",
@@ -348,6 +387,28 @@ export const englishLabels: EditorLabels = {
transcribeHint: "Add a summary and the transcript below, with AI",
transcribing: "Transcribing…",
transcribeFailed: "The recording could not be transcribed.",
syncedBlock: "Synced block",
syncedBlockUrl: "Link to the block (copy it from the block's ⋮⋮ menu)",
syncedBlockInvalid: "That isn't a link to a block of a page.",
syncedBlockMissing: "This block is no longer on its page.",
pageBreak: "Page break",
status: "Status",
statusDefault: "To do",
statusText: "Status text",
statusColor: "Status colour",
footnotes: "Footnotes",
footnote: "Footnote {n}",
footnoteText: "Footnote text",
footnoteBack: "Back to the text",
tabName: "Tab {n}",
addTab: "Add a tab",
renameTab: "Tab name",
deleteTab: "Delete tab",
subpages: "Subpages",
subpagesEmpty: "This page has no subpages yet.",
subpagesLoading: "Loading subpages…",
emoji: "Emoji",
noEmoji: "No emoji found",
},
suggest: {
mode: "Suggesting",
+105
View File
@@ -0,0 +1,105 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node } from "@tiptap/core";
import type { FileHost } from "./files";
type Kind = "video" | "audio";
/** Whether an uploaded file plays as video or audio, or neither. */
export function mediaKind(mime: string, name: string): Kind | null {
if (mime.startsWith("video/") || /\.(mp4|webm|mov|m4v|ogv)$/i.test(name)) return "video";
if (mime.startsWith("audio/") || /\.(mp3|m4a|wav|ogg|oga|flac|aac|opus)$/i.test(name)) return "audio";
return null;
}
/**
* A video or a recording that plays on the page. Like images, the node
* stores the file's API path and draws it through FileHost.resolve.
*/
function mediaNode(kind: Kind) {
return Node.create<{ host?: FileHost }>({
name: kind,
group: "block",
atom: true,
draggable: true,
addOptions() {
return { host: undefined };
},
addAttributes() {
return {
src: { default: "" },
name: { default: "" },
mime: { default: "" },
};
},
parseHTML() {
return [
{
tag: `${kind}[src]`,
getAttrs: (el) => ({
src: el.getAttribute("src") ?? "",
name: el.getAttribute("data-name") ?? el.getAttribute("title") ?? "",
mime: el.getAttribute("data-mime") ?? "",
}),
},
];
},
renderHTML({ node, HTMLAttributes }) {
return [
kind,
mergeAttributes(HTMLAttributes, {
src: node.attrs.src,
controls: "",
preload: "metadata",
"data-name": node.attrs.name || null,
"data-mime": node.attrs.mime || null,
title: node.attrs.name || null,
}),
];
},
addNodeView() {
return ({ node }) => {
const host = this.options.host;
const dom = document.createElement("div");
dom.className = `dw-media dw-media--${kind}`;
dom.setAttribute("data-type", kind);
const player = document.createElement(kind);
player.controls = true;
player.preload = "metadata";
dom.append(player);
let shown = "";
const draw = (n: typeof node) => {
const src = String(n.attrs.src ?? "");
const url = host ? host.resolve(src) : src;
if (url !== shown) {
player.src = url;
shown = url;
}
const name = String(n.attrs.name ?? "");
player.title = name;
player.setAttribute("aria-label", name || kind);
};
draw(node);
return {
dom,
update: (n) => {
if (n.type !== node.type) return false;
draw(n);
return true;
},
// Playing, seeking and the volume are not edits.
stopEvent: (e) => e.target === player && e.type !== "dragstart",
ignoreMutation: () => true,
};
};
},
});
}
export const Video = mediaNode("video");
export const Audio = mediaNode("audio");
+54
View File
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node } from "@tiptap/core";
import type { EditorLabels } from "./labels";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
pageBreak: {
/** Puts a page break where the selection is. */
setPageBreak: () => ReturnType;
};
}
}
/**
* Where printing starts a new page. On screen it is a dashed line with a
* label; in print it takes no room and only breaks the page.
*/
export const PageBreak = Node.create<{ labels: EditorLabels | null }>({
name: "pageBreak",
group: "block",
atom: true,
selectable: true,
draggable: true,
addOptions() {
return { labels: null };
},
parseHTML() {
return [{ tag: "div[data-type=pageBreak]" }];
},
renderHTML({ HTMLAttributes }) {
return [
"div",
mergeAttributes(HTMLAttributes, {
"data-type": "pageBreak",
class: "dw-page-break",
style: "break-after: page",
"data-label": this.options.labels?.blocks.pageBreak ?? "Page break",
}),
];
},
addCommands() {
return {
setPageBreak:
() =>
({ commands }) =>
commands.insertContent([{ type: this.name }, { type: "paragraph" }]),
};
},
});
+2
View File
@@ -23,6 +23,8 @@ export interface PageHost {
* where the host allows). Without it the editor cannot make linked pages.
*/
create?(title: string): Promise<PageRef>;
/** The subpages of the page being edited, in the sidebar's order (for the subpages block). */
children?(): Promise<PageRef[]>;
}
/** The app path of a page; page links are ordinary links to it. */
+55 -1
View File
@@ -7,7 +7,9 @@ import type { IconName } from "@docwell/ui/icons";
import { insertDate, isoDate } from "./dates";
import { promptEmbed, promptLinkCard, type LinkHost } from "./embeds";
import { insertFiles, type FileHost } from "./files";
import { mediaKind } from "./media";
import { createLinkedPage, type PageHost } from "./pagelinks";
import { parseBlockLink } from "./syncedpage";
import type { EditorLabels } from "./labels";
import { floatingList } from "./suggestion";
@@ -44,6 +46,7 @@ export function slashCommands(
pages?: PageHost,
excalidraw = false,
links?: LinkHost,
subpages = !!pages?.children,
): SlashCommand[] {
const block = (
id: string,
@@ -89,7 +92,7 @@ export function slashCommands(
),
{
...block("columns", "columns", ["layout", "side by side", "split", "grid", "multi-column"], () => {}),
children: ([2, 3, 4] as const).map((n) =>
children: ([2, 3, 4, 5] as const).map((n) =>
block(`columns${n}`, "columns", ["columns", "layout", "side by side", String(n)], (e, r) =>
e.chain().focus().deleteRange(r).insertColumns(n).run(),
),
@@ -105,12 +108,27 @@ export function slashCommands(
block("code", "code", ["codeblock", "```", "snippet"], (e, r) =>
e.chain().focus().deleteRange(r).toggleCodeBlock().run(),
),
block("tabs", "tabs", ["tab", "tabbed", "switch", "panes"], (e, r) =>
e.chain().focus().deleteRange(r).insertTabs().run(),
),
block("toggle", "chevron-right", ["details", "collapse", "expand", "fold", ">"], (e, r) =>
e.chain().focus().deleteRange(r).setDetails().run(),
),
block("divider", "divider", ["hr", "rule", "line", "---"], (e, r) =>
e.chain().focus().deleteRange(r).setHorizontalRule().run(),
),
block("pageBreak", "page-break", ["print", "new page", "break", "pdf"], (e, r) =>
e.chain().focus().deleteRange(r).setPageBreak().run(),
),
block("footnote", "footnote", ["note", "reference", "citation", "source", "fn"], (e, r) =>
e.chain().focus().deleteRange(r).insertFootnote().run(),
),
block("status", "status", ["badge", "label", "state", "progress", "tag"], (e, r) =>
e.chain().focus().deleteRange(r).insertStatus().run(),
),
block("emoji", "smile", ["emoticon", "smiley", ":"], (e, r) =>
e.chain().focus().deleteRange(r).insertContent(":").run(),
),
block("toc", "list", ["contents", "outline", "headings", "index"], (e, r) =>
e.chain().focus().deleteRange(r).insertTableOfContents().run(),
),
@@ -157,6 +175,19 @@ export function slashCommands(
e.chain().focus().deleteRange(r).insertContent("![[").run(),
),
);
list.push(
block("syncedBlock", "copy", ["sync", "transclude", "mirror", "reuse", "block"], (e, r) => {
e.chain().focus().deleteRange(r).run();
const text = window.prompt(l.blocks.syncedBlockUrl, "");
if (text === null || !text.trim()) return;
const at = parseBlockLink(text);
if (!at) {
onError?.(new Error(l.blocks.syncedBlockInvalid));
return;
}
e.chain().focus().insertSyncedPage({ id: at.page, title: "", block: at.block }).run();
}),
);
if (pages.create) {
list.push(
block("newPage", "page-plus", ["page", "doc", "subpage", "create"], (e, r) => {
@@ -166,13 +197,36 @@ export function slashCommands(
);
}
}
if (subpages) {
list.push(
block("subpages", "layers", ["children", "child pages", "sub pages", "index", "contents"], (e, r) =>
e.chain().focus().deleteRange(r).insertSubpages().run(),
),
);
}
if (files?.upload) {
const upload = (accept: string) => (e: Editor, r: Range) => {
e.chain().focus().deleteRange(r).run();
void pickFiles(accept).then((picked) => insertFiles(e, files, picked).catch(onError));
};
// Video and audio play on the page; files that are neither are attached as files.
const uploadMedia = (accept: string) => (e: Editor, r: Range) => {
e.chain().focus().deleteRange(r).run();
void pickFiles(accept).then(async (picked) => {
for (const file of picked) {
const up = await files.upload!(file);
const kind = mediaKind(up.mime, up.name);
const node = kind
? { type: kind, attrs: { src: up.url, name: up.name, mime: up.mime } }
: { type: "fileAttachment", attrs: { url: up.url, name: up.name, size: up.size, mime: up.mime } };
e.chain().focus().insertContentAt(e.state.selection.to, node).run();
}
}).catch(onError);
};
list.push(
block("image", "image", ["picture", "photo", "img"], upload("image/*")),
block("video", "video", ["movie", "clip", "mp4", "player"], uploadMedia("video/*")),
block("audio", "music", ["sound", "recording", "podcast", "mp3", "voice"], uploadMedia("audio/*")),
block("file", "paperclip", ["attachment", "upload", "pdf"], upload("")),
block("drawio", "diagram", ["diagram", "diagrams.net", "draw", "chart", "uml"], (e, r) =>
e.chain().focus().deleteRange(r).insertDiagram("drawio").run(),
+173
View File
@@ -0,0 +1,173 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node } from "@tiptap/core";
import { isPaletteColor, palette, type PaletteColor } from "./colors";
import { h, popover } from "./database/dom";
import type { EditorLabels } from "./labels";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
status: {
/** Inserts a status badge at the selection. */
insertStatus: (attrs?: { text?: string; color?: PaletteColor }) => ReturnType;
};
}
}
/** Badge text: one line, at most 40 characters. */
export function cleanStatus(s: unknown): string {
return typeof s === "string" ? s.replace(/\s+/g, " ").trim().slice(0, 40) : "";
}
/**
* A coloured badge in the text ("In review"). Clicking it while editing
* opens a panel to change its words and colour.
*/
export const Status = Node.create<{ labels: EditorLabels | null }>({
name: "status",
group: "inline",
inline: true,
atom: true,
selectable: true,
addOptions() {
return { labels: null };
},
addAttributes() {
return {
text: {
default: "",
parseHTML: (el) => cleanStatus(el.textContent),
renderHTML: () => ({}),
},
color: {
default: "gray",
parseHTML: (el) => {
const c = el.getAttribute("data-color");
return isPaletteColor(c) ? c : "gray";
},
renderHTML: (a) => ({ "data-color": a.color }),
},
};
},
parseHTML() {
// Before the colour marks, which also read span[data-color].
return [{ tag: "span[data-type=status]", priority: 100 }];
},
renderHTML({ node, HTMLAttributes }) {
return [
"span",
mergeAttributes(HTMLAttributes, { "data-type": "status", class: "dw-status" }),
cleanStatus(node.attrs.text) || this.options.labels?.blocks.statusDefault || "Status",
];
},
renderText({ node }) {
return cleanStatus(node.attrs.text);
},
addCommands() {
return {
insertStatus:
(attrs) =>
({ commands }) =>
commands.insertContent([
{
type: this.name,
attrs: {
text: cleanStatus(attrs?.text) || this.options.labels?.blocks.statusDefault || "To do",
color: attrs?.color ?? "gray",
},
},
{ type: "text", text: " " },
]),
};
},
addNodeView() {
return ({ node, getPos, editor }) => {
const labels = this.options.labels;
let current = node;
const dom = document.createElement("span");
dom.className = "dw-status";
dom.setAttribute("data-type", "status");
dom.contentEditable = "false";
const draw = () => {
dom.setAttribute("data-color", String(current.attrs.color));
dom.textContent = cleanStatus(current.attrs.text) || labels?.blocks.statusDefault || "Status";
};
draw();
const set = (patch: Record<string, unknown>) => {
const pos = getPos();
if (typeof pos !== "number" || !editor.isEditable) return;
editor.view.dispatch(editor.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, ...patch }));
};
const open = () => {
if (!editor.isEditable) return;
popover(
dom,
(box, close) => {
const input = h("input", {
class: "dw-db-input",
"aria-label": labels?.blocks.statusText ?? "Status text",
maxlength: "40",
});
input.value = cleanStatus(current.attrs.text);
input.addEventListener("input", () => set({ text: cleanStatus(input.value) }));
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
e.preventDefault();
close();
editor.commands.focus();
}
});
const swatches = h("div", {
class: "dw-status-pop__colors",
role: "radiogroup",
"aria-label": labels?.blocks.statusColor ?? "Status colour",
});
for (const c of palette) {
const b = h("button", {
type: "button",
class: "dw-status-pop__swatch",
"data-color": c,
role: "radio",
"aria-checked": String(current.attrs.color === c),
"aria-label": labels?.colors[c] ?? c,
title: labels?.colors[c] ?? c,
});
b.addEventListener("click", () => {
set({ color: c });
swatches.querySelectorAll("button").forEach((x) => x.setAttribute("aria-checked", String(x === b)));
});
swatches.append(b);
}
box.append(input, swatches);
// The panel is already in the page, so the field can take focus now.
input.focus();
input.select();
},
{ class: "dw-status-pop", label: labels?.blocks.status ?? "Status" },
);
};
dom.addEventListener("mousedown", (e) => {
if (!editor.isEditable) return;
e.preventDefault();
open();
});
return {
dom,
update: (n) => {
if (n.type !== node.type) return false;
current = n;
draw();
return true;
},
ignoreMutation: () => true,
};
};
},
});
+112
View File
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node } from "@tiptap/core";
import type { EditorLabels } from "./labels";
import { pagePath, type PageRef } from "./pagelinks";
import { svgIcon } from "./suggestion";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
subpages: {
/** Puts a list of the page's subpages where the selection is. */
insertSubpages: () => ReturnType;
};
}
}
export interface SubpagesOptions {
/** Lists the page's subpages (PageHost.children); without it the block shows its name only. */
children?: () => Promise<PageRef[]>;
labels: EditorLabels | null;
onNavigate?: (path: string) => void;
}
/**
* The page's subpages, listed as links and read afresh each time the page
* is opened. The document stores only the block, not the list, so exports
* and readers without a host leave it out.
*/
export const Subpages = Node.create<SubpagesOptions>({
name: "subpages",
group: "block",
atom: true,
draggable: true,
addOptions() {
return { children: undefined, labels: null, onNavigate: undefined };
},
parseHTML() {
return [{ tag: "div[data-type=subpages]" }];
},
renderHTML({ HTMLAttributes }) {
return ["div", mergeAttributes(HTMLAttributes, { "data-type": "subpages" })];
},
addCommands() {
return {
insertSubpages:
() =>
({ commands }) =>
commands.insertContent([{ type: this.name }, { type: "paragraph" }]),
};
},
addNodeView() {
const { children, labels, onNavigate } = this.options;
return () => {
const dom = document.createElement("nav");
dom.className = "dw-subpages";
dom.setAttribute("data-type", "subpages");
dom.contentEditable = "false";
dom.setAttribute("aria-label", labels?.blocks.subpages ?? "Subpages");
const note = (text: string) => {
const p = document.createElement("p");
p.className = "dw-subpages__note";
p.textContent = text;
dom.replaceChildren(p);
};
const list = (items: PageRef[]) => {
if (!items.length) return note(labels?.blocks.subpagesEmpty ?? "This page has no subpages yet.");
const ul = document.createElement("ul");
for (const p of items) {
const li = document.createElement("li");
const a = document.createElement("a");
a.className = "dw-subpages__link";
a.href = pagePath(p.id);
if (p.icon) {
const icon = document.createElement("span");
icon.className = "dw-subpages__icon";
icon.textContent = p.icon;
a.append(icon);
} else a.append(svgIcon("page", 16));
const title = document.createElement("span");
title.textContent = p.title || "…";
a.append(title);
a.addEventListener("click", (e) => {
if (!onNavigate || e.ctrlKey || e.metaKey || e.shiftKey) return;
e.preventDefault();
onNavigate(pagePath(p.id));
});
li.append(a);
ul.append(li);
}
dom.replaceChildren(ul);
};
if (!children) {
note(labels?.blocks.subpages ?? "Subpages");
} else {
note(labels?.blocks.subpagesLoading ?? "Loading subpages…");
children()
.then(list)
.catch(() => note(labels?.blocks.subpagesEmpty ?? "This page has no subpages yet."));
}
return {
dom,
stopEvent: (e) => e.type === "click" && !!(e.target as Element | null)?.closest?.("a"),
ignoreMutation: () => true,
};
};
},
});
+6 -1
View File
@@ -9,6 +9,8 @@ export interface ListItem {
label: string;
description?: string;
icon?: IconName;
/** A character drawn instead of the icon, e.g. an emoji. */
glyph?: string;
}
const svgNS = "http://www.w3.org/2000/svg";
@@ -113,7 +115,10 @@ export function floatingList<T>(opts: {
});
const glyph = document.createElement("span");
glyph.className = "dw-suggest__icon";
glyph.append(svgIcon(it.icon ?? "text"));
if (it.glyph) {
glyph.classList.add("dw-suggest__icon--glyph");
glyph.textContent = it.glyph;
} else glyph.append(svgIcon(it.icon ?? "text"));
const text = document.createElement("span");
text.className = "dw-suggest__text";
const label = document.createElement("span");
+117 -15
View File
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Editor, mergeAttributes, Node, type AnyExtension, type Range } from "@tiptap/core";
import { PluginKey } from "@tiptap/pm/state";
import { Editor, Extension, mergeAttributes, Node, type AnyExtension, type Range } from "@tiptap/core";
import type { Node as PMNode } from "@tiptap/pm/model";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { Decoration, DecorationSet } from "@tiptap/pm/view";
import Suggestion from "@tiptap/suggestion";
import type * as Y from "yjs";
import type { EditorLabels } from "./labels";
@@ -28,18 +30,87 @@ export interface SyncedPageOptions {
pages?: PageHost;
labels: EditorLabels | null;
onNavigate?: (path: string) => void;
/** The extensions of the read-only editor that draws a synced page's document. */
nested?: (doc: Y.Doc) => AnyExtension[];
/** The extensions of the read-only editor that draws a synced page's document (or one block of it). */
nested?: (doc: Y.Doc, block?: string) => AnyExtension[];
}
declare module "@tiptap/core" {
interface Commands<ReturnType> {
syncedPage: {
insertSyncedPage: (page: PageRef) => ReturnType;
/** Inserts a synced page; with block, only that block of it (a synced block). */
insertSyncedPage: (page: PageRef & { block?: string }) => ReturnType;
};
}
}
const BLOCK_ID = /^[a-z0-9]{6,16}$/;
/** The app path a synced page links to: the page, or the block on it. */
export const syncedPath = (page: string, block: string) => (block ? `${pagePath(page)}#b-${block}` : pagePath(page));
/** Whether doc has a block with id. */
function hasBlock(doc: PMNode, id: string): boolean {
let found = false;
doc.descendants((n) => {
if (n.attrs.blockId === id) found = true;
return !found;
});
return found;
}
/**
* The page and block a link to a block points at ("…/p/<page>#b-<block>",
* as the block menu copies it), or null for any other text.
*/
export function parseBlockLink(text: string): { page: string; block: string } | null {
const m = /\/p\/([A-Za-z0-9_-]+)\/?(?:\?[^#\s]*)?#b-([a-z0-9]{6,16})$/.exec(text.trim());
return m ? { page: m[1]!, block: m[2]! } : null;
}
/**
* Hides every block of a synced page's document but the one with id (and,
* of the blocks that hold it, their other children), for a synced block.
*/
export const SyncedBlockFilter = Extension.create<{ block: string }>({
name: "syncedBlockFilter",
addOptions() {
return { block: "" };
},
addProseMirrorPlugins() {
const id = this.options.block;
return [
new Plugin({
key: new PluginKey("syncedBlockFilter"),
props: {
decorations: (state) => {
let target = -1;
state.doc.descendants((n, pos) => {
if (n.attrs.blockId === id) target = pos;
return target < 0;
});
const hide: Decoration[] = [];
const hidden = { class: "dw-synced-hidden" };
if (target < 0) {
state.doc.forEach((n, off) => hide.push(Decoration.node(off, off + n.nodeSize, hidden)));
return DecorationSet.create(state.doc, hide);
}
const $t = state.doc.resolve(target);
for (let d = 0; d <= $t.depth; d++) {
const keep = $t.index(d);
let at = d === 0 ? 0 : $t.start(d);
$t.node(d).forEach((c, _o, i) => {
if (i !== keep) hide.push(Decoration.node(at, at + c.nodeSize, hidden));
at += c.nodeSize;
});
}
return DecorationSet.create(state.doc, hide);
},
},
}),
];
},
});
/** Replaces range with a synced page. */
export function insertSyncedPage(editor: Editor, range: Range, page: PageRef) {
editor.chain().focus().deleteRange(range).insertSyncedPage(page).run();
@@ -77,6 +148,14 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
parseHTML: (el) => el.getAttribute("data-icon") ?? "",
renderHTML: (a) => (a.icon ? { "data-icon": a.icon } : {}),
},
block: {
default: "",
parseHTML: (el) => {
const b = el.getAttribute("data-block") ?? "";
return BLOCK_ID.test(b) ? b : "";
},
renderHTML: (a) => (a.block ? { "data-block": a.block } : {}),
},
folded: {
default: false,
parseHTML: (el) => el.hasAttribute("data-folded"),
@@ -94,7 +173,7 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
return [
"div",
mergeAttributes(HTMLAttributes, { "data-type": "syncedPage" }),
["a", { href: pagePath(String(node.attrs.page)) }, title],
["a", { href: syncedPath(String(node.attrs.page), String(node.attrs.block ?? "")) }, title],
];
},
@@ -104,7 +183,10 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
(page) =>
({ commands }) =>
commands.insertContent([
{ type: this.name, attrs: { page: page.id, title: page.title, icon: page.icon ?? "" } },
{
type: this.name,
attrs: { page: page.id, title: page.title, icon: page.icon ?? "", block: page.block ?? "" },
},
{ type: "paragraph" },
]),
};
@@ -142,16 +224,19 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
return ({ node: initial, editor, getPos }) => {
let node = initial;
const page = String(node.attrs.page);
const block = BLOCK_ID.test(String(node.attrs.block ?? "")) ? String(node.attrs.block) : "";
const path = syncedPath(page, block);
const dom = document.createElement("div");
dom.className = "dw-synced";
dom.dataset.type = "syncedPage";
if (block) dom.classList.add("dw-synced--block");
dom.contentEditable = "false";
const head = document.createElement("div");
head.className = "dw-synced__head";
const title = document.createElement("a");
title.className = "dw-synced__title";
title.href = pagePath(page);
title.href = path;
const badge = svgIcon("copy", 14);
badge.classList.add("dw-synced__badge");
const fold = document.createElement("button");
@@ -168,8 +253,8 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
const go = (e: Event) => {
e.preventDefault();
if (onNavigate) onNavigate(pagePath(page));
else window.location.assign(pagePath(page));
if (onNavigate) onNavigate(path);
else window.location.assign(path);
};
title.addEventListener("click", go);
open.addEventListener("click", go);
@@ -220,12 +305,26 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
note(labels.syncedDenied);
} else if (p.synced && !view) {
body.replaceChildren();
view = new Editor({
const v = new Editor({
element: body,
editable: false,
extensions: nested(p.doc),
extensions: nested(p.doc, block || undefined),
editorProps: { attributes: { class: "dw-prose" } },
});
view = v;
if (block) {
// A synced block whose block was deleted says so instead of showing nothing.
const missing = document.createElement("p");
missing.className = "dw-synced__note";
missing.textContent = labels.syncedBlockMissing;
const check = () => {
const gone = !hasBlock(v.state.doc, block);
if (gone && !missing.isConnected) body.append(missing);
else if (!gone) missing.remove();
};
v.on("update", check);
check();
}
}
};
stopWatch = p.onChange(refresh);
@@ -234,7 +333,8 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
function draw() {
const t = node.attrs.title as string;
title.textContent = `${node.attrs.icon ? `${node.attrs.icon} ` : ""}${t || labels.syncedPage}`;
const fallback = block ? labels.syncedBlock : labels.syncedPage;
title.textContent = `${node.attrs.icon ? `${node.attrs.icon} ` : ""}${t || fallback}`;
const isFolded = folded();
dom.classList.toggle("is-folded", isFolded);
fold.textContent = isFolded ? labels.syncedUnfold : labels.syncedFold;
@@ -259,14 +359,16 @@ export const SyncedPage = Node.create<SyncedPageOptions>({
if (editor.isEditable && (m.title !== node.attrs.title || m.icon !== node.attrs.icon)) {
set({ title: m.title, icon: m.icon });
} else {
title.textContent = `${m.icon ? `${m.icon} ` : ""}${m.title || labels.syncedPage}`;
const fallback = block ? labels.syncedBlock : labels.syncedPage;
title.textContent = `${m.icon ? `${m.icon} ` : ""}${m.title || fallback}`;
}
});
return {
dom,
update(next) {
if (next.type !== node.type || String(next.attrs.page) !== page) return false;
if (next.type !== node.type || String(next.attrs.page) !== page || String(next.attrs.block ?? "") !== block)
return false;
node = next;
draw();
return true;
+275
View File
@@ -0,0 +1,275 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node, type Editor } from "@tiptap/core";
import type { Node as PMNode } from "@tiptap/pm/model";
import { TextSelection } from "@tiptap/pm/state";
import type { EditorLabels } from "./labels";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
tabs: {
/** Puts a tabs block with two empty tabs where the selection is. */
insertTabs: () => ReturnType;
};
}
}
/** A tab's name: one line, at most 60 characters. */
export function cleanTabTitle(s: unknown): string {
return typeof s === "string" ? s.replace(/\s+/g, " ").trim().slice(0, 60) : "";
}
const tabName = (labels: EditorLabels | null, i: number) =>
(labels?.blocks.tabName ?? "Tab {n}").replace("{n}", String(i + 1));
function emptyTab(editor: Editor, title: string): PMNode {
const { schema } = editor.state;
return schema.nodes.tab!.create({ title }, schema.nodes.paragraph!.create());
}
/**
* Content on tabs: a row of tab names over the content of the chosen one.
* Which tab shows is each reader's own choice and is not saved. Editors
* add tabs with "+", rename one by double-clicking it, and delete the
* shown one with "×". Exports show every tab, one after another.
*/
export const Tabs = Node.create<{ labels: EditorLabels | null }>({
name: "tabs",
group: "block",
content: "tab+",
defining: true,
isolating: true,
draggable: true,
addOptions() {
return { labels: null };
},
parseHTML() {
return [{ tag: "div[data-type=tabs]" }];
},
renderHTML({ HTMLAttributes }) {
return ["div", mergeAttributes(HTMLAttributes, { "data-type": "tabs", class: "dw-tabs" }), 0];
},
addCommands() {
return {
insertTabs:
() =>
({ editor, tr, dispatch }) => {
const labels = this.options.labels;
const node = editor.schema.nodes.tabs!.create(null, [
emptyTab(editor, tabName(labels, 0)),
emptyTab(editor, tabName(labels, 1)),
]);
if (!dispatch) return true;
const from = tr.selection.from;
tr.replaceSelectionWith(node);
let start = -1;
tr.doc.nodesBetween(from, Math.min(from + node.nodeSize + 2, tr.doc.content.size), (n, pos) => {
if (start < 0 && n.type.name === "tabs") start = pos;
return start < 0;
});
if (start >= 0) tr.setSelection(TextSelection.create(tr.doc, start + 3));
tr.scrollIntoView();
return true;
},
};
},
addNodeView() {
return ({ node, getPos, editor }) => {
const labels = this.options.labels;
let current = node;
let active = 0;
const dom = document.createElement("div");
dom.className = "dw-tabs";
dom.setAttribute("data-type", "tabs");
const strip = document.createElement("div");
strip.className = "dw-tabs__strip";
strip.contentEditable = "false";
strip.setAttribute("role", "tablist");
const body = document.createElement("div");
body.className = "dw-tabs__body";
dom.append(strip, body);
const pos = () => {
const p = getPos();
return typeof p === "number" ? p : null;
};
/** The position of tab i's node. */
const tabPos = (i: number) => {
const p = pos();
if (p === null) return null;
let at = p + 1;
for (let k = 0; k < i; k++) at += current.child(k).nodeSize;
return at;
};
const show = () => {
[...body.children].forEach((el, i) => {
const hide = i !== active;
if ((el as HTMLElement).hidden !== hide) (el as HTMLElement).hidden = hide;
if (el.getAttribute("role") !== "tabpanel") el.setAttribute("role", "tabpanel");
});
};
// ProseMirror draws the tabs' content after this view and redraws a tab
// when it changes, so the panels are hidden again whenever they appear.
const panels = new MutationObserver(show);
panels.observe(body, { childList: true });
const rename = (i: number) => {
const at = tabPos(i);
if (at === null || !editor.isEditable) return;
const now = String(current.child(i).attrs.title ?? "");
const next = window.prompt(labels?.blocks.renameTab ?? "Tab name", now);
if (next === null) return;
const title = cleanTabTitle(next) || tabName(labels, i);
editor.view.dispatch(editor.state.tr.setNodeAttribute(at, "title", title));
};
const add = () => {
const p = pos();
if (p === null || !editor.isEditable) return;
const end = p + current.nodeSize - 1;
const tr = editor.state.tr.insert(end, emptyTab(editor, tabName(labels, current.childCount)));
active = current.childCount;
tr.setSelection(TextSelection.create(tr.doc, end + 2));
editor.view.dispatch(tr);
editor.view.focus();
};
const remove = (i: number) => {
const at = tabPos(i);
if (at === null || !editor.isEditable) return;
const tr = editor.state.tr;
if (current.childCount <= 1) {
const p = pos()!;
tr.delete(p, p + current.nodeSize);
} else {
tr.delete(at, at + current.child(i).nodeSize);
active = Math.max(0, Math.min(active, current.childCount - 2));
}
editor.view.dispatch(tr);
};
const choose = (i: number, focus = false) => {
active = i;
draw();
if (focus) (strip.children[i] as HTMLElement | undefined)?.focus();
};
function draw() {
active = Math.min(active, current.childCount - 1);
strip.replaceChildren();
current.forEach((tab, _o, i) => {
const b = document.createElement("button");
b.type = "button";
b.className = i === active ? "dw-tabs__tab is-active" : "dw-tabs__tab";
b.setAttribute("role", "tab");
b.setAttribute("aria-selected", String(i === active));
b.tabIndex = i === active ? 0 : -1;
b.textContent = cleanTabTitle(tab.attrs.title) || tabName(labels, i);
b.addEventListener("mousedown", (e) => e.preventDefault());
b.addEventListener("click", () => choose(i));
b.addEventListener("dblclick", () => rename(i));
b.addEventListener("keydown", (e) => {
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
e.preventDefault();
const n = current.childCount;
choose((i + (e.key === "ArrowRight" ? 1 : -1) + n) % n, true);
} else if (e.key === "F2") {
e.preventDefault();
rename(i);
}
});
strip.append(b);
});
if (editor.isEditable) {
const plus = document.createElement("button");
plus.type = "button";
plus.className = "dw-tabs__action";
plus.textContent = "+";
const addLabel = labels?.blocks.addTab ?? "Add a tab";
plus.title = addLabel;
plus.setAttribute("aria-label", addLabel);
plus.addEventListener("mousedown", (e) => e.preventDefault());
plus.addEventListener("click", add);
const del = document.createElement("button");
del.type = "button";
del.className = "dw-tabs__action dw-tabs__delete";
del.textContent = "×";
const delLabel = labels?.blocks.deleteTab ?? "Delete tab";
del.title = delLabel;
del.setAttribute("aria-label", delLabel);
del.addEventListener("mousedown", (e) => e.preventDefault());
del.addEventListener("click", () => remove(active));
strip.append(plus, del);
}
show();
}
draw();
return {
dom,
contentDOM: body,
update: (n) => {
if (n.type !== node.type) return false;
current = n;
// The caret moved into another tab (find, undo): show that one.
const p = pos();
const { from } = editor.state.selection;
if (p !== null && from > p && from < p + n.nodeSize) {
let at = p + 1;
n.forEach((c, _o, i) => {
if (from > at && from < at + c.nodeSize) active = i;
at += c.nodeSize;
});
}
draw();
return true;
},
stopEvent: (e) => strip.contains(e.target as globalThis.Node),
destroy: () => panels.disconnect(),
ignoreMutation: (m) => strip.contains(m.target) || (m.type === "attributes" && m.target.parentElement === body),
};
};
},
});
/** One tab: its name and its blocks. */
export const Tab = Node.create({
name: "tab",
content: "block+",
isolating: true,
defining: true,
addAttributes() {
return {
title: {
default: "",
parseHTML: (el) => cleanTabTitle(el.getAttribute("data-title")),
renderHTML: (a) => ({ "data-title": cleanTabTitle(a.title) }),
},
};
},
parseHTML() {
return [{ tag: "div[data-type=tab]" }];
},
renderHTML({ HTMLAttributes }) {
return ["div", mergeAttributes(HTMLAttributes, { "data-type": "tab", class: "dw-tab" }), 0];
},
addNodeView() {
return ({ node }) => {
const dom = document.createElement("div");
dom.className = "dw-tab";
dom.setAttribute("data-type", "tab");
return {
dom,
contentDOM: dom,
update: (n) => n.type === node.type,
// The tabs block shows and hides its tabs; that is not an edit to read back.
ignoreMutation: (m) => m.type === "attributes" && m.target === dom,
};
};
},
});
+5
View File
@@ -196,6 +196,11 @@ export const iconPaths = {
"M19 8v6",
"M16 11h6",
],
music: ["M9 18V5l11-2v13", "M6 15a3 3 0 1 0 0 6a3 3 0 1 0 0-6z", "M17 13a3 3 0 1 0 0 6a3 3 0 1 0 0-6z"],
tabs: ["M3 9h18v11H3z", "M3 9V5h6v4", "M9 5h6v4"],
"page-break": ["M6 3v5h12V3", "M6 21v-5h12v5", "M3 12h2", "M8 12h2", "M14 12h2", "M19 12h2"],
footnote: ["M4 7h10", "M9 7v12", "M17 4h2v5", "M16 9h4"],
status: ["M7 8h10a4 4 0 0 1 0 8H7a4 4 0 0 1 0-8z", "M8 12h.01"],
} as const;
export type IconName = keyof typeof iconPaths;
+31 -1
View File
@@ -9,7 +9,7 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
/// Protocol version this app speaks. The page reports its own in "ready".
const editorProtocolVersion = 4;
const editorProtocolVersion = 5;
/// Formatting the native toolbar can apply.
enum EditorCommand {
@@ -28,10 +28,19 @@ enum EditorCommand {
taskList,
callout,
table,
footnote,
status,
tabs,
pageBreak,
emoji,
subpages,
undo,
redo,
}
/// A child page a subpages block lists.
typedef Subpage = ({String id, String title, String icon});
/// Toolbar state reported by the page.
@immutable
class EditorState {
@@ -110,6 +119,10 @@ class EditorBridge extends ChangeNotifier {
/// out the result and pass it to [answerTranscript] with the same id.
void Function(int id, String src, String name)? onTranscribe;
/// Looks up the page's child pages, in order, when a subpages block is
/// shown; without it the block lists none.
Future<List<Subpage>> Function()? onSubpages;
Completer<({String text, String before})>? _selection;
/// Whether media files get a Transcribe button, with its words.
@@ -251,12 +264,29 @@ class EditorBridge extends ChangeNotifier {
} else {
handler(id, msg['src'] as String, msg['name'] as String);
}
case 'subpages':
unawaited(_answerSubpages(msg['id'] as int));
case 'error':
_error = msg['message'] as String;
notifyListeners();
}
}
/// Answers a "subpages" request; a failed lookup lists none.
Future<void> _answerSubpages(int id) async {
var pages = const <Subpage>[];
try {
pages = await onSubpages?.call() ?? const [];
} catch (_) {}
await _post({
'type': 'subpageList',
'id': id,
'pages': [
for (final p in pages) {'id': p.id, 'title': p.title, 'icon': p.icon},
],
});
}
Future<void> _post(Map<String, dynamic> msg) =>
evaluate('window.docwell.receive(${jsonEncode(jsonEncode(msg))})');
+10
View File
@@ -198,6 +198,16 @@ class EditorToolbar extends StatelessWidget {
(EditorCommand.table, Icons.table_chart_outlined, tr('table')),
(EditorCommand.blockquote, Icons.format_quote, tr('quote')),
(EditorCommand.codeBlock, Icons.code, tr('codeBlock')),
(EditorCommand.tabs, Icons.tab_outlined, tr('toolTabs')),
(EditorCommand.footnote, Icons.superscript, tr('toolFootnote')),
(EditorCommand.status, Icons.label_outline, tr('toolStatus')),
(EditorCommand.emoji, Icons.emoji_emotions_outlined, tr('toolEmoji')),
(EditorCommand.subpages, Icons.account_tree_outlined, tr('toolSubpages')),
(
EditorCommand.pageBreak,
Icons.insert_page_break_outlined,
tr('toolPageBreak'),
),
];
@override
+30
View File
@@ -196,6 +196,12 @@ const appStrings = <String, Map<String, String>>{
'table': 'Table',
'quote': 'Quote',
'codeBlock': 'Code block',
'toolTabs': 'Tabs',
'toolFootnote': 'Footnote',
'toolStatus': 'Status',
'toolEmoji': 'Emoji',
'toolSubpages': 'Subpages',
'toolPageBreak': 'Page break',
'undo': 'Undo',
'redo': 'Redo',
},
@@ -359,6 +365,12 @@ const appStrings = <String, Map<String, String>>{
'table': 'Tabela',
'quote': 'Cytat',
'codeBlock': 'Blok kodu',
'toolTabs': 'Karty',
'toolFootnote': 'Przypis',
'toolStatus': 'Status',
'toolEmoji': 'Emoji',
'toolSubpages': 'Podstrony',
'toolPageBreak': 'Podział strony',
'undo': 'Cofnij',
'redo': 'Ponów',
},
@@ -525,6 +537,12 @@ const appStrings = <String, Map<String, String>>{
'table': 'Tabelle',
'quote': 'Zitat',
'codeBlock': 'Codeblock',
'toolTabs': 'Tabs',
'toolFootnote': 'Fußnote',
'toolStatus': 'Status',
'toolEmoji': 'Emoji',
'toolSubpages': 'Unterseiten',
'toolPageBreak': 'Seitenumbruch',
'undo': 'Rückgängig',
'redo': 'Wiederholen',
},
@@ -692,6 +710,12 @@ const appStrings = <String, Map<String, String>>{
'table': 'Tableau',
'quote': 'Citation',
'codeBlock': 'Bloc de code',
'toolTabs': 'Onglets',
'toolFootnote': 'Note de bas de page',
'toolStatus': 'Statut',
'toolEmoji': 'Emoji',
'toolSubpages': 'Sous-pages',
'toolPageBreak': 'Saut de page',
'undo': 'Annuler',
'redo': 'Rétablir',
},
@@ -857,6 +881,12 @@ const appStrings = <String, Map<String, String>>{
'table': 'Tabla',
'quote': 'Cita',
'codeBlock': 'Bloque de código',
'toolTabs': 'Pestañas',
'toolFootnote': 'Nota al pie',
'toolStatus': 'Estado',
'toolEmoji': 'Emoji',
'toolSubpages': 'Subpáginas',
'toolPageBreak': 'Salto de página',
'undo': 'Deshacer',
'redo': 'Rehacer',
},
+9
View File
@@ -107,6 +107,15 @@ class _PageScreenState extends State<PageScreen> {
unawaited(loadEditorPage(_web, server: _api.baseUrl));
_bridge.onTranscribe = (id, src, _) =>
transcribeForEditor(_api, _bridge, id, src);
// Subpages blocks list the page's children, from the space's page tree.
_bridge.onSubpages = () async {
final page = _page ?? await _api.page(widget.pageId);
final nodes = await _api.pages(page.space);
return [
for (final n in nodes)
if (n.parent == page.id) (id: n.id, title: n.title, icon: n.icon),
];
};
_load();
}
+26
View File
@@ -100,4 +100,30 @@ void main() {
});
expect(sent.last['content']['text'], "it's \"quoted\" </script> \u2028");
});
test("answers a subpages request with the page's children", () async {
bridge.onSubpages = () async => [(id: 'c1', title: 'Setup', icon: '🛠')];
bridge.handleMessage('{"type":"subpages","id":3}');
await pumpEventQueue();
expect(sent.last, {
'type': 'subpageList',
'id': 3,
'pages': [
{'id': 'c1', 'title': 'Setup', 'icon': '🛠'},
],
});
});
test('answers a subpages request with none when the lookup fails', () async {
bridge.onSubpages = () async => throw StateError('offline');
bridge.handleMessage('{"type":"subpages","id":4}');
await pumpEventQueue();
expect(sent.last, {'type': 'subpageList', 'id': 4, 'pages': <Object>[]});
});
test('sends the new block commands by name', () async {
await bridge.run(EditorCommand.footnote);
await bridge.run(EditorCommand.pageBreak);
expect(sent.map((m) => m['command']), ['footnote', 'pageBreak']);
});
}
+1 -1
View File
@@ -16,7 +16,7 @@ import (
// equal share. Exports to Markdown, Word and PDF put the columns one after
// another; HTML keeps them side by side.
const maxColumns = 4
const maxColumns = 5
// newColumns is a row of columns around these bodies. Empty bodies are left
// out; fewer than two left are returned as plain blocks, and anything past
+3 -3
View File
@@ -68,10 +68,10 @@ func TestNotionAndConfluenceColumns(t *testing.T) {
}
}
func TestColumnsPastFourJoinTheFourth(t *testing.T) {
bodies := [][]Node{{cpara("1")}, {cpara("2")}, {cpara("3")}, {cpara("4")}, {cpara("5")}}
func TestColumnsPastFiveJoinTheFifth(t *testing.T) {
bodies := [][]Node{{cpara("1")}, {cpara("2")}, {cpara("3")}, {cpara("4")}, {cpara("5")}, {cpara("6")}}
row := newColumns(bodies, nil)[0]
if len(row.Content) != 4 || len(row.Content[3].Content) != 2 {
if len(row.Content) != 5 || len(row.Content[4].Content) != 2 {
t.Fatalf("row: %+v", row)
}
}
+34 -1
View File
@@ -26,12 +26,22 @@ type DOCXOptions struct {
// highlights, links and images are kept in a form FromDOCX reads back.
// Diagrams and embeds become links, formulas their LaTeX.
func DOCX(title string, doc Node, o DOCXOptions) ([]byte, error) {
doc = withoutSuggestions(expandDatabases(doc))
doc, notes := numberFootnotes(withoutSuggestions(expandDatabases(doc)))
w := &docxWriter{o: o}
if strings.TrimSpace(title) != "" {
w.para(paraProps{style: "Title"}, func() { w.text(title, runProps{}) })
}
w.blocks(doc.Content, blockCtx{})
// Footnotes are listed at the end, numbered like their marks in the text.
if len(notes) > 0 {
w.para(paraProps{rule: true}, nil)
for i, note := range notes {
w.para(paraProps{}, func() {
w.text(strconv.Itoa(i+1)+". ", runProps{bold: true})
w.inline(note, runProps{})
})
}
}
return w.pack(title)
}
@@ -376,6 +386,25 @@ func (w *docxWriter) block(n Node, ctx blockCtx) {
w.para(paraProps{align: "center"}, func() { w.text(n.attr("latex"), runProps{code: true}) })
case "horizontalRule":
w.para(paraProps{rule: true}, nil)
case "pageBreak":
w.b.WriteString(`<w:p><w:r><w:br w:type="page"/></w:r></w:p>`)
case "tabs":
for i, tab := range n.Content {
w.para(w.textPara(ctx), func() { w.text(tabTitle(tab, i), runProps{bold: true}) })
w.blocks(tab.Content, ctx)
}
case "video", "audio":
name := n.attr("name")
if name == "" {
name = n.Type
}
w.para(paraProps{}, func() { w.text(name, runProps{href: w.link(n.attr("src"))}) })
case "subpages":
for _, p := range w.o.Subpages {
w.para(paraProps{style: "ListParagraph", indent: 360 + ctx.depth*360}, func() {
w.text(p.label(), runProps{href: w.link("/p/" + p.ID)})
})
}
case "image":
w.image(n.attr("src"), n.attr("alt"))
case "drawio", "excalidraw":
@@ -547,6 +576,10 @@ func (w *docxWriter) inline(nodes []Node, base runProps) {
w.text("@"+mentionLabel(n), runProps{bold: true})
case "dateMention":
w.text(n.attr("date"), runProps{bold: true})
case "status":
w.text(statusText(n), runProps{bold: true, shade: strings.TrimPrefix(paletteBackground[statusColor(n)], "#")})
case "footnote":
w.text("["+footnoteNumber(n)+"]", runProps{color: "787878"})
default:
w.inline(n.Content, base)
}
+124 -3
View File
@@ -19,6 +19,28 @@ type Options struct {
// PageURL rewrites links to pages (/p/<id>, with an optional #fragment
// for a block), e.g. to files in a space export; nil keeps them.
PageURL func(id, fragment string) string
// Subpages are the exported page's child pages, in order, for its
// subpages blocks; without them those blocks are left out.
Subpages []PageLink
}
// PageLink is a page a subpages block lists.
type PageLink struct {
ID string
Title string
Icon string
}
// label is the page's icon and title as a link shows them.
func (p PageLink) label() string {
t := p.Title
if t == "" {
t = "Untitled"
}
if p.Icon != "" {
return p.Icon + " " + t
}
return t
}
var pageLink = regexp.MustCompile(`^/p/([A-Za-z0-9_-]+)/?(#[\w-]*)?$`)
@@ -45,11 +67,22 @@ var safeURL = regexp.MustCompile(`^(?i)(https?://|mailto:|/|#|\.{0,2}/|[^:/?#]+(
// HTML renders the document's body as HTML.
func HTML(doc Node, o Options) string {
doc = expandDatabases(doc)
doc, notes := numberFootnotes(expandDatabases(doc))
var b strings.Builder
for _, n := range doc.Content {
writeHTML(&b, n, o)
}
if len(notes) > 0 {
b.WriteString("<section class=\"footnotes\">\n<hr>\n<ol>\n")
for i, note := range notes {
fmt.Fprintf(&b, "<li id=\"fn-%d\">", i+1)
for _, n := range note {
writeHTML(&b, n, o)
}
fmt.Fprintf(&b, " <a href=\"#fnref-%d\">↩</a></li>\n", i+1)
}
b.WriteString("</ol>\n</section>\n")
}
return b.String()
}
@@ -145,6 +178,47 @@ func writeHTML(b *strings.Builder, n Node, o Options) {
b.WriteString("</code></pre>\n")
case "horizontalRule":
b.WriteString("<hr>\n")
case "pageBreak":
b.WriteString("<div data-type=\"pageBreak\" style=\"break-after:page\"></div>\n")
case "status":
c := n.attr("color")
if !isPaletteColor(c) {
c = "gray"
}
fmt.Fprintf(b, "<span data-type=\"status\" data-color=\"%s\" style=\"background:%s;color:%s;padding:0 6px;border-radius:4px;font-size:.8em;font-weight:600\">%s</span>",
c, paletteBackground[c], paletteText[c], html.EscapeString(statusText(n)))
case "footnote":
num := footnoteNumber(n)
fmt.Fprintf(b, "<sup data-type=\"footnote\" data-text=\"%s\" id=\"fnref-%s\"><a href=\"#fn-%s\">[%s]</a></sup>",
html.EscapeString(n.attr("text")), num, num, num)
case "tabs":
// Every tab is shown, its name as a heading over its content.
b.WriteString("<div data-type=\"tabs\">\n")
for i, tab := range n.Content {
fmt.Fprintf(b, "<div data-type=\"tab\" data-title=\"%s\">\n<h4>%s</h4>\n",
html.EscapeString(tab.attr("title")), html.EscapeString(tabTitle(tab, i)))
for _, c := range tab.Content {
writeHTML(b, c, o)
}
b.WriteString("</div>\n")
}
b.WriteString("</div>\n")
case "video", "audio":
src := o.file(n.attr("src"))
if !safeURL.MatchString(src) {
return
}
fmt.Fprintf(b, "<%s src=\"%s\" controls preload=\"metadata\" data-name=\"%s\"></%s>\n",
n.Type, html.EscapeString(src), html.EscapeString(n.attr("name")), n.Type)
case "subpages":
if len(o.Subpages) == 0 {
return
}
b.WriteString("<ul data-type=\"subpages\">\n")
for _, p := range o.Subpages {
fmt.Fprintf(b, "<li><a href=\"%s\">%s</a></li>\n", html.EscapeString(o.file("/p/"+p.ID)), html.EscapeString(p.label()))
}
b.WriteString("</ul>\n")
case "hardBreak":
b.WriteString("<br>")
case "image":
@@ -262,10 +336,18 @@ func writeHTMLText(b *strings.Builder, n Node, o Options) {
// Markdown renders the document as CommonMark (with ~~strikethrough~~).
func Markdown(doc Node, o Options) string {
doc = withoutSuggestions(expandDatabases(doc))
doc, notes := numberFootnotes(withoutSuggestions(expandDatabases(doc)))
w := &mdWriter{o: o}
w.blocks(doc.Content, "", "")
return strings.TrimRight(w.b.String(), "\n") + "\n"
out := strings.TrimRight(w.b.String(), "\n") + "\n"
if len(notes) > 0 {
// Footnote definitions, as GitHub and most Markdown tools read them.
out += "\n"
for i, note := range notes {
out += "[^" + strconv.Itoa(i+1) + "]: " + strings.ReplaceAll(w.inline(oneLine(note)), "\n", " ") + "\n"
}
}
return out
}
// MarkdownPage is Markdown with the title as a leading heading.
@@ -375,6 +457,41 @@ func (w *mdWriter) block(n Node, first, rest string) {
w.lines(fence+n.attr("language")+"\n"+text+"\n"+fence, first, rest)
case "horizontalRule":
w.lines("---", first, rest)
case "pageBreak":
// Markdown has no page break; tools that print Markdown read this HTML.
w.lines("<div style=\"break-after: page\"></div>", first, rest)
case "tabs":
for i, tab := range n.Content {
p := rest
if i == 0 {
p = first
} else {
w.b.WriteString(strings.TrimRight(rest, " ") + "\n")
}
w.lines("**"+escapeMD(tabTitle(tab, i))+"**", p, rest)
if len(tab.Content) > 0 {
w.b.WriteString(strings.TrimRight(rest, " ") + "\n")
w.blocks(tab.Content, rest, rest)
}
}
case "video", "audio":
src := w.o.file(n.attr("src"))
if !safeURL.MatchString(src) {
return
}
name := n.attr("name")
if name == "" {
name = n.Type
}
w.lines("["+escapeMD(name)+"]("+mdURL(src)+")", first, rest)
case "subpages":
for i, p := range w.o.Subpages {
pre := rest
if i == 0 {
pre = first
}
w.lines("- ["+escapeMD(p.label())+"]("+mdURL(w.o.file("/p/"+p.ID))+")", pre, rest)
}
case "image":
w.lines("!["+escapeMD(n.attr("alt"))+"]("+mdURL(w.o.file(n.attr("src")))+")", first, rest)
case "fileAttachment":
@@ -475,6 +592,10 @@ func (w *mdWriter) inline(nodes []Node) string {
b.WriteString("@" + escapeMD(mentionLabel(n)))
case "dateMention":
b.WriteString(escapeMD(n.attr("date")))
case "status":
b.WriteString("`" + strings.ReplaceAll(statusText(n), "`", "'") + "`")
case "footnote":
b.WriteString("[^" + footnoteNumber(n) + "]")
default:
b.WriteString(w.inline(n.Content))
}
+108
View File
@@ -0,0 +1,108 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package convert
import (
"encoding/json"
"strconv"
)
// numberFootnotes returns a copy of doc in which each footnote carries its
// number (attr "n") in reading order, and the footnotes' texts (see
// footnoteContent) in that order. Exports show the number in the text and
// list the notes at the end, as the editor does.
func numberFootnotes(doc Node) (Node, [][]Node) {
var notes [][]Node
var walk func(n Node) Node
walk = func(n Node) Node {
if n.Type == "footnote" {
notes = append(notes, footnoteContent(n))
attrs := make(map[string]any, len(n.Attrs)+1)
for k, v := range n.Attrs {
attrs[k] = v
}
attrs["n"] = float64(len(notes))
n.Attrs = attrs
return n
}
if len(n.Content) > 0 {
content := make([]Node, len(n.Content))
for i, c := range n.Content {
content[i] = walk(c)
}
n.Content = content
}
return n
}
return walk(doc), notes
}
// footnoteContent is a footnote's text as inline nodes: its formatted text
// (attr "content": text runs with marks, and line breaks), or its plain text
// (attr "text") as one run for notes without.
func footnoteContent(n Node) []Node {
if raw, ok := n.Attrs["content"].([]any); ok && len(raw) > 0 {
var nodes []Node
if b, err := json.Marshal(raw); err == nil && json.Unmarshal(b, &nodes) == nil {
kept := nodes[:0]
for _, c := range nodes {
if (c.Type == "text" && c.Text != "") || c.Type == "hardBreak" {
c.Content = nil
kept = append(kept, c)
}
}
if len(kept) > 0 {
return kept
}
}
}
if t := n.attr("text"); t != "" {
return []Node{{Type: "text", Text: t}}
}
return nil
}
// oneLine turns a note's line breaks into spaces, for formats where a note
// must stay on one line.
func oneLine(nodes []Node) []Node {
out := make([]Node, len(nodes))
for i, n := range nodes {
if n.Type == "hardBreak" {
n = Node{Type: "text", Text: " "}
}
out[i] = n
}
return out
}
// footnoteNumber is a numbered footnote's number as text ("1"), or "*".
func footnoteNumber(n Node) string {
if v := n.intAttr("n", 0); v > 0 {
return strconv.Itoa(v)
}
return "*"
}
// statusText is a status badge's words.
func statusText(n Node) string {
if t := n.attr("text"); t != "" {
return t
}
return "Status"
}
// statusColor is a status badge's palette colour, grey when it has none.
func statusColor(n Node) string {
if c := n.attr("color"); isPaletteColor(c) {
return c
}
return "gray"
}
// tabTitle is a tab's name, or "Tab <i+1>" for one without.
func tabTitle(n Node, i int) string {
if t := n.attr("title"); t != "" {
return t
}
return "Tab " + strconv.Itoa(i+1)
}
+128
View File
@@ -0,0 +1,128 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package convert
import (
"bytes"
"strings"
"testing"
)
const docmostBlocks = `{"type":"doc","content":[
{"type":"paragraph","content":[{"type":"text","text":"Plan "},
{"type":"status","attrs":{"text":"In review","color":"green"}},
{"type":"text","text":" see"},{"type":"footnote","attrs":{"text":"First note"}},
{"type":"text","text":" and"},{"type":"footnote","attrs":{"text":"Second note"}}]},
{"type":"pageBreak"},
{"type":"tabs","content":[
{"type":"tab","attrs":{"title":"Mac"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Cmd"}]}]},
{"type":"tab","attrs":{"title":""},"content":[{"type":"paragraph","content":[{"type":"text","text":"Ctrl"}]}]}]},
{"type":"video","attrs":{"src":"/api/v1/files/v1","name":"demo.mp4"}},
{"type":"audio","attrs":{"src":"javascript:alert(1)","name":"x"}},
{"type":"subpages"},
{"type":"syncedPage","attrs":{"page":"P1","block":"k3j9x2a1"}}]}`
func TestDocmostBlocksExport(t *testing.T) {
doc, err := Parse([]byte(docmostBlocks))
if err != nil {
t.Fatal(err)
}
h := HTML(doc, Options{})
for _, want := range []string{
`data-type="status" data-color="green"`, `>In review</span>`,
`<a href="#fn-1">[1]</a>`, `<a href="#fn-2">[2]</a>`,
`<li id="fn-2">Second note <a href="#fnref-2">↩</a></li>`,
`break-after:page`,
`<h4>Mac</h4>`, `<h4>Tab 2</h4>`, `<p>Ctrl</p>`,
`<video src="/api/v1/files/v1" controls`,
`<a href="/p/P1#b-k3j9x2a1">Synced block</a>`,
} {
if !strings.Contains(h, want) {
t.Errorf("html lacks %q:\n%s", want, h)
}
}
if strings.Contains(h, "javascript:") {
t.Errorf("html keeps an unsafe media address:\n%s", h)
}
md := Markdown(doc, Options{})
for _, want := range []string{
"Plan `In review` see[^1] and[^2]",
"[^1]: First note\n[^2]: Second note\n",
"**Mac**\n\nCmd\n\n**Tab 2**\n\nCtrl",
"[demo.mp4](/api/v1/files/v1)",
} {
if !strings.Contains(md, want) {
t.Errorf("markdown lacks %q:\n%s", want, md)
}
}
if got := PlainText(doc.Content[0]); got != "Plan In review see (First note) and (Second note)" {
t.Errorf("plain text: %q", got)
}
if _, err := DOCX("T", doc, DOCXOptions{}); err != nil {
t.Errorf("docx: %v", err)
}
pdf, err := PDF("T", doc, PDFOptions{})
if err != nil || !bytes.HasPrefix(pdf, []byte("%PDF")) {
t.Errorf("pdf: %v", err)
}
}
func TestFootnotesAreNumberedWithoutChangingTheDocument(t *testing.T) {
doc, _ := Parse([]byte(docmostBlocks))
numbered, notes := numberFootnotes(doc)
if len(notes) != 2 || PlainText(Node{Content: notes[1]}) != "Second note" {
t.Fatalf("notes: %v", notes)
}
if footnoteNumber(numbered.Content[0].Content[5]) != "2" {
t.Errorf("second footnote: %+v", numbered.Content[0].Content[5])
}
if _, ok := doc.Content[0].Content[3].Attrs["n"]; ok {
t.Error("numbering changed the original document")
}
}
func TestFormattedFootnotesAndSubpagesExport(t *testing.T) {
doc, err := Parse([]byte(`{"type":"doc","content":[
{"type":"paragraph","content":[{"type":"text","text":"See"},
{"type":"footnote","attrs":{"text":"Read the guide now","content":[
{"type":"text","text":"Read "},
{"type":"text","text":"the guide","marks":[{"type":"bold"},{"type":"link","attrs":{"href":"https://example.com"}}]},
{"type":"hardBreak"},
{"type":"text","text":"now"},
{"type":"paragraph","content":[{"type":"text","text":"dropped"}]}]}}]},
{"type":"subpages"}]}`))
if err != nil {
t.Fatal(err)
}
o := Options{Subpages: []PageLink{{ID: "c1", Title: "Setup", Icon: "🛠"}, {ID: "c2"}}}
h := HTML(doc, o)
for _, want := range []string{
`<li id="fn-1">Read <strong><a href="https://example.com">the guide</a></strong><br>now <a href="#fnref-1">`,
`<ul data-type="subpages">`, `<li><a href="/p/c1">🛠 Setup</a></li>`, `<li><a href="/p/c2">Untitled</a></li>`,
} {
if !strings.Contains(h, want) {
t.Errorf("html lacks %q:\n%s", want, h)
}
}
if strings.Contains(h, "dropped") {
t.Errorf("html keeps a block inside a footnote:\n%s", h)
}
md := Markdown(doc, o)
for _, want := range []string{"[^1]: Read [**the guide**](https://example.com) now\n", "- [🛠 Setup](/p/c1)\n- [Untitled](/p/c2)"} {
if !strings.Contains(md, want) {
t.Errorf("markdown lacks %q:\n%s", want, md)
}
}
if strings.Contains(Markdown(doc, Options{}), "/p/c1") {
t.Error("subpages listed without any given")
}
if _, err := DOCX("T", doc, DOCXOptions{Options: o}); err != nil {
t.Errorf("docx: %v", err)
}
if _, err := PDF("T", doc, PDFOptions{Options: o}); err != nil {
t.Errorf("pdf: %v", err)
}
}
+18 -1
View File
@@ -51,8 +51,16 @@ func (n Node) card() (href, title string) {
if icon := n.attr("icon"); icon != "" && title != "" {
title = icon + " " + title
}
// A synced block shows one block of the page and links to it.
block := n.attr("block")
if block != "" {
href += "#b-" + block
}
if title == "" {
title = "Synced page"
if block != "" {
title = "Synced block"
}
}
return href, title
}
@@ -98,8 +106,17 @@ func Title(doc Node) (string, Node) {
// PlainText is the node's text with no formatting.
func PlainText(n Node) string {
if n.Type == "text" {
switch n.Type {
case "text":
return n.Text
case "status":
return n.attr("text")
case "footnote":
// Search finds a page by its footnotes too.
if t := n.attr("text"); t != "" {
return " (" + t + ")"
}
return ""
}
var s string
for _, c := range n.Content {
+52 -1
View File
@@ -42,7 +42,7 @@ const maxPDFImagePixels = 50_000_000
// heading and page numbers. Diagrams (stored as SVG) and Mermaid charts are
// not drawn: diagrams become a link to their file, Mermaid its source.
func PDF(title string, doc Node, o PDFOptions) (out []byte, err error) {
doc = withoutSuggestions(expandDatabases(doc))
doc, notes := numberFootnotes(withoutSuggestions(expandDatabases(doc)))
defer func() {
// fpdf panics on some input instead of failing; one bad page must
// not take the server down.
@@ -81,6 +81,20 @@ func PDF(title string, doc Node, o PDFOptions) (out []byte, err error) {
for _, n := range doc.Content {
w.block(n, 0, pdfGap)
}
// Footnotes are listed at the end, numbered like their marks in the text.
if len(notes) > 0 {
w.block(Node{Type: "horizontalRule"}, 0, pdfTightGap)
for i, note := range notes {
w.room(pdfLine)
w.at(0)
w.f.SetFont("go", "B", pdfBody-1)
w.ink()
w.f.Write(pdfLine, strconv.Itoa(i+1)+". ")
w.inline(note, "", pdfBody-1)
w.f.Ln(pdfLine)
w.f.Ln(pdfTightGap)
}
}
var buf bytes.Buffer
if err := f.Output(&buf); err != nil {
return nil, err
@@ -305,6 +319,33 @@ func (w *pdfWriter) block(n Node, indent, gap float64) {
w.f.Line(pdfMargin+indent, y, pdfMargin+w.width, y)
w.f.SetY(y + 1.5)
w.f.Ln(gap)
case "pageBreak":
w.f.AddPage()
case "tabs":
for i, tab := range n.Content {
w.at(indent)
w.f.SetFont("go", "B", pdfBody)
w.ink()
w.f.MultiCell(w.width-indent, pdfLine, pdfText(tabTitle(tab, i)), "", "L", false)
w.f.Ln(pdfTightGap)
for _, c := range tab.Content {
w.block(c, indent, gap)
}
}
case "video", "audio":
name := n.attr("name")
if name == "" {
name = n.Type
}
w.note(name, n.attr("src"), indent)
w.f.Ln(gap)
case "subpages":
for _, p := range w.o.Subpages {
w.note(p.label(), "/p/"+p.ID, indent)
}
if len(w.o.Subpages) > 0 {
w.f.Ln(gap)
}
case "image":
w.image(n.attr("src"), n.attr("alt"), indent)
w.f.Ln(gap)
@@ -400,6 +441,16 @@ func (w *pdfWriter) inline(nodes []Node, style string, size float64) {
w.f.SetFont("go", pdfStyle(style+"B"), size)
w.ink()
w.f.Write(pdfLine, pdfText(n.attr("date")))
case "status":
w.f.SetFont("go", pdfStyle(style+"B"), size-1)
w.f.SetTextColor(rgb(paletteText[statusColor(n)]))
w.f.Write(pdfLine, pdfText(strings.ToUpper(statusText(n))))
w.ink()
case "footnote":
w.f.SetFont("go", pdfStyle(style), size-2)
w.f.SetTextColor(120, 120, 120)
w.f.Write(pdfLine, pdfText("["+footnoteNumber(n)+"]"))
w.ink()
default:
w.inline(n.Content, style, size)
}
+9 -1
View File
@@ -45,6 +45,9 @@ type exportedPage struct {
rec pageRecord
path string // file inside the zip, e.g. "Guides/Setup.md"
depth int
// parent is the nearest exported page above this one ("" at the top),
// whose subpages blocks list this page.
parent string
}
type exportedFile struct {
@@ -83,7 +86,7 @@ func (s *Service) PrepareSpaceExport(ctx context.Context, c access.Caller, space
if dir != "" {
path = dir + "/" + path
}
e.pages = append(e.pages, exportedPage{rec: p, path: path, depth: depth})
e.pages = append(e.pages, exportedPage{rec: p, path: path, depth: depth, parent: shownParent})
under, d = p.ID, depth+1
underDir = strings.TrimSuffix(path, ext)
}
@@ -201,6 +204,11 @@ func (e *SpaceExport) render(ctx context.Context, p exportedPage) ([]byte, error
return e.s.publicURL + "/p/" + id + fragment
},
}
for _, c := range e.pages {
if c.parent == p.rec.ID {
opts.Subpages = append(opts.Subpages, convert.PageLink{ID: c.rec.ID, Title: c.rec.Title, Icon: c.rec.Icon})
}
}
if e.format == ".html" {
return []byte(convert.HTMLPage(p.rec.Title, doc, opts)), nil
}
+23
View File
@@ -60,6 +60,25 @@ func exportName(title, ext string) string {
return name + ext
}
// subpageLinks are the child pages of p that c can open, in order, for the
// subpages blocks in its content raw. Pages without one skip the lookup.
func (s *Service) subpageLinks(ctx context.Context, c access.Caller, p pageRecord, raw []byte) ([]convert.PageLink, error) {
if !bytes.Contains(raw, []byte(`"subpages"`)) {
return nil, nil
}
nodes, err := s.ListPages(ctx, c, p.Space)
if err != nil {
return nil, err
}
var out []convert.PageLink
for _, n := range nodes {
if n.Parent == p.ID {
out = append(out, convert.PageLink{ID: n.ID, Title: n.Title, Icon: n.Icon})
}
}
return out, nil
}
// ExportPage renders a page as Markdown ("markdown"), HTML ("html"), PDF
// ("pdf") or Word ("docx") (viewer).
func (s *Service) ExportPage(ctx context.Context, c access.Caller, id, format string) (Export, error) {
@@ -76,6 +95,10 @@ func (s *Service) ExportPage(ctx context.Context, c access.Caller, id, format st
return Export{}, err
}
opts := convert.Options{FileURL: func(path string) string { return s.publicURL + path }}
opts.Subpages, err = s.subpageLinks(ctx, c, p, raw)
if err != nil {
return Export{}, err
}
switch format {
case "markdown", "md", "":
return Export{
@@ -48,14 +48,26 @@ export function useEditorLabels() {
/**
* "[[" page links find pages in the page's workspace through search. With
* parent, the editor can also make new pages, as children of that page.
* With current (the page shown, also for readers), the subpages block
* lists its children.
*/
export function usePageLinks(
workspace: () => string | undefined,
parent?: () => { space: string; id: string } | undefined,
current?: () => { space: string; id: string } | undefined,
): PageHost {
const api = useApi();
const spaces = useSpacesStore();
return {
async children() {
const at = current?.();
if (!at) return [];
// The sidebar's tree when it has the space; the server's otherwise (a shared or linked page).
const nodes = spaces.space(at.space)
? spaces.childrenOf(at.space, at.id)
: (await api.spaces.pages(at.space)).filter((n) => n.parent === at.id);
return nodes.map((n) => ({ id: n.id, title: n.title, icon: n.icon }));
},
async create(title) {
const at = parent?.();
if (!at) throw new Error("no page to add the new page to");
+2 -78
View File
@@ -1,80 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// The emoji the page icon picker offers, by group, each with English words to
// find it by. Any other emoji can still be typed or pasted into the search.
export type EmojiGroup = "smileys" | "people" | "nature" | "food" | "activity" | "travel" | "objects" | "symbols";
export interface Emoji {
char: string;
words: string;
}
const raw: Record<EmojiGroup, string> = {
smileys: `😀 grinning smile happy|😃 smiley happy|😄 smile laugh|😁 grin beam|😆 laughing|😅 sweat smile|🤣 rofl rolling laugh|😂 joy tears laugh|🙂 slight smile|🙃 upside down|😉 wink|😊 blush happy|😇 innocent halo angel|🥰 love hearts|😍 heart eyes love|🤩 star struck|😘 kiss blow|😋 yum tasty|😛 tongue|😜 wink tongue|🤪 zany crazy|🤑 money|🤗 hug|🤭 oops giggle|🤫 shush quiet|🤔 thinking|🤐 zipper mouth|😐 neutral|😑 expressionless|😶 no mouth|😏 smirk|😒 unamused|🙄 eye roll|😬 grimace|😌 relieved|😔 pensive sad|😪 sleepy|😴 sleeping|😷 mask sick|🤒 thermometer ill|🤯 mind blown exploding|🥳 party celebrate|😎 cool sunglasses|🤓 nerd geek|🧐 monocle|😕 confused|😟 worried|😮 surprised open mouth|😲 astonished|😳 flushed|🥺 pleading|😢 cry tear|😭 sob crying|😱 scream fear|😤 triumph steam|😡 angry rage|🤬 cursing|😈 devil|💀 skull dead|💩 poop|🤡 clown|👻 ghost|👽 alien|🤖 robot|😺 cat smile|❤️ heart love red`,
people: `👋 wave hello hi|🤚 raised back hand|✋ hand stop|👌 ok okay|✌️ victory peace|🤞 crossed fingers luck|🤟 love you|🤘 rock horns|👈 point left|👉 point right|👆 point up|👇 point down|☝️ index up|👍 thumbs up like yes|👎 thumbs down no|✊ fist|👊 punch|👏 clap applause|🙌 raised hands hooray|🤝 handshake deal|🙏 pray thanks please|✍️ writing|💪 muscle strong|🧠 brain|👀 eyes look|👁️ eye|👤 person user|👥 people users team|🧑‍💻 developer coder technologist|🧑‍🏫 teacher|🧑‍🎓 student|🧑‍🔬 scientist|🧑‍🎨 artist|🧑‍🍳 cook chef|🧑‍🔧 mechanic|🧑‍⚕️ doctor health|🧑‍💼 office worker business|🕵️ detective|👷 construction worker|🦸 superhero|🧙 wizard mage|🏃 running|🚶 walking|🧘 yoga meditation|👪 family|👶 baby`,
nature: `🐶 dog puppy|🐱 cat kitten|🐭 mouse|🐰 rabbit bunny|🦊 fox|🐻 bear|🐼 panda|🐨 koala|🐯 tiger|🦁 lion|🐮 cow|🐷 pig|🐸 frog|🐵 monkey|🐔 chicken|🐧 penguin|🐦 bird|🦉 owl|🦄 unicorn|🐝 bee|🐛 bug|🦋 butterfly|🐢 turtle|🐍 snake|🐙 octopus|🐬 dolphin|🐳 whale|🐟 fish|🦈 shark|🌵 cactus|🎄 christmas tree|🌲 evergreen tree|🌳 tree|🌴 palm|🌱 seedling sprout|🌿 herb|🍀 clover luck|🍁 maple leaf|🍂 fallen leaves autumn|🌷 tulip|🌹 rose|🌻 sunflower|🌸 blossom|💐 bouquet flowers|🍄 mushroom|🌍 earth world globe|🌙 moon night|⭐ star|🌟 glowing star|✨ sparkles|⚡ lightning zap|🔥 fire hot|🌈 rainbow|☀️ sun|⛅ cloud sun|☁️ cloud|🌧️ rain|❄️ snow snowflake|💧 droplet water|🌊 wave ocean sea`,
food: `🍏 green apple|🍎 apple red|🍐 pear|🍊 orange|🍋 lemon|🍌 banana|🍉 watermelon|🍇 grapes|🍓 strawberry|🫐 blueberries|🍒 cherries|🍑 peach|🥭 mango|🍍 pineapple|🥥 coconut|🥝 kiwi|🍅 tomato|🥑 avocado|🥦 broccoli|🥕 carrot|🌽 corn|🌶️ pepper hot|🥔 potato|🍞 bread|🥐 croissant|🧀 cheese|🥚 egg|🍳 cooking|🥞 pancakes|🥓 bacon|🍔 burger|🍟 fries|🍕 pizza|🌭 hot dog|🌮 taco|🌯 burrito|🥗 salad|🍝 pasta spaghetti|🍜 ramen noodles|🍣 sushi|🍱 bento|🍦 ice cream|🍩 doughnut|🍪 cookie|🎂 birthday cake|🍰 cake|🧁 cupcake|🍫 chocolate|🍬 candy|🍿 popcorn|☕ coffee|🍵 tea|🧃 juice|🥤 drink|🍺 beer|🍷 wine|🍸 cocktail|🥂 cheers champagne|🍽️ dinner plate`,
activity: `⚽ soccer football|🏀 basketball|🏈 american football|⚾ baseball|🎾 tennis|🏐 volleyball|🏉 rugby|🎱 billiards|🏓 ping pong|🏸 badminton|🥅 goal|⛳ golf|🏹 archery|🎣 fishing|🥊 boxing|🎽 running shirt|⛸️ ice skate|🎿 ski|🏂 snowboard|🏋️ weights gym|🚴 cycling bike|🏆 trophy win|🥇 gold medal first|🥈 silver medal|🥉 bronze medal|🏅 medal|🎖️ military medal|🎫 ticket|🎪 circus|🎭 theatre drama|🎨 art palette paint|🎬 movie clapper film|🎤 microphone sing|🎧 headphones music|🎼 score|🎹 piano|🥁 drum|🎷 saxophone|🎺 trumpet|🎸 guitar|🎻 violin|🎲 dice game|♟️ chess|🎯 target goal dart|🎳 bowling|🎮 video game|🧩 puzzle|🎉 party popper tada|🎊 confetti|🎈 balloon|🎁 gift present`,
travel: `🚗 car|🚕 taxi|🚌 bus|🚎 trolleybus|🏎️ race car|🚓 police car|🚑 ambulance|🚒 fire engine|🚚 truck delivery|🚜 tractor|🛵 scooter|🚲 bicycle|🛴 kick scooter|🚂 train locomotive|🚆 train|🚇 metro subway|✈️ airplane flight|🛫 departure|🛬 arrival|🚀 rocket launch|🛸 ufo|🚁 helicopter|⛵ sailboat|🚤 speedboat|🚢 ship|⚓ anchor|🗺️ map|🧭 compass|🏔️ mountain snow|⛰️ mountain|🌋 volcano|🏕️ camping|🏖️ beach|🏝️ island|🏠 house home|🏡 garden home|🏢 office building|🏬 department store|🏭 factory|🏥 hospital|🏦 bank|🏨 hotel|🏪 shop store|🏫 school|🏛️ classical building|⛪ church|🏰 castle|🗼 tower|🗽 statue liberty|⛲ fountain|🌆 city|🌃 night city|🌉 bridge|🎡 ferris wheel|🎢 roller coaster|🚦 traffic light|🚧 construction|⛽ fuel`,
objects: `📄 page document|📃 curl page|📑 bookmark tabs|📝 memo note write|📋 clipboard|📌 pushpin pin|📍 location pin|📎 paperclip|🖇️ paperclips|📏 ruler|📐 triangle ruler|✂️ scissors|🗂️ dividers index|📁 folder|📂 open folder|🗃️ card box|🗄️ cabinet|🗑️ trash wastebasket|📅 calendar date|📆 tear off calendar|🗓️ spiral calendar|📇 card index|📈 chart up growth|📉 chart down|📊 bar chart stats|📒 ledger|📓 notebook|📔 notebook decorative|📕 book closed|📗 green book|📘 blue book|📙 orange book|📚 books library|📖 open book read|🔖 bookmark|🏷️ label tag|💼 briefcase work|💻 laptop computer|🖥️ desktop computer|⌨️ keyboard|🖱️ mouse computer|📱 phone mobile|☎️ telephone|📞 receiver call|📠 fax|🔋 battery|🔌 plug|💡 bulb idea|🔦 flashlight|🕯️ candle|💰 money bag|💳 card credit|🧾 receipt|✉️ envelope mail|📧 email|📨 incoming mail|📦 package box|📮 postbox|🔒 lock locked|🔓 unlocked|🔑 key|🗝️ old key|🔨 hammer|🛠️ tools|🔧 wrench|🔩 nut bolt|⚙️ gear settings|🧰 toolbox|🧲 magnet|🧪 test tube|🔬 microscope|🔭 telescope|📡 satellite|💊 pill|🩺 stethoscope|🛒 cart shopping|🎓 graduation cap|👑 crown|💎 gem diamond|⏰ alarm clock|⏳ hourglass|⌛ hourglass done|🕐 clock time|📷 camera photo|🎥 video camera|📺 television tv|📻 radio|🔔 bell notification|📣 megaphone announce|📢 loudspeaker|🔍 search magnifier|🧭 compass direction`,
symbols: `✅ check done yes|☑️ ballot check|✔️ check mark|❌ cross no|❎ cross button|➕ plus add|➖ minus|➗ divide|✖️ multiply|❓ question|❔ white question|❗ exclamation important|‼️ double exclamation|⚠️ warning|🚫 prohibited|⛔ no entry|🛑 stop|💯 hundred|🔴 red circle|🟠 orange circle|🟡 yellow circle|🟢 green circle|🔵 blue circle|🟣 purple circle|⚫ black circle|⚪ white circle|🟥 red square|🟧 orange square|🟨 yellow square|🟩 green square|🟦 blue square|🟪 purple square|⬛ black square|⬜ white square|🔶 orange diamond|🔷 blue diamond|♻️ recycle|⚛️ atom|☮️ peace|☯️ yin yang|♾️ infinity|💲 dollar|💱 exchange|©️ copyright|®️ registered|™️ trademark|🔝 top|🔜 soon|🆕 new|🆓 free|🆗 ok|🆙 up|🆒 cool|ℹ️ info information|🔤 abc letters|🔢 numbers|#️⃣ hash|➡️ right arrow|⬅️ left arrow|⬆️ up arrow|⬇️ down arrow|🔄 refresh sync|🔁 repeat|▶️ play|⏸️ pause|⏹️ stop|⏩ fast forward|💬 speech chat comment|💭 thought|🗯️ anger bubble|💤 sleep zzz|💥 boom collision|💫 dizzy|🎵 music note|🔗 link|🏁 finish flag|🚩 red flag|🏳️ white flag|🏴 black flag|💜 purple heart|💙 blue heart|💚 green heart|💛 yellow heart|🧡 orange heart|🖤 black heart|💔 broken heart`,
};
export const emojiGroups = Object.keys(raw) as EmojiGroup[];
export const emojiByGroup: Record<EmojiGroup, Emoji[]> = Object.fromEntries(
emojiGroups.map((g) => [
g,
raw[g].split("|").map((entry) => {
const [char = "", ...words] = entry.trim().split(" ");
return { char, words: words.join(" ") };
}),
]),
) as Record<EmojiGroup, Emoji[]>;
/** The emoji whose words start with every word of the query, in group order. */
export function searchEmoji(query: string): Emoji[] {
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
if (!terms.length) return [];
const seen = new Set<string>();
const out: Emoji[] = [];
for (const g of emojiGroups) {
for (const e of emojiByGroup[g]) {
if (seen.has(e.char)) continue;
const words = e.words.split(" ");
if (terms.every((t) => words.some((w) => w.startsWith(t)))) {
seen.add(e.char);
out.push(e);
}
}
}
return out;
}
/** Text that is itself an icon: a few characters with no letters or digits, as the server keeps at most 32 bytes. */
export function typedEmoji(text: string): string | null {
const t = text.trim();
if (!t || /[\p{L}\p{N}]/u.test(t) || new TextEncoder().encode(t).length > 32) return null;
return /\p{Extended_Pictographic}/u.test(t) ? t : null;
}
const recentKey = "docwell.recentEmoji";
/** The emoji this browser picked last, newest first. */
export function recentEmoji(): string[] {
try {
const list = JSON.parse(localStorage.getItem(recentKey) ?? "[]");
return Array.isArray(list) ? list.filter((x) => typeof x === "string").slice(0, 16) : [];
} catch {
return [];
}
}
export function rememberEmoji(char: string) {
try {
localStorage.setItem(recentKey, JSON.stringify([char, ...recentEmoji().filter((c) => c !== char)].slice(0, 16)));
} catch {
// Private windows may refuse storage; the picker works without it.
}
}
// The emoji list lives with the editor, whose ":" picker uses it too.
export * from "@docwell/editor/emoji";
+64 -2
View File
@@ -255,7 +255,7 @@
"deleteForever": "Endgültig löschen",
"confirmPurge": "„{title}“ und alle Unterseiten endgültig löschen?",
"readOnly": "Du kannst diese Seite lesen, aber nicht ändern.",
"placeholder": "Schreib los…",
"placeholder": "Schreib etwas. Tippe „/“ für Befehle",
"someone": "Jemand",
"collab": {
"connecting": "Verbinde…",
@@ -597,6 +597,10 @@
"label": "4 Spalten",
"description": "Vier Blöcke nebeneinander"
},
"columns5": {
"label": "5 Spalten",
"description": "Fünf Blöcke nebeneinander"
},
"table": {
"label": "Tabelle",
"description": "Zeilen und Spalten"
@@ -628,6 +632,42 @@
"database": {
"label": "Datenbank",
"description": "Einträge als Tabelle, Board oder Kalender"
},
"video": {
"label": "Video",
"description": "Ein Video hochladen, das auf der Seite abgespielt wird"
},
"audio": {
"label": "Audio",
"description": "Eine Aufnahme hochladen, die auf der Seite abgespielt wird"
},
"pageBreak": {
"label": "Seitenumbruch",
"description": "Beim Drucken eine neue Seite beginnen"
},
"footnote": {
"label": "Fußnote",
"description": "Eine nummerierte Anmerkung am Ende der Seite"
},
"tabs": {
"label": "Tabs",
"description": "Inhalt auf mehreren Tabs"
},
"status": {
"label": "Status",
"description": "Ein farbiges Etikett im Text"
},
"emoji": {
"label": "Emoji",
"description": "Ein Emoji auswählen (oder : tippen)"
},
"subpages": {
"label": "Unterseiten",
"description": "Die Unterseiten dieser Seite auflisten"
},
"syncedBlock": {
"label": "Synchronisierter Block",
"description": "Einen Block einer anderen Seite zeigen, immer aktuell"
}
},
"format": {
@@ -690,7 +730,29 @@
"transcribe": "Transkribieren",
"transcribeHint": "Mit KI eine Zusammenfassung und das Transkript darunter einfügen",
"transcribing": "Wird transkribiert …",
"transcribeFailed": "Die Aufnahme konnte nicht transkribiert werden."
"transcribeFailed": "Die Aufnahme konnte nicht transkribiert werden.",
"syncedBlock": "Synchronisierter Block",
"syncedBlockUrl": "Link zum Block (kopiere ihn aus dem ⋮⋮-Menü des Blocks)",
"syncedBlockInvalid": "Das ist kein Link zu einem Block einer Seite.",
"syncedBlockMissing": "Dieser Block ist nicht mehr auf seiner Seite.",
"pageBreak": "Seitenumbruch",
"status": "Status",
"statusDefault": "Offen",
"statusText": "Statustext",
"statusColor": "Statusfarbe",
"footnotes": "Fußnoten",
"footnote": "Fußnote {n}",
"footnoteText": "Text der Fußnote",
"footnoteBack": "Zurück zum Text",
"tabName": "Tab {n}",
"addTab": "Tab hinzufügen",
"renameTab": "Name des Tabs",
"deleteTab": "Tab löschen",
"subpages": "Unterseiten",
"subpagesEmpty": "Diese Seite hat noch keine Unterseiten.",
"subpagesLoading": "Unterseiten werden geladen…",
"emoji": "Emoji",
"noEmoji": "Kein Emoji gefunden"
},
"colors": {
"gray": "Grau",
+64 -2
View File
@@ -255,7 +255,7 @@
"deleteForever": "Delete forever",
"confirmPurge": "Delete \"{title}\" and every page inside it for good?",
"readOnly": "You can read this page but not change it.",
"placeholder": "Start writing…",
"placeholder": "Write anything. Type “/” for commands",
"someone": "Someone",
"collab": {
"connecting": "Connecting…",
@@ -597,6 +597,10 @@
"label": "4 columns",
"description": "Four blocks side by side"
},
"columns5": {
"label": "5 columns",
"description": "Five blocks side by side"
},
"table": {
"label": "Table",
"description": "Rows and columns"
@@ -628,6 +632,42 @@
"database": {
"label": "Database",
"description": "Records in a table, board or calendar"
},
"video": {
"label": "Video",
"description": "Upload a video that plays on the page"
},
"audio": {
"label": "Audio",
"description": "Upload a recording that plays on the page"
},
"pageBreak": {
"label": "Page break",
"description": "Start a new page when printing"
},
"footnote": {
"label": "Footnote",
"description": "A numbered note at the end of the page"
},
"tabs": {
"label": "Tabs",
"description": "Content on several tabs"
},
"status": {
"label": "Status",
"description": "A coloured badge in the text"
},
"emoji": {
"label": "Emoji",
"description": "Pick an emoji (or type :)"
},
"subpages": {
"label": "Subpages",
"description": "List this page's subpages"
},
"syncedBlock": {
"label": "Synced block",
"description": "Show a block of another page, always up to date"
}
},
"format": {
@@ -690,7 +730,29 @@
"transcribe": "Transcribe",
"transcribeHint": "Add a summary and the transcript below, with AI",
"transcribing": "Transcribing…",
"transcribeFailed": "The recording could not be transcribed."
"transcribeFailed": "The recording could not be transcribed.",
"syncedBlock": "Synced block",
"syncedBlockUrl": "Link to the block (copy it from the block's ⋮⋮ menu)",
"syncedBlockInvalid": "That isn't a link to a block of a page.",
"syncedBlockMissing": "This block is no longer on its page.",
"pageBreak": "Page break",
"status": "Status",
"statusDefault": "To do",
"statusText": "Status text",
"statusColor": "Status colour",
"footnotes": "Footnotes",
"footnote": "Footnote {n}",
"footnoteText": "Footnote text",
"footnoteBack": "Back to the text",
"tabName": "Tab {n}",
"addTab": "Add a tab",
"renameTab": "Tab name",
"deleteTab": "Delete tab",
"subpages": "Subpages",
"subpagesEmpty": "This page has no subpages yet.",
"subpagesLoading": "Loading subpages…",
"emoji": "Emoji",
"noEmoji": "No emoji found"
},
"colors": {
"gray": "Grey",
+64 -2
View File
@@ -255,7 +255,7 @@
"deleteForever": "Eliminar para siempre",
"confirmPurge": "¿Eliminar para siempre «{title}» y todas sus subpáginas?",
"readOnly": "Puedes leer esta página, pero no cambiarla.",
"placeholder": "Empieza a escribir…",
"placeholder": "Escribe lo que quieras. Pulsa «/» para ver los comandos",
"someone": "Alguien",
"collab": {
"connecting": "Conectando…",
@@ -597,6 +597,10 @@
"label": "4 columnas",
"description": "Cuatro bloques uno al lado del otro"
},
"columns5": {
"label": "5 columnas",
"description": "Cinco bloques uno al lado del otro"
},
"table": {
"label": "Tabla",
"description": "Filas y columnas"
@@ -628,6 +632,42 @@
"database": {
"label": "Base de datos",
"description": "Registros en tabla, tablero o calendario"
},
"video": {
"label": "Vídeo",
"description": "Sube un vídeo que se reproduce en la página"
},
"audio": {
"label": "Audio",
"description": "Sube una grabación que se reproduce en la página"
},
"pageBreak": {
"label": "Salto de página",
"description": "Empieza una página nueva al imprimir"
},
"footnote": {
"label": "Nota al pie",
"description": "Una nota numerada al final de la página"
},
"tabs": {
"label": "Pestañas",
"description": "Contenido en varias pestañas"
},
"status": {
"label": "Estado",
"description": "Una etiqueta de color en el texto"
},
"emoji": {
"label": "Emoji",
"description": "Elige un emoji (o escribe :)"
},
"subpages": {
"label": "Subpáginas",
"description": "Muestra las subpáginas de esta página"
},
"syncedBlock": {
"label": "Bloque sincronizado",
"description": "Muestra un bloque de otra página, siempre al día"
}
},
"format": {
@@ -690,7 +730,29 @@
"transcribe": "Transcribir",
"transcribeHint": "Añadir debajo un resumen y la transcripción, con IA",
"transcribing": "Transcribiendo…",
"transcribeFailed": "No se pudo transcribir la grabación."
"transcribeFailed": "No se pudo transcribir la grabación.",
"syncedBlock": "Bloque sincronizado",
"syncedBlockUrl": "Enlace al bloque (cópialo desde el menú ⋮⋮ del bloque)",
"syncedBlockInvalid": "Eso no es un enlace a un bloque de una página.",
"syncedBlockMissing": "Este bloque ya no está en su página.",
"pageBreak": "Salto de página",
"status": "Estado",
"statusDefault": "Pendiente",
"statusText": "Texto del estado",
"statusColor": "Color del estado",
"footnotes": "Notas al pie",
"footnote": "Nota al pie {n}",
"footnoteText": "Texto de la nota",
"footnoteBack": "Volver al texto",
"tabName": "Pestaña {n}",
"addTab": "Añadir pestaña",
"renameTab": "Nombre de la pestaña",
"deleteTab": "Eliminar pestaña",
"subpages": "Subpáginas",
"subpagesEmpty": "Esta página aún no tiene subpáginas.",
"subpagesLoading": "Cargando subpáginas…",
"emoji": "Emoji",
"noEmoji": "No se encontró ningún emoji"
},
"colors": {
"gray": "Gris",
+64 -2
View File
@@ -255,7 +255,7 @@
"deleteForever": "Supprimer définitivement",
"confirmPurge": "Supprimer définitivement « {title} » et toutes ses sous-pages ?",
"readOnly": "Vous pouvez lire cette page mais pas la modifier.",
"placeholder": "Commencez à écrire…",
"placeholder": "Écrivez ce que vous voulez. Tapez « / » pour les commandes",
"someone": "Quelqu’un",
"collab": {
"connecting": "Connexion…",
@@ -597,6 +597,10 @@
"label": "4 colonnes",
"description": "Quatre blocs côte à côte"
},
"columns5": {
"label": "5 colonnes",
"description": "Cinq blocs côte à côte"
},
"table": {
"label": "Tableau",
"description": "Lignes et colonnes"
@@ -628,6 +632,42 @@
"database": {
"label": "Base de données",
"description": "Des éléments en tableau, kanban ou calendrier"
},
"video": {
"label": "Vidéo",
"description": "Importer une vidéo lue sur la page"
},
"audio": {
"label": "Audio",
"description": "Importer un enregistrement lu sur la page"
},
"pageBreak": {
"label": "Saut de page",
"description": "Commencer une nouvelle page à l’impression"
},
"footnote": {
"label": "Note de bas de page",
"description": "Une note numérotée à la fin de la page"
},
"tabs": {
"label": "Onglets",
"description": "Du contenu sur plusieurs onglets"
},
"status": {
"label": "Statut",
"description": "Une étiquette colorée dans le texte"
},
"emoji": {
"label": "Emoji",
"description": "Choisir un emoji (ou tapez :)"
},
"subpages": {
"label": "Sous-pages",
"description": "Lister les sous-pages de cette page"
},
"syncedBlock": {
"label": "Bloc synchronisé",
"description": "Afficher un bloc d’une autre page, toujours à jour"
}
},
"format": {
@@ -690,7 +730,29 @@
"transcribe": "Transcrire",
"transcribeHint": "Ajouter dessous un résumé et la transcription, avec l’IA",
"transcribing": "Transcription…",
"transcribeFailed": "L’enregistrement n’a pas pu être transcrit."
"transcribeFailed": "L’enregistrement n’a pas pu être transcrit.",
"syncedBlock": "Bloc synchronisé",
"syncedBlockUrl": "Lien vers le bloc (copiez-le depuis le menu ⋮⋮ du bloc)",
"syncedBlockInvalid": "Ce n’est pas un lien vers un bloc d’une page.",
"syncedBlockMissing": "Ce bloc n’est plus sur sa page.",
"pageBreak": "Saut de page",
"status": "Statut",
"statusDefault": "À faire",
"statusText": "Texte du statut",
"statusColor": "Couleur du statut",
"footnotes": "Notes de bas de page",
"footnote": "Note {n}",
"footnoteText": "Texte de la note",
"footnoteBack": "Retour au texte",
"tabName": "Onglet {n}",
"addTab": "Ajouter un onglet",
"renameTab": "Nom de l’onglet",
"deleteTab": "Supprimer l’onglet",
"subpages": "Sous-pages",
"subpagesEmpty": "Cette page n’a pas encore de sous-pages.",
"subpagesLoading": "Chargement des sous-pages…",
"emoji": "Emoji",
"noEmoji": "Aucun emoji trouvé"
},
"colors": {
"gray": "Gris",
+64 -2
View File
@@ -255,7 +255,7 @@
"deleteForever": "Usuń na zawsze",
"confirmPurge": "Usunąć na zawsze „{title}” i wszystkie strony wewnątrz?",
"readOnly": "Możesz czytać tę stronę, ale nie możesz jej zmieniać.",
"placeholder": "Zacznij pisać…",
"placeholder": "Napisz cokolwiek. Wpisz „/”, aby zobaczyć polecenia",
"someone": "Ktoś",
"collab": {
"connecting": "Łączenie…",
@@ -597,6 +597,10 @@
"label": "4 kolumny",
"description": "Cztery bloki obok siebie"
},
"columns5": {
"label": "5 kolumn",
"description": "Pięć bloków obok siebie"
},
"table": {
"label": "Tabela",
"description": "Wiersze i kolumny"
@@ -628,6 +632,42 @@
"database": {
"label": "Baza danych",
"description": "Rekordy w tabeli, na tablicy lub w kalendarzu"
},
"video": {
"label": "Wideo",
"description": "Prześlij film odtwarzany na stronie"
},
"audio": {
"label": "Audio",
"description": "Prześlij nagranie odtwarzane na stronie"
},
"pageBreak": {
"label": "Podział strony",
"description": "Nowa strona przy drukowaniu"
},
"footnote": {
"label": "Przypis",
"description": "Numerowana uwaga na końcu strony"
},
"tabs": {
"label": "Karty",
"description": "Treść na kilku kartach"
},
"status": {
"label": "Status",
"description": "Kolorowa etykieta w tekście"
},
"emoji": {
"label": "Emoji",
"description": "Wybierz emoji (albo wpisz :)"
},
"subpages": {
"label": "Podstrony",
"description": "Lista podstron tej strony"
},
"syncedBlock": {
"label": "Zsynchronizowany blok",
"description": "Pokaż blok z innej strony, zawsze aktualny"
}
},
"format": {
@@ -690,7 +730,29 @@
"transcribe": "Transkrybuj",
"transcribeHint": "Dodaj poniżej podsumowanie i transkrypcję z pomocą AI",
"transcribing": "Transkrypcja…",
"transcribeFailed": "Nie udało się przetranskrybować nagrania."
"transcribeFailed": "Nie udało się przetranskrybować nagrania.",
"syncedBlock": "Zsynchronizowany blok",
"syncedBlockUrl": "Link do bloku (skopiuj go z menu ⋮⋮ bloku)",
"syncedBlockInvalid": "To nie jest link do bloku na stronie.",
"syncedBlockMissing": "Tego bloku nie ma już na jego stronie.",
"pageBreak": "Podział strony",
"status": "Status",
"statusDefault": "Do zrobienia",
"statusText": "Tekst statusu",
"statusColor": "Kolor statusu",
"footnotes": "Przypisy",
"footnote": "Przypis {n}",
"footnoteText": "Treść przypisu",
"footnoteBack": "Wróć do tekstu",
"tabName": "Karta {n}",
"addTab": "Dodaj kartę",
"renameTab": "Nazwa karty",
"deleteTab": "Usuń kartę",
"subpages": "Podstrony",
"subpagesEmpty": "Ta strona nie ma jeszcze podstron.",
"subpagesLoading": "Wczytywanie podstron…",
"emoji": "Emoji",
"noEmoji": "Nie znaleziono emoji"
},
"colors": {
"gray": "Szary",
@@ -87,6 +87,7 @@ const mentions = useMentions(() => page.value?.workspace);
const pageLinks = usePageLinks(
() => page.value?.workspace,
() => (page.value && editable.value ? { space: page.value.space, id: page.value.id } : undefined),
() => (page.value ? { space: page.value.space, id: page.value.id } : undefined),
);
// Link cards: docwell-server reads the linked page's title and picture.
const linkHost = { preview: (url: string) => api.pages.preview(url, page.value?.workspace) };