oficina / mapa Public

Editor schema completion: exact fences, origins at build, parseDOM

The groundwork for Phase 2's serialiser (level-up spec §6.3, §6.4):

- code_block keeps every byte of a fence the text does not: the opening
  fence with its spaces, the info, and the last line when markup.codeText
  left it out (close), so an edited fence is written back as it was read.
- fromBlocks takes the origin for each block as it builds it, and can
  leave off the trailing paragraph for a pasted slice.
- parseDOM for HTML pasted from outside (§6.6): Mapa's own headings read
  one level down, chips come back as links, unsafe addresses are not
  links, Google Docs' bold wrapper is not bold.
- markup.mjs gives each block's UTF-16 offsets beside Go's byte offsets,
  and cleanBody, the stored body rule.

L4 still holds on all 758 bodies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 94b6260cb76dd4a8af42459772df221852dffa4b parent 6e3aa6b
5 files changed, +145 −31
  • editor/fromMarkdown.mjs +34 −23
  • editor/markup.mjs +22 −0
  • editor/schema.mjs +87 −6
  • internal/mapa/static/editor.191a361976920a15.js +2 −0
  • internal/mapa/static/editor.9c9edc5536b1d844.js +0 −2
diff --git a/editor/fromMarkdown.mjs b/editor/fromMarkdown.mjs
index 464ec50..4e817f6 100644
--- a/editor/fromMarkdown.mjs
+++ b/editor/fromMarkdown.mjs
@@ -4,67 +4,78 @@
// renderList nests them; and the document always ends in a paragraph,
// the place the editor keeps to type in (§6.2).
//
-// Origins and the side table (§6.4) are Phase 2's; this builds the nodes
-// whose toDOM gate L4 compares with the server's HTML.
+// Origins and the side table (§6.4) are fidelity.mjs's: options.origin
+// gives the origin for the block at an index of blocks, and it is set on
+// that block's textblock (or rule) as it is made. options.trailing false
+// leaves off the trailing paragraph, for a pasted slice.
import { Mark } from 'prosemirror-model'
import {
- parse, plain, spans, words, task, itemSyntax, isDate,
+ parse, plain, spans, words, task, itemSyntax, isDate, isFenceLine,
+ fenceOf, closesFence,
Paragraph, Heading, Item, Code, Quote, Rule,
InCode, WikiLink, WebLink, Embed
} from './markup.mjs'
-export function fromMarkdown (schema, body) {
- return fromBlocks(schema, parse(body))
+export function fromMarkdown (schema, body, options) {
+ return fromBlocks(schema, parse(body), options)
}
-export function fromBlocks (schema, blocks) {
+export function fromBlocks (schema, blocks, options = {}) {
+ const origin = options.origin ?? (() => null)
const content = []
for (let index = 0; index < blocks.length;) {
if (blocks[index].kind === Item) {
- const [lists, next] = listsFrom(schema, blocks, index)
+ const [lists, next] = listsFrom(schema, blocks, index, origin)
content.push(...lists)
index = next
continue
}
- content.push(blockNode(schema, blocks[index]))
+ content.push(blockNode(schema, blocks[index], origin(index)))
index++
}
const last = content[content.length - 1]
- if (!last || last.type !== schema.nodes.paragraph) {
+ if (options.trailing !== false &&
+ (!last || last.type !== schema.nodes.paragraph)) {
content.push(schema.nodes.paragraph.create())
}
return schema.nodes.doc.create(null, content)
}
-function blockNode (schema, block) {
+function blockNode (schema, block, origin) {
const marker = block.marker || null
const text = plain(block)
switch (block.kind) {
case Heading:
return schema.nodes.heading.create(
- { marker, level: block.level, source: block.source },
+ { origin, marker, level: block.level, source: block.source },
inlineNodes(schema, text))
case Code:
- return codeNode(schema, block, text)
+ return codeNode(schema, block, text, origin)
case Rule:
- return schema.nodes.horizontal_rule.create({ source: block.source })
+ return schema.nodes.horizontal_rule.create({ origin, source: block.source })
case Quote:
return schema.nodes.blockquote.create(
{ marker, prefix: quotePrefixes(block.source) },
- schema.nodes.paragraph.create(null, inlineNodes(schema, text)))
+ schema.nodes.paragraph.create({ origin }, inlineNodes(schema, text)))
}
- return schema.nodes.paragraph.create({ marker }, inlineNodes(schema, text))
+ return schema.nodes.paragraph.create({ origin, marker },
+ inlineNodes(schema, text))
}
-function codeNode (schema, block, text) {
+// codeNode keeps every byte of a fence that the text does not: the
+// opening line (fence and info) and, when markup.codeText left it out,
+// the last line (close).
+function codeNode (schema, block, text, origin) {
const lines = block.source.split('\n')
- const fence = /^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(lines[0])
+ const fence = /^( {0,3}(?:`{3,}|~{3,}))(.*)$/u.exec(lines[0])
+ const last = lines[lines.length - 1]
return schema.nodes.code_block.create({
+ origin,
fence: fence[1],
info: fence[2],
- closed: lines.length > 1 && lines[lines.length - 1].trimStart()
- .startsWith(fence[1].slice(0, 3))
+ closed: lines.length > 1 && closesFence(last, fenceOf(lines[0])),
+ close: lines.length > 1 && isFenceLine(last) ? last : null
}, text === '' ? null : schema.text(text))
}
@@ -75,7 +86,7 @@ function quotePrefixes (source) {
// listsFrom is renderList's nesting: depth is min(level, lists open), a
// level skip nests one deep, and an item of the other kind starts a new
// list at its depth.
-function listsFrom (schema, blocks, start) {
+function listsFrom (schema, blocks, start, origin) {
const top = []
const open = []
let index = start
@@ -93,7 +104,7 @@ function listsFrom (schema, blocks, start) {
else open[depth - 1].items.at(-1).lists.push(list)
open.push(list)
}
- open[depth].items.push({ block, lists: [] })
+ open[depth].items.push({ block, lists: [], origin: origin(index) })
}
return [top.map(list => listNode(schema, list)), index]
}
@@ -103,7 +114,7 @@ function listNode (schema, list) {
list.items.map(item => itemNode(schema, item)))
}
-function itemNode (schema, { block, lists }) {
+function itemNode (schema, { block, lists, origin }) {
const [text, box] = task(plain(block))
const attrs = {
marker: block.marker || null,
@@ -111,7 +122,7 @@ function itemNode (schema, { block, lists }) {
task: box !== null,
checked: box
}
- const paragraph = schema.nodes.paragraph.create(null,
+ const paragraph = schema.nodes.paragraph.create({ origin },
inlineNodes(schema, text))
return schema.nodes.list_item.create(attrs,
[paragraph, ...lists.map(list => listNode(schema, list))])
diff --git a/editor/markup.mjs b/editor/markup.mjs
index f4d6152..5f24efb 100644
--- a/editor/markup.mjs
+++ b/editor/markup.mjs
@@ -74,6 +74,12 @@ export function utf8Length (text) {
return length
}
+// cleanBody is the one rule for a stored body (internal/mapa/pages.go):
+// "\n" line endings, and no trailing spaces, tabs or newlines.
+export function cleanBody (body) {
+ return normalise(body).replace(/[ \t\n]+$/u, '')
+}
+
export function normalise (body) {
return body.replaceAll('\r\n', '\n').replaceAll('\r', '\n')
}
@@ -82,8 +88,10 @@ export function normalise (body) {
export function parse (body) {
const lines = normalise(body).split('\n')
const offsets = [0]
+ const indexes = [0]
for (const line of lines) {
offsets.push(offsets[offsets.length - 1] + utf8Length(line) + 1)
+ indexes.push(indexes[indexes.length - 1] + line.length + 1)
}
const blocks = []
for (let index = 0; index < lines.length;) {
@@ -95,6 +103,10 @@ export function parse (body) {
block.marker = marker(block)
block.start = offsets[index]
block.end = block.start + utf8Length(block.source)
+ // from and to are the same offsets in JavaScript's UTF-16 units, into
+ // the normalised body, for the editor's own slicing (fidelity.mjs).
+ block.from = indexes[index]
+ block.to = block.from + block.source.length
blocks.push(block)
index = next
}
@@ -301,6 +313,16 @@ function wordStart (text, index) {
export function isDateShaped (text) { return isoDate.test(text) }
+// The block tests the serialiser needs, exactly as parse applies them.
+export function isFenceLine (line) { return fenceLine.test(line) }
+export function isRuleLine (line) { return ruleLine.test(line) }
+export function fenceOf (line) { return fenceLine.exec(line)?.[1] ?? null }
+
+// closesFence is parseFence's test for a closing line.
+export function closesFence (line, fence) {
+ return trimLeft(line, ' ').startsWith(fence)
+}
+
// isDate is time.Parse(time.DateOnly): a real day in the Gregorian
// calendar, year 0000 to 9999.
export function isDate (text) {
diff --git a/editor/schema.mjs b/editor/schema.mjs
index 0c46adf..6262d2e 100644
--- a/editor/schema.mjs
+++ b/editor/schema.mjs
@@ -7,9 +7,14 @@
// Attributes that keep a block's Markdown exact (indents, bullets, fences,
// quote prefixes, sources) are never drawn. origin is the side table's key
// (§6.4), never serialised. marker is a block's ^id, drawn as its id.
+//
+// parseDOM is for HTML pasted from outside Mapa (§6.6): it maps what it
+// can onto the subset, and everything else becomes text. Mapa's own
+// clipboard never goes through it (clipboard.mjs).
import { Schema } from 'prosemirror-model'
import { wikiChip, embedChip } from './chips.mjs'
+import { safeURL, isDate } from './markup.mjs'
// markerAttrs is a block's id: its ^id, as an anchor (base §3.2).
function markerAttrs (node) {
@@ -25,6 +30,7 @@ const nodes = {
group: 'block',
content: 'inline*',
attrs: { ...textblock },
+ parseDOM: [{ tag: 'p' }],
toDOM: node => ['p', markerAttrs(node), 0]
},
@@ -35,6 +41,11 @@ const nodes = {
content: 'inline*',
defining: true,
attrs: { ...textblock, level: { default: 1 }, source: { default: null } },
+ // h1 is a level 1 heading, and h2 to h6 are read as Mapa draws them,
+ // one level down, so a page's own HTML comes back as it was typed.
+ parseDOM: [1, 2, 3, 4, 5, 6].map(level => ({
+ tag: `h${level}`, attrs: { level: Math.max(level - 1, 1) }
+ })),
toDOM: node => [`h${Math.min(node.attrs.level + 1, 6)}`,
markerAttrs(node), 0]
},
@@ -45,12 +56,14 @@ const nodes = {
bullet_list: {
group: 'block',
content: 'list_item+',
+ parseDOM: [{ tag: 'ul' }],
toDOM: () => ['ul', 0]
},
ordered_list: {
group: 'block',
content: 'list_item+',
+ parseDOM: [{ tag: 'ol' }],
toDOM: () => ['ol', 0]
},
@@ -68,6 +81,15 @@ const nodes = {
task: { default: false },
checked: { default: null }
},
+ parseDOM: [{
+ tag: 'li',
+ getAttrs: dom => {
+ const box = dom.getAttribute('mapa-task')
+ if (box === 'open') return { task: true, checked: ' ' }
+ if (box === 'done') return { task: true, checked: 'x' }
+ return {}
+ }
+ }],
toDOM: node => {
const attrs = markerAttrs(node)
if (node.attrs.task) {
@@ -84,11 +106,15 @@ const nodes = {
content: 'paragraph',
defining: true,
attrs: { marker: { default: null }, prefix: { default: null } },
+ parseDOM: [{ tag: 'blockquote' }],
toDOM: node => ['blockquote', markerAttrs(node), 0]
},
- // code_block: fence is the opening fence's characters, info what
- // follows it, closed whether a closing fence was found.
+ // code_block: fence is the opening fence as typed, its spaces and its
+ // run of backticks or tildes; info is the rest of that line. closed is
+ // whether Go's parser found a closing line. close is the last line when
+ // the text does not hold it (markup.codeText drops a last line that
+ // looks like a fence, closing or not), or null. A new block is closed.
code_block: {
group: 'block',
content: 'text*',
@@ -99,14 +125,17 @@ const nodes = {
origin: { default: null },
fence: { default: '```' },
info: { default: '' },
- closed: { default: true }
+ closed: { default: true },
+ close: { default: '```' }
},
+ parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
toDOM: () => ['pre', ['code', 0]]
},
horizontal_rule: {
group: 'block',
attrs: { origin: { default: null }, source: { default: '---' } },
+ parseDOM: [{ tag: 'hr' }],
toDOM: () => ['hr']
},
@@ -119,6 +148,7 @@ const nodes = {
group: 'inline',
selectable: false,
attrs: { indent: { default: '' } },
+ parseDOM: [{ tag: 'br' }],
toDOM: () => ['br']
}
}
@@ -130,11 +160,36 @@ const marks = {
attrs: { href: {}, bare: { default: false } },
inclusive: false,
excludes: 'em strong code',
+ parseDOM: [{
+ tag: 'a[href]',
+ getAttrs: dom => safeURL(dom.getAttribute('href')) ? { href: dom.getAttribute('href') } : false
+ }],
toDOM: mark => ['a', { href: mark.attrs.href, rel: 'noopener noreferrer' }, 0]
},
- em: { toDOM: () => ['em', 0] },
- strong: { toDOM: () => ['strong', 0] },
- code: { excludes: '_', toDOM: () => ['code', 0] }
+ em: {
+ parseDOM: [{ tag: 'em' }, { tag: 'i' }, { style: 'font-style=italic' }],
+ toDOM: () => ['em', 0]
+ },
+ strong: {
+ parseDOM: [{ tag: 'strong' }, {
+ // Google Docs wraps a whole paste in <b style="font-weight:normal">.
+ tag: 'b', getAttrs: dom => dom.style?.fontWeight !== 'normal' && null
+ }, {
+ style: 'font-weight',
+ getAttrs: value => /^(bold(er)?|[6-9]\d{2,})$/u.test(value) && null
+ }],
+ toDOM: () => ['strong', 0]
+ },
+ code: { excludes: '_', parseDOM: [{ tag: 'code' }], toDOM: () => ['code', 0] }
+}
+
+// chipText is a chip's words, without its glyph or its note.
+function chipText (dom) {
+ let text = ''
+ for (const child of dom.childNodes) {
+ if (child.nodeType === 3) text += child.nodeValue
+ }
+ return text.trim()
}
// atoms are Mapa's inline atoms. Their chips need the viewer's answer for
@@ -150,6 +205,18 @@ function atoms (resolve) {
target: {}, anchor: { default: '' }, shown: { default: '' },
source: { default: null }, origin: { default: null }
},
+ // A chip from Mapa's HTML comes back as a link to the words shown.
+ parseDOM: [{
+ tag: 'a[mapa-chip]',
+ priority: 60,
+ getAttrs: dom => {
+ const day = /^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u
+ .exec(dom.getAttribute('href') ?? '')
+ if (day) return false
+ const target = chipText(dom)
+ return target === '' ? false : { target }
+ }
+ }],
toDOM: node => wikiChip(node.attrs,
resolve(node.attrs.target, node.attrs.anchor))
},
@@ -159,12 +226,26 @@ function atoms (resolve) {
date: {}, anchor: { default: '' }, shown: { default: '' },
source: { default: null }, origin: { default: null }
},
+ parseDOM: [{
+ tag: 'a[mapa-chip]',
+ priority: 61,
+ getAttrs: dom => {
+ const day = /^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u
+ .exec(dom.getAttribute('href') ?? '')
+ return day && isDate(day[1]) ? { date: day[1] } : false
+ }
+ }],
toDOM: node => wikiChip({ ...node.attrs, target: node.attrs.date },
resolve(node.attrs.date, node.attrs.anchor))
},
embed: {
...atom,
attrs: { ref: {}, source: { default: null }, origin: { default: null } },
+ parseDOM: [{
+ tag: 'span[mapa-chip="embed"]',
+ priority: 60,
+ getAttrs: dom => chipText(dom) === '' ? false : { ref: chipText(dom) }
+ }],
toDOM: node => embedChip(node.attrs.ref)
}
}
diff --git a/internal/mapa/static/editor.191a361976920a15.js b/internal/mapa/static/editor.191a361976920a15.js
new file mode 100644
index 0000000..6216f60
--- /dev/null
+++ b/internal/mapa/static/editor.191a361976920a15.js
@@ -0,0 +1,2 @@
+function p(i){this.content=i}p.prototype={constructor:p,find:function(i){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===i)return t;return-1},get:function(i){var t=this.find(i);return t==-1?void 0:this.content[t+1]},update:function(i,t,e){var n=e&&e!=i?this.remove(e):this,r=n.find(i),s=n.content.slice();return r==-1?s.push(e||i,t):(s[r+1]=t,e&&(s[r]=e)),new p(s)},remove:function(i){var t=this.find(i);if(t==-1)return this;var e=this.content.slice();return e.splice(t,2),new p(e)},addToStart:function(i,t){return new p([i,t].concat(this.remove(i).content))},addToEnd:function(i,t){var e=this.remove(i).content.slice();return e.push(i,t),new p(e)},addBefore:function(i,t,e){var n=this.remove(t),r=n.content.slice(),s=n.find(i);return r.splice(s==-1?r.length:s,0,t,e),new p(r)},forEach:function(i){for(var t=0;t<this.content.length;t+=2)i(this.content[t],this.content[t+1])},prepend:function(i){return i=p.from(i),i.size?new p(i.content.concat(this.subtract(i).content)):this},append:function(i){return i=p.from(i),i.size?new p(this.subtract(i).content.concat(i.content)):this},subtract:function(i){var t=this;i=p.from(i);for(var e=0;e<i.content.length;e+=2)t=t.remove(i.content[e]);return t},toObject:function(){var i={};return this.forEach(function(t,e){i[t]=e}),i},get size(){return this.content.length>>1}};p.from=function(i){if(i instanceof p)return i;var t=[];if(i)for(var e in i)t.push(e,i[e]);return new p(t)};var D=p;function Q(i,t,e){for(let n=0;;n++){if(n==i.childCount||n==t.childCount)return i.childCount==t.childCount?null:e;let r=i.child(n),s=t.child(n);if(r==s){e+=r.nodeSize;continue}if(!r.sameMarkup(s))return e;if(r.isText&&r.text!=s.text){let l=r.text,o=s.text,a=0;for(;l[a]==o[a];a++)e++;return a&&a<l.length&&a<o.length&&K(l.charCodeAt(a-1))&&Y(l.charCodeAt(a))&&e--,e}if(r.content.size||s.content.size){let l=Q(r.content,s.content,e+1);if(l!=null)return l}e+=r.nodeSize}}function X(i,t,e,n){for(let r=i.childCount,s=t.childCount;;){if(r==0||s==0)return r==s?null:{a:e,b:n};let l=i.child(--r),o=t.child(--s),a=l.nodeSize;if(l==o){e-=a,n-=a;continue}if(!l.sameMarkup(o))return{a:e,b:n};if(l.isText&&l.text!=o.text){let h=l.text,c=o.text,d=h.length,m=c.length;for(;d>0&&m>0&&h[d-1]==c[m-1];)d--,m--,e--,n--;return d&&m&&d<h.length&&K(h.charCodeAt(d-1))&&Y(h.charCodeAt(d))&&(e++,n++),{a:e,b:n}}if(l.content.size||o.content.size){let h=X(l.content,o.content,e-1,n-1);if(h)return h}e-=a,n-=a}}function Y(i){return i>=56320&&i<57344}function K(i){return i>=55296&&i<56320}var f=class i{constructor(t,e){if(this.content=t,this.size=e||0,e==null)for(let n=0;n<t.length;n++)this.size+=t[n].nodeSize}nodesBetween(t,e,n,r=0,s){for(let l=0,o=0;o<e;l++){let a=this.content[l],h=o+a.nodeSize;if(h>t&&n(a,r+o,s||null,l)!==!1&&a.content.size){let c=o+1;a.nodesBetween(Math.max(0,t-c),Math.min(a.content.size,e-c),n,r+c)}o=h}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let s="",l=!0;return this.nodesBetween(t,e,(o,a)=>{let h=o.isText?o.text.slice(Math.max(t,a)-a,e-a):o.isLeaf?r?typeof r=="function"?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&h||o.isTextblock)&&n&&(l?l=!1:s+=n),s+=h},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),s=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),s=1);s<t.content.length;s++)r.push(t.content[s]);return new i(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let n=[],r=0;if(e>t)for(let s=0,l=0;l<e;s++){let o=this.content[s],a=l+o.nodeSize;a>t&&((l<t||a>e)&&(o.isText?o=o.cut(Math.max(0,t-l),Math.min(o.text.length,e-l)):o=o.cut(Math.max(0,t-l-1),Math.min(o.content.size,e-l-1))),n.push(o),r+=o.nodeSize),l=a}return new i(n,r)}cutByIndex(t,e){return t==e?i.empty:t==0&&e==this.content.length?this:new i(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),s=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new i(r,s)}addToStart(t){return new i([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new i(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return Q(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return X(this,t,e,n)}findIndex(t){if(t==0)return M(0,t);if(t==this.size)return M(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=this.child(e),s=n+r.nodeSize;if(s>=t)return s==t?M(e+1,s):M(e,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return i.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return i.fromArray(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return i.empty;let e,n=0;for(let r=0;r<t.length;r++){let s=t[r];n+=s.nodeSize,r&&s.isText&&t[r-1].sameMarkup(s)?(e||(e=t.slice(0,r)),e[e.length-1]=s.withText(e[e.length-1].text+s.text)):e&&e.push(s)}return new i(e||t,n)}static from(t){if(!t)return i.empty;if(t instanceof i)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new i([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};f.empty=new f([],0);var N={index:0,offset:0};function M(i,t){return N.index=i,N.offset=t,N}function E(i,t){if(i===t)return!0;if(!(i&&typeof i=="object")||!(t&&typeof t=="object"))return!1;let e=Array.isArray(i);if(Array.isArray(t)!=e)return!1;if(e){if(i.length!=t.length)return!1;for(let n=0;n<i.length;n++)if(!E(i[n],t[n]))return!1}else{for(let n in i)if(!(n in t)||!E(i[n],t[n]))return!1;for(let n in t)if(!(n in i))return!1}return!0}var u=class i{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let s=t[r];if(this.eq(s))return t;if(this.type.excludes(s.type))e||(e=t.slice(0,r));else{if(s.type.excludes(this.type))return t;!n&&s.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(s)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&E(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return i.none;if(t instanceof i)return[t];let e=t.slice();return e.sort((n,r)=>n.type.rank-r.type.rank),e}};u.none=[];var b=class extends Error{},S=class i{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=tt(this.content,t+this.openStart,e,this.openStart+1,this.openEnd+1);return n&&new i(n,this.openStart,this.openEnd)}removeBetween(t,e){return new i(_(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return i.empty;let n=e.openStart||0,r=e.openEnd||0;if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new i(f.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let s=t.firstChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=t.lastChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.lastChild)r++;return new i(t,n,r)}};S.empty=new S(f.empty,0,0);function _(i,t,e){let{index:n,offset:r}=i.findIndex(t),s=i.maybeChild(n),{index:l,offset:o}=i.findIndex(e);if(r==t||s.isText){if(o!=e&&!i.child(l).isText)throw new RangeError("Removing non-flat range");return i.cut(0,t).append(i.cut(e))}if(n!=l)throw new RangeError("Removing non-flat range");return i.replaceChild(n,s.copy(_(s.content,t-r-1,e-r-1)))}function tt(i,t,e,n,r,s){let{index:l,offset:o}=i.findIndex(t),a=i.maybeChild(l);if(o==t||a.isText)return s&&n<=0&&r<=0&&!s.canReplace(l,l,e)?null:i.cut(0,t).append(e).append(i.cut(t));let h=tt(a.content,t-o-1,e,l==0?n-1:0,l==i.childCount-1?r-1:0,a);return h&&i.replaceChild(l,a.copy(h))}function kt(i,t,e){if(e.openStart>i.depth)throw new b("Inserted content deeper than insertion position");if(i.depth-e.openStart!=t.depth-e.openEnd)throw new b("Inconsistent open depths");return et(i,t,e,0)}function et(i,t,e,n){let r=i.index(n),s=i.node(n);if(r==t.index(n)&&n<i.depth-e.openStart){let l=et(i,t,e,n+1);return s.copy(s.content.replaceChild(r,l))}else if(e.content.size)if(!e.openStart&&!e.openEnd&&i.depth==n&&t.depth==n){let l=i.parent,o=l.content;return y(l,o.cut(0,i.parentOffset).append(e.content).append(o.cut(t.parentOffset)))}else{let{start:l,end:o}=wt(e,i);return y(s,it(i,l,o,t,n))}else return y(s,C(i,t,n))}function nt(i,t){if(!t.type.compatibleContent(i.type))throw new b("Cannot join "+t.type.name+" onto "+i.type.name)}function I(i,t,e){let n=i.node(e);return nt(n,t.node(e)),n}function x(i,t){let e=t.length-1;e>=0&&i.isText&&i.sameMarkup(t[e])?t[e]=i.withText(t[e].text+i.text):t.push(i)}function O(i,t,e,n){let r=(t||i).node(e),s=0,l=t?t.index(e):r.childCount;i&&(s=i.index(e),i.depth>e?s++:i.textOffset&&(x(i.nodeAfter,n),s++));for(let o=s;o<l;o++)x(r.child(o),n);t&&t.depth==e&&t.textOffset&&x(t.nodeBefore,n)}function y(i,t){if(!i.type.validContent(t))throw new b("Invalid content for node "+i.type.name);return i.copy(t)}function it(i,t,e,n,r){let s=i.depth>r&&I(i,t,r+1),l=n.depth>r&&I(e,n,r+1),o=[];return O(null,i,r,o),s&&l&&t.index(r)==e.index(r)?(nt(s,l),x(y(s,it(i,t,e,n,r+1)),o)):(s&&x(y(s,C(i,t,r+1)),o),O(t,e,r,o),l&&x(y(l,C(e,n,r+1)),o)),O(n,null,r,o),new f(o)}function C(i,t,e){let n=[];if(O(null,i,e,n),i.depth>e){let r=I(i,t,e+1);x(y(r,C(i,t,e+1)),n)}return O(t,null,e,n),new f(n)}function wt(i,t){let e=t.depth-i.openStart,r=t.node(e).copy(i.content);for(let s=e-1;s>=0;s--)r=t.node(s).copy(f.from(r));return{start:r.resolveNoCache(i.openStart+e),end:r.resolveNoCache(r.content.size-i.openEnd-e)}}var v=class i{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let s=0;s<t;s++)r+=n.child(s).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return u.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let o=n;n=r,r=o}let s=n.marks;for(var l=0;l<s.length;l++)s[l].type.spec.inclusive===!1&&(!r||!s[l].isInSet(r.marks))&&(s=s[l--].removeFromSet(s));return s}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!r||!n[s].isInSet(r.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new B(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,s=e;for(let l=t;;){let{index:o,offset:a}=l.content.findIndex(s),h=s-a;if(n.push(l,o,r+a),!h||(l=l.child(o),l.isText))break;s=h-1,r+=a+1}return new i(e,n,s)}static resolveCached(t,e){let n=H.get(t);if(n)for(let s=0;s<n.elts.length;s++){let l=n.elts[s];if(l.pos==e)return l}else H.set(t,n=new F);let r=n.elts[n.i]=i.resolve(t,e);return n.i=(n.i+1)%bt,r}},F=class{constructor(){this.elts=[],this.i=0}},bt=12,H=new WeakMap,B=class{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},St=Object.create(null),g=class i{constructor(t,e,n,r=u.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||f.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&E(this.attrs,e||t.defaultAttrs||St)&&u.sameSet(this.marks,n||u.none)}copy(t=null){return t==this.content?this:new i(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new i(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return t==0&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return S.empty;let r=this.resolve(t),s=this.resolve(e),l=n?0:r.sharedDepth(e),o=r.start(l),h=r.node(l).content.cut(r.pos-o,s.pos-o);return new S(h,r.depth-l,s.depth-l)}replace(t,e,n){return kt(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return v.resolveCached(this,t)}resolveNoCache(t){return v.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,s=>(n.isInSet(s.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),rt(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=f.empty,r=0,s=n.childCount){let l=this.contentMatchAt(t).matchFragment(n,r,s),o=l&&l.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(t).matchType(n),l=s&&s.matchFragment(this.content,e);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=u.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!u.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(e=>e.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=f.fromJSON(t,e.content),s=t.nodeType(e.type).create(e.attrs,r,n);return s.type.checkAttrs(s.attrs),s}};g.prototype.text=void 0;var L=class i extends g{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new i(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new i(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return t==0&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function rt(i,t){for(let e=i.length-1;e>=0;e--)t=i[e].type.name+"("+t+")";return t}var k=class i{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new P(t,e);if(n.next==null)return i.empty;let r=st(n);n.next&&n.err("Unexpected trailing text");let s=Tt(At(r));return zt(s,n),s}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let s=e;r&&s<n;s++)r=r.matchType(t.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];function s(l,o){let a=l.matchFragment(t,n);if(a&&(!e||a.validEnd))return f.from(o.map(h=>h.createAndFill()));for(let h=0;h<l.next.length;h++){let{type:c,next:d}=l.next[h];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let m=s(d,o.concat(c));if(m)return m}}return null}return s(this,[])}findWrapping(t){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==t)return this.wrapCache[n+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(t)){let l=[];for(let o=r;o.type;o=o.via)l.push(o.type);return l.reverse()}for(let l=0;l<s.next.length;l++){let{type:o,next:a}=s.next[l];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in e)&&(!r.type||a.validEnd)&&(n.push({match:o.contentMatch,type:o,via:r}),e[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(n){t.push(n);for(let r=0;r<n.next.length;r++)t.indexOf(n.next[r].next)==-1&&e(n.next[r].next)}return e(this),t.map((n,r)=>{let s=r+(n.validEnd?"*":" ")+" ";for(let l=0;l<n.next.length;l++)s+=(l?", ":"")+n.next[l].type.name+"->"+t.indexOf(n.next[l].next);return s}).join(`
+`)}};k.empty=new k(!0);var P=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function st(i){let t=[];do t.push(Ot(i));while(i.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function Ot(i){let t=[];do t.push(Mt(i));while(i.next&&i.next!=")"&&i.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Mt(i){let t=vt(i);for(;;)if(i.eat("+"))t={type:"plus",expr:t};else if(i.eat("*"))t={type:"star",expr:t};else if(i.eat("?"))t={type:"opt",expr:t};else if(i.eat("{"))t=Et(i,t);else break;return t}function V(i){/\D/.test(i.next)&&i.err("Expected number, got '"+i.next+"'");let t=Number(i.next);return i.pos++,t}function Et(i,t){let e=V(i),n=e;return i.eat(",")&&(i.next!="}"?n=V(i):n=-1),i.eat("}")||i.err("Unclosed braced range"),{type:"range",min:e,max:n,expr:t}}function Ct(i,t){let e=i.nodeTypes,n=e[t];if(n)return[n];let r=[];for(let s in e){let l=e[s];l.isInGroup(t)&&r.push(l)}return r.length==0&&i.err("No node type or group '"+t+"' found"),r}function vt(i){if(i.eat("(")){let t=st(i);return i.eat(")")||i.err("Missing closing paren"),t}else if(/\W/.test(i.next))i.err("Unexpected token '"+i.next+"'");else{let t=Ct(i,i.next).map(e=>(i.inline==null?i.inline=e.isInline:i.inline!=e.isInline&&i.err("Mixing inline and block content"),{type:"name",value:e}));return i.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function At(i){let t=[[]];return r(s(i,0),e()),t;function e(){return t.push([])-1}function n(l,o,a){let h={term:a,to:o};return t[l].push(h),h}function r(l,o){l.forEach(a=>a.to=o)}function s(l,o){if(l.type=="choice")return l.exprs.reduce((a,h)=>a.concat(s(h,o)),[]);if(l.type=="seq")for(let a=0;;a++){let h=s(l.exprs[a],o);if(a==l.exprs.length-1)return h;r(h,o=e())}else if(l.type=="star"){let a=e();return n(o,a),r(s(l.expr,a),a),[n(a)]}else if(l.type=="plus"){let a=e();return r(s(l.expr,o),a),r(s(l.expr,a),a),[n(a)]}else{if(l.type=="opt")return[n(o)].concat(s(l.expr,o));if(l.type=="range"){let a=o;for(let h=0;h<l.min;h++){let c=e();r(s(l.expr,a),c),a=c}if(l.max==-1)r(s(l.expr,a),a);else for(let h=l.min;h<l.max;h++){let c=e();n(a,c),r(s(l.expr,a),c),a=c}return[n(a)]}else{if(l.type=="name")return[n(o,void 0,l.value)];throw new Error("Unknown expr type")}}}}function lt(i,t){return t-i}function Z(i,t){let e=[];return n(t),e.sort(lt);function n(r){let s=i[r];if(s.length==1&&!s[0].term)return n(s[0].to);e.push(r);for(let l=0;l<s.length;l++){let{term:o,to:a}=s[l];!o&&e.indexOf(a)==-1&&n(a)}}}function Tt(i){let t=Object.create(null);return e(Z(i,0));function e(n){let r=[];n.forEach(l=>{i[l].forEach(({term:o,to:a})=>{if(!o)return;let h;for(let c=0;c<r.length;c++)r[c][0]==o&&(h=r[c][1]);Z(i,a).forEach(c=>{h||r.push([o,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=t[n.join(",")]=new k(n.indexOf(i.length-1)>-1);for(let l=0;l<r.length;l++){let o=r[l][1].sort(lt);s.next.push({type:r[l][0],next:t[o.join(",")]||e(o)})}return s}}function zt(i,t){for(let e=0,n=[i];e<n.length;e++){let r=n[e],s=!r.validEnd,l=[];for(let o=0;o<r.next.length;o++){let{type:a,next:h}=r.next[o];l.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(h)==-1&&n.push(h)}s&&t.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ot(i){let t=Object.create(null);for(let e in i){let n=i[e];if(!n.hasDefault)return null;t[e]=n.default}return t}function at(i,t){let e=Object.create(null);for(let n in i){let r=t&&t[n];if(r===void 0){let s=i[n];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+n)}e[n]=r}return e}function ht(i,t,e,n){for(let r in t)if(!(r in i))throw new RangeError(`Unsupported attribute ${r} for ${e} of type ${n}`);for(let r in i)i[r].validate&&i[r].validate(t[r])}function ct(i,t){let e=Object.create(null);if(t)for(let n in t)e[n]=new W(i,n,t[n]);return e}var A=class i{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=ct(t,n.attrs),this.defaultAttrs=ot(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==k.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:at(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new g(this,this.computeAttrs(t),f.from(e),u.setFrom(n))}createChecked(t=null,e,n){return e=f.from(e),this.checkContent(e),new g(this,this.computeAttrs(t),e,u.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),e=f.from(e),e.size){let l=this.contentMatch.fillBefore(e);if(!l)return null;e=l.append(e)}let r=this.contentMatch.matchFragment(e),s=r&&r.fillBefore(f.empty,!0);return s?new g(this,t,e.append(s),u.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){ht(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:u.none:t}static compile(t,e){let n=Object.create(null);t.forEach((s,l)=>n[s]=new i(s,e,l));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Rt(i,t,e){let n=e.split("|");return r=>{let s=r===null?"null":typeof r;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${i}, got ${s}`)}}var W=class{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Rt(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}},q=class i{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=ct(t,r.attrs),this.excluded=null;let s=ot(this.attrs);this.instance=s?new u(this,s):null}create(t=null){return!t&&this.instance?this.instance:new u(this,at(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach((s,l)=>n[s]=new i(s,r++,e,l)),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){ht(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}},T=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=D.from(t.nodes),e.marks=D.from(t.marks||{}),this.nodes=A.compile(this.spec.nodes,this),this.marks=q.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],l=s.spec.content||"",o=s.spec.marks;if(s.contentMatch=n[l]||(n[l]=k.parse(l,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=o=="_"?null:o?G(this,o.split(" ")):o==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],l=s.spec.excludes;s.excluded=l==null?[s]:l==""?[]:G(this,l.split(" "))}this.nodeFromJSON=r=>g.fromJSON(this,r),this.markFromJSON=r=>u.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof A){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new L(n,n.defaultAttrs,t,u.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function G(i,t){let e=[];for(let n=0;n<t.length;n++){let r=t[n],s=i.marks[r],l=s;if(s)e.push(s);else for(let o in i.marks){let a=i.marks[o];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&e.push(l=a)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return e}var ut="http://www.w3.org/2000/svg",Dt={page:["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 13h6","M9 17h4"],"page-plus":["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 15h6","M12 12v6"],calendar:["M8 2v4","M16 2v4","M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z","M3 10h18"],block:["M13 4v16","M17 4v16","M19 4H9.5a4.5 4.5 0 0 0 0 9H13"],embed:["M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z","m3.3 7 8.7 5 8.7-5","M12 22V12"]};function ft(i){return[`${ut} svg`,{"mapa-i":"",viewBox:"0 0 24 24","aria-hidden":"true"},...Dt[i].map(t=>[`${ut} path`,{d:t}])]}function z({href:i,kind:t,title:e,label:n,icon:r,shown:s,note:l}){let o={href:i,"mapa-chip":t};e&&(o.title=e),o["aria-label"]=n;let a=["a",o,ft(r),s];return l&&a.push(["span",{"mapa-chip-note":""},l]),a}function J({target:i,anchor:t,shown:e},n){let r=e||i;if(n.broken)return["span",{"mapa-chip":"broken"},r];if(n.day)return Nt(e,n);if(n.pending)return z({href:n.href,kind:"pending",icon:"page-plus",shown:r,label:`${r}, page not written yet`});let s=n.title||i,l={href:n.href,kind:"team",icon:"page",shown:r,label:`${r}, team page`};return n.alias&&(l.title=`Now called ${s}`,l.label=`${r}, now called ${s}`),t&&(l.kind=l.icon="block",l.label=`${r}, a block in ${s}`),t&&n.blockGone&&(l.kind="block gone",l.label=`${r}, block removed from ${s}`,l.note="block removed"),z(l)}function Nt(i,t){return z(i?{href:t.href,kind:"date",icon:"calendar",shown:i,label:`${i}, your note for ${t.day}`}:{href:t.href,kind:"date",icon:"calendar",shown:t.day,label:`${t.day}, your note`})}function pt(i){return["span",{"mapa-chip":"embed",role:"img","aria-label":`${i}, embedded item, not shown yet`},ft("embed"),i]}var It=/^[A-Za-z0-9\-_.~!$&'()*+,;=:[\]<>"]$/u,Ft=/^[A-Za-z0-9\-._:~!$&'()*+,;=%@]$/u,dt=/^[0-9A-Fa-f]$/u;function j(i){let t=Bt(i);if(t===null)return!1;switch(t.scheme){case"http":case"https":return t.host!==""&&!t.host.startsWith("[");case"mailto":return t.opaque!==""}return!1}function Bt(i){let t=i.indexOf("#"),e=t<0?i:i.slice(0,t),n=t<0?"":i.slice(t+1),r=Lt(e);return r===null||n!==""&&!$(n)?null:r}function Lt(i){if(/[\x00-\x1f\x7f]/u.test(i))return null;if(i==="*")return{scheme:"",host:"",opaque:""};let t=Pt(i);if(t===null)return null;let e=t.rest,n={scheme:t.name.toLowerCase(),host:"",opaque:""};if(e.endsWith("?")&&e.split("?").length===2?e=e.slice(0,-1):e.includes("?")&&(e=e.slice(0,e.indexOf("?"))),!e.startsWith("/")){if(n.scheme!=="")return n.opaque=e,n;if(e.split("/")[0].includes(":"))return null}if((n.scheme!==""||!e.startsWith("///"))&&e.startsWith("//")){let r=e.slice(2);e="";let s=r.indexOf("/");s>=0&&(e=r.slice(s),r=r.slice(0,s));let l=Wt(n.scheme,r);if(l===null)return null;n.host=l}return $(e)?n:null}function Pt(i){for(let t=0;t<i.length;t++){let e=i[t];if(!/^[A-Za-z]$/u.test(e)){if(/^[0-9+\-.]$/u.test(e)){if(t===0)return{name:"",rest:i};continue}return e===":"?t===0?null:{name:i.slice(0,t),rest:i.slice(t+1)}:{name:"",rest:i}}}return{name:"",rest:i}}function Wt(i,t){let e=t.lastIndexOf("@"),n=qt(i,e<0?t:t.slice(e+1));if(n===null||e<0)return n;let r=t.slice(0,e);for(let s of r)if(!Ft.test(s))return null;return $(r)?n:null}function qt(i,t){let e=t.lastIndexOf("[");if(e>0)return null;if(e===0)return"[";let n=t.indexOf(":");if(n!==-1){let r=t.lastIndexOf(":");if(r!==n&&i!=="http"&&i!=="https"&&(n=r),!/^:[0-9]*$/u.test(t.slice(n)))return null}return Jt(t)?t:null}function Jt(i){for(let t=0;t<i.length;t++){let e=i[t];if(e==="%"){if(!gt(i,t)||parseInt(i[t+1],16)<8&&i.slice(t,t+3)!=="%25")return!1;t+=2}else if(e.charCodeAt(0)<128&&!It.test(e))return!1}return!0}function $(i){for(let t=0;t<i.length;t++)if(i[t]==="%"){if(!gt(i,t))return!1;t+=2}return!0}function gt(i,t){return t+2<i.length&&dt.test(i[t+1])&&dt.test(i[t+2])}var w="[^\\t\\n\\f\\r ]",te=new RegExp(`^(#{1,6})[ \\t]+${w}`,"u");var jt=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/u;function $t(i){return jt.test(i)}function mt(i){if(!$t(i))return!1;let[t,e,n]=i.split("-").map(Number);if(e<1||e>12||n<1)return!1;let s=[31,t%4===0&&(t%100!==0||t%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];return n<=s[e-1]}var ee=new RegExp(`\\*\\*\\*(${w}(?:[^*]*?${w})?)\\*\\*\\*`,"gu"),ne=new RegExp(`\\*\\*(${w}(?:[^*]*?${w})?)\\*\\*`,"gu"),ie=new RegExp(`\\*(${w}(?:[^*]*?${w})?)\\*`,"gu");function R(i){return i.attrs.marker?{id:`b-${i.attrs.marker}`}:{}}var xt={origin:{default:null},marker:{default:null}},Ut={doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...xt},parseDOM:[{tag:"p"}],toDOM:i=>["p",R(i),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{...xt,level:{default:1},source:{default:null}},parseDOM:[1,2,3,4,5,6].map(i=>({tag:`h${i}`,attrs:{level:Math.max(i-1,1)}})),toDOM:i=>[`h${Math.min(i.attrs.level+1,6)}`,R(i),0]},bullet_list:{group:"block",content:"list_item+",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},ordered_list:{group:"block",content:"list_item+",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},list_item:{content:"paragraph (bullet_list | ordered_list)*",defining:!0,attrs:{marker:{default:null},indent:{default:""},bullet:{default:"-"},number:{default:null},delim:{default:null},task:{default:!1},checked:{default:null}},parseDOM:[{tag:"li",getAttrs:i=>{let t=i.getAttribute("mapa-task");return t==="open"?{task:!0,checked:" "}:t==="done"?{task:!0,checked:"x"}:{}}}],toDOM:i=>{let t=R(i);return i.attrs.task&&(t["mapa-task"]=i.attrs.checked===" "?"open":"done"),["li",t,0]}},blockquote:{group:"block",content:"paragraph",defining:!0,attrs:{marker:{default:null},prefix:{default:null}},parseDOM:[{tag:"blockquote"}],toDOM:i=>["blockquote",R(i),0]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{origin:{default:null},fence:{default:"```"},info:{default:""},closed:{default:!0},close:{default:"```"}},parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>["pre",["code",0]]},horizontal_rule:{group:"block",attrs:{origin:{default:null},source:{default:"---"}},parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},text:{group:"inline"},hard_break:{inline:!0,group:"inline",selectable:!1,attrs:{indent:{default:""}},parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},Ht={link:{attrs:{href:{},bare:{default:!1}},inclusive:!1,excludes:"em strong code",parseDOM:[{tag:"a[href]",getAttrs:i=>j(i.getAttribute("href"))?{href:i.getAttribute("href")}:!1}],toDOM:i=>["a",{href:i.attrs.href,rel:"noopener noreferrer"},0]},em:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:i=>i.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:i=>/^(bold(er)?|[6-9]\d{2,})$/u.test(i)&&null}],toDOM:()=>["strong",0]},code:{excludes:"_",parseDOM:[{tag:"code"}],toDOM:()=>["code",0]}};function U(i){let t="";for(let e of i.childNodes)e.nodeType===3&&(t+=e.nodeValue);return t.trim()}function Vt(i){let t={inline:!0,group:"inline",atom:!0,selectable:!0};return{wikilink:{...t,attrs:{target:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},parseDOM:[{tag:"a[mapa-chip]",priority:60,getAttrs:e=>{if(/^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u.exec(e.getAttribute("href")??""))return!1;let r=U(e);return r===""?!1:{target:r}}}],toDOM:e=>J(e.attrs,i(e.attrs.target,e.attrs.anchor))},datelink:{...t,attrs:{date:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},parseDOM:[{tag:"a[mapa-chip]",priority:61,getAttrs:e=>{let n=/^\/d\/([0-9]{4}-[0-9]{2}-[0-9]{2})$/u.exec(e.getAttribute("href")??"");return n&&mt(n[1])?{date:n[1]}:!1}}],toDOM:e=>J({...e.attrs,target:e.attrs.date},i(e.attrs.date,e.attrs.anchor))},embed:{...t,attrs:{ref:{},source:{default:null},origin:{default:null}},parseDOM:[{tag:'span[mapa-chip="embed"]',priority:60,getAttrs:e=>U(e)===""?!1:{ref:U(e)}}],toDOM:e=>pt(e.attrs.ref)}}}var Zt=i=>({href:`/new?title=${encodeURIComponent(i)}`,pending:!0});function yt(i=Zt){return new T({nodes:{...Ut,...Vt(i)},marks:Ht})}var ce=yt();export{ce as schema};
diff --git a/internal/mapa/static/editor.9c9edc5536b1d844.js b/internal/mapa/static/editor.9c9edc5536b1d844.js
deleted file mode 100644
index 83b4696..0000000
--- a/internal/mapa/static/editor.9c9edc5536b1d844.js
+++ /dev/null
@@ -1,2 +0,0 @@
-function p(i){this.content=i}p.prototype={constructor:p,find:function(i){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===i)return t;return-1},get:function(i){var t=this.find(i);return t==-1?void 0:this.content[t+1]},update:function(i,t,e){var n=e&&e!=i?this.remove(e):this,r=n.find(i),s=n.content.slice();return r==-1?s.push(e||i,t):(s[r+1]=t,e&&(s[r]=e)),new p(s)},remove:function(i){var t=this.find(i);if(t==-1)return this;var e=this.content.slice();return e.splice(t,2),new p(e)},addToStart:function(i,t){return new p([i,t].concat(this.remove(i).content))},addToEnd:function(i,t){var e=this.remove(i).content.slice();return e.push(i,t),new p(e)},addBefore:function(i,t,e){var n=this.remove(t),r=n.content.slice(),s=n.find(i);return r.splice(s==-1?r.length:s,0,t,e),new p(r)},forEach:function(i){for(var t=0;t<this.content.length;t+=2)i(this.content[t],this.content[t+1])},prepend:function(i){return i=p.from(i),i.size?new p(i.content.concat(this.subtract(i).content)):this},append:function(i){return i=p.from(i),i.size?new p(this.subtract(i).content.concat(i.content)):this},subtract:function(i){var t=this;i=p.from(i);for(var e=0;e<i.content.length;e+=2)t=t.remove(i.content[e]);return t},toObject:function(){var i={};return this.forEach(function(t,e){i[t]=e}),i},get size(){return this.content.length>>1}};p.from=function(i){if(i instanceof p)return i;var t=[];if(i)for(var e in i)t.push(e,i[e]);return new p(t)};var N=p;function H(i,t,e){for(let n=0;;n++){if(n==i.childCount||n==t.childCount)return i.childCount==t.childCount?null:e;let r=i.child(n),s=t.child(n);if(r==s){e+=r.nodeSize;continue}if(!r.sameMarkup(s))return e;if(r.isText&&r.text!=s.text){let l=r.text,o=s.text,h=0;for(;l[h]==o[h];h++)e++;return h&&h<l.length&&h<o.length&&Q(l.charCodeAt(h-1))&&Z(l.charCodeAt(h))&&e--,e}if(r.content.size||s.content.size){let l=H(r.content,s.content,e+1);if(l!=null)return l}e+=r.nodeSize}}function G(i,t,e,n){for(let r=i.childCount,s=t.childCount;;){if(r==0||s==0)return r==s?null:{a:e,b:n};let l=i.child(--r),o=t.child(--s),h=l.nodeSize;if(l==o){e-=h,n-=h;continue}if(!l.sameMarkup(o))return{a:e,b:n};if(l.isText&&l.text!=o.text){let a=l.text,f=o.text,d=a.length,m=f.length;for(;d>0&&m>0&&a[d-1]==f[m-1];)d--,m--,e--,n--;return d&&m&&d<a.length&&Q(a.charCodeAt(d-1))&&Z(a.charCodeAt(d))&&(e++,n++),{a:e,b:n}}if(l.content.size||o.content.size){let a=G(l.content,o.content,e-1,n-1);if(a)return a}e-=h,n-=h}}function Z(i){return i>=56320&&i<57344}function Q(i){return i>=55296&&i<56320}var u=class i{constructor(t,e){if(this.content=t,this.size=e||0,e==null)for(let n=0;n<t.length;n++)this.size+=t[n].nodeSize}nodesBetween(t,e,n,r=0,s){for(let l=0,o=0;o<e;l++){let h=this.content[l],a=o+h.nodeSize;if(a>t&&n(h,r+o,s||null,l)!==!1&&h.content.size){let f=o+1;h.nodesBetween(Math.max(0,t-f),Math.min(h.content.size,e-f),n,r+f)}o=a}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let s="",l=!0;return this.nodesBetween(t,e,(o,h)=>{let a=o.isText?o.text.slice(Math.max(t,h)-h,e-h):o.isLeaf?r?typeof r=="function"?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&n&&(l?l=!1:s+=n),s+=a},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),s=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),s=1);s<t.content.length;s++)r.push(t.content[s]);return new i(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let n=[],r=0;if(e>t)for(let s=0,l=0;l<e;s++){let o=this.content[s],h=l+o.nodeSize;h>t&&((l<t||h>e)&&(o.isText?o=o.cut(Math.max(0,t-l),Math.min(o.text.length,e-l)):o=o.cut(Math.max(0,t-l-1),Math.min(o.content.size,e-l-1))),n.push(o),r+=o.nodeSize),l=h}return new i(n,r)}cutByIndex(t,e){return t==e?i.empty:t==0&&e==this.content.length?this:new i(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),s=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new i(r,s)}addToStart(t){return new i([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new i(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return H(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return G(this,t,e,n)}findIndex(t){if(t==0)return O(0,t);if(t==this.size)return O(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=this.child(e),s=n+r.nodeSize;if(s>=t)return s==t?O(e+1,s):O(e,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return i.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return i.fromArray(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return i.empty;let e,n=0;for(let r=0;r<t.length;r++){let s=t[r];n+=s.nodeSize,r&&s.isText&&t[r-1].sameMarkup(s)?(e||(e=t.slice(0,r)),e[e.length-1]=s.withText(e[e.length-1].text+s.text)):e&&e.push(s)}return new i(e||t,n)}static from(t){if(!t)return i.empty;if(t instanceof i)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new i([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};u.empty=new u([],0);var R={index:0,offset:0};function O(i,t){return R.index=i,R.offset=t,R}function E(i,t){if(i===t)return!0;if(!(i&&typeof i=="object")||!(t&&typeof t=="object"))return!1;let e=Array.isArray(i);if(Array.isArray(t)!=e)return!1;if(e){if(i.length!=t.length)return!1;for(let n=0;n<i.length;n++)if(!E(i[n],t[n]))return!1}else{for(let n in i)if(!(n in t)||!E(i[n],t[n]))return!1;for(let n in t)if(!(n in i))return!1}return!0}var c=class i{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let s=t[r];if(this.eq(s))return t;if(this.type.excludes(s.type))e||(e=t.slice(0,r));else{if(s.type.excludes(this.type))return t;!n&&s.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(s)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&E(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return i.none;if(t instanceof i)return[t];let e=t.slice();return e.sort((n,r)=>n.type.rank-r.type.rank),e}};c.none=[];var w=class extends Error{},S=class i{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=Y(this.content,t+this.openStart,e,this.openStart+1,this.openEnd+1);return n&&new i(n,this.openStart,this.openEnd)}removeBetween(t,e){return new i(X(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return i.empty;let n=e.openStart||0,r=e.openEnd||0;if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new i(u.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let s=t.firstChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=t.lastChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.lastChild)r++;return new i(t,n,r)}};S.empty=new S(u.empty,0,0);function X(i,t,e){let{index:n,offset:r}=i.findIndex(t),s=i.maybeChild(n),{index:l,offset:o}=i.findIndex(e);if(r==t||s.isText){if(o!=e&&!i.child(l).isText)throw new RangeError("Removing non-flat range");return i.cut(0,t).append(i.cut(e))}if(n!=l)throw new RangeError("Removing non-flat range");return i.replaceChild(n,s.copy(X(s.content,t-r-1,e-r-1)))}function Y(i,t,e,n,r,s){let{index:l,offset:o}=i.findIndex(t),h=i.maybeChild(l);if(o==t||h.isText)return s&&n<=0&&r<=0&&!s.canReplace(l,l,e)?null:i.cut(0,t).append(e).append(i.cut(t));let a=Y(h.content,t-o-1,e,l==0?n-1:0,l==i.childCount-1?r-1:0,h);return a&&i.replaceChild(l,h.copy(a))}function ut(i,t,e){if(e.openStart>i.depth)throw new w("Inserted content deeper than insertion position");if(i.depth-e.openStart!=t.depth-e.openEnd)throw new w("Inconsistent open depths");return K(i,t,e,0)}function K(i,t,e,n){let r=i.index(n),s=i.node(n);if(r==t.index(n)&&n<i.depth-e.openStart){let l=K(i,t,e,n+1);return s.copy(s.content.replaceChild(r,l))}else if(e.content.size)if(!e.openStart&&!e.openEnd&&i.depth==n&&t.depth==n){let l=i.parent,o=l.content;return y(l,o.cut(0,i.parentOffset).append(e.content).append(o.cut(t.parentOffset)))}else{let{start:l,end:o}=pt(e,i);return y(s,_(i,l,o,t,n))}else return y(s,M(i,t,n))}function $(i,t){if(!t.type.compatibleContent(i.type))throw new w("Cannot join "+t.type.name+" onto "+i.type.name)}function I(i,t,e){let n=i.node(e);return $(n,t.node(e)),n}function x(i,t){let e=t.length-1;e>=0&&i.isText&&i.sameMarkup(t[e])?t[e]=i.withText(t[e].text+i.text):t.push(i)}function b(i,t,e,n){let r=(t||i).node(e),s=0,l=t?t.index(e):r.childCount;i&&(s=i.index(e),i.depth>e?s++:i.textOffset&&(x(i.nodeAfter,n),s++));for(let o=s;o<l;o++)x(r.child(o),n);t&&t.depth==e&&t.textOffset&&x(t.nodeBefore,n)}function y(i,t){if(!i.type.validContent(t))throw new w("Invalid content for node "+i.type.name);return i.copy(t)}function _(i,t,e,n,r){let s=i.depth>r&&I(i,t,r+1),l=n.depth>r&&I(e,n,r+1),o=[];return b(null,i,r,o),s&&l&&t.index(r)==e.index(r)?($(s,l),x(y(s,_(i,t,e,n,r+1)),o)):(s&&x(y(s,M(i,t,r+1)),o),b(t,e,r,o),l&&x(y(l,M(e,n,r+1)),o)),b(n,null,r,o),new u(o)}function M(i,t,e){let n=[];if(b(null,i,e,n),i.depth>e){let r=I(i,t,e+1);x(y(r,M(i,t,e+1)),n)}return b(t,null,e,n),new u(n)}function pt(i,t){let e=t.depth-i.openStart,r=t.node(e).copy(i.content);for(let s=e-1;s>=0;s--)r=t.node(s).copy(u.from(r));return{start:r.resolveNoCache(i.openStart+e),end:r.resolveNoCache(r.content.size-i.openEnd-e)}}var C=class i{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let s=0;s<t;s++)r+=n.child(s).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return c.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let o=n;n=r,r=o}let s=n.marks;for(var l=0;l<s.length;l++)s[l].type.spec.inclusive===!1&&(!r||!s[l].isInSet(r.marks))&&(s=s[l--].removeFromSet(s));return s}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!r||!n[s].isInSet(r.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new F(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,s=e;for(let l=t;;){let{index:o,offset:h}=l.content.findIndex(s),a=s-h;if(n.push(l,o,r+h),!a||(l=l.child(o),l.isText))break;s=a-1,r+=h+1}return new i(e,n,s)}static resolveCached(t,e){let n=W.get(t);if(n)for(let s=0;s<n.elts.length;s++){let l=n.elts[s];if(l.pos==e)return l}else W.set(t,n=new D);let r=n.elts[n.i]=i.resolve(t,e);return n.i=(n.i+1)%dt,r}},D=class{constructor(){this.elts=[],this.i=0}},dt=12,W=new WeakMap,F=class{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},gt=Object.create(null),g=class i{constructor(t,e,n,r=c.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||u.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&E(this.attrs,e||t.defaultAttrs||gt)&&c.sameSet(this.marks,n||c.none)}copy(t=null){return t==this.content?this:new i(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new i(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return t==0&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return S.empty;let r=this.resolve(t),s=this.resolve(e),l=n?0:r.sharedDepth(e),o=r.start(l),a=r.node(l).content.cut(r.pos-o,s.pos-o);return new S(a,r.depth-l,s.depth-l)}replace(t,e,n){return ut(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return C.resolveCached(this,t)}resolveNoCache(t){return C.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,s=>(n.isInSet(s.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),tt(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=u.empty,r=0,s=n.childCount){let l=this.contentMatchAt(t).matchFragment(n,r,s),o=l&&l.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let h=r;h<s;h++)if(!this.type.allowsMarks(n.child(h).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(t).matchType(n),l=s&&s.matchFragment(this.content,e);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=c.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!c.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(e=>e.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=u.fromJSON(t,e.content),s=t.nodeType(e.type).create(e.attrs,r,n);return s.type.checkAttrs(s.attrs),s}};g.prototype.text=void 0;var B=class i extends g{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):tt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new i(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new i(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return t==0&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function tt(i,t){for(let e=i.length-1;e>=0;e--)t=i[e].type.name+"("+t+")";return t}var k=class i{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new P(t,e);if(n.next==null)return i.empty;let r=et(n);n.next&&n.err("Unexpected trailing text");let s=bt(St(r));return Ot(s,n),s}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let s=e;r&&s<n;s++)r=r.matchType(t.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];function s(l,o){let h=l.matchFragment(t,n);if(h&&(!e||h.validEnd))return u.from(o.map(a=>a.createAndFill()));for(let a=0;a<l.next.length;a++){let{type:f,next:d}=l.next[a];if(!(f.isText||f.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let m=s(d,o.concat(f));if(m)return m}}return null}return s(this,[])}findWrapping(t){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==t)return this.wrapCache[n+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(t)){let l=[];for(let o=r;o.type;o=o.via)l.push(o.type);return l.reverse()}for(let l=0;l<s.next.length;l++){let{type:o,next:h}=s.next[l];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in e)&&(!r.type||h.validEnd)&&(n.push({match:o.contentMatch,type:o,via:r}),e[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(n){t.push(n);for(let r=0;r<n.next.length;r++)t.indexOf(n.next[r].next)==-1&&e(n.next[r].next)}return e(this),t.map((n,r)=>{let s=r+(n.validEnd?"*":" ")+" ";for(let l=0;l<n.next.length;l++)s+=(l?", ":"")+n.next[l].type.name+"->"+t.indexOf(n.next[l].next);return s}).join(`
-`)}};k.empty=new k(!0);var P=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function et(i){let t=[];do t.push(mt(i));while(i.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function mt(i){let t=[];do t.push(xt(i));while(i.next&&i.next!=")"&&i.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function xt(i){let t=wt(i);for(;;)if(i.eat("+"))t={type:"plus",expr:t};else if(i.eat("*"))t={type:"star",expr:t};else if(i.eat("?"))t={type:"opt",expr:t};else if(i.eat("{"))t=yt(i,t);else break;return t}function j(i){/\D/.test(i.next)&&i.err("Expected number, got '"+i.next+"'");let t=Number(i.next);return i.pos++,t}function yt(i,t){let e=j(i),n=e;return i.eat(",")&&(i.next!="}"?n=j(i):n=-1),i.eat("}")||i.err("Unclosed braced range"),{type:"range",min:e,max:n,expr:t}}function kt(i,t){let e=i.nodeTypes,n=e[t];if(n)return[n];let r=[];for(let s in e){let l=e[s];l.isInGroup(t)&&r.push(l)}return r.length==0&&i.err("No node type or group '"+t+"' found"),r}function wt(i){if(i.eat("(")){let t=et(i);return i.eat(")")||i.err("Missing closing paren"),t}else if(/\W/.test(i.next))i.err("Unexpected token '"+i.next+"'");else{let t=kt(i,i.next).map(e=>(i.inline==null?i.inline=e.isInline:i.inline!=e.isInline&&i.err("Mixing inline and block content"),{type:"name",value:e}));return i.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function St(i){let t=[[]];return r(s(i,0),e()),t;function e(){return t.push([])-1}function n(l,o,h){let a={term:h,to:o};return t[l].push(a),a}function r(l,o){l.forEach(h=>h.to=o)}function s(l,o){if(l.type=="choice")return l.exprs.reduce((h,a)=>h.concat(s(a,o)),[]);if(l.type=="seq")for(let h=0;;h++){let a=s(l.exprs[h],o);if(h==l.exprs.length-1)return a;r(a,o=e())}else if(l.type=="star"){let h=e();return n(o,h),r(s(l.expr,h),h),[n(h)]}else if(l.type=="plus"){let h=e();return r(s(l.expr,o),h),r(s(l.expr,h),h),[n(h)]}else{if(l.type=="opt")return[n(o)].concat(s(l.expr,o));if(l.type=="range"){let h=o;for(let a=0;a<l.min;a++){let f=e();r(s(l.expr,h),f),h=f}if(l.max==-1)r(s(l.expr,h),h);else for(let a=l.min;a<l.max;a++){let f=e();n(h,f),r(s(l.expr,h),f),h=f}return[n(h)]}else{if(l.type=="name")return[n(o,void 0,l.value)];throw new Error("Unknown expr type")}}}}function nt(i,t){return t-i}function U(i,t){let e=[];return n(t),e.sort(nt);function n(r){let s=i[r];if(s.length==1&&!s[0].term)return n(s[0].to);e.push(r);for(let l=0;l<s.length;l++){let{term:o,to:h}=s[l];!o&&e.indexOf(h)==-1&&n(h)}}}function bt(i){let t=Object.create(null);return e(U(i,0));function e(n){let r=[];n.forEach(l=>{i[l].forEach(({term:o,to:h})=>{if(!o)return;let a;for(let f=0;f<r.length;f++)r[f][0]==o&&(a=r[f][1]);U(i,h).forEach(f=>{a||r.push([o,a=[]]),a.indexOf(f)==-1&&a.push(f)})})});let s=t[n.join(",")]=new k(n.indexOf(i.length-1)>-1);for(let l=0;l<r.length;l++){let o=r[l][1].sort(nt);s.next.push({type:r[l][0],next:t[o.join(",")]||e(o)})}return s}}function Ot(i,t){for(let e=0,n=[i];e<n.length;e++){let r=n[e],s=!r.validEnd,l=[];for(let o=0;o<r.next.length;o++){let{type:h,next:a}=r.next[o];l.push(h.name),s&&!(h.isText||h.hasRequiredAttrs())&&(s=!1),n.indexOf(a)==-1&&n.push(a)}s&&t.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function it(i){let t=Object.create(null);for(let e in i){let n=i[e];if(!n.hasDefault)return null;t[e]=n.default}return t}function rt(i,t){let e=Object.create(null);for(let n in i){let r=t&&t[n];if(r===void 0){let s=i[n];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+n)}e[n]=r}return e}function st(i,t,e,n){for(let r in t)if(!(r in i))throw new RangeError(`Unsupported attribute ${r} for ${e} of type ${n}`);for(let r in i)i[r].validate&&i[r].validate(t[r])}function lt(i,t){let e=Object.create(null);if(t)for(let n in t)e[n]=new J(i,n,t[n]);return e}var v=class i{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=lt(t,n.attrs),this.defaultAttrs=it(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==k.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:rt(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new g(this,this.computeAttrs(t),u.from(e),c.setFrom(n))}createChecked(t=null,e,n){return e=u.from(e),this.checkContent(e),new g(this,this.computeAttrs(t),e,c.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),e=u.from(e),e.size){let l=this.contentMatch.fillBefore(e);if(!l)return null;e=l.append(e)}let r=this.contentMatch.matchFragment(e),s=r&&r.fillBefore(u.empty,!0);return s?new g(this,t,e.append(s),c.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){st(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:c.none:t}static compile(t,e){let n=Object.create(null);t.forEach((s,l)=>n[s]=new i(s,e,l));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Et(i,t,e){let n=e.split("|");return r=>{let s=r===null?"null":typeof r;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${t} on type ${i}, got ${s}`)}}var J=class{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Et(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}},q=class i{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=lt(t,r.attrs),this.excluded=null;let s=it(this.attrs);this.instance=s?new c(this,s):null}create(t=null){return!t&&this.instance?this.instance:new c(this,rt(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach((s,l)=>n[s]=new i(s,r++,e,l)),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){st(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}},T=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=N.from(t.nodes),e.marks=N.from(t.marks||{}),this.nodes=v.compile(this.spec.nodes,this),this.marks=q.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],l=s.spec.content||"",o=s.spec.marks;if(s.contentMatch=n[l]||(n[l]=k.parse(l,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=o=="_"?null:o?V(this,o.split(" ")):o==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],l=s.spec.excludes;s.excluded=l==null?[s]:l==""?[]:V(this,l.split(" "))}this.nodeFromJSON=r=>g.fromJSON(this,r),this.markFromJSON=r=>c.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof v){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new B(n,n.defaultAttrs,t,c.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function V(i,t){let e=[];for(let n=0;n<t.length;n++){let r=t[n],s=i.marks[r],l=s;if(s)e.push(s);else for(let o in i.marks){let h=i.marks[o];(r=="_"||h.spec.group&&h.spec.group.split(" ").indexOf(r)>-1)&&e.push(l=h)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return e}var ot="http://www.w3.org/2000/svg",Mt={page:["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 13h6","M9 17h4"],"page-plus":["M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z","M14 2v4a2 2 0 0 0 2 2h4","M9 15h6","M12 12v6"],calendar:["M8 2v4","M16 2v4","M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z","M3 10h18"],block:["M13 4v16","M17 4v16","M19 4H9.5a4.5 4.5 0 0 0 0 9H13"],embed:["M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z","m3.3 7 8.7 5 8.7-5","M12 22V12"]};function ht(i){return[`${ot} svg`,{"mapa-i":"",viewBox:"0 0 24 24","aria-hidden":"true"},...Mt[i].map(t=>[`${ot} path`,{d:t}])]}function A({href:i,kind:t,title:e,label:n,icon:r,shown:s,note:l}){let o={href:i,"mapa-chip":t};e&&(o.title=e),o["aria-label"]=n;let h=["a",o,ht(r),s];return l&&h.push(["span",{"mapa-chip-note":""},l]),h}function L({target:i,anchor:t,shown:e},n){let r=e||i;if(n.broken)return["span",{"mapa-chip":"broken"},r];if(n.day)return Ct(e,n);if(n.pending)return A({href:n.href,kind:"pending",icon:"page-plus",shown:r,label:`${r}, page not written yet`});let s=n.title||i,l={href:n.href,kind:"team",icon:"page",shown:r,label:`${r}, team page`};return n.alias&&(l.title=`Now called ${s}`,l.label=`${r}, now called ${s}`),t&&(l.kind=l.icon="block",l.label=`${r}, a block in ${s}`),t&&n.blockGone&&(l.kind="block gone",l.label=`${r}, block removed from ${s}`,l.note="block removed"),A(l)}function Ct(i,t){return A(i?{href:t.href,kind:"date",icon:"calendar",shown:i,label:`${i}, your note for ${t.day}`}:{href:t.href,kind:"date",icon:"calendar",shown:t.day,label:`${t.day}, your note`})}function at(i){return["span",{"mapa-chip":"embed",role:"img","aria-label":`${i}, embedded item, not shown yet`},ht("embed"),i]}function z(i){return i.attrs.marker?{id:`b-${i.attrs.marker}`}:{}}var ft={origin:{default:null},marker:{default:null}},vt={doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...ft},toDOM:i=>["p",z(i),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{...ft,level:{default:1},source:{default:null}},toDOM:i=>[`h${Math.min(i.attrs.level+1,6)}`,z(i),0]},bullet_list:{group:"block",content:"list_item+",toDOM:()=>["ul",0]},ordered_list:{group:"block",content:"list_item+",toDOM:()=>["ol",0]},list_item:{content:"paragraph (bullet_list | ordered_list)*",defining:!0,attrs:{marker:{default:null},indent:{default:""},bullet:{default:"-"},number:{default:null},delim:{default:null},task:{default:!1},checked:{default:null}},toDOM:i=>{let t=z(i);return i.attrs.task&&(t["mapa-task"]=i.attrs.checked===" "?"open":"done"),["li",t,0]}},blockquote:{group:"block",content:"paragraph",defining:!0,attrs:{marker:{default:null},prefix:{default:null}},toDOM:i=>["blockquote",z(i),0]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{origin:{default:null},fence:{default:"```"},info:{default:""},closed:{default:!0}},toDOM:()=>["pre",["code",0]]},horizontal_rule:{group:"block",attrs:{origin:{default:null},source:{default:"---"}},toDOM:()=>["hr"]},text:{group:"inline"},hard_break:{inline:!0,group:"inline",selectable:!1,attrs:{indent:{default:""}},toDOM:()=>["br"]}},Tt={link:{attrs:{href:{},bare:{default:!1}},inclusive:!1,excludes:"em strong code",toDOM:i=>["a",{href:i.attrs.href,rel:"noopener noreferrer"},0]},em:{toDOM:()=>["em",0]},strong:{toDOM:()=>["strong",0]},code:{excludes:"_",toDOM:()=>["code",0]}};function At(i){let t={inline:!0,group:"inline",atom:!0,selectable:!0};return{wikilink:{...t,attrs:{target:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},toDOM:e=>L(e.attrs,i(e.attrs.target,e.attrs.anchor))},datelink:{...t,attrs:{date:{},anchor:{default:""},shown:{default:""},source:{default:null},origin:{default:null}},toDOM:e=>L({...e.attrs,target:e.attrs.date},i(e.attrs.date,e.attrs.anchor))},embed:{...t,attrs:{ref:{},source:{default:null},origin:{default:null}},toDOM:e=>at(e.attrs.ref)}}}var zt=i=>({href:`/new?title=${encodeURIComponent(i)}`,pending:!0});function ct(i=zt){return new T({nodes:{...vt,...At(i)},marks:Tt})}var qt=ct();export{qt as schema};