Add Mobile 1.0 and UnifiedPush notifications

Mobile app (Android):
- Sign-in to any server, with authenticator codes. The server address and
  token are kept in secure storage; a dropped connection never signs out.
- Workspaces, recent pages, spaces and a foldable page tree; search; the
  inbox with mark-read.
- Pages open read-only in the shared editor from their saved content and
  join the live document to edit (with the native toolbar). Page links in
  the text open in the app (new "navigate" bridge message).
- Comments: threads, replies, resolve.
- "Save to Docwell" in the Android share sheet makes a page from shared
  text, with web addresses as links.
- Offline reading: every answer the app reads is kept on the phone, and
  used when the server can't be reached.
- Push through UnifiedPush (ntfy, NextPush, ...). The app uses the Android
  connector directly; the umbrella package pulls in a native crypto build
  for Linux that breaks `dart run` and tests.

Server:
- /me/devices registers a phone's UnifiedPush endpoint and Web Push keys
  (new push_devices collection). Each notification is also pushed,
  encrypted with RFC 8291 aes128gcm so the distributor can't read it; the
  app drops messages that don't decrypt. Endpoints answering 404/410 are
  forgotten. Endpoints follow the webhook address rules.
- /collab accepts the apps' own origins ("null" for the mobile editor page,
  wails:// for the desktop app). Sign-in is a token in the first message,
  not a cookie, so this opens no cross-site hijacking.

Tried on an Android 15 emulator: sign-in, browsing, reading, live editing,
sharing and offline reading. Not covered: push end to end (no distributor
on the emulator), iOS, and YouTube embeds, which refuse to play from the
app's local editor page (error 153).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-01 14:52:20 +01:00
1 parent 40d515d15b
commit 1f580ca6f8
46 files changed
+4381 -369

No files matched your search

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
/// <reference path="../pb_data/types.d.ts" />
// push_devices: phones that get push notifications. endpoint is the
// UnifiedPush address the phone's distributor (ntfy, …) gave the app;
// docwell-server POSTs each notification there, encrypted to the app's
// Web Push keys (RFC 8291). A device whose endpoint
// answers 404 or 410 is deleted.
migrate(
(app) => {
const users = app.findCollectionByNameOrId("users");
app.save(
new Collection({
type: "base",
name: "push_devices",
fields: [
{ name: "user", type: "relation", collectionId: users.id, maxSelect: 1, required: true, cascadeDelete: true },
{ name: "endpoint", type: "text", required: true, max: 1000 },
// The app's Web Push keys (base64url): messages are encrypted to them.
{ name: "p256dh", type: "text", required: true, max: 200 },
{ name: "auth", type: "text", required: true, max: 100 },
{ name: "name", type: "text", max: 100 },
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
],
indexes: [
"CREATE UNIQUE INDEX idx_push_devices_endpoint ON push_devices (endpoint)",
"CREATE INDEX idx_push_devices_user ON push_devices (user)",
],
}),
);
},
(app) => {
app.delete(app.findCollectionByNameOrId("push_devices"));
},
);
+130
View File
@@ -331,6 +331,46 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/me/devices": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** The caller's phones registered for push notifications, newest first */
get: operations["listDevices"];
put?: never;
/**
* Register a phone for push notifications (UnifiedPush)
* @description endpoint is the address the phone's UnifiedPush distributor (ntfy, NextPush, …) gave the app. For each notification docwell-server POSTs a PushMessage there, encrypted to the app's Web Push keys (RFC 8291, aes128gcm). Registering the same endpoint again updates it. Endpoints that answer 404 or 410 are forgotten. A person keeps up to 10 phones; registering an 11th drops the oldest.
*/
post: operations["registerDevice"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/me/devices/{id}": {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/** Stop push notifications to one of the caller's phones */
delete: operations["removeDevice"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/auth/me": {
parameters: {
query?: never;
@@ -2380,6 +2420,20 @@ export interface components {
icon: string;
deletedAt: string;
};
PushDevice: {
id: string;
name: string;
created: string;
};
/** @description The JSON body docwell-server POSTs to a phone's push endpoint */
PushMessage: {
/** @description The page's icon and title */
title: string;
/** @description For example "Ann mentioned you: …" */
body: string;
/** @description The app route to open, for example /p/<id>?comment=<id> */
route: string;
};
ArchivedPage: {
id: string;
title: string;
@@ -3322,6 +3376,82 @@ export interface operations {
403: components["responses"]["Error"];
};
};
listDevices: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["PushDevice"][];
};
};
404: components["responses"]["Error"];
};
};
registerDevice: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
endpoint: string;
/** @description The app's P-256 public key */
p256dh: string;
/** @description The app's 16-byte auth secret */
auth: string;
/** @description e.g. the phone's model */
name?: string;
};
};
};
responses: {
/** @description Registered */
201: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["PushDevice"];
};
};
400: components["responses"]["Error"];
404: components["responses"]["Error"];
};
};
removeDevice: {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Removed */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
404: components["responses"]["Error"];
};
};
getMe: {
parameters: {
query?: never;
+57 -55
View File
@@ -14,21 +14,23 @@
`),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=Qe.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=Qe.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
`),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=Qe.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`)||Re.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
`))),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=Qe.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`)||Re.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
`,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=_u(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}=Ou(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=ju(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 T}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
`),i=n.isParagraphContinuation??(e=>Yf(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(`
`,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 T}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
`);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 Zf(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=Xf(p,g.map(e=>Jf(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 Qf=4;function $f(e){let t=0;for(let n of e)t=n===` `?t+Qf-t%Qf:t+1;return t}function ep(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=$f(a);return($f(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 tp(e,t){let n={...e};return jf(e)&&jf(t)&&Object.keys(t).forEach(r=>{jf(t[r])&&jf(e[r])?n[r]=tp(e[r],t[r]):n[r]=t[r]}),n}function np(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 rp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},ip=(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 ap(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:Bn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function op(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}=ap({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 sp(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 cp(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=ip(u,e.find);if(a&&sp(l,a,i)&&op({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function lp(e){let{editor:t,rules:n}=e,r=new E({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:yu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;cp({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 cp({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&&cp({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?cp({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var up=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{...ju(A(this,`addOptions`,{name:this.name}))}}get storage(){return{...ju(A(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>tp(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}},dp=class e extends up{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)}},fp=class{constructor(e){this.find=e.find,this.handler=e.handler}},pp=(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 mp(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||pp(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 hp=null,gp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function _p(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(mp({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`,()=>{hp===t&&(hp=null)}),n.map(e=>new E({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(hp=t)},i=()=>{hp&&=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=hp;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:yu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=gp(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(kf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var vp=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=()=>dp.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(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 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:Bn.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=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 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=ad(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 E({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;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{...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:()=>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(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 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 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||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=Yc({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 E({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:xu(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=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=()=>gp.handleExit({editor:e,mark:t})),i){Line truncated
`)}}})]}}),xp=yp.create({name:`commands`,addCommands(){return{...ef}}}),Sp=yp.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 St){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()}}),Cp=yp.create({name:`drop`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),wp=yp.create({name:`editable`,addProseMirrorPlugins(){return[new E({key:new D(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Tp=new D(`focusEvents`),Ep=yp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new E({key:Tp,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}}}})]}}),Dp=yp.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:C.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 E({key:new D(`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=C.atStart(t.doc).from,l=C.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}})]}}),Op=yp.create({name:`paste`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),kp=yp.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new E({key:new D(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Ap=yp.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Ou(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 E({key:new D(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),jp=!1;function Mp(e){if(jp)return;jp=!0;let t;try{let n=Dt.fromJSON(e,Line truncated
`)}}})]}}),Ep=wp.create({name:`commands`,addCommands(){return{...tf}}}),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=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 St){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 E({key:new D(`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 E({key:new D(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Ap=new D(`focusEvents`),jp=wp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new E({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:C.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 E({key:new D(`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=C.atStart(t.doc).from,l=C.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}})]}}),Np=wp.create({name:`paste`,addProseMirrorPlugins(){return[new E({key:new D(`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 E({key:new D(`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}=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 E({key:new D(`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=Dt.fromJSON(e,Line truncated
position: relative;
}
@@ -98,21 +100,21 @@ img.ProseMirror-separator {
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`,Fp=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=Bn.create({doc:t,schema:this.schema,selection:e||void 0})}Mp(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(Pp,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=Au(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
}`,Bp=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=Bn.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():Xc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Xc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Of(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 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
`,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 Np(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Ip(e){return new rp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=ju(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 Lp(e){return new rp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=ju(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 Rp(e){return new rp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=ju(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 zp(e){return new rp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=ju(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&It(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&&Jt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Bp=e=>`touches`in e,Vp=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
`)}},wg=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[jh]?Mh(e,t):nm(e)?$p(e,e=>em(t,t=>wg(e,t))):Nh(e)?zh(e,(e,n)=>wg(e,t[n])):!1,Tg=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),wg(t,n)}equals(e){return this.constructor===e.constructor&&Kh(this.shape,e.shape)}[Sg](){return!0}[jh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){$m()}get nullable(){return i_(this,y_)}get optional(){return new Ig(this)}cast(e){return C_(e,this),e}expect(e){return C_(e,this),e}},Eg=class extends Tg{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}},Dg=(e,t=null)=>new Eg(e,t);Dg(Eg);var Og=class extends Tg{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}},kg=e=>new Og(e);Dg(Og);var Ag=class extends Tg{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}},jg=(...e)=>new Ag(e),Mg=Dg(Ag),Ng=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Pg=e=>{if(m_.check(e))return[Ng(e)];if(Mg.check(e))return e.shape.map(e=>e+``);if(p_.check(e))return[`[+-]?\\d+.?\\d*`];if(h_.check(e))return[`.*`];if(a_.check(e))return e.shape.map(Pg).flat(1);eh()};Dg(class extends Tg{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Pg).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 Fg=Symbol(`optional`),Ig=class extends Tg{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[Fg](){return!0}},Lg=Dg(Ig),Rg=class extends Tg{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Rg,Dg(Rg);var zg=class e extends Tg{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):zh(this.shape,(n,r)=>{let i=this._isPartial&&!Bh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Bg=e=>new zg(e),Vg=Dg(zg),Hg=kg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Ug=class extends Tg{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&zh(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)})}},Wg=(e,t)=>new Ug(e,t),Gg=Dg(Ug),Kg=class extends Tg{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&zh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},qg=(...e)=>new Kg(e);Dg(Kg);var Jg=class extends Tg{constructor(e){super(),this.shape=e.length===1?e[0]:new r_(e)}check(e,t){let n=nm(e)&&$p(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Yg=(...e)=>new Jg(e),Xg=Dg(Jg),Zg=kg(e=>nm(e)),Qg=class extends Tg{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}},$g=(e,t=null)=>new Qg(e,t);Dg(Qg);var e_=$g(Tg),t_=Dg(class extends Tg{constructor(e){super(),this.len=e.length-1,this.args=qg(...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}}),n_=kg(e=>typeof e==`function`);Dg(class extends Tg{constructor(e){super(),this.shape=e}check(e,t){let n=$p(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var r_=class extends Tg{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=em(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},i_=(...e)=>e.findIndex(e=>a_.check(e))>=0?i_(...e.map(e=>S_(e)).map(e=>a_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new r_(e),a_=Dg(r_),o_=()=>!0,s_=kg(o_),c_=Dg(Og,e=>e.shape===o_),l_=kg(e=>typeof e==`bigint`),u_=kg(e=>e===l_),d_=kg(e=>typeof e==`symbol`);kg(e=>e===d_);var f_=kg(e=>typeof e==`number`),p_=kg(e=>e===f_),m_=kg(e=>typeof e==`string`),h_=kg(e=>e===m_),g_=kg(e=>typeof e==`boolean`),__=kg(e=>e===g_),v_=jg(void 0);Dg(Ag,e=>e.shape.length===1&&e.shape[0]===void 0),jg(void 0);var y_=jg(null),b_=Dg(Ag,e=>e.shape.length===1&&e.shape[0]===null);Dg(Uint8Array),Dg(Eg,e=>e.shape===Uint8Array);var x_=i_(f_,m_,y_,v_,l_,g_,d_);(()=>{let e=Yg(s_),t=Wg(m_,s_),n=i_(f_,m_,y_,g_,e,t);return e.shape=n,t.shape.values=n,n})();var S_=e=>{if(e_.check(e))return e;ifLine truncated
`;n.right=new Ux(N(o,hy(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Ex(i)),n.right.integrate(e,0),n.forward()}Lb(e,t,n,s)},Ub=(e,t,n,r,i)=>{let a=t,o=Wp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===yx){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 yx:{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&&Rb(i,n);break}}}t=t.right}return s},Wb=(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===yx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Gb=e=>{let t=0;return jy(e.doc,n=>{let r=e._start,i=e._start,a=Wp(),o=Gp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case yx:Rb(o,i.content);break;default:t+=Ub(n,r,i,a,o),a=Gp(o),r=i}i=i.right}}),t},Kb=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&&Cy(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===yx&&e.constructor!==lx&&t.add(e.parent)})}jy(n,n=>{nv(e,e.deleteSet,e=>{if(e instanceof lx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===yx?t.add(r):Wb(n,e)});for(let e of t)Gb(e)})},qb=(e,t,n)=>{let r=n,i=Gp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Ix:case _x:case Ex:n<t.right.length&&by(e,N(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Ub(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&ab(o._searchMarker,t.index,-r+n),t},Jb=class extends Yy{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=[];jy(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},Rh(o)||(e.attributes=Ph({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Ix:case _x: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 Ex: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 yx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Nb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Nb(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;Nb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Nb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Rb(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}},Yb=class e extends sb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Zy(),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 Jb(this,e,t);ob(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Zy();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Ex&&(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)):jy(this.doc,n=>{let r=new Pb(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)&&Vb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&qb(n,r,a.delete):Hb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??Zy();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(dy(s,e)||t!==void 0&&dy(s,t))switch(s.content.constructor){case Ex:{let r=i.get(`ychange`);e!==void 0&&!dy(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&&!dy(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 Ix:case _x:{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 yx:dy(s,e)&&(c(),Rb(i,s.content))}s=s.right}c()};return e||t?jy(a,n=>{e&&fy(n,e),t&&fy(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)):jy(r,r=>{let i=Ib(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Vb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):jy(r,r=>{let i=Ib(r,this,e,!n);Vb(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)):jy(n,n=>{qb(n,Ib(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)):jy(r,r=>{let i=Ib(r,this,e,!1);i.right!==null&&Hb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):jy(this.doc,t=>{bb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):jy(this.doc,n=>{xb(n,this,e,t)})}getAttribute(e){return Sb(this,e)}getAttributes(){return Cb(this)}_write(e){e.writeTypeRef(jx)}},Xb=e=>new Yb,Zb=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Zy()}[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===ex||t.constructor===Qb)&&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})}},Qb=class e extends sb{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 sb?e.clone():e)),t}get length(){return this.doc??Zy(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Zb(this,e)}querySelector(e){e=e.toUpperCase();let t=new Zb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Qp(new Zb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ob(this,e,new nx(this,t,e))}toString(){return fb(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),db(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):jy(this.doc,n=>{_b(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)jy(this.doc,n=>{let r=e&&e instanceof sb?e._item:e;hb(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 Qm(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):jy(this.doc,n=>{yb(n,this,e,t)})}toArray(){return lb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return mb(this,e)}slice(e=0,t=this.length){return cb(this,e,t)}forEach(e){db(this,e)}_write(e){e.writeTypeRef(Nx)}},$b=e=>new Qb,ex=class e extends Qb{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 Ih(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>eLine 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 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=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 Hp(e){return new cp({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 Up(e){return new cp({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 Wp(e){return new cp({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&&It(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&&Jt(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
`)}},kg=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ih]?Lh(e,t):sm(e)?im(e,e=>am(t,t=>kg(e,t))):Rh(e)?Wh(e,(e,n)=>kg(e,t[n])):!1,Ag=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),kg(t,n)}equals(e){return this.constructor===e.constructor&&Zh(this.shape,e.shape)}[Dg](){return!0}[Ih](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ih()}get nullable(){return l_(this,w_)}get optional(){return new Vg(this)}cast(e){return O_(e,this),e}expect(e){return O_(e,this),e}},jg=class extends Ag{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}},Mg=(e,t=null)=>new jg(e,t);Mg(jg);var Ng=class extends Ag{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}},Pg=e=>new Ng(e);Mg(Ng);var Fg=class extends Ag{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}},Ig=(...e)=>new Fg(e),Lg=Mg(Fg),Rg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),zg=e=>{if(y_.check(e))return[Rg(e)];if(Lg.check(e))return e.shape.map(e=>e+``);if(v_.check(e))return[`[+-]?\\d+.?\\d*`];if(b_.check(e))return[`.*`];if(u_.check(e))return e.shape.map(zg).flat(1);ah()};Mg(class extends Ag{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(zg).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 Bg=Symbol(`optional`),Vg=class extends Ag{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[Bg](){return!0}},Hg=Mg(Vg),Ug=class extends Ag{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Ug,Mg(Ug);var Wg=class e extends Ag{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):Wh(this.shape,(n,r)=>{let i=this._isPartial&&!Gh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Gg=e=>new Wg(e),Kg=Mg(Wg),qg=Pg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Jg=class extends Ag{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Wh(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)})}},Yg=(e,t)=>new Jg(e,t),Xg=Mg(Jg),Zg=class extends Ag{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Wh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Qg=(...e)=>new Zg(e);Mg(Zg);var $g=class extends Ag{constructor(e){super(),this.shape=e.length===1?e[0]:new c_(e)}check(e,t){let n=sm(e)&&im(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},e_=(...e)=>new $g(e),t_=Mg($g),n_=Pg(e=>sm(e)),r_=class extends Ag{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}},i_=(e,t=null)=>new r_(e,t);Mg(r_);var a_=i_(Ag),o_=Mg(class extends Ag{constructor(e){super(),this.len=e.length-1,this.args=Qg(...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}}),s_=Pg(e=>typeof e==`function`);Mg(class extends Ag{constructor(e){super(),this.shape=e}check(e,t){let n=im(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var c_=class extends Ag{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=am(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},l_=(...e)=>e.findIndex(e=>u_.check(e))>=0?l_(...e.map(e=>D_(e)).map(e=>u_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new c_(e),u_=Mg(c_),d_=()=>!0,f_=Pg(d_),p_=Mg(Ng,e=>e.shape===d_),m_=Pg(e=>typeof e==`bigint`),h_=Pg(e=>e===m_),g_=Pg(e=>typeof e==`symbol`);Pg(e=>e===g_);var __=Pg(e=>typeof e==`number`),v_=Pg(e=>e===__),y_=Pg(e=>typeof e==`string`),b_=Pg(e=>e===y_),x_=Pg(e=>typeof e==`boolean`),S_=Pg(e=>e===x_),C_=Ig(void 0);Mg(Fg,e=>e.shape.length===1&&e.shape[0]===void 0),Ig(void 0);var w_=Ig(null),T_=Mg(Fg,e=>e.shape.length===1&&e.shape[0]===null);Mg(Uint8Array),Mg(jg,e=>e.shape===Uint8Array);var E_=l_(__,y_,w_,C_,m_,x_,g_);(()=>{let e=e_(f_),t=Yg(y_,f_),n=l_(__,y_,w_,x_,e,t);return e.shape=n,t.shape.values=n,n})();var D_=e=>{if(a_.check(e))return e;ifLine truncated
`;n.right=new Jx(N(o,by(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new jx(i)),n.right.integrate(e,0),n.forward()}Hb(e,t,n,s)},Jb=(e,t,n,r,i)=>{let a=t,o=Yp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===wx){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 wx:{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&&Ub(i,n);break}}}t=t.right}return s},Yb=(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===wx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Xb=e=>{let t=0;return Iy(e.doc,n=>{let r=e._start,i=e._start,a=Yp(),o=Xp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case wx:Ub(o,i.content);break;default:t+=Jb(n,r,i,a,o),a=Xp(o),r=i}i=i.right}}),t},Zb=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&&Oy(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===wx&&e.constructor!==mx&&t.add(e.parent)})}Iy(n,n=>{sv(e,e.deleteSet,e=>{if(e instanceof mx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===wx?t.add(r):Yb(n,e)});for(let e of t)Xb(e)})},Qb=(e,t,n)=>{let r=n,i=Xp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Vx:case Sx:case jx:n<t.right.length&&Ty(e,N(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Jb(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&ub(o._searchMarker,t.index,-r+n),t},$b=class extends eb{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=[];Iy(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},Uh(o)||(e.attributes=zh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Vx:case Sx: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 jx: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 wx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Rb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Rb(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;Rb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Rb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Ub(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}},ex=class e extends fb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??nb(),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 $b(this,e,t);db(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??nb();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===jx&&(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)):Iy(this.doc,n=>{let r=new zb(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)&&Kb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Qb(n,r,a.delete):qb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??nb();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(gy(s,e)||t!==void 0&&gy(s,t))switch(s.content.constructor){case jx:{let r=i.get(`ychange`);e!==void 0&&!gy(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&&!gy(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 Vx:case Sx:{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 wx:gy(s,e)&&(c(),Ub(i,s.content))}s=s.right}c()};return e||t?Iy(a,n=>{e&&_y(n,e),t&&_y(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)):Iy(r,r=>{let i=Vb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Kb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Iy(r,r=>{let i=Vb(r,this,e,!n);Kb(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)):Iy(n,n=>{Qb(n,Vb(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)):Iy(r,r=>{let i=Vb(r,this,e,!1);i.right!==null&&qb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Iy(this.doc,t=>{Tb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Iy(this.doc,n=>{Eb(n,this,e,t)})}getAttribute(e){return Db(this,e)}getAttributes(){return Ob(this)}_write(e){e.writeTypeRef(Ix)}},tx=e=>new ex,nx=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??nb()}[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===ax||t.constructor===rx)&&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})}},rx=class e extends fb{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 fb?e.clone():e)),t}get length(){return this.doc??nb(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new nx(this,e)}querySelector(e){e=e.toUpperCase();let t=new nx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),rm(new nx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){db(this,e,new sx(this,t,e))}toString(){return _b(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),gb(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Iy(this.doc,n=>{Sb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Iy(this.doc,n=>{let r=e&&e instanceof fb?e._item:e;bb(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 rh(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Iy(this.doc,n=>{wb(n,this,e,t)})}toArray(){return mb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yb(this,e)}slice(e=0,t=this.length){return pb(this,e,t)}forEach(e){gb(this,e)}_write(e){e.writeTypeRef(Rx)}},ix=e=>new rx,ax=class e extends rx{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 Vh(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:()=>vT(this.editor,this.type)}},addInputRules(){return[zp({find:yT,type:this.type})]}}),xT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ST=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,CT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,wT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,TT=dp.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 _T(`strong`,{...Fu(this.options.HTMLAttributes,e),children:_T(`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[Ip({find:xT,type:this.type}),Ip({find:CT,type:this.type})]},addPasteRules(){return[Up({find:ST,type:this.type}),Up({find:wT,type:this.type})]}}),ET=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},DT=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 OT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var kT=dp.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,Fu(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(OT(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[Ip({find:ET,type:this.type})]},addPasteRules(){return[Up({find:DT,type:this.type})]}}),AT=4,jT=/^```([a-z]+)?[\s\n]$/,MT=/^~~~([a-z]+)?[\s\n]$/,NT=Hp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:AT,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`,Fu(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??AT,{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:()=>CT(this.editor,this.type)}},addInputRules(){return[Wp({find:wT,type:this.type})]}}),ET=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,DT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,OT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,kT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,AT=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 ST(`strong`,{...A(this.options.HTMLAttributes,e),children:ST(`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:ET,type:this.type}),Vp({find:OT,type:this.type})]},addPasteRules(){return[Jp({find:DT,type:this.type}),Jp({find:kT,type:this.type})]}}),jT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},MT=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 NT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var PT=gp.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(NT(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:jT,type:this.type})]},addPasteRules(){return[Jp({find:MT,type:this.type})]}}),FT=4,IT=/^```([a-z]+)?[\s\n]$/,LT=/^~~~([a-z]+)?[\s\n]$/,RT=qp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:FT,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??FT,{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??AT,{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??FT,{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(w.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
@@ -121,28 +123,29 @@ 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(C.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Rp({find:jT,type:this.type,getAttributes:e=>({language:e[1]})}),Rp({find:MT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new E({key:new D(`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(w.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),PT=Hp.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(C.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Up({find:IT,type:this.type,getAttributes:e=>({language:e[1]})}),Up({find:LT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new E({key:new D(`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(w.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),zT=qp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``}),FT=Hp.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`,Fu(this.options.HTMLAttributes,e)]},renderText(){return`
`):``}),BT=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`,A(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()}}}),IT=Hp.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]}`,Fu(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=>Rp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),LT=Hp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,Fu(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(w.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(T.create(t.doc,n.pos)):t.setSelection(w.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(w.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Lp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),RT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,BT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,VT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,HT=dp.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`,Fu(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[Ip({find:RT,type:this.type}),Ip({find:BT,type:this.type})]},addPasteRules(){return[Up({find:zT,type:this.type}),Up({find:VT,type:this.type})]}}),UT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6Line truncated
`,gD=`️`,_D=`‍`,vD=``,yD=null,bD=null;function xD(e=[]){let t={};iE.groups=t;let n=new iE;yD??=TD(UT),bD??=TD(WT),F(n,`'`,IE),F(n,`{`,yE),F(n,`}`,bE),F(n,`[`,xE),F(n,`]`,SE),F(n,`(`,CE),F(n,`)`,wE),F(n,`<`,TE),F(n,`>`,EE),F(n,`(`,DE),F(n,`)`,OE),F(n,`「`,kE),F(n,`」`,AE),F(n,`『`,jE),F(n,`』`,ME),F(n,`<`,NE),F(n,`>`,PE),F(n,`&`,FE),F(n,`*`,LE),F(n,`@`,RE),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,`%`,YE),F(n,`|`,XE),F(n,`+`,ZE),F(n,`#`,QE),F(n,`?`,$E),F(n,`"`,eD),F(n,`/`,rD),F(n,`;`,nD),F(n,`~`,iD),F(n,`_`,aD),F(n,`\\`,zE),F(n,`・`,tD);let r=aE(n,fD,gE,{[GT]:!0});aE(r,fD,r);let i=aE(r,lD,lE,{[JT]:!0}),a=aE(r,uD,uE,{[YT]:!0}),o=aE(n,lD,sE,{[KT]:!0});aE(o,fD,i),aE(o,lD,o),aE(i,fD,i),aE(i,lD,i);let s=aE(n,uD,cE,{[qT]:!0});aE(s,lD),aE(s,fD,a),aE(s,uD,s),aE(a,fD,a),aE(a,lD),aE(a,uD,a);let c=F(n,hD,vE,{[eE]:!0}),l=F(n,mD,_E,{[eE]:!0}),u=aE(n,pD,_E,{[eE]:!0});F(n,vD,u),F(l,hD,c),F(l,vD,u),aE(l,pD,u),F(u,mD),F(u,hD),aE(u,pD,u),F(u,vD,u);let d=aE(n,dD,oD,{[ZT]:!0});F(d,`#`),aE(d,dD,d),F(d,gD,d);let f=F(d,_D);F(f,`#`),aE(f,dD,d);let p=[[lD,o],[fD,i]],m=[[lD,null],[uD,s],[fD,a]];for(let e=0;e<yD.length;e++)wD(n,yD[e],fE,sE,p);for(let e=0;e<bD.length;e++)wD(n,bD[e],pE,cE,m);nE(fE,{tld:!0,ascii:!0},t),nE(pE,{utld:!0,alpha:!0},t),wD(n,`file`,mE,sE,p),wD(n,`mailto`,mE,sE,p),wD(n,`http`,hE,sE,p),wD(n,`https`,hE,sE,p),wD(n,`ftp`,hE,sE,p),wD(n,`ftps`,hE,sE,p),nE(mE,{scheme:!0,ascii:!0},t),nE(hE,{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]?{[QT]:!0}:{[$T]:!0};r.indexOf(`-`)>=0?i[XT]=!0:lD.test(r)?fD.test(r)?i[JT]=!0:i[KT]=!0:i[GT]=!0,oE(n,r,r,i)}return oE(n,`localhost`,dE,{ascii:!0}),n.jd=new iE(sD),{start:n,tokens:Object.assign({groups:t},cD)}}function SD(e,t){let n=CD(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 CD(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 wD(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 iE(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new iE(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function TD(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 ED={defaultProtocol:`http`,events:null,format:OD,formatHref:OD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function DD(e,t=null){let n=Object.assign({},ED);e&&(n=Object.assign(n,e instanceof DD?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()}DD.prototype={o:ED,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]:ED[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 OD(e){return e}function kD(e,t){this.t=`token`,this.v=e,this.tk=t}kD.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=ED.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()}}}),VT=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]}`,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=>Up({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),HT=qp.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(w.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(T.create(t.doc,n.pos)):t.setSelection(w.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(w.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Hp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,WT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,GT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,KT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qT=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`,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[Vp({find:UT,type:this.type}),Vp({find:GT,type:this.type})]},addPasteRules(){return[Jp({find:WT,type:this.type}),Jp({find:KT,type:this.type})]}}),JT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,xD=`️`,SD=`‍`,CD=``,wD=null,TD=null;function ED(e=[]){let t={};lE.groups=t;let n=new lE;wD??=AD(JT),TD??=AD(YT),F(n,`'`,VE),F(n,`{`,wE),F(n,`}`,TE),F(n,`[`,EE),F(n,`]`,DE),F(n,`(`,OE),F(n,`)`,kE),F(n,`<`,AE),F(n,`>`,jE),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,`*`,HE),F(n,`@`,UE),F(n,"`",GE),F(n,`^`,KE),F(n,`:`,qE),F(n,`,`,JE),F(n,`$`,YE),F(n,`.`,XE),F(n,`=`,ZE),F(n,`!`,QE),F(n,`-`,$E),F(n,`%`,eD),F(n,`|`,tD),F(n,`+`,nD),F(n,`#`,rD),F(n,`?`,iD),F(n,`"`,aD),F(n,`/`,cD),F(n,`;`,sD),F(n,`~`,lD),F(n,`_`,uD),F(n,`\\`,WE),F(n,`・`,oD);let r=uE(n,_D,xE,{[XT]:!0});uE(r,_D,r);let i=uE(r,mD,mE,{[$T]:!0}),a=uE(r,hD,hE,{[eE]:!0}),o=uE(n,mD,fE,{[ZT]:!0});uE(o,_D,i),uE(o,mD,o),uE(i,_D,i),uE(i,mD,i);let s=uE(n,hD,pE,{[QT]:!0});uE(s,mD),uE(s,_D,a),uE(s,hD,s),uE(a,_D,a),uE(a,mD),uE(a,hD,a);let c=F(n,bD,CE,{[aE]:!0}),l=F(n,yD,SE,{[aE]:!0}),u=uE(n,vD,SE,{[aE]:!0});F(n,CD,u),F(l,bD,c),F(l,CD,u),uE(l,vD,u),F(u,yD),F(u,bD),uE(u,vD,u),F(u,CD,u);let d=uE(n,gD,dD,{[nE]:!0});F(d,`#`),uE(d,gD,d),F(d,xD,d);let f=F(d,SD);F(f,`#`),uE(f,gD,d);let p=[[mD,o],[_D,i]],m=[[mD,null],[hD,s],[_D,a]];for(let e=0;e<wD.length;e++)kD(n,wD[e],_E,fE,p);for(let e=0;e<TD.length;e++)kD(n,TD[e],vE,pE,m);sE(_E,{tld:!0,ascii:!0},t),sE(vE,{utld:!0,alpha:!0},t),kD(n,`file`,yE,fE,p),kD(n,`mailto`,yE,fE,p),kD(n,`http`,bE,fE,p),kD(n,`https`,bE,fE,p),kD(n,`ftp`,bE,fE,p),kD(n,`ftps`,bE,fE,p),sE(yE,{scheme:!0,ascii:!0},t),sE(bE,{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]?{[rE]:!0}:{[iE]:!0};r.indexOf(`-`)>=0?i[tE]=!0:mD.test(r)?_D.test(r)?i[$T]=!0:i[ZT]=!0:i[XT]=!0,dE(n,r,r,i)}return dE(n,`localhost`,gE,{ascii:!0}),n.jd=new lE(fD),{start:n,tokens:Object.assign({groups:t},pD)}}function DD(e,t){let n=OD(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 OD(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 kD(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 lE(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new lE(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function AD(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 jD={defaultProtocol:`http`,events:null,format:ND,formatHref:ND,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function MD(e,t=null){let n=Object.assign({},jD);e&&(n=Object.assign(n,e instanceof MD?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()}MD.prototype={o:jD,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]:jD[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 ND(e){return e}function PD(e,t){this.t=`token`,this.v=e,this.tk=t}PD.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=jD.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`);VD.customSchemes.push([e,t])}function WD(){VD.scanner=xD(VD.customSchemes);for(let e=0;e<VD.tokenQueue.length;e++)VD.tokenQueue[e][1]({scanner:VD.scanner});VD.parser=ID(VD.scanner.tokens);for(let e=0;e<VD.pluginQueue.length;e++)VD.pluginQueue[e][1]({scanner:VD.scanner,parser:VD.parser});return VD.initialized=!0,VD}function GD(e){return VD.initialized||WD(),LD(VD.parser.start,e,SD(VD.scanner.start,e))}GD.scan=SD;function KD(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 DD(n),i=GD(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 qD=`[\0- \xA0 ᠎ -\u2029  ]`,JD=new RegExp(qD),YD=RegExp(`${qD}$`),XD=RegExp(`${qD}+$`),ZD=new RegExp(qD,`g`);function QD(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(XD)?.[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 $D(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function eO(e){return new E({key:new D(`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 Dt)||!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=>QD(o,t,e.type))}if(Qu(s).forEach(({newRange:t})=>{let n=hu(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(!YD.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(JD).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=GD(n).map(t=>t.toObject(e.defaultProtocol));if(!$D(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 tO(e){return new E({key:new D(`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 nO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,rO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function iO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function aO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&iO(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 oO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||iO(e,t.index??0)||aO(e,t.index??0)?!1:!!r.trim()&&n(i)}function sO(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 cO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function lO(e){return{href:e.data?.href,title:e.data?.title??null}}function uO(e){let t=Ip({find:t=>{let n=nO.exec(t);return!n||!oO(t,n,e.isAllowedHref)?null:sO(n)},type:e.type,getAttributes:lO});return new rp({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 dO(e){let t=Up({find:t=>{let n=[];for(let r of t.matchAll(rO))oO(t,r,e.isAllowedHref)&&n.push(sO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>cO(t,e)));return[...n,...r]},type:e.type,getAttributes:lO});return new fp({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 fO(e){return new E({key:new D(`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=KD(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(hO,this.editor.getAttributes(gO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=zp({find:_O,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=zp({find:_O,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(gO),editor:this.editor})),[e]}}),yO=(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}},bO=(e,t,n,r)=>{let i=yO(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},xO=(e,t,n)=>bO(e.state,e.view.dispatch,t,n),SO=(e,t)=>yp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>xO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),CO=[[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`]],wO=`abcdefghijklmnopqrstuvwxyz`,TO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function EO(e){let t=e,n=``;for(let[e,r]of CO)for(;t>=e;)n+=r,t-=e;return n}function DO(e){return EO(e).toUpperCase()}function OO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of CO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function kO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=OO(e);return t<=0?!1:(e===e.toLowerCase()?EO(t):DO(t))===e}function AO(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 jO(e){if(e<=26)return wO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?wO[n]:wO[t]+wO[n]}function MO(e){if(e&&!/^\d+$/.test(e)){if(kO(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 NO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=MO(e);if(t===`i`||t===`I`)return OO(e);if(t===`a`||t===`A`){let t=AO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function PO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return jO(t);case`A`:return jO(t).toUpperCase();case`i`:return EO(t);case`I`:return DO(t);default:return String(t)}}function FO(e){if(e.length===0)return!1;let t=MO(e[0])??`numeric`,n=NO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=PO(t,n+r);if(e[r]!==i)return!1}return!0}function IO(e){return{type:MO(e),start:NO(e)}}function LO(e){let{type:t,start:n}=IO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function RO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${jO(r)}${n}`;case`A`:return`${jO(r).toUpperCase()}${n}`;case`i`:return`${EO(r)}${n}`;case`I`:return`${DO(r)}${n}`;default:return`${r}${n}`}}function zO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function BO(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var VO=`&nbsp;`,HO=1,UO=e=>(e?.level??HO)>HO;function WO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function GO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var KO=Hp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,Fu(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(WO(e))return{type:`listItem`,content:[{type:`paragraph`,content:GO(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`);KD.customSchemes.push([e,t])}function YD(){KD.scanner=ED(KD.customSchemes);for(let e=0;e<KD.tokenQueue.length;e++)KD.tokenQueue[e][1]({scanner:KD.scanner});KD.parser=VD(KD.scanner.tokens);for(let e=0;e<KD.pluginQueue.length;e++)KD.pluginQueue[e][1]({scanner:KD.scanner,parser:KD.parser});return KD.initialized=!0,KD}function XD(e){return KD.initialized||YD(),HD(KD.parser.start,e,DD(KD.scanner.start,e))}XD.scan=DD;function ZD(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 MD(n),i=XD(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 QD=`[\0- \xA0 ᠎ -\u2029  ]`,$D=new RegExp(QD),eO=RegExp(`${QD}$`),tO=RegExp(`${QD}+$`),nO=new RegExp(QD,`g`);function rO(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(tO)?.[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 iO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function aO(e){return new E({key:new D(`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 Dt)||!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=>rO(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(!eO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split($D).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=XD(n).map(t=>t.toObject(e.defaultProtocol));if(!iO(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 oO(e){return new E({key:new D(`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 sO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,cO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function lO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function uO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&lO(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 dO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||lO(e,t.index??0)||uO(e,t.index??0)?!1:!!r.trim()&&n(i)}function fO(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 pO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function mO(e){return{href:e.data?.href,title:e.data?.title??null}}function hO(e){let t=Vp({find:t=>{let n=sO.exec(t);return!n||!dO(t,n,e.isAllowedHref)?null:fO(n)},type:e.type,getAttributes:mO});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 gO(e){let t=Jp({find:t=>{let n=[];for(let r of t.matchAll(cO))dO(t,r,e.isAllowedHref)&&n.push(fO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>pO(t,e)));return[...n,...r]},type:e.type,getAttributes:mO});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 _O(e){return new E({key:new D(`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=ZD(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(bO,this.editor.getAttributes(xO)).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:SO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Wp({find:SO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(xO),editor:this.editor})),[e]}}),wO=(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}},TO=(e,t,n,r)=>{let i=wO(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},EO=(e,t,n)=>TO(e.state,e.view.dispatch,t,n),DO=(e,t)=>wp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>EO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),OO=[[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`]],kO=`abcdefghijklmnopqrstuvwxyz`,AO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function jO(e){let t=e,n=``;for(let[e,r]of OO)for(;t>=e;)n+=r,t-=e;return n}function MO(e){return jO(e).toUpperCase()}function NO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of OO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function PO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=NO(e);return t<=0?!1:(e===e.toLowerCase()?jO(t):MO(t))===e}function FO(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 IO(e){if(e<=26)return kO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?kO[n]:kO[t]+kO[n]}function LO(e){if(e&&!/^\d+$/.test(e)){if(PO(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 RO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=LO(e);if(t===`i`||t===`I`)return NO(e);if(t===`a`||t===`A`){let t=FO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function zO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return IO(t);case`A`:return IO(t).toUpperCase();case`i`:return jO(t);case`I`:return MO(t);default:return String(t)}}function BO(e){if(e.length===0)return!1;let t=LO(e[0])??`numeric`,n=RO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=zO(t,n+r);if(e[r]!==i)return!1}return!0}function VO(e){return{type:LO(e),start:RO(e)}}function HO(e){let{type:t,start:n}=VO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function UO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${IO(r)}${n}`;case`A`:return`${IO(r).toUpperCase()}${n}`;case`i`:return`${jO(r)}${n}`;case`I`:return`${MO(r)}${n}`;default:return`${r}${n}`}}function WO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function GO(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var KO=`&nbsp;`,qO=1,JO=e=>(e?.level??qO)>qO;function YO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function XO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var ZO=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`,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(YO(e))return{type:`listItem`,content:[{type:`paragraph`,content:XO(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 uk=RegExp(`^(${TO})([.)])\\s+(.+)$`);function dk(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(uk);if(!t)return null;n.push({marker:t[1],content:t[3]})}return FO(n.map(e=>e.marker))?{type:`orderedList`,attrs:LO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function fk(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=ck(a.contentLines),c=o.join(`
`)}),r=h,n=h}return[t,r]}var hk=RegExp(`^(${AO})([.)])\\s+(.+)$`);function gk(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(hk);if(!t)return null;n.push({marker:t[1],content:t[3]})}return BO(n.map(e=>e.marker))?{type:`orderedList`,attrs:HO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function _k(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=pk(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=fk(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 pk(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 mk=64;function hk(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 gk(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!nk.test(n))return[[],0,[]];let r=mk,i=hk(e,r),a=lk(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=hk(e,r),a=lk(i);return[a[0],a[1],i]}var _k=`listItem`,vk=`textStyle`,yk=/^(\d+)\.\s$/;function bk(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 xk=Hp.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=bk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=bk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=Fu(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?pk(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]=gk(e);if(r.length===0)return;let o=fk(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(_k,this.editor.getAttributes(vk)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new E({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=dk(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=zp({find:yk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=zp({find:yk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(vk)}),joinPredicate:e,editor:this.editor})),[t]}}),Sk=/^\s*(\[([( |x])?\])\s$/,Ck=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,wk=(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`}`},Tk=Hp.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`,Fu(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)=>ep(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[SO(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=Ck;let l=e=>{let t=wk(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[zp({find:Sk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Ek=Hp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`Line 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=Zf(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=Zf(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()}}});yp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(vO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(KO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(tk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(xk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Tk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Ek.configure(this.options.taskList)),e}});var Dk=`&nbsp;`,Ok=`\xA0`,kk=Hp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,Fu(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===Dk||n[0].text===Dk||n[0].raw===Ok||n[0].text===Ok)&&r.length===1&&r[0].type===`text`&&(r[0].text===Dk||r[0].text===Ok)?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?Dk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ak=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Mk=dp.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`,Fu(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[Ip({find:Ak,type:this.type})]},addPasteRules(){return[Up({find:jk,type:this.type})]}}),Nk=Hp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Pk=dp.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`,Fu(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),togLine 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=_k(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 vk(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 yk=64;function bk(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 xk(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!sk.test(n))return[[],0,[]];let r=yk,i=bk(e,r),a=mk(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=bk(e,r),a=mk(i);return[a[0],a[1],i]}var Sk=`listItem`,Ck=`textStyle`,wk=/^(\d+)\.\s$/;function Tk(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 Ek=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=Tk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Tk(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?vk(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]=xk(e);if(r.length===0)return;let o=_k(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(Sk,this.editor.getAttributes(Ck)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new E({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=gk(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:wk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wp({find:wk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ck)}),joinPredicate:e,editor:this.editor})),[t]}}),Dk=/^\s*(\[([( |x])?\])\s$/,Ok=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,kk=(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`}`},Ak=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`,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)=>ap(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[DO(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=Ok;let l=e=>{let t=kk(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[Wp({find:Dk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),jk=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(CO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ZO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ok.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ek.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Ak.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(jk.configure(this.options.taskList)),e}});var Mk=`&nbsp;`,Nk=`\xA0`,Pk=qp.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===Mk||n[0].text===Mk||n[0].raw===Nk||n[0].text===Nk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Mk||r[0].text===Nk)?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?Mk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Fk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ik=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Lk=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`,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[Vp({find:Fk,type:this.type})]},addPasteRules(){return[Jp({find:Ik,type:this.type})]}}),Rk=qp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),zk=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`,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
`).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=Wj(e.anchor,t,()=>{Jj(e.anchor,t,{placement:`bottom-start`,middleware:[Gj(6),qj(),Kj({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(),Yj===d&&(Yj=null),n||e.onCancel?.())}let d=()=>u();return Yj=d,n.focus(),e.multiline||n.select(),d}var Zj=[{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 Qj(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of Zj){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function $j(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var eM=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function tM(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;Xj({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e($j(t)),onCancel:()=>e(``)})})}async function nM(e,t,n,r){let i=await tM(e,t,t.blocks.embedUrl);i&&(Qj(i)?e.chain().focus().insertEmbed(i).run():await iM(e,i,n,r))}async function rM(e,t,n,r){let i=await tM(e,t,t.blocks.linkUrl);i&&await iM(e,i,n,r)}async function iM(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 aM=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=$j(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=$j(e),i=Qj(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}: ${eM(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.createElement(`figcaption`);o.className=`dw-embed__caption`;let s=document.createElement(`a`);s.href=r,s.targeLine 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
@@ -153,7 +156,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`},WA=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`},$M=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+`
@@ -163,7 +166,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`},GA=function(e,t){return`M983 `+(10+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},eN=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
@@ -172,7 +175,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`},KA=function(e,t){return`M424,`+(2398+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},tN=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
@@ -182,18 +185,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`},qA=function(e,t){return`M473,`+(2713+e+t)+`
h400000v`+(40+e)+`h-400000z`},nN=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`},JA=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},YA=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`},rN=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},iN=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`},XA=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=UA(t,HA);break;case`sqrtSize1`:r=WA(t,HA);break;case`sqrtSize2`:r=GA(t,HA);break;case`sqrtSize3`:r=KA(t,HA);break;case`sqrtSize4`:r=qA(t,HA);break;case`sqrtTall`:r=YA(t,HA,n)}return r},ZA=function(e,t){switch(e){case`⎜`:return VA(`M291 0 H417 V`+t+` H291z`);case`∣`:return VA(`M145 0 H188 V`+t+` H145z`);case`∥`:return VA(`M145 0 H188 V`+t+` H145z`)+VA(`M367 0 H410 V`+t+` H367z`);case`⎟`:return VA(`M457 0 H583 V`+t+` H457z`);case`⎢`:return VA(`M319 0 H403 V`+t+` H319z`);case`⎥`:return VA(`M263 0 H347 V`+t+` H263z`);case`⎪`:return VA(`M384 0 H504 V`+t+` H384z`);case`⏐`:return VA(`M312 0 H355 V`+t+` H312z`);case`‖`:return VA(`M257 0 H300 V`+t+` H257z`)+VA(`M478 0 H521 V`+t+` H478z`);default:return``}},QA={doubleleftarrow:`M262 157
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},aN=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=QM(t,ZM);break;case`sqrtSize1`:r=$M(t,ZM);break;case`sqrtSize2`:r=eN(t,ZM);break;case`sqrtSize3`:r=tN(t,ZM);break;case`sqrtSize4`:r=nN(t,ZM);break;case`sqrtTall`:r=iN(t,ZM,n)}return r},oN=function(e,t){switch(e){case`⎜`:return XM(`M291 0 H417 V`+t+` H291z`);case`∣`:return XM(`M145 0 H188 V`+t+` H145z`);case`∥`:return XM(`M145 0 H188 V`+t+` H145z`)+XM(`M367 0 H410 V`+t+` H367z`);case`⎟`:return XM(`M457 0 H583 V`+t+` H457z`);case`⎢`:return XM(`M319 0 H403 V`+t+` H319z`);case`⎥`:return XM(`M263 0 H347 V`+t+` H263z`);case`⎪`:return XM(`M384 0 H504 V`+t+` H384z`);case`⏐`:return XM(`M312 0 H355 V`+t+` H312z`);case`‖`:return XM(`M257 0 H300 V`+t+` H257z`)+XM(`M478 0 H521 V`+t+` H478z`);default:return``}},sN={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
@@ -239,10 +242,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:VA(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:VA(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:VA(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:VA(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:XM(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:XM(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:XM(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:XM(`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:VA(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:XM(`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
@@ -291,7 +294,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:VA(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:VA(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:VA(`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:XM(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:XM(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:XM(`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
@@ -364,7 +367,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`},$A=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`},cN=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
@@ -392,19 +395,18 @@ 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 ej(e){return`toText`in e}var tj=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(ej(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},nj={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},rj={ex:!0,em:!0,mu:!0},ij=function(e){return typeof e!=`string`&&(e=e.unit),e in nj||e in rj||e===`ex`},aj=function(e,t){var n;if(e.unit in nj)n=nj[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 I(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},R=function(e){return+e.toFixed(4)+`em`},oj=function(e){return e.filter(e=>e).join(` `)},sj=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=cA(n)+`:`+r+`;`)}return t},cj=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)}},lj=function(e){var t=document.createElement(e);t.className=oj(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},uj=/[\s"'>/=\x00-\x1f]/,dj=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+dA(oj(this.classes))+`"`);var n=sj(this.style);n&&(t+=` style="`+dA(n)+`"`);for(var r of Object.keys(this.attributes)){if(uj.test(r))throw new I(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+dA(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},fj=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,cj.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return lj.call(this,`span`)}toMarkup(){return dj.call(this,`span`)}},pj=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,cj.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 lj.call(this,`a`)}toMarkup(){return dj.call(this,`a`)}},mj=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="`+dA(this.src)+`"`+(` alt="`+dA(this.alt)+`"`),t=sj(this.style);return t&&(e+=` style="`+dA(t)+`"`),e+=`'/>`,e}},hj={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},gj=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=RA(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=hj[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=R(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=oj(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+=dA(oj(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new _j([new vj(d[v])],{width:`400em`,height:R(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=wM([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=R(m),l.push(b)}return{span:Y([`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=R(o),a>0&&(i.style.minWidth=R(a)),i},NN=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=Y([`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 yj({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new yj({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=wM([],[new _j(c,{width:`100%`,height:R(o)})],i)}return a.height=o,a.style.height=R(o),a},PN=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],FN=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],IN=new Set(PN),LN=new Set(FN);function RN(e){return IN.has(e)}function Q(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 zN(e){var t=BN(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function BN(e){return e.type===`atom`||LN.has(e.type)?e:null}function VN(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 I(t,e);return r}var HN=e=>{if(e instanceof gj)return e;if(Sj(e)&&e.children.length===1)return HN(e.children[0])},UN=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Q(e.base,`accent`),n=r.base,e.base=n,i=xj(rN(e,t)),e.base=r):(r=Q(e,`accent`),n=r.base);var a=rN(n,t.havingCrampedStyle()),o=r.isShifty&&mA(n),s=0;o&&(s=HN(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=MN(r,t),u=AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+R(2*s)+`)`,marginLeft:R(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=FM(`vec`,t),f=PM.vec[1]):(d=bM({type:`textord`,mode:r.mode,text:r.label},t),d=bj(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=Y([`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=R(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=Y([`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},WN=(e,t)=>{var n=e.isStretchy?kN(e.label):new Z(`mo`,[dN(e.label,e.mode)]),r=new Z(`mover`,[vN(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},GN=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));X({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=GM(t[0]),r=!GN.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:UN,mathmlBuilder:WN}),X({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}}}),X({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=rN(e.base,t),r=MN(e,t),i=e.label===`\\utilde`?.12:0;return Y([`mord`,`accentunder`],[AM({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=kN(e.label),r=new Z(`munder`,[vN(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var KN=e=>{var t=new Z(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};X({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrightarLine truncated
]`,LF=`\\\\[a-zA-Z@]+`,RF=`\\\\[^\ud800-\udfff]`,zF=`(`+LF+`)`+IF+`*`,BF=`\\\\(
-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 lN(e){return`toText`in e}var uN=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(lN(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},dN={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},fN={ex:!0,em:!0,mu:!0},pN=function(e){return typeof e!=`string`&&(e=e.unit),e in dN||e in fN||e===`ex`},mN=function(e,t){var n;if(e.unit in dN)n=dN[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 I(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},R=function(e){return+e.toFixed(4)+`em`},hN=function(e){return e.filter(e=>e).join(` `)},gN=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=_M(n)+`:`+r+`;`)}return t},_N=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)}},vN=function(e){var t=document.createElement(e);t.className=hN(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},yN=/[\s"'>/=\x00-\x1f]/,bN=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+bM(hN(this.classes))+`"`);var n=gN(this.style);n&&(t+=` style="`+bM(n)+`"`);for(var r of Object.keys(this.attributes)){if(yN.test(r))throw new I(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+bM(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},xN=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,_N.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return vN.call(this,`span`)}toMarkup(){return bN.call(this,`span`)}},SN=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,_N.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 vN.call(this,`a`)}toMarkup(){return bN.call(this,`a`)}},CN=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="`+bM(this.src)+`"`+(` alt="`+bM(this.alt)+`"`),t=gN(this.style);return t&&(e+=` style="`+bM(t)+`"`),e+=`'/>`,e}},wN={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},TN=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=qM(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=wN[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=R(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=hN(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+=bM(hN(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new EN([new DN(d[v])],{width:`400em`,height:R(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=NP([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=R(m),l.push(b)}return{span:Y([`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=R(o),a>0&&(i.style.minWidth=R(a)),i},HF=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=Y([`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 ON({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new ON({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=NP([],[new EN(c,{width:`100%`,height:R(o)})],i)}return a.height=o,a.style.height=R(o),a},UF=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],WF=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],GF=new Set(UF),KF=new Set(WF);function qF(e){return GF.has(e)}function Q(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 JF(e){var t=YF(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function YF(e){return e.type===`atom`||KF.has(e.type)?e:null}function XF(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 I(t,e);return r}var ZF=e=>{if(e instanceof TN)return e;if(jN(e)&&e.children.length===1)return ZF(e.children[0])},QF=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Q(e.base,`accent`),n=r.base,e.base=n,i=AN(fF(e,t)),e.base=r):(r=Q(e,`accent`),n=r.base);var a=fF(n,t.havingCrampedStyle()),o=r.isShifty&&CM(n),s=0;o&&(s=ZF(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=VF(r,t),u=zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+R(2*s)+`)`,marginLeft:R(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=WP(`vec`,t),f=UP.vec[1]):(d=kP({type:`textord`,mode:r.mode,text:r.label},t),d=kN(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=Y([`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=R(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=Y([`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},$F=(e,t)=>{var n=e.isStretchy?RF(e.label):new Z(`mo`,[bF(e.label,e.mode)]),r=new Z(`mover`,[DF(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},eI=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));X({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=eF(t[0]),r=!eI.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:QF,mathmlBuilder:$F}),X({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}}}),X({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=fF(e.base,t),r=VF(e,t),i=e.label===`\\utilde`?.12:0;return Y([`mord`,`accentunder`],[zP({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=RF(e.label),r=new Z(`munder`,[DF(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var tI=e=>{var t=new Z(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};X({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrightarLine truncated
]`,KL=`\\\\[a-zA-Z@]+`,qL=`\\\\[^\ud800-\udfff]`,JL=`(`+KL+`)`+GL+`*`,YL=`\\\\(
|[ \r ]+
?)[ \r ]*`,VF=`[̀-ͯ]`,HF=RegExp(VF+`+$`),UF=`(`+IF+`+)|`+(BF+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(VF+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(VF+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+zF)+(`|`+RF+`)`),WF=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(UF,`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 WP(`EOF`,new UP(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new I(`Unexpected character: '`+e[t]+`'`,new WP(e[t],new UP(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 WP(r,new UP(this,t,this.tokenRegex.lastIndex))}},GF=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 I(`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}},KF=HP;$(`\\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 qF={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 I("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=qF[t.text],r==null||r>=n)throw new I(`Invalid base-`+n+` digit `+t.text);for(var i;(i=qF[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var JF=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new I(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new I(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new I(`\\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 I(`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=>JF(e,!1,!0,!1)),$(`\\renewcommand`,e=>JF(e,!0,!1,!1)),$(`\\providecommand`,e=>JF(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),FF[n],Aj.math[n],Aj.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(aI,t[0])&&!Aj[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=aI[t[0]]+t.slice(1));var i=HF.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(Aj[this.mode][t]){this.settings.strict&&this.mode===`math`&&Qj.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=Aj[this.mode][t].group,s=UP.range(e);a=RN(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&&(BA(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:UP.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(!iI[l])throw new I(`Unknown accent ' `+l+`'`,e);var u=iI[l][this.mode]||iI[l].text;if(!u)throw new I(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:UP.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};oI.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var sI=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new oI(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 I(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new WP(`\\df@tag`)])}]}return r},cI=function(e,t,n){t.textContent=``;var r=fI(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.`),cI=function(){throw new I(`KaTeX doesn't work in quirks mode.`)});var lI=function(e,t){return fI(e,t).toMarkup()},uI=function(e,t){return sI(e,new bA(t))},dI=function(e,t,n){if(n.throwOnError||!(e instanceof I))throw e;var r=Y([`katex-error`],[new gj(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},fI=function(e,t){var n=new bA(t);try{return EN(sI(e,n),e,n)}catch(t){return dI(t,e,n)}},pI={version:`0.18.10`,render:cI,renderToString:lI,ParseError:I,SETTINGS_SCHEMA:gA,__parse:uI,__renderToDomTree:fI,__renderToHTMLTree:function(e,t){var n=new bA(t);try{return DN(sI(e,n),e,n)}catch(t){return dI(t,e,n)}},__setFontMetrics:Ej,__defineSymbol:z,__defineFunction:X,__defineMacro:$,__domTree:{Span:fj,Anchor:pj,SymbolNode:gj,SvgNode:_j,PathNode:vj,LineNode:yj}},mI=Hp.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`,Fu(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 rp({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{pI.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)}}}}}),hI=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},gI=Hp.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`,Fu(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 rp({find:hI,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{pI.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)}}}}}),_I=yp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[mI.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),gI.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}}),vI=Math.min,yI=Math.max,bI=Math.round,xI=Math.floor,SI=e=>({x:e,y:e}),CI={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function wI(e,t,n){return yI(e,vI(t,n))}function TI(e,t){return typeof e==`function`?e(t):e}function EI(e){return e.split(`-`)[0]}function DI(e){return e.split(`-`)[1]}function OI(e){return e===`x`?`y`:`x`}function kI(e){return e===`y`?`height`:`width`}function AI(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function jI(e){return OI(AI(e))}function MI(e,t,n){n===void 0&&(n=!1);let r=DI(e),i=jI(e),a=kI(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=VI(o)),[o,VI(o)]}function NI(e){let t=VI(e);return[PI(e),t,PI(t)]}function PI(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var FI=[`left`,`right`],II=[`right`,`left`],LI=[`top`,`bottom`],RI=[`bottom`,`top`];function zI(e,t,n){switch(e){case`top`:case`bottom`:return n?t?II:FI:t?FILine 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=$L(e.anchor,t,()=>{rR(e.anchor,t,{placement:`bottom-start`,middleware:[eR(6),nR(),tR({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(),iR===d&&(iR=null),n||e.onCancel?.())}let d=()=>u();return iR=d,n.focus(),e.multiline||n.select(),d}function oR(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;aR({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 _I.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function sR(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Of(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.map(Of).join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function cR(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
`);return/\s/.test(n)}):!1}function lR(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 uR(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:lR(e)}function dR({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&&!cR(r)}function fR({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function pR({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),k.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 mR({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 hR({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 gR({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[eR({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(nR()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function _R(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 vR({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&&_R(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=$L(c,o,()=>{rR(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 yR({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,_=hR({editor:e,items:n}),v=gR({placeLine truncated
Idea --> Draft --> Review --> Published`,NR=null;function PR(e){return NR??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),NR}var FR=0;async function IR(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 PR(r)).render(`dw-mermaid-${++FR}`,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 LR=Hp.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`,Fu(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=MR)=>({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 IR(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;aR({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void IR(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),IR(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void IR(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),IR(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}),RR=e=>`/p/${encodeURIComponent(e)}`,zR=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function BR(e){return zR.exec(e)?.[1]??``}function VR(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:RR(n.id)}}]},{type:`text`,text:` `}]).run()}var HR=yp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(SR({editor:this.editor,pluginKey:new D(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:AR({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>VR(e.editor,e.range,t)})})),t&&r.push(new E({key:new D(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!BR(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function UR(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 WR(e,t,n,r,i=!1){let a=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),o=[a(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),a(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),a(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),a(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),a(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),a(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),a(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),a(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),a(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),a(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),a(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),a(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focuLine truncated
?)[ \r ]*`,XL=`[̀-ͯ]`,ZL=RegExp(XL+`+$`),QL=`(`+GL+`+)|`+(YL+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(XL+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(XL+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+JL)+(`|`+qL+`)`),$L=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(QL,`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 $I(`EOF`,new QI(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new I(`Unexpected character: '`+e[t]+`'`,new $I(e[t],new QI(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 $I(r,new QI(this,t,this.tokenRegex.lastIndex))}},eR=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 I(`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}},tR=ZI;$(`\\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 nR={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 I("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=nR[t.text],r==null||r>=n)throw new I(`Invalid base-`+n+` digit `+t.text);for(var i;(i=nR[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var rR=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new I(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new I(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new I(`\\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 I(`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=>rR(e,!1,!0,!1)),$(`\\renewcommand`,e=>rR(e,!0,!1,!1)),$(`\\providecommand`,e=>rR(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),WL[n],zN.math[n],zN.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(mR,t[0])&&!zN[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=mR[t[0]]+t.slice(1));var i=ZL.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(zN[this.mode][t]){this.settings.strict&&this.mode===`math`&&sP.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=zN[this.mode][t].group,s=QI.range(e);a=qF(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&&(YM(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:QI.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(!pR[l])throw new I(`Unknown accent ' `+l+`'`,e);var u=pR[l][this.mode]||pR[l].text;if(!u)throw new I(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:QI.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};hR.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var gR=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new hR(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 I(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new $I(`\\df@tag`)])}]}return r},_R=function(e,t,n){t.textContent=``;var r=xR(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.`),_R=function(){throw new I(`KaTeX doesn't work in quirks mode.`)});var vR=function(e,t){return xR(e,t).toMarkup()},yR=function(e,t){return gR(e,new kM(t))},bR=function(e,t,n){if(n.throwOnError||!(e instanceof I))throw e;var r=Y([`katex-error`],[new TN(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},xR=function(e,t){var n=new kM(t);try{return FF(gR(e,n),e,n)}catch(t){return bR(t,e,n)}},SR={version:`0.18.10`,render:_R,renderToString:vR,ParseError:I,SETTINGS_SCHEMA:TM,__parse:yR,__renderToDomTree:xR,__renderToHTMLTree:function(e,t){var n=new kM(t);try{return IF(gR(e,n),e,n)}catch(t){return bR(t,e,n)}},__setFontMetrics:FN,__defineSymbol:z,__defineFunction:X,__defineMacro:$,__domTree:{Span:xN,Anchor:SN,SymbolNode:TN,SvgNode:EN,PathNode:DN,LineNode:ON}},CR=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`,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 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{SR.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)}}}}}),wR=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},TR=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`,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 cp({find:wR,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{SR.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)}}}}}),ER=wp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[CR.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),TR.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function DR(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;Xj({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 ER.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function OR(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=kf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegELine truncated
`);return/\s/.test(n)}):!1}function AR(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 jR(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:AR(e)}function MR({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&&!kR(r)}function NR({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function PR({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 FR({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 IR({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 LR({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Gj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(qj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function RR(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 zR({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&&RR(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Wj(c,o,()=>{Jj(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 BR({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,_=IR({editor:e,items:n}),v=LR({placLine truncated
Idea --> Draft --> Review --> Published`,ez=null;function tz(e){return ez??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),ez}var nz=0;async function rz(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 tz(r)).render(`dw-mermaid-${++nz}`,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 iz=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`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=$R)=>({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 rz(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;Xj({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void rz(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),rz(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void rz(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),rz(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}),az=e=>`/p/${encodeURIComponent(e)}`,oz=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function sz(e){return oz.exec(e)?.[1]??``}function cz(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:az(n.id)}}]},{type:`text`,text:` `}]).run()}var lz=wp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(UR({editor:this.editor,pluginKey:new D(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:ZR({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>cz(e.editor,e.range,t)})})),t&&r.push(new E({key:new D(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!sz(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function uz(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 dz(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(`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(`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().deleteLine truncated
<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-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-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;--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-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(ifraLine 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-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;--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-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-cLine truncated
/*$vite$:1*/</style>
</head>
<body>
+1 -1
View File
@@ -127,7 +127,7 @@ export class EditorBridge {
return new Editor({
element: this.el,
editable: this.editable,
extensions: docwellExtensions(opts),
extensions: docwellExtensions({ ...opts, onNavigate: (path) => this.send({ type: "navigate", path }) }),
editorProps: { attributes: { class: "dw-prose" } },
onUpdate: ({ editor }) => this.send({ type: "change", content: editor.getJSON() }),
onSelectionUpdate: ({ editor }) => this.reportState(editor),
+2
View File
@@ -52,6 +52,8 @@ export type EditorMessage =
| { type: "change"; content: JSONContent }
| { type: "state"; state: EditorState }
| { type: "collab"; status: string }
/** A link to a page was followed; path is an app route like "/p/<id>". */
| { type: "navigate"; path: string }
| { type: "error"; message: string };
/** Bumped when a message changes shape, so the app can refuse a stale bundle. */
+4 -1
View File
@@ -63,7 +63,10 @@ export function scrollToBlock(editor: Editor, id: string): boolean {
dom.scrollIntoView({ block: "center" });
// An animation, not a class: ProseMirror redraws nodes whose attributes change.
const flash = getComputedStyle(dom).getPropertyValue("--color-selection").trim() || "rgba(47,125,109,.25)";
dom.animate?.([{ backgroundColor: flash }, { backgroundColor: "transparent" }], { duration: 2000, easing: "ease-out" });
dom.animate?.([{ backgroundColor: flash }, { backgroundColor: "transparent" }], {
duration: 2000,
easing: "ease-out",
});
return true;
}
+14 -1
View File
@@ -12,6 +12,8 @@ android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// flutter_local_notifications needs java.time on older Android versions.
isCoreLibraryDesugaringEnabled = true
}
defaultConfig {
@@ -19,7 +21,8 @@ android {
applicationId = "app.docwell.docwell_mobile"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
// flutter_local_notifications needs Android 7.0 (API 24).
minSdk = maxOf(flutter.minSdkVersion, 24)
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
@@ -43,3 +46,13 @@ kotlin {
flutter {
source = "../.."
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
// The UnifiedPush connector brings Tink for the JVM and secure storage brings
// tink-android, which holds the same classes; keep the Android build only.
configurations.all {
exclude(group = "com.google.crypto.tink", module = "tink")
}
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application
android:label="Docwell"
android:name="${applicationName}"
@@ -25,6 +26,12 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- "Save to Docwell" for text and links shared from other apps. -->
<intent-filter android:label="Save to Docwell">
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
@@ -1,5 +1,45 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package app.docwell.docwell_mobile
import android.content.Intent
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
class MainActivity : FlutterActivity()
// "Save to Docwell" in the share sheet: text and links shared from other
// apps are handed to Flutter over the docwell/share channel.
class MainActivity : FlutterActivity() {
private var channel: MethodChannel? = null
private var pending: Map<String, String>? = null
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "docwell/share").apply {
setMethodCallHandler { call, result ->
when (call.method) {
// The share that started the app, once.
"takeShared" -> {
result.success(pending)
pending = null
}
else -> result.notImplemented()
}
}
}
pending = shared(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val share = shared(intent) ?: return
channel?.invokeMethod("shared", share)
}
private fun shared(intent: Intent?): Map<String, String>? {
if (intent?.action != Intent.ACTION_SEND || intent.type?.startsWith("text/") != true) return null
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return null
val subject = intent.getStringExtra(Intent.EXTRA_SUBJECT) ?: ""
return mapOf("text" to text.take(100_000), "subject" to subject.take(500))
}
}
+228 -13
View File
@@ -1,51 +1,238 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'generated/models.dart';
import 'response_cache.dart';
export 'generated/models.dart';
export 'response_cache.dart';
/// Minimal docwell-server client. Requests are written by hand; the models
/// are generated from api/openapi.yaml (tool/generate_api.dart).
/// docwell-server client. Requests are written by hand; the models are
/// generated from api/openapi.yaml (tool/generate_api.dart).
///
/// Reads go through [cache]: every successful GET is kept, and when the
/// server can't be reached the last copy is returned instead, so pages read
/// before stay readable offline. [offline] says whether the last read came
/// from the cache.
class DocwellApi {
DocwellApi(String baseUrl, {http.Client? client})
: baseUrl = baseUrl.replaceAll(RegExp(r'/+$'), ''),
_client = client ?? http.Client();
DocwellApi(
String baseUrl, {
http.Client? client,
ResponseCache? cache,
this.onUnauthorized,
}) : baseUrl = baseUrl.replaceAll(RegExp(r'/+$'), ''),
_client = client ?? http.Client(),
cache = cache ?? MemoryCache();
final String baseUrl;
final http.Client _client;
final ResponseCache cache;
/// Called when the server rejects the token (expired, signed out elsewhere).
void Function()? onUnauthorized;
/// PocketBase auth token of the signed-in user, sent as a bearer token.
String? token;
/// Whether the last read came from the offline cache.
bool offline = false;
/// The live-editing WebSocket address.
String get collabUrl =>
'${baseUrl.replaceFirst(RegExp('^http'), 'ws')}/collab';
Future<String> version() async {
final body = await _send('GET', '/api/v1/version');
return body['version'] as String;
}
// ---- Sign-in -------------------------------------------------------------
/// Signs in with email and password and keeps the token for later calls.
/// Accounts with two-step sign-in answer [TotpRequired].
Future<User> login(String email, String password) async {
final body = await _send('POST', '/api/v1/auth/login', {
'email': email,
'password': password,
});
return _session(body);
}
/// Second step: a code from an authenticator app, or a recovery code.
Future<User> verifyTotp(String challenge, String code) async => _session(
await _send('POST', '/api/v1/auth/totp/verify', {
'challenge': challenge,
'code': code,
}),
);
/// Swaps the saved token for a fresh one at start-up.
Future<User> refresh() async =>
_session(await _send('POST', '/api/v1/auth/refresh'));
User _session(Map<String, dynamic> body) {
token = body['token'] as String;
// Kept so the next start without a connection still knows who this is.
unawaited(cache.write('/api/v1/auth/me', jsonEncode(body['user'])));
return User.fromJson(body['user'] as Map<String, dynamic>);
}
Future<User> me() async =>
User.fromJson(await _send('GET', '/api/v1/auth/me'));
/// The signed-in user (cached, so the app can start offline).
Future<User> me() async => User.fromJson(await _get('/api/v1/auth/me'));
void logout() => token = null;
// ---- Browsing (cached for offline reading) -------------------------------
Future<List<Workspace>> workspaces() async => (await _getList(
'/api/v1/workspaces',
)).map((e) => Workspace.fromJson(e as Map<String, dynamic>)).toList();
Future<List<Space>> spaces(String workspace) async => (await _getList(
'/api/v1/workspaces/${_id(workspace)}/spaces',
)).map((e) => Space.fromJson(e as Map<String, dynamic>)).toList();
/// The space's page tree as a flat list in depth-first order.
Future<List<PageNode>> pages(String space) async => (await _getList(
'/api/v1/spaces/${_id(space)}/pages',
)).map((e) => PageNode.fromJson(e as Map<String, dynamic>)).toList();
Future<Page> page(String id) async =>
Page.fromJson(await _get('/api/v1/pages/${_id(id)}'));
Future<PageContent> content(String id) async =>
PageContent.fromJson(await _get('/api/v1/pages/${_id(id)}/content'));
Future<List<PageItem>> recent(String workspace) async => (await _getList(
'/api/v1/workspaces/${_id(workspace)}/recent',
)).map((e) => PageItem.fromJson(e as Map<String, dynamic>)).toList();
Future<SearchResult> search(
String workspace,
String q,
) async => SearchResult.fromJson(
await _send(
'GET',
'/api/v1/workspaces/${_id(workspace)}/search?q=${Uri.encodeQueryComponent(q)}&limit=30',
),
);
// ---- Writing -------------------------------------------------------------
Future<Page> createPage(
String space, {
String title = '',
String parent = '',
}) async => Page.fromJson(
await _send('POST', '/api/v1/spaces/${_id(space)}/pages', {
'title': title,
if (parent.isNotEmpty) 'parent': parent,
}),
);
/// Replaces the page's document (Tiptap JSON).
Future<void> saveContent(String page, Map<String, dynamic> doc) =>
_send('PUT', '/api/v1/pages/${_id(page)}/content', {'content': doc});
/// Records that the user opened the page, for their recent list.
Future<void> visit(String page) =>
_send('POST', '/api/v1/pages/${_id(page)}/visit');
// ---- Comments ------------------------------------------------------------
Future<List<Comment>> comments(String page) async => (await _getList(
'/api/v1/pages/${_id(page)}/comments',
)).map((e) => Comment.fromJson(e as Map<String, dynamic>)).toList();
Future<Comment> addComment(
String page,
String body, {
String parent = '',
}) async => Comment.fromJson(
await _send('POST', '/api/v1/pages/${_id(page)}/comments', {
'body': body,
if (parent.isNotEmpty) 'parent': parent,
}),
);
/// Resolves a thread, or opens it again.
Future<void> resolveComment(String id, bool resolved) => _send(
'POST',
'/api/v1/comments/${_id(id)}/resolve',
{'resolved': resolved},
);
// ---- Notifications -------------------------------------------------------
Future<NotificationList> notifications() async => NotificationList.fromJson(
await _send('GET', '/api/v1/notifications?limit=50'),
);
Future<void> markRead({List<String> ids = const [], bool all = false}) =>
_send('POST', '/api/v1/notifications/read', {'ids': ids, 'all': all});
/// Registers this phone's UnifiedPush endpoint and Web Push keys.
Future<PushDevice> registerDevice({
required String endpoint,
required String p256dh,
required String auth,
String name = '',
}) async => PushDevice.fromJson(
await _send('POST', '/api/v1/me/devices', {
'endpoint': endpoint,
'p256dh': p256dh,
'auth': auth,
'name': name,
}),
);
Future<void> removeDevice(String id) =>
_send('DELETE', '/api/v1/me/devices/${_id(id)}');
// ---- Transport -----------------------------------------------------------
static String _id(String id) => Uri.encodeComponent(id);
Future<Map<String, dynamic>> _get(String path) async =>
(await _cached(path)) as Map<String, dynamic>;
Future<List<dynamic>> _getList(String path) async =>
(await _cached(path)) as List<dynamic>;
/// A GET that falls back to the cached copy when the server is unreachable.
Future<Object?> _cached(String path) async {
try {
final raw = await _raw('GET', path);
offline = false;
unawaited(cache.write(path, raw));
return raw.isEmpty ? null : jsonDecode(raw);
} on DocwellApiException {
rethrow;
} catch (e) {
final copy = await cache.read(path);
if (copy == null) rethrow;
offline = true;
return jsonDecode(copy);
}
}
Future<Map<String, dynamic>> _send(
String method,
String path, [
Object? body,
]) async {
final raw = await _raw(method, path, body);
if (raw.isEmpty) return <String, dynamic>{};
final data = jsonDecode(raw);
return data is Map<String, dynamic> ? data : {'items': data};
}
Future<String> _raw(String method, String path, [Object? body]) async {
final req = http.Request(method, Uri.parse('$baseUrl$path'));
req.headers['Accept'] = 'application/json';
if (token != null) req.headers['Authorization'] = 'Bearer $token';
@@ -56,16 +243,25 @@ class DocwellApi {
final res = await http.Response.fromStream(
await _client.send(req).timeout(const Duration(seconds: 15)),
);
final data = res.body.isEmpty
? <String, dynamic>{}
: jsonDecode(res.body) as Map<String, dynamic>;
final text = utf8.decode(res.bodyBytes);
if (res.statusCode >= 300) {
Map<String, dynamic> data = {};
try {
data = jsonDecode(text) as Map<String, dynamic>;
} catch (_) {}
if (res.statusCode == HttpStatus.unauthorized &&
token != null &&
!path.startsWith('/api/v1/auth/')) {
onUnauthorized?.call();
}
throw DocwellApiException(
res.statusCode,
data['error'] as String? ?? 'unknown',
code: data['error'] as String? ?? 'unknown',
challenge: data['challenge'] as String? ?? '',
message: data['message'] as String? ?? '',
);
}
return data;
return text;
}
}
@@ -74,14 +270,33 @@ extension UserRoles on User {
bool get isManager => role == Role.admin || role == Role.superadmin;
}
extension SpaceRoles on SpaceRole {
/// May change the page's text.
bool get canEdit => this == SpaceRole.admin || this == SpaceRole.editor;
/// May add comments.
bool get canComment => canEdit || this == SpaceRole.commenter;
}
class DocwellApiException implements Exception {
DocwellApiException(this.status, [this.code = 'unknown']);
DocwellApiException(
this.status, {
this.code = 'unknown',
this.challenge = '',
this.message = '',
});
final int status;
/// Machine-readable error code from the server, e.g. "invalid_credentials".
final String code;
/// Set with "totp_required": send it to [DocwellApi.verifyTotp] with a code.
final String challenge;
/// The server's human-readable explanation, when it sent one.
final String message;
@override
String toString() => 'Docwell API error $status ($code)';
}
+52
View File
@@ -1048,6 +1048,58 @@ class TrashedPage {
};
}
class PushDevice {
const PushDevice({
required this.id,
required this.name,
required this.created,
});
factory PushDevice.fromJson(Map<String, dynamic> json) => PushDevice(
id: json['id'] as String,
name: json['name'] as String,
created: json['created'] as String,
);
final String id;
final String name;
final String created;
Map<String, dynamic> toJson() => {'id': id, 'name': name, 'created': created};
}
/// The JSON body docwell-server POSTs to a phone's push endpoint
class PushMessage {
const PushMessage({
required this.title,
required this.body,
required this.route,
});
factory PushMessage.fromJson(Map<String, dynamic> json) => PushMessage(
title: json['title'] as String,
body: json['body'] as String,
route: json['route'] as String,
);
/// The page's icon and title
final String title;
/// For example "Ann mentioned you: …"
final String body;
/// The app route to open, for example /p/`<id>`?comment=`<id>`
final String route;
Map<String, dynamic> toJson() => {
'title': title,
'body': body,
'route': route,
};
}
class ArchivedPage {
const ArchivedPage({
required this.id,
+66
View File
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:convert';
import 'dart:io';
/// Keeps server answers for reading offline, keyed by request path.
abstract class ResponseCache {
Future<String?> read(String key);
Future<void> write(String key, String body);
/// Forgets everything (signing out, switching servers).
Future<void> clear();
}
/// Kept in memory only: tests, and before the disk cache is ready.
class MemoryCache implements ResponseCache {
final _items = <String, String>{};
@override
Future<String?> read(String key) async => _items[key];
@override
Future<void> write(String key, String body) async => _items[key] = body;
@override
Future<void> clear() async => _items.clear();
}
/// One file per answer in the app's private storage. Pages someone opened
/// stay readable without a connection; nothing is fetched ahead.
class FileCache implements ResponseCache {
FileCache(this.dir);
final Directory dir;
File _file(String key) => File(
'${dir.path}/${base64Url.encode(utf8.encode(key)).replaceAll('=', '')}.json',
);
@override
Future<String?> read(String key) async {
try {
return await _file(key).readAsString();
} on FileSystemException {
return null;
}
}
@override
Future<void> write(String key, String body) async {
try {
await dir.create(recursive: true);
// Write then rename, so a crash never leaves half a file.
final tmp = File('${_file(key).path}.tmp');
await tmp.writeAsString(body, flush: true);
await tmp.rename(_file(key).path);
} on FileSystemException {
// A full disk only costs offline reading.
}
}
@override
Future<void> clear() async {
if (await dir.exists()) await dir.delete(recursive: true);
}
}
+181
View File
@@ -0,0 +1,181 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';
import 'package:flutter/material.dart';
import 'api/docwell_api.dart';
import 'push.dart';
import 'screens/home_screen.dart';
import 'screens/login_screen.dart';
import 'screens/page_screen.dart';
import 'screens/share_screen.dart';
import 'session.dart';
import 'share.dart';
/// Makes a client for a server address (with its offline cache).
typedef ApiFactory = DocwellApi Function(String server);
/// What the signed-in screens share.
class AppSession {
AppSession({required this.api, required this.user, this.push});
final DocwellApi api;
final User user;
final PushService? push;
}
class DocwellApp extends StatefulWidget {
const DocwellApp({
super.key,
required this.sessions,
required this.apiFor,
this.push,
this.shares,
this.defaultServer = '',
});
final SessionStore sessions;
final ApiFactory apiFor;
final PushService? push;
final ShareReceiver? shares;
/// Pre-filled on the sign-in screen the first time.
final String defaultServer;
@override
State<DocwellApp> createState() => _DocwellAppState();
}
class _DocwellAppState extends State<DocwellApp> {
final _navigator = GlobalKey<NavigatorState>();
AppSession? _session;
bool _restoring = true;
String _server = '';
// A route or share that arrived before sign-in finished.
String? _pendingRoute;
SharedText? _pendingShare;
@override
void initState() {
super.initState();
unawaited(_restore());
unawaited(widget.push?.init(_openRoute));
unawaited(widget.shares?.listen(_openShare));
}
/// Signs back in with the saved token. Only the server rejecting it signs
/// out; without a connection the app starts offline with cached pages.
Future<void> _restore() async {
_server = await widget.sessions.lastServer() ?? widget.defaultServer;
final saved = await widget.sessions.load();
if (saved != null) {
final api = widget.apiFor(saved.server)..token = saved.token;
try {
final user = await api.refresh();
await widget.sessions.save(saved.server, api.token!);
_signedIn(api, user);
} on DocwellApiException {
await widget.sessions.clearToken();
} catch (_) {
try {
// Offline: the last /auth/me answer is in the cache.
_signedIn(api, await api.me());
} catch (_) {}
}
}
if (mounted) setState(() => _restoring = false);
}
void _signedIn(DocwellApi api, User user) {
api.onUnauthorized = _signOut;
widget.push?.api = api;
setState(
() => _session = AppSession(api: api, user: user, push: widget.push),
);
final route = _pendingRoute;
final share = _pendingShare;
_pendingRoute = null;
_pendingShare = null;
if (route != null) _openRoute(route);
if (share != null) _openShare(share);
}
Future<void> _onLogin(DocwellApi api, User user) async {
await widget.sessions.save(api.baseUrl, api.token!);
_server = api.baseUrl;
_signedIn(api, user);
}
Future<void> _signOut() async {
final s = _session;
if (s == null) return;
await widget.push?.disable();
widget.push?.api = null;
s.api.logout();
await s.api.cache.clear();
await widget.sessions.clearToken();
_navigator.currentState?.popUntil((r) => r.isFirst);
if (mounted) setState(() => _session = null);
}
/// Opens an app route from a notification: `/p/<id>` (with `?comment=…`).
void _openRoute(String route) {
final s = _session;
if (s == null) {
_pendingRoute = route;
return;
}
final uri = Uri.parse(route);
if (uri.pathSegments.length == 2 && uri.pathSegments[0] == 'p') {
_navigator.currentState?.push(
MaterialPageRoute<void>(
builder: (_) => PageScreen(
session: s,
pageId: uri.pathSegments[1],
openComment: uri.queryParameters['comment'],
),
),
);
}
}
void _openShare(SharedText shared) {
final s = _session;
if (s == null) {
_pendingShare = shared;
return;
}
_navigator.currentState?.push(
MaterialPageRoute<void>(
builder: (_) => ShareScreen(session: s, shared: shared),
),
);
}
@override
Widget build(BuildContext context) {
const brand = Color(0xFF2F7D6D);
final s = _session;
return MaterialApp(
title: 'Docwell',
navigatorKey: _navigator,
theme: ThemeData(colorSchemeSeed: brand, useMaterial3: true),
darkTheme: ThemeData(
colorSchemeSeed: brand,
brightness: Brightness.dark,
useMaterial3: true,
),
home: _restoring
? const Scaffold(body: Center(child: CircularProgressIndicator()))
: s == null
? LoginScreen(
server: _server,
apiFor: widget.apiFor,
onSignedIn: _onLogin,
)
: HomeScreen(session: s, onSignOut: _signOut),
);
}
}
+7
View File
@@ -68,6 +68,7 @@ class EditorBridge extends ChangeNotifier {
String? _error;
final _readyCompleter = Completer<void>();
final _changes = StreamController<Map<String, dynamic>>.broadcast();
final _navigations = StreamController<String>.broadcast();
/// The latest document (Tiptap JSON), null until there is one.
Map<String, dynamic>? get content => _content;
@@ -88,6 +89,9 @@ class EditorBridge extends ChangeNotifier {
/// Every edit the user makes.
Stream<Map<String, dynamic>> get changes => _changes.stream;
/// App routes of page links the user followed, e.g. `/p/<id>`.
Stream<String> get navigations => _navigations.stream;
/// Call once the page has loaded.
Future<void> hello() => _post({'type': 'hello'});
@@ -153,6 +157,8 @@ class EditorBridge extends ChangeNotifier {
case 'collab':
_collabStatus = msg['status'] as String;
notifyListeners();
case 'navigate':
_navigations.add(msg['path'] as String);
case 'error':
_error = msg['message'] as String;
notifyListeners();
@@ -165,6 +171,7 @@ class EditorBridge extends ChangeNotifier {
@override
void dispose() {
_changes.close();
_navigations.close();
super.dispose();
}
}
+3 -3
View File
@@ -95,7 +95,7 @@ class _EditorScreenState extends State<EditorScreen> {
],
),
),
_Toolbar(bridge: _bridge),
EditorToolbar(bridge: _bridge),
],
),
);
@@ -103,8 +103,8 @@ class _EditorScreenState extends State<EditorScreen> {
}
/// Formatting buttons above the keyboard, lit up from the page's state.
class _Toolbar extends StatelessWidget {
const _Toolbar({required this.bridge});
class EditorToolbar extends StatelessWidget {
const EditorToolbar({super.key, required this.bridge});
final EditorBridge bridge;
+23 -268
View File
@@ -1,280 +1,35 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'api/docwell_api.dart';
import 'editor/editor_screen.dart';
void main() {
runApp(const DocwellApp());
}
import 'app.dart';
import 'push.dart';
import 'session.dart';
import 'share.dart';
// Android emulators reach the host machine at 10.0.2.2.
const defaultServerUrl = 'http://10.0.2.2:8080';
class DocwellApp extends StatefulWidget {
const DocwellApp({super.key, this.api});
final DocwellApi? api;
@override
State<DocwellApp> createState() => _DocwellAppState();
}
class _DocwellAppState extends State<DocwellApp> {
late final DocwellApi _api = widget.api ?? DocwellApi(defaultServerUrl);
// Kept in memory only for now; secure storage comes with the full mobile app.
User? _user;
@override
Widget build(BuildContext context) {
const brand = Color(0xFF2F5FD0);
return MaterialApp(
title: 'Docwell',
theme: ThemeData(colorSchemeSeed: brand, useMaterial3: true),
darkTheme: ThemeData(
colorSchemeSeed: brand,
brightness: Brightness.dark,
useMaterial3: true,
),
home: _user == null
? LoginScreen(api: _api, onSignedIn: (u) => setState(() => _user = u))
: HomeScreen(
api: _api,
user: _user!,
onSignOut: () => setState(() {
_api.logout();
_user = null;
}),
),
);
}
}
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key, required this.api, required this.onSignedIn});
final DocwellApi api;
final ValueChanged<User> onSignedIn;
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final _email = TextEditingController();
final _password = TextEditingController();
bool _busy = false;
String? _error;
static const _messages = {
'invalid_credentials': 'Wrong email or password.',
'account_disabled': 'This account is disabled.',
'mfa_required': 'Two-step sign-in is not supported in the app yet.',
};
Future<void> _submit() async {
setState(() {
_busy = true;
_error = null;
});
try {
widget.onSignedIn(
await widget.api.login(_email.text.trim(), _password.text),
);
} on DocwellApiException catch (e) {
setState(() => _error = _messages[e.code] ?? 'Sign-in failed.');
} catch (_) {
setState(() => _error = "Can't reach the server.");
} finally {
if (mounted) setState(() => _busy = false);
}
}
@override
void dispose() {
_email.dispose();
_password.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Sign in to Docwell',
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: 24),
TextField(
key: const Key('email'),
controller: _email,
keyboardType: TextInputType.emailAddress,
autofillHints: const [AutofillHints.email],
decoration: const InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 12),
TextField(
key: const Key('password'),
controller: _password,
obscureText: true,
autofillHints: const [AutofillHints.password],
onSubmitted: (_) => _submit(),
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
),
if (_error != null) ...[
const SizedBox(height: 12),
Text(
_error!,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
const SizedBox(height: 20),
FilledButton(
onPressed: _busy ? null : _submit,
child: const Text('Sign in'),
),
],
),
),
),
),
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final support = await getApplicationSupportDirectory();
runApp(
DocwellApp(
sessions: SecureSessionStore(),
// Each server keeps its own offline copy.
apiFor: (server) => DocwellApi(
server,
cache: FileCache(
Directory('${support.path}/cache/${Uri.encodeComponent(server)}'),
),
),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({
super.key,
required this.api,
required this.user,
required this.onSignOut,
});
final DocwellApi api;
final User user;
final VoidCallback onSignOut;
@override
State<HomeScreen> createState() => _HomeScreenState();
}
String _roleLabel(Role role) => switch (role) {
Role.superadmin => 'Superadmin',
Role.admin => 'Admin',
Role.user => 'User',
};
/// A local page for trying the WebView editor before pages sync to mobile.
const _scratchPage = {
'type': 'doc',
'content': [
{
'type': 'heading',
'attrs': {'level': 1},
'content': [
{'type': 'text', 'text': 'Scratch page'},
],
},
{
'type': 'paragraph',
'content': [
{'type': 'text', 'text': 'This is the same editor as the web app.'},
],
},
],
};
class _HomeScreenState extends State<HomeScreen> {
late Future<String> _version = widget.api.version();
void _retry() => setState(() => _version = widget.api.version());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Docwell'),
actions: [
TextButton(
onPressed: widget.onSignOut,
child: const Text('Sign out'),
),
],
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Hello, ${widget.user.name}',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 4),
Text(
widget.user.organizationName.isEmpty
? _roleLabel(widget.user.role)
: '${_roleLabel(widget.user.role)} · ${widget.user.organizationName}',
),
const SizedBox(height: 16),
FutureBuilder<String>(
future: _version,
builder: (context, snap) {
if (snap.connectionState != ConnectionState.done) {
return const CircularProgressIndicator();
}
if (snap.hasError) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('Server unreachable'),
const SizedBox(height: 12),
FilledButton(
onPressed: _retry,
child: const Text('Retry'),
),
],
);
}
return Text('Connected · v${snap.data}');
},
),
const SizedBox(height: 24),
OutlinedButton.icon(
icon: const Icon(Icons.edit_note),
label: const Text('Try the editor'),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const EditorScreen(
title: 'Scratch page',
content: _scratchPage,
),
),
),
),
],
),
),
);
}
push: PushService(),
shares: ShareReceiver(),
defaultServer: defaultServerUrl,
),
);
}
+166
View File
@@ -0,0 +1,166 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:convert';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:unifiedpush_platform_interface/data/push_endpoint.dart';
import 'package:unifiedpush_platform_interface/data/push_message.dart';
import 'package:unifiedpush_platform_interface/unifiedpush_platform_interface.dart';
import 'api/docwell_api.dart' hide PushMessage;
/// Push notifications through UnifiedPush (Android). The phone's distributor
/// app (ntfy, NextPush, …) gives this app an endpoint; docwell-server sends
/// notifications there, encrypted to this app's Web Push keys. Messages that
/// don't decrypt are dropped, so knowing the endpoint is not enough to send
/// a notification.
class PushService extends ChangeNotifier {
PushService({FlutterSecureStorage? storage})
: _storage = storage ?? const FlutterSecureStorage();
static const _instance = 'docwell';
final FlutterSecureStorage _storage;
final _local = FlutterLocalNotificationsPlugin();
DocwellApi? _api;
void Function(String route)? _open;
/// Whether this phone gets push notifications (it registered an endpoint).
bool get enabled => _deviceId != null;
String? _deviceId;
/// Why push can't be turned on, e.g. no distributor installed.
String? problem;
bool get supported => !kIsWeb && Platform.isAndroid;
/// Sets up the handlers. [open] receives the app route of a tapped
/// notification.
Future<void> init(void Function(String route) open) async {
_open = open;
if (!supported) return;
_deviceId = await _storage.read(key: 'push_device');
await _local.initialize(
settings: const InitializationSettings(
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
),
onDidReceiveNotificationResponse: (r) {
final route = r.payload;
if (route != null && route.startsWith('/')) _open?.call(route);
},
);
// A tap that started the app.
final launch = await _local.getNotificationAppLaunchDetails();
final route = launch?.notificationResponse?.payload;
if (launch?.didNotificationLaunchApp == true && route != null) {
Future.microtask(() => _open?.call(route));
}
await UnifiedPushPlatform.instance.initializeCallback(
onNewEndpoint: (e, _) => _registerEndpoint(e),
onUnregistered: (_) => _forget(),
onMessage: (m, _) => _show(m),
);
}
/// The signed-in session: endpoints get registered with this server.
set api(DocwellApi? api) {
_api = api;
// Endpoints can change; the connector reports them again on register.
if (api != null && enabled) _register();
}
/// Turns push on. Returns false (and sets [problem]) when the phone has
/// no UnifiedPush distributor.
Future<bool> enable() async {
if (!supported) return false;
problem = null;
final ok = await UnifiedPushPlatform.instance
.tryUseCurrentOrDefaultDistributor();
if (!ok) {
final all = await UnifiedPushPlatform.instance.getDistributors(const []);
if (all.isEmpty) {
problem =
'Install a UnifiedPush distributor such as ntfy to get notifications.';
notifyListeners();
return false;
}
await UnifiedPushPlatform.instance.saveDistributor(all.first);
}
await _local
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>()
?.requestNotificationsPermission();
await _register();
return true;
}
Future<void> _register() =>
UnifiedPushPlatform.instance.register(_instance, const [], null, null);
/// Turns push off on this phone and tells the server to stop.
Future<void> disable() async {
final id = _deviceId;
if (id != null) {
try {
await _api?.removeDevice(id);
} catch (_) {
// The server forgets endpoints that stop answering anyway.
}
}
if (supported) await UnifiedPushPlatform.instance.unregister(_instance);
await _forget();
}
Future<void> _registerEndpoint(PushEndpoint e) async {
final keys = e.pubKeySet;
final api = _api;
if (keys == null || api == null) return;
try {
final device = await api.registerDevice(
endpoint: e.url,
p256dh: keys.pubKey,
auth: keys.auth,
name: 'Android',
);
_deviceId = device.id;
await _storage.write(key: 'push_device', value: device.id);
notifyListeners();
} catch (err) {
problem = 'The server did not accept this phone: $err';
notifyListeners();
}
}
Future<void> _forget() async {
_deviceId = null;
await _storage.delete(key: 'push_device');
notifyListeners();
}
Future<void> _show(PushMessage m) async {
if (!m.decrypted) return;
final Map<String, dynamic> msg;
try {
msg = jsonDecode(utf8.decode(m.content)) as Map<String, dynamic>;
} catch (_) {
return;
}
await _local.show(
id: DateTime.now().millisecondsSinceEpoch & 0x7fffffff,
title: msg['title'] as String? ?? 'Docwell',
body: msg['body'] as String? ?? '',
notificationDetails: const NotificationDetails(
android: AndroidNotificationDetails(
'activity',
'Comments and mentions',
channelDescription: 'Replies, mentions and pages shared with you',
importance: Importance.defaultImportance,
),
),
payload: msg['route'] as String?,
);
}
}
+256
View File
@@ -0,0 +1,256 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart' hide Notification, Page;
import '../api/docwell_api.dart';
import '../app.dart';
import 'widgets.dart';
/// A page's comment threads with their replies. People who may comment can
/// start a thread, reply and resolve.
class CommentsScreen extends StatefulWidget {
const CommentsScreen({
super.key,
required this.session,
required this.page,
this.highlight,
});
final AppSession session;
final Page page;
/// A comment to scroll to and mark (from a notification).
final String? highlight;
@override
State<CommentsScreen> createState() => _CommentsScreenState();
}
class _CommentsScreenState extends State<CommentsScreen> {
DocwellApi get _api => widget.session.api;
List<Comment>? _comments;
String? _error;
bool _showResolved = false;
final _text = TextEditingController();
Comment? _replyTo;
bool _busy = false;
bool get _canComment => widget.page.role.canComment && !widget.page.inTrash;
@override
void initState() {
super.initState();
_load();
}
Future<void> _load() async {
try {
final list = await _api.comments(widget.page.id);
if (mounted) {
setState(() {
_comments = list;
_error = null;
});
}
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
Future<void> _send() async {
final body = _text.text.trim();
if (body.isEmpty) return;
setState(() => _busy = true);
try {
await _api.addComment(widget.page.id, body, parent: _replyTo?.id ?? '');
_text.clear();
_replyTo = null;
await _load();
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(describeError(e))));
}
} finally {
if (mounted) setState(() => _busy = false);
}
}
Future<void> _resolve(Comment c) async {
try {
await _api.resolveComment(c.id, c.resolvedAt.isEmpty);
await _load();
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(describeError(e))));
}
}
}
Widget _comment(Comment c, {bool reply = false}) {
final marked = c.id == widget.highlight;
final theme = Theme.of(context);
return Container(
color: marked ? theme.colorScheme.secondaryContainer : null,
padding: EdgeInsets.fromLTRB(reply ? 40 : 16, 8, 16, 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (c.quote.isNotEmpty)
Container(
margin: const EdgeInsets.only(bottom: 6),
padding: const EdgeInsets.only(left: 8),
decoration: BoxDecoration(
border: Border(
left: BorderSide(color: theme.colorScheme.outline, width: 3),
),
),
child: Text(
c.quote,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodySmall,
),
),
Text.rich(
TextSpan(
children: [
TextSpan(
text: c.author.name.isEmpty ? c.author.email : c.author.name,
style: const TextStyle(fontWeight: FontWeight.w600),
),
TextSpan(
text: ' ${shortDate(c.created)}',
style: theme.textTheme.bodySmall,
),
],
),
),
const SizedBox(height: 2),
Text(c.body),
],
),
);
}
@override
Widget build(BuildContext context) {
final all = _comments;
final threads = (all ?? [])
.where(
(c) => c.parent.isEmpty && (_showResolved || c.resolvedAt.isEmpty),
)
.toList();
final resolved = (all ?? [])
.where((c) => c.parent.isEmpty && c.resolvedAt.isNotEmpty)
.length;
return Scaffold(
appBar: AppBar(
title: const Text('Comments'),
actions: [
if (resolved > 0)
TextButton(
onPressed: () => setState(() => _showResolved = !_showResolved),
child: Text(
_showResolved ? 'Hide resolved' : 'Resolved ($resolved)',
),
),
],
),
body: Column(
children: [
Expanded(
child: RefreshIndicator(
onRefresh: _load,
child: ListView(
children: [
if (_error != null)
ErrorTile(message: _error!, onRetry: _load)
else if (all == null)
const Padding(
padding: EdgeInsets.all(32),
child: Center(child: CircularProgressIndicator()),
)
else if (threads.isEmpty)
const ListTile(title: Text('No comments yet.')),
for (final t in threads)
Card(
margin: const EdgeInsets.fromLTRB(12, 8, 12, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_comment(t),
for (final r in all!.where((c) => c.parent == t.id))
_comment(r, reply: true),
OverflowBar(
alignment: MainAxisAlignment.end,
children: [
if (t.canResolve)
TextButton(
onPressed: () => _resolve(t),
child: Text(
t.resolvedAt.isEmpty ? 'Resolve' : 'Reopen',
),
),
if (_canComment && t.resolvedAt.isEmpty)
TextButton(
onPressed: () => setState(() => _replyTo = t),
child: const Text('Reply'),
),
],
),
],
),
),
],
),
),
),
if (_canComment)
SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 8, 8, 8),
child: Row(
children: [
Expanded(
child: TextField(
key: const Key('comment-text'),
controller: _text,
minLines: 1,
maxLines: 5,
decoration: InputDecoration(
hintText: _replyTo == null
? 'Comment on the page'
: 'Reply to ${_replyTo!.author.name}',
border: const OutlineInputBorder(),
isDense: true,
suffixIcon: _replyTo == null
? null
: IconButton(
tooltip: 'Cancel reply',
icon: const Icon(Icons.close),
onPressed: () =>
setState(() => _replyTo = null),
),
),
),
),
IconButton(
key: const Key('comment-send'),
tooltip: 'Send',
icon: const Icon(Icons.send),
onPressed: _busy ? null : _send,
),
],
),
),
),
],
),
);
}
}
+244
View File
@@ -0,0 +1,244 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
import '../app.dart';
import 'notifications_screen.dart';
import 'page_screen.dart';
import 'search_screen.dart';
import 'space_screen.dart';
import 'widgets.dart';
/// The start screen: the current workspace's recent pages and spaces.
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key, required this.session, required this.onSignOut});
final AppSession session;
final VoidCallback onSignOut;
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
DocwellApi get _api => widget.session.api;
List<Workspace>? _workspaces;
Workspace? _workspace;
List<Space> _spaces = [];
List<PageItem> _recent = [];
int _unread = 0;
String? _error;
bool _offline = false;
@override
void initState() {
super.initState();
_load();
}
Future<void> _load() async {
try {
final list = await _api.workspaces();
var offline = _api.offline;
final ws =
list.where((w) => w.id == _workspace?.id).firstOrNull ??
list.firstOrNull;
List<Space> spaces = [];
List<PageItem> recent = [];
if (ws != null) {
spaces = await _api.spaces(ws.id);
offline |= _api.offline;
recent = await _api.recent(ws.id).catchError((_) => <PageItem>[]);
}
final unread = offline
? _unread
: await _api
.notifications()
.then((n) => n.unread)
.catchError((_) => _unread);
if (!mounted) return;
setState(() {
_workspaces = list;
_workspace = ws;
_spaces = spaces;
_recent = recent;
_unread = unread;
_offline = offline;
_error = null;
});
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
void _open(Widget screen) => Navigator.of(
context,
).push(MaterialPageRoute<void>(builder: (_) => screen)).then((_) => _load());
Future<void> _togglePush(bool on) async {
final push = widget.session.push;
if (push == null) return;
if (on) {
final ok = await push.enable();
if (!ok && mounted && push.problem != null) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(push.problem!)));
}
} else {
await push.disable();
}
if (mounted) setState(() {});
}
void _account() {
final push = widget.session.push;
final user = widget.session.user;
showModalBottomSheet<void>(
context: context,
showDragHandle: true,
builder: (context) => SafeArea(
child: StatefulBuilder(
builder: (context, setSheet) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.person_outline),
title: Text(user.name.isEmpty ? user.email : user.name),
subtitle: Text('${user.email}\n${_api.baseUrl}'),
isThreeLine: true,
),
if (push != null && push.supported)
SwitchListTile(
key: const Key('push-toggle'),
secondary: const Icon(Icons.notifications_outlined),
title: const Text('Push notifications'),
subtitle: Text(
push.problem ??
'Mentions, replies and shares, through UnifiedPush.',
),
value: push.enabled,
onChanged: (on) async {
await _togglePush(on);
setSheet(() {});
},
),
ListTile(
key: const Key('sign-out'),
leading: const Icon(Icons.logout),
title: const Text('Sign out'),
onTap: () {
Navigator.of(context).pop();
widget.onSignOut();
},
),
],
),
),
),
);
}
@override
Widget build(BuildContext context) {
final ws = _workspace;
final workspaces = _workspaces;
return Scaffold(
appBar: AppBar(
title: workspaces == null || workspaces.length < 2
? Text(ws?.name ?? 'Docwell')
: PopupMenuButton<Workspace>(
tooltip: 'Switch workspace',
onSelected: (w) {
setState(() => _workspace = w);
_load();
},
itemBuilder: (_) => [
for (final w in workspaces)
PopupMenuItem(value: w, child: Text(w.name)),
],
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(ws?.name ?? 'Docwell')),
const Icon(Icons.arrow_drop_down),
],
),
),
actions: [
if (ws != null)
IconButton(
tooltip: 'Search',
icon: const Icon(Icons.search),
onPressed: () =>
_open(SearchScreen(session: widget.session, workspace: ws)),
),
IconButton(
tooltip: 'Inbox',
icon: Badge(
isLabelVisible: _unread > 0,
label: Text('$_unread'),
child: const Icon(Icons.inbox_outlined),
),
onPressed: () =>
_open(NotificationsScreen(session: widget.session)),
),
IconButton(
tooltip: 'Account',
icon: const Icon(Icons.account_circle_outlined),
onPressed: _account,
),
],
),
body: RefreshIndicator(
onRefresh: _load,
child: ListView(
children: [
if (_offline) const OfflineBanner(),
if (_error != null)
ErrorTile(message: _error!, onRetry: _load)
else if (workspaces == null)
const Padding(
padding: EdgeInsets.all(32),
child: Center(child: CircularProgressIndicator()),
)
else if (ws == null)
const ListTile(
title: Text('No workspaces yet'),
subtitle: Text('Create one in the web app.'),
)
else ...[
if (_recent.isNotEmpty) ...[
const SectionTitle('Recent'),
for (final p in _recent.take(5))
ListTile(
leading: PageIcon(p.icon),
title: Text(p.title.isEmpty ? 'Untitled' : p.title),
subtitle: Text(p.spaceName),
onTap: () => _open(
PageScreen(session: widget.session, pageId: p.id),
),
),
],
const SectionTitle('Spaces'),
if (_spaces.isEmpty)
const ListTile(title: Text('No spaces you can open yet.')),
for (final s in _spaces)
ListTile(
key: Key('space-${s.id}'),
leading: s.icon.isEmpty
? const Icon(Icons.folder_outlined)
: Text(s.icon, style: const TextStyle(fontSize: 22)),
title: Text(s.name),
subtitle: s.description.isEmpty ? null : Text(s.description),
onTap: () =>
_open(SpaceScreen(session: widget.session, space: s)),
),
],
],
),
),
);
}
}
+209
View File
@@ -0,0 +1,209 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
import '../app.dart';
/// Signs in: the server's address, email and password, then an
/// authenticator code for accounts with two-step sign-in.
class LoginScreen extends StatefulWidget {
const LoginScreen({
super.key,
required this.server,
required this.apiFor,
required this.onSignedIn,
});
final String server;
final ApiFactory apiFor;
final Future<void> Function(DocwellApi api, User user) onSignedIn;
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
late final _server = TextEditingController(text: widget.server);
final _email = TextEditingController();
final _password = TextEditingController();
final _code = TextEditingController();
bool _busy = false;
String? _error;
DocwellApi? _api;
String _challenge = '';
static const _messages = {
'invalid_credentials': 'Wrong email or password.',
'account_disabled': 'This account is disabled.',
'invalid_code': 'That code is not right. Try the next one.',
'mfa_required':
'This account signs in with an emailed code. Use the web app for now.',
};
/// The address as typed, with https:// added when the scheme is missing.
String get _serverUrl {
final s = _server.text.trim();
return s.startsWith('http://') || s.startsWith('https://')
? s
: 'https://$s';
}
Future<void> _run(Future<void> Function() action) async {
setState(() {
_busy = true;
_error = null;
});
try {
await action();
} on DocwellApiException catch (e) {
if (e.code == 'totp_required' && e.challenge.isNotEmpty) {
setState(() => _challenge = e.challenge);
} else {
setState(
() => _error =
_messages[e.code] ??
(e.message.isNotEmpty ? e.message : 'Sign-in failed.'),
);
}
} on FormatException {
setState(() => _error = 'That server address is not valid.');
} catch (_) {
setState(
() => _error =
"Can't reach the server. Check the address and connection.",
);
} finally {
if (mounted) setState(() => _busy = false);
}
}
void _submit() => _run(() async {
final api = _api?.baseUrl == _serverUrl.replaceAll(RegExp(r'/+$'), '')
? _api!
: widget.apiFor(_serverUrl);
_api = api;
final user = await api.login(_email.text.trim(), _password.text);
await widget.onSignedIn(api, user);
});
void _verify() => _run(() async {
final api = _api!;
final user = await api.verifyTotp(_challenge, _code.text.trim());
await widget.onSignedIn(api, user);
});
@override
void dispose() {
_server.dispose();
_email.dispose();
_password.dispose();
_code.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final totp = _challenge.isNotEmpty;
return Scaffold(
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
totp ? 'Two-step sign-in' : 'Sign in to Docwell',
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: 24),
if (!totp) ...[
TextField(
key: const Key('server'),
controller: _server,
keyboardType: TextInputType.url,
autocorrect: false,
decoration: const InputDecoration(
labelText: 'Server address',
hintText: 'docs.example.com',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 12),
TextField(
key: const Key('email'),
controller: _email,
keyboardType: TextInputType.emailAddress,
autofillHints: const [AutofillHints.email],
decoration: const InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 12),
TextField(
key: const Key('password'),
controller: _password,
obscureText: true,
autofillHints: const [AutofillHints.password],
onSubmitted: (_) => _submit(),
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
),
] else ...[
const Text(
'Enter the 6-digit code from your authenticator app, or a recovery code.',
),
const SizedBox(height: 12),
TextField(
key: const Key('code'),
controller: _code,
autofocus: true,
autofillHints: const [AutofillHints.oneTimeCode],
onSubmitted: (_) => _verify(),
decoration: const InputDecoration(
labelText: 'Code',
border: OutlineInputBorder(),
),
),
],
if (_error != null) ...[
const SizedBox(height: 12),
Text(
_error!,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
const SizedBox(height: 20),
FilledButton(
onPressed: _busy ? null : (totp ? _verify : _submit),
child: Text(totp ? 'Verify' : 'Sign in'),
),
if (totp)
TextButton(
onPressed: _busy
? null
: () => setState(() {
_challenge = '';
_code.clear();
}),
child: const Text('Back'),
),
],
),
),
),
),
),
),
);
}
}
@@ -0,0 +1,131 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart' hide Notification, Page;
import '../api/docwell_api.dart';
import '../app.dart';
import 'page_screen.dart';
import 'widgets.dart';
String notificationText(Notification n) {
final who = n.actor == null
? 'Someone'
: (n.actor!.name.isEmpty ? n.actor!.email : n.actor!.name);
return switch (n.type) {
NotificationType.comment => '$who commented',
NotificationType.reply => '$who replied',
NotificationType.mention => '$who mentioned you',
NotificationType.share => '$who shared a page with you',
NotificationType.resolved => '$who resolved a thread',
};
}
/// The inbox: mentions, replies, comments and shares, newest first.
class NotificationsScreen extends StatefulWidget {
const NotificationsScreen({super.key, required this.session});
final AppSession session;
@override
State<NotificationsScreen> createState() => _NotificationsScreenState();
}
class _NotificationsScreenState extends State<NotificationsScreen> {
DocwellApi get _api => widget.session.api;
NotificationList? _list;
String? _error;
@override
void initState() {
super.initState();
_load();
}
Future<void> _load() async {
try {
final list = await _api.notifications();
if (mounted) {
setState(() {
_list = list;
_error = null;
});
}
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
Future<void> _open(Notification n) async {
if (!n.read) await _api.markRead(ids: [n.id]).catchError((_) {});
final page = n.page;
if (page == null || !mounted) return;
await Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => PageScreen(
session: widget.session,
pageId: page.id,
openComment: n.comment.isEmpty ? null : n.comment,
),
),
);
_load();
}
Future<void> _readAll() async {
await _api.markRead(all: true).catchError((_) {});
_load();
}
@override
Widget build(BuildContext context) {
final list = _list;
return Scaffold(
appBar: AppBar(
title: const Text('Inbox'),
actions: [
if ((list?.unread ?? 0) > 0)
TextButton(onPressed: _readAll, child: const Text('Mark all read')),
],
),
body: RefreshIndicator(
onRefresh: _load,
child: ListView(
children: [
if (_error != null)
ErrorTile(message: _error!, onRetry: _load)
else if (list == null)
const Padding(
padding: EdgeInsets.all(32),
child: Center(child: CircularProgressIndicator()),
)
else if (list.items.isEmpty)
const ListTile(title: Text("You're all caught up.")),
for (final n in list?.items ?? <Notification>[])
ListTile(
key: Key('notification-${n.id}'),
leading: Icon(
n.read
? Icons.notifications_none
: Icons.notifications_active,
color: n.read ? null : Theme.of(context).colorScheme.primary,
),
title: Text(
'${notificationText(n)} · ${(n.page?.title ?? '').isNotEmpty ? n.page!.title : 'Untitled'}',
style: TextStyle(fontWeight: n.read ? null : FontWeight.w600),
),
subtitle: Text(
[
n.excerpt,
shortDate(n.created),
].where((s) => s.isNotEmpty).join('\n'),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
onTap: () => _open(n),
),
],
),
),
);
}
}
+257
View File
@@ -0,0 +1,257 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';
import 'package:flutter/material.dart' hide Notification, Page;
import 'package:webview_flutter/webview_flutter.dart';
import '../api/docwell_api.dart';
import '../app.dart';
import '../editor/bridge.dart';
import '../editor/editor_screen.dart' show EditorToolbar, editorAsset;
import 'comments_screen.dart';
import 'widgets.dart';
/// A page in the shared editor (ADR-4). It opens read-only from the last
/// saved content, which is kept for reading offline; Edit joins the live
/// document so changes sync with everyone else on the page.
class PageScreen extends StatefulWidget {
const PageScreen({
super.key,
required this.session,
required this.pageId,
this.startEditing = false,
this.openComment,
});
final AppSession session;
final String pageId;
final bool startEditing;
/// Opens the comments on this thread (from a notification).
final String? openComment;
@override
State<PageScreen> createState() => _PageScreenState();
}
class _PageScreenState extends State<PageScreen> {
DocwellApi get _api => widget.session.api;
final _web = WebViewController();
late final EditorBridge _bridge = EditorBridge(evaluate: _web.runJavaScript);
StreamSubscription<String>? _links;
Page? _page;
Map<String, dynamic>? _content;
String? _error;
bool _offline = false;
bool _editing = false;
bool _connected = false;
bool get _canEdit {
final p = _page;
return p != null &&
!p.inTrash &&
!p.archived &&
p.role.canEdit &&
!_offline;
}
@override
void initState() {
super.initState();
_bridge.addListener(() {
if (mounted) setState(() {});
});
_links = _bridge.navigations.listen(_follow);
_web
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(Colors.transparent)
..addJavaScriptChannel(
'DocwellNative',
onMessageReceived: (m) => _bridge.handleMessage(m.message),
)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (_) async {
if (!mounted) return;
await _bridge.setTheme(
dark: Theme.of(context).brightness == Brightness.dark,
);
await _bridge.hello();
},
// The page is bundled; links open nowhere (page links come
// through the bridge as navigate messages).
onNavigationRequest: (req) => req.url.startsWith('file:')
? NavigationDecision.navigate
: NavigationDecision.prevent,
),
)
..loadFlutterAsset(editorAsset);
_load();
}
Future<void> _load() async {
try {
final page = await _api.page(widget.pageId);
var offline = _api.offline;
final content = await _api.content(widget.pageId);
offline |= _api.offline;
if (!offline) unawaited(_api.visit(widget.pageId).catchError((_) {}));
if (!mounted) return;
setState(() {
_page = page;
_content = content.content;
_offline = offline;
_error = null;
});
await _bridge.ready;
if (!_connected) {
await _bridge.setEditable(false);
await _bridge.setContent(_content);
}
if (widget.startEditing && _canEdit && !_editing) await _edit();
if (widget.openComment != null && mounted) _comments();
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
Future<void> _edit() async {
final token = _api.token;
if (token == null) return;
final user = widget.session.user;
if (!_connected) {
await _bridge.connect(
url: _api.collabUrl,
page: widget.pageId,
token: token,
userName: user.name.isEmpty ? user.email : user.name,
userColor: userColor(user.id),
);
_connected = true;
}
await _bridge.setEditable(true);
await _bridge.focus();
setState(() => _editing = true);
}
Future<void> _done() async {
await _bridge.setEditable(false);
setState(() => _editing = false);
}
void _follow(String route) {
final m = RegExp(r'^/p/([A-Za-z0-9_-]+)').firstMatch(route);
if (m == null) return;
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => PageScreen(session: widget.session, pageId: m[1]!),
),
);
}
void _comments() {
final page = _page;
if (page == null) return;
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => CommentsScreen(
session: widget.session,
page: page,
highlight: widget.openComment,
),
),
);
}
@override
void dispose() {
// Keep the offline copy current with what was just edited.
if (_connected) {
unawaited(_api.content(widget.pageId).then((_) {}, onError: (_) {}));
}
_links?.cancel();
_bridge.dispose();
super.dispose();
}
String? get _status => switch (_bridge.collabStatus) {
'offline' => 'Reconnecting…',
'denied' => "You can't edit this page any more.",
'connecting' => 'Connecting…',
_ => null,
};
@override
Widget build(BuildContext context) {
final page = _page;
final title = page == null
? ''
: '${page.icon.isEmpty ? '' : '${page.icon} '}${page.title.isEmpty ? 'Untitled' : page.title}';
return Scaffold(
appBar: AppBar(
title: Text(title, overflow: TextOverflow.ellipsis),
actions: [
if (page != null && !_offline)
IconButton(
tooltip: 'Comments',
icon: const Icon(Icons.mode_comment_outlined),
onPressed: _comments,
),
if (_editing)
TextButton(onPressed: _done, child: const Text('Done'))
else if (_canEdit)
IconButton(
key: const Key('edit'),
tooltip: 'Edit',
icon: const Icon(Icons.edit_outlined),
onPressed: _bridge.isReady ? _edit : null,
),
],
),
body: Column(
children: [
if (_offline) const OfflineBanner(),
if (page?.archived == true)
const MaterialBanner(
content: Text('This page is archived and read-only.'),
actions: [SizedBox.shrink()],
),
if (_editing && _status != null)
MaterialBanner(
content: Text(_status!),
actions: const [SizedBox.shrink()],
),
if (_bridge.error != null)
MaterialBanner(
content: Text(_bridge.error!),
actions: const [SizedBox.shrink()],
),
if (_error != null)
Expanded(
child: ErrorTile(message: _error!, onRetry: _load),
)
else
Expanded(
child: Stack(
children: [
WebViewWidget(controller: _web),
if (!_bridge.isReady || page == null)
const Center(child: CircularProgressIndicator())
// The live document replaces the saved copy once it has
// synced; until then the editor would look empty.
else if (_connected && _bridge.collabStatus != 'connected')
ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: const Center(child: CircularProgressIndicator()),
),
],
),
),
if (_editing) EditorToolbar(bridge: _bridge),
],
),
);
}
}
+126
View File
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
import '../app.dart';
import 'page_screen.dart';
import 'widgets.dart';
/// Searches the workspace's pages as you type.
class SearchScreen extends StatefulWidget {
const SearchScreen({
super.key,
required this.session,
required this.workspace,
});
final AppSession session;
final Workspace workspace;
@override
State<SearchScreen> createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
final _query = TextEditingController();
Timer? _debounce;
List<SearchHit> _hits = [];
String? _error;
bool _searching = false;
int _seq = 0;
void _changed(String q) {
_debounce?.cancel();
_debounce = Timer(const Duration(milliseconds: 250), () => _search(q));
}
Future<void> _search(String q) async {
final seq = ++_seq;
if (q.trim().isEmpty) {
setState(() => _hits = []);
return;
}
setState(() => _searching = true);
try {
final res = await widget.session.api.search(
widget.workspace.id,
q.trim(),
);
if (seq == _seq && mounted) {
setState(() {
_hits = res.items;
_error = null;
});
}
} catch (e) {
if (seq == _seq && mounted) setState(() => _error = describeError(e));
} finally {
if (seq == _seq && mounted) setState(() => _searching = false);
}
}
@override
void dispose() {
_debounce?.cancel();
_query.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: TextField(
key: const Key('search'),
controller: _query,
autofocus: true,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
hintText: 'Search ${widget.workspace.name}',
border: InputBorder.none,
),
onChanged: _changed,
onSubmitted: _search,
),
bottom: _searching
? const PreferredSize(
preferredSize: Size.fromHeight(2),
child: LinearProgressIndicator(minHeight: 2),
)
: null,
),
body: _error != null
? ErrorTile(message: _error!, onRetry: () => _search(_query.text))
: ListView(
children: [
if (_query.text.trim().isNotEmpty &&
_hits.isEmpty &&
!_searching)
const ListTile(title: Text('Nothing found.')),
for (final h in _hits)
ListTile(
leading: PageIcon(h.icon),
title: Text(h.title.isEmpty ? 'Untitled' : h.title),
subtitle: Text(
[
h.spaceName,
h.snippet,
].where((s) => s.isNotEmpty).join(' · '),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) =>
PageScreen(session: widget.session, pageId: h.id),
),
),
),
],
),
);
}
}
+202
View File
@@ -0,0 +1,202 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
import '../app.dart';
import '../share.dart';
import 'page_screen.dart';
import 'widgets.dart';
final _url = RegExp(r'https?://[^\s<>"]+');
/// The document for shared text: a paragraph per line, with web addresses
/// as links.
Map<String, dynamic> sharedDoc(String text) {
List<Map<String, dynamic>> inline(String line) {
final out = <Map<String, dynamic>>[];
var at = 0;
for (final m in _url.allMatches(line)) {
if (m.start > at) {
out.add({'type': 'text', 'text': line.substring(at, m.start)});
}
out.add({
'type': 'text',
'text': m[0],
'marks': [
{
'type': 'link',
'attrs': {'href': m[0]},
},
],
});
at = m.end;
}
if (at < line.length) out.add({'type': 'text', 'text': line.substring(at)});
return out;
}
return {
'type': 'doc',
'content': [
for (final line in text.trim().split(RegExp(r'\r?\n')))
line.trim().isEmpty
? {'type': 'paragraph'}
: {'type': 'paragraph', 'content': inline(line)},
],
};
}
/// A title for shared text: the sender's subject, else the first line.
String sharedTitle(SharedText s) {
if (s.subject.trim().isNotEmpty) return s.subject.trim();
final first = s.text.trim().split('\n').first.trim();
return first.length > 80 ? '${first.substring(0, 79)}…' : first;
}
/// "Save to Docwell": makes a page from text or a link shared by another app.
class ShareScreen extends StatefulWidget {
const ShareScreen({super.key, required this.session, required this.shared});
final AppSession session;
final SharedText shared;
@override
State<ShareScreen> createState() => _ShareScreenState();
}
class _ShareScreenState extends State<ShareScreen> {
DocwellApi get _api => widget.session.api;
late final _title = TextEditingController(text: sharedTitle(widget.shared));
List<(Workspace, Space)>? _targets;
(Workspace, Space)? _target;
String? _error;
bool _busy = false;
@override
void initState() {
super.initState();
_load();
}
/// Every space, in every workspace, the user can add pages to.
Future<void> _load() async {
try {
final targets = <(Workspace, Space)>[];
for (final ws in await _api.workspaces()) {
for (final s in await _api.spaces(ws.id)) {
if (s.role == SpaceCallerRole.admin ||
s.role == SpaceCallerRole.editor) {
targets.add((ws, s));
}
}
}
if (mounted) {
setState(() {
_targets = targets;
_target = targets.firstOrNull;
});
}
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
Future<void> _save() async {
final target = _target;
if (target == null) return;
setState(() => _busy = true);
try {
final page = await _api.createPage(
target.$2.id,
title: _title.text.trim(),
);
await _api.saveContent(page.id, sharedDoc(widget.shared.text));
if (!mounted) return;
Navigator.of(context).pushReplacement(
MaterialPageRoute<void>(
builder: (_) => PageScreen(session: widget.session, pageId: page.id),
),
);
} catch (e) {
if (mounted) {
setState(() {
_busy = false;
_error = describeError(e);
});
}
}
}
@override
void dispose() {
_title.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final targets = _targets;
return Scaffold(
appBar: AppBar(title: const Text('Save to Docwell')),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
TextField(
key: const Key('share-title'),
controller: _title,
decoration: const InputDecoration(
labelText: 'Page title',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
if (targets == null && _error == null)
const Center(child: CircularProgressIndicator())
else if (targets != null && targets.isEmpty)
const Text("There's no space you can add pages to.")
else if (targets != null)
DropdownButtonFormField<(Workspace, Space)>(
initialValue: _target,
decoration: const InputDecoration(
labelText: 'Space',
border: OutlineInputBorder(),
),
items: [
for (final t in targets)
DropdownMenuItem(
value: t,
child: Text(
'${t.$2.name} · ${t.$1.name}',
overflow: TextOverflow.ellipsis,
),
),
],
onChanged: (t) => setState(() => _target = t),
),
const SizedBox(height: 16),
Text('Text', style: Theme.of(context).textTheme.labelLarge),
const SizedBox(height: 4),
Text(
widget.shared.text,
maxLines: 12,
overflow: TextOverflow.ellipsis,
),
if (_error != null) ...[
const SizedBox(height: 12),
Text(
_error!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
const SizedBox(height: 20),
FilledButton(
key: const Key('share-save'),
onPressed: _busy || _target == null ? null : _save,
child: const Text('Save as a new page'),
),
],
),
);
}
}
+158
View File
@@ -0,0 +1,158 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
import '../app.dart';
import 'page_screen.dart';
import 'widgets.dart';
/// One page of the tree with how deep it sits.
typedef TreeRow = ({PageNode page, int depth});
/// The space's pages in tree order with their depth. The server lists them
/// depth-first; a page whose parent isn't listed sits at the top.
List<TreeRow> treeRows(List<PageNode> pages) {
final depth = <String, int>{};
return [
for (final p in pages)
(
page: p,
depth: depth[p.id] = p.parent.isEmpty ? 0 : (depth[p.parent] ?? -1) + 1,
),
];
}
/// A space's page tree. Branches start folded; tap the arrow to open them.
class SpaceScreen extends StatefulWidget {
const SpaceScreen({super.key, required this.session, required this.space});
final AppSession session;
final Space space;
@override
State<SpaceScreen> createState() => _SpaceScreenState();
}
class _SpaceScreenState extends State<SpaceScreen> {
List<PageNode>? _pages;
final _open = <String>{};
String? _error;
bool _offline = false;
bool get _canEdit =>
widget.space.role == SpaceCallerRole.admin ||
widget.space.role == SpaceCallerRole.editor;
@override
void initState() {
super.initState();
_load();
}
Future<void> _load() async {
final api = widget.session.api;
try {
final pages = await api.pages(widget.space.id);
if (mounted) {
setState(() {
_pages = pages;
_offline = api.offline;
_error = null;
});
}
} catch (e) {
if (mounted) setState(() => _error = describeError(e));
}
}
Future<void> _openPage(String id, {bool edit = false}) async {
await Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) =>
PageScreen(session: widget.session, pageId: id, startEditing: edit),
),
);
_load();
}
Future<void> _newPage() async {
try {
final p = await widget.session.api.createPage(widget.space.id);
await _openPage(p.id, edit: true);
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(describeError(e))));
}
}
}
@override
Widget build(BuildContext context) {
final pages = _pages;
final rows = pages == null ? <TreeRow>[] : treeRows(pages);
final hasChildren = {for (final p in pages ?? <PageNode>[]) p.parent};
// A row shows when every ancestor is open.
final visible = <TreeRow>[];
final shown = <String>{''};
for (final r in rows) {
if (shown.contains(r.page.parent) &&
(r.page.parent.isEmpty || _open.contains(r.page.parent))) {
visible.add(r);
shown.add(r.page.id);
}
}
return Scaffold(
appBar: AppBar(title: Text(widget.space.name)),
floatingActionButton: _canEdit && !_offline
? FloatingActionButton(
tooltip: 'New page',
onPressed: _newPage,
child: const Icon(Icons.add),
)
: null,
body: RefreshIndicator(
onRefresh: _load,
child: ListView(
children: [
if (_offline) const OfflineBanner(),
if (_error != null)
ErrorTile(message: _error!, onRetry: _load)
else if (pages == null)
const Padding(
padding: EdgeInsets.all(32),
child: Center(child: CircularProgressIndicator()),
)
else if (pages.isEmpty)
const ListTile(title: Text('No pages yet.')),
for (final r in visible)
ListTile(
key: Key('page-${r.page.id}'),
contentPadding: EdgeInsets.only(
left: 8.0 + r.depth * 20,
right: 16,
),
leading: hasChildren.contains(r.page.id)
? IconButton(
tooltip: _open.contains(r.page.id) ? 'Fold' : 'Unfold',
icon: Icon(
_open.contains(r.page.id)
? Icons.expand_more
: Icons.chevron_right,
),
onPressed: () => setState(() {
if (!_open.remove(r.page.id)) _open.add(r.page.id);
}),
)
: SizedBox(width: 48, child: PageIcon(r.page.icon)),
title: Text(r.page.title.isEmpty ? 'Untitled' : r.page.title),
onTap: () => _openPage(r.page.id),
),
],
),
),
);
}
}
+112
View File
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:io';
import 'package:flutter/material.dart';
import '../api/docwell_api.dart';
/// A short, human explanation of a failed request.
String describeError(Object e) {
if (e is DocwellApiException) {
if (e.status == 404) return 'Not found, or you no longer have access.';
if (e.status == 403) return "You don't have permission to do that.";
return e.message.isNotEmpty ? e.message : 'The server refused (${e.code}).';
}
if (e is SocketException || e is HttpException) {
return "Can't reach the server, and this hasn't been opened before.";
}
return "Can't reach the server.";
}
class OfflineBanner extends StatelessWidget {
const OfflineBanner({super.key});
@override
Widget build(BuildContext context) => MaterialBanner(
key: const Key('offline'),
leading: const Icon(Icons.cloud_off_outlined),
content: const Text('Offline: showing what was saved on this phone.'),
actions: const [SizedBox.shrink()],
);
}
class ErrorTile extends StatelessWidget {
const ErrorTile({super.key, required this.message, required this.onRetry});
final String message;
final VoidCallback onRetry;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Text(message, textAlign: TextAlign.center),
const SizedBox(height: 12),
FilledButton(onPressed: onRetry, child: const Text('Retry')),
],
),
);
}
class SectionTitle extends StatelessWidget {
const SectionTitle(this.text, {super.key});
final String text;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.fromLTRB(16, 20, 16, 4),
child: Text(
text.toUpperCase(),
style: Theme.of(context).textTheme.labelSmall?.copyWith(
letterSpacing: 0.8,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);
}
/// A page's emoji icon, or a generic page icon.
class PageIcon extends StatelessWidget {
const PageIcon(this.icon, {super.key});
final String icon;
@override
Widget build(BuildContext context) => SizedBox(
width: 28,
child: Center(
child: icon.isEmpty
? const Icon(Icons.description_outlined)
: Text(icon, style: const TextStyle(fontSize: 20)),
),
);
}
/// PocketBase dates look like "2026-10-30 21:05:00.000Z".
String shortDate(String s) {
final d = DateTime.tryParse(s.replaceFirst(' ', 'T'))?.toLocal();
if (d == null) return '';
final now = DateTime.now();
final hm =
'${d.hour.toString().padLeft(2, '0')}:${d.minute.toString().padLeft(2, '0')}';
if (d.year == now.year && d.month == now.month && d.day == now.day) {
return hm;
}
return '${d.day}.${d.month.toString().padLeft(2, '0')}.${d.year} $hm';
}
/// A stable colour for a user id, as the web editor's carets use.
String userColor(String id) {
const hues = [
'#2f7d6d', '#7c5cc4', '#c2571a', '#2f6fbf', //
'#b8327a', '#5f8a1f', '#a0761c', '#1f8a9a',
];
var h = 0;
for (final c in id.codeUnits) {
h = (h * 31 + c) & 0xffffffff;
}
return hues[h % hues.length];
}
+63
View File
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
/// The server address and sign-in token, kept between app starts. The token
/// lives in the Android Keystore / iOS Keychain through secure storage.
abstract class SessionStore {
Future<({String server, String token})?> load();
Future<void> save(String server, String token);
/// Signs out on this phone; the server address is kept for next time.
Future<void> clearToken();
Future<String?> lastServer();
}
class SecureSessionStore implements SessionStore {
SecureSessionStore([FlutterSecureStorage? storage])
: _storage = storage ?? const FlutterSecureStorage();
final FlutterSecureStorage _storage;
@override
Future<({String server, String token})?> load() async {
final server = await _storage.read(key: 'server');
final token = await _storage.read(key: 'token');
if (server == null || token == null) return null;
return (server: server, token: token);
}
@override
Future<void> save(String server, String token) async {
await _storage.write(key: 'server', value: server);
await _storage.write(key: 'token', value: token);
}
@override
Future<void> clearToken() => _storage.delete(key: 'token');
@override
Future<String?> lastServer() => _storage.read(key: 'server');
}
/// For tests.
class MemorySessionStore implements SessionStore {
String? server;
String? token;
@override
Future<({String server, String token})?> load() async =>
server == null || token == null ? null : (server: server!, token: token!);
@override
Future<void> save(String server, String token) async {
this.server = server;
this.token = token;
}
@override
Future<void> clearToken() async => token = null;
@override
Future<String?> lastServer() async => server;
}
+39
View File
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter/services.dart';
/// Text or a link shared to the app from another app.
class SharedText {
const SharedText(this.text, [this.subject = '']);
final String text;
/// The sender's title for it, e.g. a web page's title; often empty.
final String subject;
}
/// "Save to Docwell" from the Android share sheet (see MainActivity.kt).
class ShareReceiver {
static const _channel = MethodChannel('docwell/share');
/// Calls [onShare] for the share that started the app and every later one.
Future<void> listen(void Function(SharedText) onShare) async {
_channel.setMethodCallHandler((call) async {
if (call.method == 'shared') onShare(_read(call.arguments));
});
try {
final first = await _channel.invokeMethod<Object?>('takeShared');
if (first != null) onShare(_read(first));
} on MissingPluginException {
// Not on Android.
}
}
static SharedText _read(Object? raw) {
final m = (raw as Map).cast<String, Object?>();
return SharedText(
m['text'] as String? ?? '',
m['subject'] as String? ?? '',
);
}
}
+341
View File
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
url: "https://pub.dev"
source: hosted
version: "2.7.0"
async:
dependency: transitive
description:
@@ -33,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.2"
code_assets:
dependency: transitive
description:
name: code_assets
sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
collection:
dependency: transitive
description:
@@ -41,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: e3626ae6270383c9e3a549f34c9e4cd26c09ae6a9adaab2bf4737a00340efdc4
url: "https://pub.dev"
source: hosted
version: "3.0.8"
cupertino_icons:
dependency: "direct main"
description:
@@ -49,6 +73,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.9"
dbus:
dependency: transitive
description:
name: dbus
sha256: a48d5da28e89bd02196e80d81ed8d7954923d00a0f4a68cc20b575038f023383
url: "https://pub.dev"
source: hosted
version: "0.7.15"
fake_async:
dependency: transitive
description:
@@ -57,6 +89,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.3"
ffi:
dependency: transitive
description:
name: ffi
sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
ffi_leak_tracker:
dependency: transitive
description:
name: ffi_leak_tracker
sha256: "4093d4ef9ca06ffe2786e73bfb25e22aa92112b9bb4ec941f11e3e6b61489a97"
url: "https://pub.dev"
source: hosted
version: "0.1.2"
file:
dependency: transitive
description:
@@ -83,16 +131,125 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: fd5fc8966a8b34337ac182dc394f3506139b69d8138d4e9e174a13d6468adcd4
url: "https://pub.dev"
source: hosted
version: "22.3.3"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
sha256: "3b89a4bf095fa5f8a99beeabf982c5bd506c3ad25e7b9e61da945e994dc5b615"
url: "https://pub.dev"
source: hosted
version: "8.0.2"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
sha256: "43c3761d916c9bd3d5c7ebbc44d82f4990329840c0c5d62ad5260cc1b5d399bd"
url: "https://pub.dev"
source: hosted
version: "12.2.0"
flutter_local_notifications_web:
dependency: transitive
description:
name: flutter_local_notifications_web
sha256: "516afaf97a2d1e67a036c6617321b00d205d72f7a67b6eccf936cd565f985878"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_local_notifications_windows:
dependency: transitive
description:
name: flutter_local_notifications_windows
sha256: "6f43bdd03b171b7a90f22647506fea33e2bb12294b7c7c7a3d690e960a382945"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
flutter_secure_storage:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: d4e1fb6b2cb524868929e78dc0282fa000554b22060fb53789dc481c9fc95bb8
url: "https://pub.dev"
source: hosted
version: "11.2.0"
flutter_secure_storage_darwin:
dependency: transitive
description:
name: flutter_secure_storage_darwin
sha256: a031ceac9b070e62ef183cd7f7d1a8798ebde402d5049f0fe6eb3a51bd797a21
url: "https://pub.dev"
source: hosted
version: "0.4.3"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: caa75bd78f017422912e3a904933113b2428eb79f981ac37acd2dd2a700458ea
url: "https://pub.dev"
source: hosted
version: "3.0.3"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
name: flutter_secure_storage_platform_interface
sha256: "64951127f001f546891c86f414972bf49ef2c4c8a4c92c65f5790cc0c9100045"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
flutter_secure_storage_web:
dependency: transitive
description:
name: flutter_secure_storage_web
sha256: "073a62b3aeb866ab4ce795f960413948e51e5a42a9b0c8333b6daf5bb3208a1c"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
flutter_secure_storage_windows:
dependency: transitive
description:
name: flutter_secure_storage_windows
sha256: "471951813a97006d899db4948acc654a4f28c440083ea08178935ce20b173ec1"
url: "https://pub.dev"
source: hosted
version: "4.2.2"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: "218aeb56050c714f62a3182775320dfa04602b55074873e24e31bbd39bda96fb"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
hooks:
dependency: transitive
description:
name: hooks
sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
http:
dependency: "direct main"
description:
@@ -114,6 +271,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
jni:
dependency: transitive
description:
name: jni
sha256: d8df6dab6847855512fe44dd9032b0bbe34dda7bf7597e41d30750879779813f
url: "https://pub.dev"
source: hosted
version: "1.1.1"
jni_flutter:
dependency: transitive
description:
name: jni_flutter
sha256: "0dd33d67797560f66e961a6053882d4df54bd345bf063b8fe7ea133f7ad8b191"
url: "https://pub.dev"
source: hosted
version: "1.0.4+1"
jni_util:
dependency: transitive
description:
name: jni_util
sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
leak_tracker:
dependency: transitive
description:
@@ -146,6 +327,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.0"
logging:
dependency: transitive
description:
name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
url: "https://pub.dev"
source: hosted
version: "1.3.0"
matcher:
dependency: transitive
description:
@@ -170,6 +359,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
native_toolchain_c:
dependency: transitive
description:
name: native_toolchain_c
sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572"
url: "https://pub.dev"
source: hosted
version: "0.17.6"
objective_c:
dependency: transitive
description:
name: objective_c
sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52"
url: "https://pub.dev"
source: hosted
version: "9.3.0"
package_config:
dependency: transitive
description:
name: package_config
sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d
url: "https://pub.dev"
source: hosted
version: "3.0.0"
path:
dependency: transitive
description:
@@ -178,6 +391,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825
url: "https://pub.dev"
source: hosted
version: "2.1.6"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
url: "https://pub.dev"
source: hosted
version: "2.6.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
url: "https://pub.dev"
source: hosted
version: "7.0.2"
platform:
dependency: transitive
description:
@@ -202,6 +471,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.6"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
record_use:
dependency: transitive
description:
name: record_use
sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
sky_engine:
dependency: transitive
description: flutter
@@ -263,6 +548,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.11"
timezone:
dependency: transitive
description:
name: timezone
sha256: "9f4e5a1a0e4fef7dd3424842c0575db01bfb7a11730e8d55753fcd5c5c98767b"
url: "https://pub.dev"
source: hosted
version: "0.11.2"
typed_data:
dependency: transitive
description:
@@ -271,6 +564,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
unifiedpush_android:
dependency: "direct main"
description:
name: unifiedpush_android
sha256: a902e505e91c8e28b54b379bb27f255f66df409274a97af24d6719f12f0d13dc
url: "https://pub.dev"
source: hosted
version: "3.5.0"
unifiedpush_platform_interface:
dependency: "direct main"
description:
name: unifiedpush_platform_interface
sha256: "83372bc8d794b8b12ef6993b518d7be907dcfc2191bdf6de0ece5c4445d89880"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
unifiedpush_storage_interface:
dependency: transitive
description:
name: unifiedpush_storage_interface
sha256: b8d423a4695efc616aa21d8ab48fb5ef99d6288c68b56282b8faac1579ceabd9
url: "https://pub.dev"
source: hosted
version: "1.0.0"
vector_math:
dependency: transitive
description:
@@ -335,6 +652,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.26.2"
win32:
dependency: transitive
description:
name: win32
sha256: a0b93865d5644f11cf6a8c3f6db909f1ec168958b5805f6cc684adea957cd63d
url: "https://pub.dev"
source: hosted
version: "6.4.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
sha256: "67f0aff7be013d107995e9b75bf4e7f2c3ef2dfdb2c8e68024bba0a7fd5756a4"
url: "https://pub.dev"
source: hosted
version: "7.0.1"
yaml:
dependency: "direct dev"
description:
+5
View File
@@ -36,6 +36,11 @@ dependencies:
cupertino_icons: ^1.0.8
http: ^1.6.0
webview_flutter: ^4.14.1
flutter_secure_storage: ^11.2.0
path_provider: ^2.1.6
flutter_local_notifications: ^22.3.3
unifiedpush_android: ^3.5.0
unifiedpush_platform_interface: ^4.0.0
dev_dependencies:
flutter_test:
sdk: flutter
+280 -24
View File
@@ -1,10 +1,16 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:convert';
import 'dart:io';
import 'package:docwell_mobile/api/docwell_api.dart';
import 'package:docwell_mobile/main.dart';
import 'package:flutter/material.dart';
import 'package:docwell_mobile/app.dart';
import 'package:docwell_mobile/screens/comments_screen.dart';
import 'package:docwell_mobile/screens/share_screen.dart';
import 'package:docwell_mobile/screens/space_screen.dart';
import 'package:docwell_mobile/session.dart';
import 'package:docwell_mobile/share.dart';
import 'package:flutter/material.dart' hide Page;
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';
@@ -22,6 +28,41 @@ const ann = {
'role': 'admin',
'organization': 'o1',
'organizationName': 'Acme',
'totp': false,
};
const workspace = {
'id': 'w1',
'name': 'Acme Docs',
'slug': 'acme',
'organization': 'o1',
'organizationName': 'Acme',
'role': 'owner',
'created': '2026-10-01 09:00:00.000Z',
};
const space = {
'id': 's1',
'workspace': 'w1',
'name': 'Guides',
'slug': 'guides',
'icon': '',
'description': 'How we work',
'visibility': 'open',
'defaultRole': 'editor',
'role': 'editor',
'limited': false,
'created': '2026-10-01 09:00:00.000Z',
};
Map<String, dynamic> node(String id, String parent, String title) => {
'id': id,
'parent': parent,
'title': title,
'icon': '',
'position': 'a',
'restricted': false,
'updated': '2026-10-01 09:00:00.000Z',
};
http.Response json(int status, Object body) => http.Response(
@@ -30,26 +71,83 @@ http.Response json(int status, Object body) => http.Response(
headers: {'content-type': 'application/json'},
);
DocwellApi fakeApi() => DocwellApi(
'http://server.test/',
client: MockClient((req) async {
switch (req.url.path) {
case '/api/v1/auth/login':
/// A fake docwell-server. [down] makes every request fail like a dropped
/// connection.
class FakeServer {
bool down = false;
final comments = <Map<String, dynamic>>[];
MockClient get client => MockClient((req) async {
if (down) throw const SocketException('offline');
final authed = req.headers['Authorization'] == 'Bearer tok';
switch ((req.method, req.url.path)) {
case ('POST', '/api/v1/auth/login'):
final body = jsonDecode(req.body) as Map<String, dynamic>;
if (body['password'] == 'password123') {
return json(200, {'token': 'tok', 'user': ann});
}
if (body['password'] == 'two-step') {
return json(401, {'error': 'totp_required', 'challenge': 'ch1'});
}
return json(401, {'error': 'invalid_credentials'});
case '/api/v1/version':
return req.headers['Authorization'] == 'Bearer tok'
? json(200, {'name': 'docwell-server', 'version': '1.0.0'})
case ('POST', '/api/v1/auth/totp/verify'):
final body = jsonDecode(req.body) as Map<String, dynamic>;
return body['challenge'] == 'ch1' && body['code'] == '123456'
? json(200, {'token': 'tok', 'user': ann})
: json(400, {'error': 'invalid_code'});
case ('POST', '/api/v1/auth/refresh'):
return authed
? json(200, {'token': 'tok', 'user': ann})
: json(401, {'error': 'unauthorized'});
}
if (!authed) return json(401, {'error': 'unauthorized'});
switch ((req.method, req.url.path)) {
case ('GET', '/api/v1/workspaces'):
return json(200, [workspace]);
case ('GET', '/api/v1/workspaces/w1/spaces'):
return json(200, [space]);
case ('GET', '/api/v1/workspaces/w1/recent'):
return json(200, []);
case ('GET', '/api/v1/notifications'):
return json(200, {'items': [], 'unread': 2});
case ('GET', '/api/v1/spaces/s1/pages'):
return json(200, [
node('p1', '', 'Setup'),
node('p2', 'p1', 'Details'),
]);
case ('GET', '/api/v1/pages/p1/comments'):
return json(200, comments);
case ('POST', '/api/v1/pages/p1/comments'):
final body = jsonDecode(req.body) as Map<String, dynamic>;
final c = {
'id': 'c${comments.length + 1}',
'parent': body['parent'] ?? '',
'page': 'p1',
'author': {'id': 'u1', 'email': 'ann@docwell.test', 'name': 'Ann'},
'body': body['body'],
'quote': '',
'anchor': null,
'created': '2026-10-01 09:00:00.000Z',
'editedAt': '',
'resolvedAt': '',
'resolvedBy': null,
'reactions': [],
'canEdit': true,
'canDelete': true,
'canResolve': true,
};
comments.add(c);
return json(201, c);
}
return json(404, {'error': 'not_found'});
}),
);
});
DocwellApi api(String server, ResponseCache cache) =>
DocwellApi(server, client: client, cache: cache);
}
Future<void> signIn(WidgetTester tester, String password) async {
await tester.enterText(find.byKey(const Key('server')), 'server.test');
await tester.enterText(find.byKey(const Key('email')), 'ann@docwell.test');
await tester.enterText(find.byKey(const Key('password')), password);
await tester.tap(find.widgetWithText(FilledButton, 'Sign in'));
@@ -57,22 +155,180 @@ Future<void> signIn(WidgetTester tester, String password) async {
}
void main() {
testWidgets('signs in, shows the user, and signs out', (tester) async {
await tester.pumpWidget(DocwellApp(api: fakeApi()));
await signIn(tester, 'password123');
late FakeServer server;
late MemorySessionStore sessions;
late MemoryCache cache;
expect(find.text('Hello, Ann'), findsOneWidget);
expect(find.text('Admin · Acme'), findsOneWidget);
expect(find.text('Connected · v1.0.0'), findsOneWidget);
await tester.tap(find.text('Sign out'));
await tester.pumpAndSettle();
expect(find.text('Sign in to Docwell'), findsOneWidget);
setUp(() {
server = FakeServer();
sessions = MemorySessionStore();
cache = MemoryCache();
});
testWidgets('shows an error for a wrong password', (tester) async {
await tester.pumpWidget(DocwellApp(api: fakeApi()));
Widget app() =>
DocwellApp(sessions: sessions, apiFor: (url) => server.api(url, cache));
testWidgets('signs in, lists the workspace, and signs out', (tester) async {
await tester.pumpWidget(app());
await tester.pumpAndSettle();
await signIn(tester, 'wrong');
expect(find.text('Wrong email or password.'), findsOneWidget);
await signIn(tester, 'password123');
expect(find.text('Acme Docs'), findsOneWidget);
expect(find.text('Guides'), findsOneWidget);
expect(sessions.server, 'https://server.test');
expect(sessions.token, 'tok');
await tester.tap(find.byTooltip('Account'));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('sign-out')));
await tester.pumpAndSettle();
expect(find.text('Sign in to Docwell'), findsOneWidget);
expect(sessions.token, isNull);
});
testWidgets('asks for the authenticator code', (tester) async {
await tester.pumpWidget(app());
await tester.pumpAndSettle();
await signIn(tester, 'two-step');
expect(find.text('Two-step sign-in'), findsOneWidget);
await tester.enterText(find.byKey(const Key('code')), '123456');
await tester.tap(find.widgetWithText(FilledButton, 'Verify'));
await tester.pumpAndSettle();
expect(find.text('Guides'), findsOneWidget);
});
testWidgets('starts offline from the saved session and cache', (
tester,
) async {
// A first, online start fills the cache.
sessions
..server = 'https://server.test'
..token = 'tok';
await tester.pumpWidget(app());
await tester.pumpAndSettle();
expect(find.text('Guides'), findsOneWidget);
// Then the connection drops and the app starts again.
server.down = true;
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(app());
await tester.pumpAndSettle();
expect(find.byKey(const Key('offline')), findsOneWidget);
expect(find.text('Guides'), findsOneWidget);
// A dropped connection does not sign out.
expect(sessions.token, 'tok');
});
testWidgets('a rejected token signs out', (tester) async {
sessions
..server = 'https://server.test'
..token = 'expired';
await tester.pumpWidget(app());
await tester.pumpAndSettle();
expect(find.text('Sign in to Docwell'), findsOneWidget);
expect(sessions.token, isNull);
});
testWidgets('shows the page tree, folded', (tester) async {
final api = server.api('https://server.test', cache)..token = 'tok';
final session = AppSession(api: api, user: User.fromJson(ann));
await tester.pumpWidget(
MaterialApp(
home: SpaceScreen(session: session, space: Space.fromJson(space)),
),
);
await tester.pumpAndSettle();
expect(find.text('Setup'), findsOneWidget);
expect(find.text('Details'), findsNothing);
await tester.tap(find.byTooltip('Unfold'));
await tester.pumpAndSettle();
expect(find.text('Details'), findsOneWidget);
expect(find.byTooltip('New page'), findsOneWidget);
});
testWidgets('adds a comment and a reply', (tester) async {
final api = server.api('https://server.test', cache)..token = 'tok';
final session = AppSession(api: api, user: User.fromJson(ann));
final page = Page.fromJson({
'id': 'p1',
'workspace': 'w1',
'space': 's1',
'parent': '',
'title': 'Setup',
'icon': '',
'created': '',
'updated': '',
'deletedAt': '',
'inTrash': false,
'archivedAt': '',
'archived': false,
'ancestors': [],
'role': 'editor',
'restricted': false,
'isTemplate': false,
'favorite': false,
});
await tester.pumpWidget(
MaterialApp(
home: CommentsScreen(session: session, page: page),
),
);
await tester.pumpAndSettle();
expect(find.text('No comments yet.'), findsOneWidget);
await tester.enterText(find.byKey(const Key('comment-text')), 'Looks good');
await tester.tap(find.byKey(const Key('comment-send')));
await tester.pumpAndSettle();
expect(find.text('Looks good'), findsOneWidget);
await tester.tap(find.text('Reply'));
await tester.pumpAndSettle();
await tester.enterText(find.byKey(const Key('comment-text')), 'Thanks');
await tester.tap(find.byKey(const Key('comment-send')));
await tester.pumpAndSettle();
expect(find.text('Thanks'), findsOneWidget);
expect(server.comments.last['parent'], 'c1');
});
test('tree rows get their depth', () {
final rows = treeRows([
PageNode.fromJson(node('a', '', 'A')),
PageNode.fromJson(node('b', 'a', 'B')),
PageNode.fromJson(node('c', 'b', 'C')),
PageNode.fromJson(node('d', '', 'D')),
]);
expect(rows.map((r) => r.depth), [0, 1, 2, 0]);
});
test('shared text becomes paragraphs with links', () {
final doc = sharedDoc('Read this\nhttps://example.com/a later');
final paras = doc['content'] as List;
expect(paras, hasLength(2));
final second = (paras[1] as Map)['content'] as List;
expect((second[0] as Map)['marks'], isNotNull);
expect((second[1] as Map)['text'], ' later');
expect(sharedTitle(const SharedText('first line\nsecond')), 'first line');
expect(sharedTitle(const SharedText('x', 'Article')), 'Article');
});
test(
'reads fall back to the cache only when the server is unreachable',
() async {
final api = server.api('https://server.test', cache)..token = 'tok';
expect((await api.workspaces()).single.name, 'Acme Docs');
expect(api.offline, isFalse);
server.down = true;
expect((await api.workspaces()).single.name, 'Acme Docs');
expect(api.offline, isTrue);
// Nothing cached: the error comes through.
await expectLater(api.pages('s1'), throwsA(isA<SocketException>()));
server.down = false;
// A refusal is never hidden behind the cache.
api.token = 'other';
await expectLater(api.workspaces(), throwsA(isA<DocwellApiException>()));
},
);
}
+6
View File
@@ -26,6 +26,7 @@ import (
"docwell/server/internal/instance"
"docwell/server/internal/jobs"
"docwell/server/internal/mail"
"docwell/server/internal/push"
"docwell/server/internal/search"
"docwell/server/internal/settings"
"docwell/server/internal/store/pocketbase"
@@ -108,6 +109,10 @@ func run(log *slog.Logger) error {
dirSvc.UseSearch(index)
dirSvc.UseWebhooks(hooks)
go hooks.Run(indexCtx)
// Phones get pushes through UnifiedPush; endpoints follow the webhook address rules.
pushSvc := push.New(db, log, push.Options{AllowLocal: cfg.WebhooksAllowLocal})
dirSvc.UsePush(pushSvc)
go pushSvc.Run(indexCtx)
reg.Register("webhooks.prune", "Deletes webhook deliveries older than 30 days", 24*time.Hour, hooks.Prune)
go reg.Every(indexCtx, "webhooks.prune", 24*time.Hour)
if days := cfg.AuditRetentionDays; days > 0 {
@@ -139,6 +144,7 @@ func run(log *slog.Logger) error {
Collab: hub,
Audit: auditLog,
Previews: unfurl.New(),
Push: pushSvc,
Admin: admin.Handler("/admin"),
Log: log,
}),
+23
View File
@@ -1137,6 +1137,13 @@ type PublicSettings struct {
Signup bool `json:"signup"`
}
// PushDevice defines model for PushDevice.
type PushDevice struct {
Created string `json:"created"`
Id string `json:"id"`
Name string `json:"name"`
}
// Reaction defines model for Reaction.
type Reaction struct {
Count int `json:"count"`
@@ -1587,6 +1594,19 @@ type PreviewLinkParams struct {
Url string `form:"url" json:"url"`
}
// RegisterDeviceJSONBody defines parameters for RegisterDevice.
type RegisterDeviceJSONBody struct {
// Auth The app's 16-byte auth secret
Auth string `json:"auth"`
Endpoint string `json:"endpoint"`
// Name e.g. the phone's model
Name *string `json:"name,omitempty"`
// P256dh The app's P-256 public key
P256dh string `json:"p256dh"`
}
// CreateApiTokenJSONBody defines parameters for CreateApiToken.
type CreateApiTokenJSONBody struct {
// ExpiresDays 0 never expires
@@ -1867,6 +1887,9 @@ type AddGroupMemberJSONRequestBody = EmailRequest
// CreateInviteJSONRequestBody defines body for CreateInvite for application/json ContentType.
type CreateInviteJSONRequestBody = CreateInviteRequest
// RegisterDeviceJSONRequestBody defines body for RegisterDevice for application/json ContentType.
type RegisterDeviceJSONRequestBody RegisterDeviceJSONBody
// CreateApiTokenJSONRequestBody defines body for CreateApiToken for application/json ContentType.
type CreateApiTokenJSONRequestBody CreateApiTokenJSONBody
+1
View File
@@ -32,6 +32,7 @@ type Service struct {
search Searcher
publicURL string
hooks WebhookSender
push Pusher
}
func New(pb *pocketbase.Client, forget func(userID string), docs Docs) *Service {
+53 -1
View File
@@ -15,6 +15,7 @@ import (
"docwell/server/internal/access"
"docwell/server/internal/apperr"
"docwell/server/internal/mail"
"docwell/server/internal/push"
"docwell/server/internal/store/pocketbase"
)
@@ -146,8 +147,55 @@ func excerpt(s string) string {
return s
}
// Pusher sends a notification to a person's phones (package push).
type Pusher interface {
Notify(user string, m push.Message)
}
// UsePush turns on push notifications to phones.
func (s *Service) UsePush(p Pusher) { s.push = p }
// pushMessage is the phone notification for one stored notification.
func (s *Service) pushMessage(ctx context.Context, e event, kind string) push.Message {
who := "Someone"
if e.actor != "" {
if u, err := s.getUser(ctx, e.actor); err == nil {
who = u.Name
if who == "" {
who = u.Email
}
}
}
title := strings.TrimSpace(e.page.Icon + " " + e.page.Title)
if strings.TrimSpace(e.page.Title) == "" {
title = strings.TrimSpace(e.page.Icon + " Untitled")
}
var body string
switch kind {
case NotifyComment:
body = who + " commented"
case NotifyReply:
body = who + " replied"
case NotifyMention:
body = who + " mentioned you"
case NotifyShare:
body = who + " shared this page with you"
case NotifyResolved:
body = who + " resolved a thread"
}
if x := excerpt(e.excerpt); x != "" && kind != NotifyShare {
body += ": " + x
}
route := "/p/" + e.page.ID
if e.comment != "" {
route += "?comment=" + url.QueryEscape(e.comment)
}
return push.Message{Title: title, Body: body, Route: route}
}
// send stores the event's notifications, for recipients who can still open
// the page (best effort: a failure only loses notifications).
// the page, and pushes them to their phones (best effort: a failure only
// loses notifications).
func (s *Service) send(ctx context.Context, e event) {
for userID, kind := range e.to {
if !validID(userID) {
@@ -171,6 +219,10 @@ func (s *Service) send(ctx context.Context, e event) {
}
if _, err := pocketbase.Create[struct{}](ctx, s.pb, "notifications", body); err != nil {
slog.Default().Warn("notify: create", "user", userID, "err", err)
continue
}
if s.push != nil {
s.push.Notify(userID, s.pushMessage(ctx, e, kind))
}
}
}
+2
View File
@@ -67,6 +67,7 @@ type api struct {
instance InstanceService
collab CollabHub
previews LinkPreviewer
push PushService
log *slog.Logger
}
@@ -215,6 +216,7 @@ func (a *api) routes(mux *routeMux) {
a.shareRoutes(mux)
a.permissionRoutes(mux)
a.linkRoutes(mux)
a.pushRoutes(mux)
a.securityRoutes(mux, a.dir)
a.webhookRoutes(mux)
a.commentRoutes(mux)
+19 -1
View File
@@ -45,7 +45,15 @@ func (a *api) collabRoute(mux *routeMux, origins []string) {
writeJSON(w, http.StatusNotFound, map[string]string{"error": "not_found"})
return
}
conn, err := websocket.Accept(w, r, &websocket.AcceptOptions{OriginPatterns: patterns})
opts := &websocket.AcceptOptions{OriginPatterns: patterns}
// The apps' editors have origins no server can list: the mobile
// WebView's bundled page sends "null", the desktop app wails://.
// Signing in takes the token as the first message (no cookies), so
// another site's page can't ride on someone's session either way.
if appOrigin(r.Header.Get("Origin")) {
opts.InsecureSkipVerify = true
}
conn, err := websocket.Accept(w, r, opts)
if err != nil {
return
}
@@ -176,3 +184,13 @@ func (p *wsPeer) write(ctx context.Context, conn *websocket.Conn) {
}
}
}
// appOrigin reports whether origin is one of Docwell's own apps: the mobile
// editor page (a local file, "null") or the desktop app (Wails).
func appOrigin(origin string) bool {
if origin == "null" {
return true
}
u, err := url.Parse(origin)
return err == nil && (u.Scheme == "wails" || u.Hostname() == "wails.localhost")
}
+50
View File
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package httpapi
import (
"context"
"net/http"
"docwell/server/internal/apperr"
"docwell/server/internal/push"
)
// PushService registers the caller's phones for push notifications.
type PushService interface {
Register(ctx context.Context, user, endpoint, p256dh, auth, name string) (push.Device, error)
List(ctx context.Context, user string) ([]push.Device, error)
Remove(ctx context.Context, user, id string) error
}
var errPushOff = apperr.NotFound("push notifications are off on this server")
func (a *api) pushRoutes(mux *routeMux) {
mux.HandleFunc("GET /api/v1/me/devices", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
if a.push == nil {
a.respond(w, nil, errPushOff)
return
}
list, err := a.push.List(r.Context(), caller(r).ID)
a.respond(w, list, err)
}))
mux.HandleFunc("POST /api/v1/me/devices", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
if a.push == nil {
a.respond(w, nil, errPushOff)
return
}
var in struct{ Endpoint, P256dh, Auth, Name string }
if !a.decode(w, r, &in) {
return
}
d, err := a.push.Register(r.Context(), caller(r).ID, in.Endpoint, in.P256dh, in.Auth, in.Name)
a.respondStatus(w, http.StatusCreated, d, err)
}))
mux.HandleFunc("DELETE /api/v1/me/devices/{id}", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
if a.push == nil {
a.respond(w, nil, errPushOff)
return
}
a.respondNoContent(w, a.push.Remove(r.Context(), caller(r).ID, r.PathValue("id")))
}))
}
+5
View File
@@ -34,6 +34,8 @@ type Deps struct {
MaxUpload int64
// Collab serves /collab; nil disables live editing.
Collab CollabHub
// Push registers phones for push notifications; nil turns them off.
Push PushService
// Previews reads pages for link cards; nil turns link previews off.
Previews LinkPreviewer
// Audit records changes and serves the audit log; nil turns both off.
@@ -71,6 +73,9 @@ func newMux(d Deps) *routeMux {
if d.Previews != nil {
a.previews = d.Previews
}
if d.Push != nil {
a.push = d.Push
}
a.routes(mux)
a.fileRoutes(mux, max(d.MaxUpload, 1<<20))
a.collabRoute(mux, d.CORSOrigins)
+13
View File
@@ -72,3 +72,16 @@ func TestCORS(t *testing.T) {
t.Error("unknown origin must not be allowed")
}
}
func TestAppOrigin(t *testing.T) {
for _, o := range []string{"null", "wails://wails.localhost", "http://wails.localhost:34115"} {
if !appOrigin(o) {
t.Errorf("%q refused", o)
}
}
for _, o := range []string{"", "https://evil.example", "http://wails.localhost.evil.example"} {
if appOrigin(o) {
t.Errorf("%q accepted", o)
}
}
}
+238
View File
@@ -0,0 +1,238 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// Package push sends notifications to people's phones through UnifiedPush:
// the Docwell app registers the endpoint its distributor (ntfy, NextPush, …)
// gave it, and the server POSTs a small JSON message there. No Google or
// Apple account is involved, which suits self-hosting.
package push
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"log/slog"
"net"
"net/http"
"net/url"
"regexp"
"strings"
"time"
"docwell/server/internal/apperr"
"docwell/server/internal/store/pocketbase"
"docwell/server/internal/webhooks"
)
// maxDevices caps the phones one person registers.
const maxDevices = 10
// Message is what a phone receives. UnifiedPush caps messages at 4 KB.
type Message struct {
Title string `json:"title"`
Body string `json:"body"`
// Route is the app route to open, e.g. "/p/<id>?comment=<id>".
Route string `json:"route"`
}
// Device is one registered phone.
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
Created string `json:"created"`
}
type deviceRecord struct {
ID string `json:"id"`
User string `json:"user"`
Endpoint string `json:"endpoint"`
P256dh string `json:"p256dh"`
Auth string `json:"auth"`
Name string `json:"name"`
Created string `json:"created"`
}
func (r deviceRecord) view() Device { return Device{ID: r.ID, Name: r.Name, Created: r.Created} }
type job struct {
user string
msg Message
}
type Options struct {
// AllowLocal lets endpoints be on loopback and link-local addresses
// (development). Private networks are always allowed: a self-hosted
// distributor usually lives there.
AllowLocal bool
}
type Service struct {
pb *pocketbase.Client
log *slog.Logger
client *http.Client
queue chan job
}
func New(pb *pocketbase.Client, log *slog.Logger, opts Options) *Service {
dialer := &net.Dialer{Timeout: 10 * time.Second, Control: webhooks.Guard(opts.AllowLocal)}
return &Service{
pb: pb, log: log, queue: make(chan job, 1000),
client: &http.Client{
Timeout: 10 * time.Second,
Transport: &http.Transport{DialContext: dialer.DialContext, Proxy: nil},
CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse },
},
}
}
// Run delivers queued messages until ctx ends.
func (s *Service) Run(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case j := <-s.queue:
s.deliver(ctx, j)
}
}
}
// Notify queues a message for every phone of user. It never blocks: when the
// queue is full the message is dropped (the notification is still in the inbox).
func (s *Service) Notify(user string, m Message) {
select {
case s.queue <- job{user: user, msg: m}:
default:
s.log.Warn("push: queue full, message dropped", "user", user)
}
}
func (s *Service) devices(ctx context.Context, user string) ([]deviceRecord, error) {
res, err := pocketbase.List[deviceRecord](ctx, s.pb, "push_devices", pocketbase.ListOptions{
PerPage: maxDevices * 2, Filter: fmt.Sprintf("user = '%s'", user), Sort: "-created",
})
return res.Items, err
}
func (s *Service) deliver(ctx context.Context, j job) {
devices, err := s.devices(ctx, j.user)
if err != nil {
s.log.Warn("push: list devices", "user", j.user, "err", err)
return
}
plain, _ := json.Marshal(j.msg)
for _, d := range devices {
body, err := encrypt(plain, d.P256dh, d.Auth)
if err != nil {
s.log.Warn("push: encrypt", "device", d.ID, "err", err)
continue
}
code, err := s.post(ctx, d.Endpoint, body)
switch {
case err != nil:
s.log.Warn("push: send", "device", d.ID, "err", err)
case code == http.StatusNotFound || code == http.StatusGone:
// The app was uninstalled or the distributor dropped the endpoint.
_ = s.pb.Delete(ctx, "push_devices", d.ID)
case code >= 300:
s.log.Warn("push: endpoint refused", "device", d.ID, "status", code)
}
}
}
func (s *Service) post(ctx context.Context, endpoint string, body []byte) (int, error) {
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(body))
if err != nil {
return 0, err
}
req.Header.Set("Content-Type", "application/octet-stream")
req.Header.Set("Content-Encoding", "aes128gcm")
// RFC 8030 urgency and lifetime, which ntfy and other distributors honour.
req.Header.Set("Urgency", "normal")
req.Header.Set("TTL", "86400")
res, err := s.client.Do(req)
if err != nil {
return 0, err
}
_, _ = io.Copy(io.Discard, io.LimitReader(res.Body, 64<<10))
_ = res.Body.Close()
return res.StatusCode, nil
}
// cleanEndpoint validates a distributor's endpoint.
func cleanEndpoint(raw string) (string, error) {
raw = strings.TrimSpace(raw)
u, err := url.Parse(raw)
if err != nil || (u.Scheme != "https" && u.Scheme != "http") || u.Host == "" || len(raw) > 1000 || u.User != nil {
return "", apperr.InvalidFields(map[string]string{"endpoint": "Endpoint must be an http(s) address."})
}
return u.String(), nil
}
// Register saves a phone's endpoint and Web Push keys for user.
// Registering an endpoint again (the app does on every start) updates it
// instead of adding a copy.
func (s *Service) Register(ctx context.Context, user, endpoint, p256dh, auth, name string) (Device, error) {
endpoint, err := cleanEndpoint(endpoint)
if err != nil {
return Device{}, err
}
if err := checkKeys(p256dh, auth); err != nil {
return Device{}, apperr.InvalidFields(map[string]string{"p256dh": "Send the endpoint's Web Push keys (" + err.Error() + ")."})
}
keys := map[string]any{"user": user, "name": name, "p256dh": p256dh, "auth": auth}
name = strings.TrimSpace(name)
if r := []rune(name); len(r) > 100 {
name = string(r[:100])
}
res, err := pocketbase.List[deviceRecord](ctx, s.pb, "push_devices", pocketbase.ListOptions{
PerPage: 1, Filter: fmt.Sprintf("endpoint = '%s'", strings.ReplaceAll(endpoint, "'", "")),
})
if err != nil {
return Device{}, err
}
if len(res.Items) > 0 {
// Endpoints are secret to the phone; one moving to another account
// means the same phone signed in as someone else.
rec, err := pocketbase.Update[deviceRecord](ctx, s.pb, "push_devices", res.Items[0].ID, keys)
return rec.view(), err
}
existing, err := s.devices(ctx, user)
if err != nil {
return Device{}, err
}
if len(existing) >= maxDevices {
// The oldest phone makes room; people replace phones more than they add them.
_ = s.pb.Delete(ctx, "push_devices", existing[len(existing)-1].ID)
}
keys["endpoint"] = endpoint
rec, err := pocketbase.Create[deviceRecord](ctx, s.pb, "push_devices", keys)
return rec.view(), err
}
// List returns user's phones, newest first.
func (s *Service) List(ctx context.Context, user string) ([]Device, error) {
recs, err := s.devices(ctx, user)
out := make([]Device, 0, len(recs))
for _, r := range recs {
out = append(out, r.view())
}
return out, err
}
var deviceID = regexp.MustCompile(`^[A-Za-z0-9]{1,32}$`)
// Remove forgets one of user's phones (signing out on it).
func (s *Service) Remove(ctx context.Context, user, id string) error {
if !deviceID.MatchString(id) {
return apperr.NotFound("device not found")
}
rec, err := pocketbase.Get[deviceRecord](ctx, s.pb, "push_devices", id)
if err != nil || rec.User != user {
return apperr.NotFound("device not found")
}
return s.pb.Delete(ctx, "push_devices", id)
}
+143
View File
@@ -0,0 +1,143 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package push
import (
"bytes"
"context"
"crypto/aes"
"crypto/cipher"
"crypto/ecdh"
"crypto/hkdf"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"encoding/json"
"io"
"log/slog"
"net/http"
"net/http/httptest"
"testing"
)
func TestCleanEndpoint(t *testing.T) {
for _, ok := range []string{"https://ntfy.sh/upAbC123?up=1", " http://ntfy.lan/topic "} {
if _, err := cleanEndpoint(ok); err != nil {
t.Errorf("%q refused: %v", ok, err)
}
}
for _, bad := range []string{"", "ftp://x/y", "https://user:pw@ntfy.sh/x", "javascript:alert(1)", "https://"} {
if _, err := cleanEndpoint(bad); err == nil {
t.Errorf("%q accepted", bad)
}
}
}
// phone is the app's side: its key pair and auth secret.
type phone struct {
key *ecdh.PrivateKey
auth []byte
}
func newPhone(t *testing.T) phone {
k, err := ecdh.P256().GenerateKey(rand.Reader)
if err != nil {
t.Fatal(err)
}
auth := make([]byte, 16)
_, _ = rand.Read(auth)
return phone{key: k, auth: auth}
}
func (p phone) keys() (string, string) {
return base64.RawURLEncoding.EncodeToString(p.key.PublicKey().Bytes()), base64.RawURLEncoding.EncodeToString(p.auth)
}
// decrypt is RFC 8291 from the receiving end, written out independently.
func (p phone) decrypt(t *testing.T, body []byte) []byte {
t.Helper()
salt, rs, idlen := body[:16], binary.BigEndian.Uint32(body[16:20]), int(body[20])
asPub := body[21 : 21+idlen]
if rs != recordSize {
t.Fatalf("record size %d", rs)
}
as, err := ecdh.P256().NewPublicKey(asPub)
if err != nil {
t.Fatal(err)
}
shared, _ := p.key.ECDH(as)
info := append(append([]byte("WebPush: info\x00"), p.key.PublicKey().Bytes()...), asPub...)
ikm, _ := hkdf.Key(sha256.New, shared, p.auth, string(info), 32)
cek, _ := hkdf.Key(sha256.New, ikm, salt, "Content-Encoding: aes128gcm\x00", 16)
nonce, _ := hkdf.Key(sha256.New, ikm, salt, "Content-Encoding: nonce\x00", 12)
block, _ := aes.NewCipher(cek)
gcm, _ := cipher.NewGCM(block)
plain, err := gcm.Open(nil, nonce, body[21+idlen:], nil)
if err != nil {
t.Fatalf("decrypt: %v", err)
}
if plain[len(plain)-1] != 2 {
t.Fatal("missing last-record delimiter")
}
return plain[:len(plain)-1]
}
func TestEncrypt(t *testing.T) {
ph := newPhone(t)
pub, auth := ph.keys()
if err := checkKeys(pub, auth); err != nil {
t.Fatal(err)
}
msg := []byte(`{"title":"Setup","body":"Ann mentioned you","route":"/p/abc"}`)
body, err := encrypt(msg, pub, auth)
if err != nil {
t.Fatal(err)
}
if bytes.Contains(body, []byte("Ann")) {
t.Fatal("plaintext visible")
}
if got := ph.decrypt(t, body); !bytes.Equal(got, msg) {
t.Fatalf("got %s", got)
}
if err := checkKeys("bm90IGEga2V5", auth); err == nil {
t.Fatal("bad public key accepted")
}
if err := checkKeys(pub, "c2hvcnQ"); err == nil {
t.Fatal("short auth secret accepted")
}
}
func TestPost(t *testing.T) {
var got []byte
var headers http.Header
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
headers = r.Header
got, _ = io.ReadAll(r.Body)
w.WriteHeader(http.StatusCreated)
}))
defer srv.Close()
ph := newPhone(t)
pub, auth := ph.keys()
s := New(nil, slog.New(slog.NewTextHandler(io.Discard, nil)), Options{AllowLocal: true})
plain, _ := json.Marshal(Message{Title: "Setup", Body: "Ann mentioned you", Route: "/p/abc"})
body, _ := encrypt(plain, pub, auth)
code, err := s.post(context.Background(), srv.URL, body)
if err != nil || code != http.StatusCreated {
t.Fatalf("post = %d, %v", code, err)
}
if headers.Get("Content-Encoding") != "aes128gcm" || headers.Get("TTL") == "" {
t.Fatalf("headers %v", headers)
}
var m Message
if err := json.Unmarshal(ph.decrypt(t, got), &m); err != nil || m.Route != "/p/abc" {
t.Fatalf("got %+v, %v", m, err)
}
// Without AllowLocal, loopback endpoints are refused.
strict := New(nil, slog.New(slog.NewTextHandler(io.Discard, nil)), Options{})
if _, err := strict.post(context.Background(), srv.URL, body); err == nil {
t.Fatal("loopback endpoint reached")
}
}
+113
View File
@@ -0,0 +1,113 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package push
import (
"crypto/aes"
"crypto/cipher"
"crypto/ecdh"
"crypto/hkdf"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"errors"
)
// Web Push message encryption (RFC 8291, "aes128gcm" from RFC 8188), which
// UnifiedPush uses: only the app, which holds the private key, can read a
// message, so the distributor's server (ntfy.sh, …) sees nothing but its
// size. The app drops messages that don't decrypt, so knowing an endpoint
// is not enough to send someone a fake notification.
// recordSize is the RFC 8188 record size; a message fits in one record.
const recordSize = 4096
// decodeKey reads a base64url key (padded or not).
func decodeKey(s string) ([]byte, error) {
if b, err := base64.RawURLEncoding.DecodeString(s); err == nil {
return b, nil
}
return base64.URLEncoding.DecodeString(s)
}
// checkKeys validates a phone's public key (uncompressed P-256) and auth secret.
func checkKeys(p256dh, auth string) error {
pub, err := decodeKey(p256dh)
if err != nil {
return errors.New("bad public key")
}
if _, err := ecdh.P256().NewPublicKey(pub); err != nil {
return errors.New("bad public key")
}
secret, err := decodeKey(auth)
if err != nil || len(secret) != 16 {
return errors.New("bad auth secret")
}
return nil
}
// encrypt seals plaintext for the phone with public key p256dh and auth
// secret auth, returning the aes128gcm body.
func encrypt(plaintext []byte, p256dh, auth string) ([]byte, error) {
uaPub, err := decodeKey(p256dh)
if err != nil {
return nil, err
}
secret, err := decodeKey(auth)
if err != nil {
return nil, err
}
ua, err := ecdh.P256().NewPublicKey(uaPub)
if err != nil {
return nil, err
}
as, err := ecdh.P256().GenerateKey(rand.Reader)
if err != nil {
return nil, err
}
shared, err := as.ECDH(ua)
if err != nil {
return nil, err
}
asPub := as.PublicKey().Bytes()
// RFC 8291 section 3.4: mix the auth secret and both public keys in.
keyInfo := append(append([]byte("WebPush: info\x00"), uaPub...), asPub...)
ikm, err := hkdf.Key(sha256.New, shared, secret, string(keyInfo), 32)
if err != nil {
return nil, err
}
salt := make([]byte, 16)
if _, err := rand.Read(salt); err != nil {
return nil, err
}
cek, err := hkdf.Key(sha256.New, ikm, salt, "Content-Encoding: aes128gcm\x00", 16)
if err != nil {
return nil, err
}
nonce, err := hkdf.Key(sha256.New, ikm, salt, "Content-Encoding: nonce\x00", 12)
if err != nil {
return nil, err
}
block, err := aes.NewCipher(cek)
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
if len(plaintext)+1+gcm.Overhead() > recordSize {
return nil, errors.New("message too long")
}
// One record, so it is the last: padding delimiter 0x02.
sealed := gcm.Seal(nil, nonce, append(plaintext, 2), nil)
header := make([]byte, 0, 16+4+1+len(asPub))
header = append(header, salt...)
header = binary.BigEndian.AppendUint32(header, recordSize)
header = append(header, byte(len(asPub)))
header = append(header, asPub...)
return append(header, sealed...), nil
}
+6
View File
@@ -134,6 +134,12 @@ func guard(allowLocal bool) func(network, address string, _ syscall.RawConn) err
}
}
// Guard is the same address check for other outgoing requests to
// user-given addresses (push endpoints).
func Guard(allowLocal bool) func(network, address string, _ syscall.RawConn) error {
return guard(allowLocal)
}
// Run delivers queued events until ctx ends.
func (d *Dispatcher) Run(ctx context.Context) {
for {
+70
View File
@@ -328,6 +328,61 @@ paths:
"204": { description: Revoked }
"401": { $ref: "#/components/responses/Error" }
"403": { $ref: "#/components/responses/Error" }
/api/v1/me/devices:
get:
operationId: listDevices
tags: [auth]
summary: The caller's phones registered for push notifications, newest first
security: [{ bearer: [] }]
responses:
"200":
description: OK
content:
application/json:
schema: { type: array, items: { $ref: "#/components/schemas/PushDevice" } }
"404": { $ref: "#/components/responses/Error" }
post:
operationId: registerDevice
tags: [auth]
summary: Register a phone for push notifications (UnifiedPush)
description: >-
endpoint is the address the phone's UnifiedPush distributor (ntfy, NextPush, …) gave the app.
For each notification docwell-server POSTs a PushMessage there, encrypted to the app's
Web Push keys (RFC 8291, aes128gcm). Registering the
same endpoint again updates it. Endpoints that answer 404 or 410 are forgotten. A person
keeps up to 10 phones; registering an 11th drops the oldest.
security: [{ bearer: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [endpoint, p256dh, auth]
properties:
endpoint: { type: string, maxLength: 1000 }
p256dh: { type: string, description: The app's P-256 public key, uncompressed, base64url }
auth: { type: string, description: The app's 16-byte auth secret, base64url }
name: { type: string, maxLength: 100, description: e.g. the phone's model }
responses:
"201":
description: Registered
content:
application/json:
schema: { $ref: "#/components/schemas/PushDevice" }
"400": { $ref: "#/components/responses/Error" }
"404": { $ref: "#/components/responses/Error" }
/api/v1/me/devices/{id}:
parameters:
- { name: id, in: path, required: true, schema: { type: string } }
delete:
operationId: removeDevice
tags: [auth]
summary: Stop push notifications to one of the caller's phones
security: [{ bearer: [] }]
responses:
"204": { description: Removed }
"404": { $ref: "#/components/responses/Error" }
/api/v1/auth/me:
get:
operationId: getMe
@@ -2807,6 +2862,21 @@ components:
title: { type: string }
icon: { type: string }
deletedAt: { type: string }
PushDevice:
type: object
required: [id, name, created]
properties:
id: { type: string }
name: { type: string }
created: { type: string }
PushMessage:
type: object
description: The JSON body docwell-server POSTs to a phone's push endpoint
required: [title, body, route]
properties:
title: { type: string, description: The page's icon and title }
body: { type: string, description: 'For example "Ann mentioned you: …"' }
route: { type: string, description: 'The app route to open, for example /p/<id>?comment=<id>' }
ArchivedPage:
type: object
required: [id, title, icon, archivedAt]
+196
View File
@@ -1,15 +1,211 @@
al.essio.dev/pkg/shellescape v1.6.0/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
atomicgo.dev/cursor v0.2.0/go.mod h1:Lr4ZJB3U7DfPPOkbH7/6TOtJ4vFGHlgj1nc+n900IpU=
atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ=
atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU=
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc=
github.com/AlekSi/pointer v1.2.0/go.mod h1:gZGfd3dpW4vEc/UlyfKKi1roIqcCgwOIvb0tSNSBle0=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM=
github.com/Ladicle/tabwriter v1.0.0/go.mod h1:c4MdCjxQyTbGuQO/gvqJ+IA/89UEwrsD6hUCW98dyp4=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06/go.mod h1:7erjKLwalezA0k99cWs5L11HWOAPNjdUZ6RxH1BXbbM=
github.com/alecthomas/chroma/v2 v2.23.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/atterpac/refresh v1.1.4/go.mod h1:+vQ8OHgGmZ7wwoZfxxkT6Nr/gKA8j78Rbt+qcLLDEoc=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/blackwell-systems/gcf-go v1.2.2/go.mod h1:E4fW1kxdrIoWxlI4iwZL8mh7BvdLTkE88NyijtGGcZc=
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
github.com/blevesearch/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:9eJDeqxJ3E7WnLebQUlPD7ZjSce7AnDb9vjGmMCbD0A=
github.com/blevesearch/goleveldb v1.0.1/go.mod h1:WrU8ltZbIp0wAoig/MHbrPCXSOLpe79nz5lv5nqfYrQ=
github.com/blevesearch/snowball v0.6.1/go.mod h1:ZF0IBg5vgpeoUhnMza2v0A/z8m1cWPlwhke08LpNusg=
github.com/blevesearch/stempel v0.2.0/go.mod h1:wjeTHqQv+nQdbPuJ/YcvOjTInA2EIc6Ks1FoSUzSLvc=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/cavaliergopher/cpio v1.0.1/go.mod h1:pBdaqQjnvXxdS/6CvNDwIANIFSP0xRKI16PX4xejRQc=
github.com/chainguard-dev/git-urls v1.0.2/go.mod h1:rbGgj10OS7UgZlbzdUQIQpT0k/D4+An04HJY7Ol+Y/o=
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk=
github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=
github.com/charmbracelet/x/ansi v0.11.4/go.mod h1:/5AZ+UfWExW3int5H5ugnsG/PWjNcSQcwYsHBlPFQN4=
github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA=
github.com/charmbracelet/x/exp/slice v0.0.0-20260122224438-b01af16209d9/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA=
github.com/charmbracelet/x/exp/strings v0.0.0-20260122224438-b01af16209d9/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8=
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
github.com/clipperhouse/displaywidth v0.7.0/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o=
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
github.com/clipperhouse/uax29/v2 v2.4.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k=
github.com/couchbase/moss v0.2.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37grCIubs=
github.com/cyphar/filepath-securejoin v0.6.1/go.mod h1:A8hd4EnAeyujCJRrICiOWqjS1AX0a9kM5XL+NwKoYSc=
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dominikbraun/graph v0.23.0/go.mod h1:yOjYyogZLY1LSG9E33JWZJiq5k83Qy2C6POAuiViluc=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.9.0/go.mod h1:jCnQMLj9eUgGU7+ludSTYoZL/GGmii14RxKFj7ROgHw=
github.com/go-git/go-git/v5 v5.19.2/go.mod h1:QqCBE1EFN5ddFmrliLQ3/ntRCUjZU3EJuwuB/jWEHjk=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-task/template v0.2.0/go.mod h1:dbdoUb6qKnHQi1y6o+IdIrs0J4o/SEhSTA6bbzZmdtc=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/rpmpack v0.7.1/go.mod h1:h1JL16sUTWCLI/c39ox1rDaTBo3BXUQGjczVJyK4toU=
github.com/gookit/color v1.6.0/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs=
github.com/goreleaser/chglog v0.7.4/go.mod h1:dTVoZZagTz7hHdWaZ9OshHntKiF44HbWIHWxYJQ/h0Y=
github.com/goreleaser/fileglob v1.4.0/go.mod h1:1pbHx7hhmJIxNZvm6fi6WVrnP0tndq6p3ayWdLn1Yf8=
github.com/goreleaser/nfpm/v2 v2.44.1/go.mod h1:drIYLqkla9SaOLbSnaFOmSIv5LXGfhHcbK54st97b4s=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA=
github.com/jackmordaunt/icns/v2 v2.2.7/go.mod h1:ovoTxGguSuoUGKMk5Nn3R7L7BgMQkylsO+bblBuI22A=
github.com/jaypipes/ghw v0.21.3/go.mod h1:GPrvwbtPoxYUenr74+nAnWbardIZq600vJDD5HnPsPE=
github.com/jaypipes/pcidb v1.1.1/go.mod h1:x27LT2krrUgjf875KxQXKB0Ha/YXLdZRVmw6hH0G7g8=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kataras/blocks v0.0.8/go.mod h1:9Jm5zx6BB+06NwA+OhTbHW1xkMOYxahnqTN5DveZ2Yg=
github.com/kataras/golog v0.1.11/go.mod h1:mAkt1vbPowFUuUGvexyQ5NFW6djEgGyxQBIARJ0AH4A=
github.com/kataras/iris/v12 v12.2.11/go.mod h1:uMAeX8OqG9vqdhyrIPv8Lajo/wXTtAF43wchP9WHt2w=
github.com/kataras/pio v0.0.13/go.mod h1:k3HNuSw+eJ8Pm2lA4lRhg3DiCjVgHlP8hmXApSej3oM=
github.com/kataras/sitemap v0.0.6/go.mod h1:dW4dOCNs896OR1HmG+dMLdT7JjDk7mYBzoIRwuj5jA4=
github.com/kataras/tunnel v0.0.4/go.mod h1:9FkU4LaeifdMWqZu7o20ojmW4B7hdhv2CMLwfnHGpYw=
github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/konoui/go-qsort v0.1.0/go.mod h1:UOsvdDPBzyQDk9Tb21hETK6KYXGYQTnoZB5qeKA1ARs=
github.com/konoui/lipo v0.10.0/go.mod h1:R+0EgDVrLKKS37SumAO8zhpEprjjoKEkrT3QqKQE35k=
github.com/labstack/echo/v4 v4.15.1/go.mod h1:xmw1clThob0BSVRX1CRQkGQ/vjwcpOMjQZSZa9fKA/c=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/leaanthony/clir v1.7.0/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
github.com/leaanthony/dmg v0.0.0-20260731074841-5c28840cf819/go.mod h1:gL114o+2XWHHI50xydocqXc4sBntbpiyaLyarUH0VA4=
github.com/leaanthony/winicon v1.0.0/go.mod h1:en5xhijl92aphrJdmRPlh4NI1L6wq3gEm0LpXAPghjU=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/lmittmann/tint v1.1.3/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-zglob v0.0.6/go.mod h1:MxxjyoXXnMxfIpxTK2GAkw1w8glPsQILx3N5wrKakiY=
github.com/mdempsky/unconvert v0.0.0-20250216222326-4a038b3d31f5/go.mod h1:mVCHGHs8r8jnrZ2ammcv8ySbhG2+rEPXegFmdNA51GI=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/modelcontextprotocol/go-sdk v1.6.1/go.mod h1:kzm3kzFL1/+AziGOE0nUs3gvPoNxMCvkxokMkuFapXQ=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pterm/pterm v0.12.82/go.mod h1:TyuyrPjnxfwP+ccJdBTeWHtd/e0ybQHkOS/TakajZCw=
github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
github.com/sajari/fuzzy v1.0.0/go.mod h1:OjYR6KxoWOe9+dOlXeiCJd4dIbED4Oo8wpS89o0pwOo=
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.3.2/go.mod h1:bEg3iQAuw+jyiw+484wwFJoKSLwcfd7fqRy+N0QTiow=
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/tc-hib/winres v0.3.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
github.com/tdewolff/minify/v2 v2.20.19/go.mod h1:ulkFoeAVWMLEyjuDz1ZIWOA31g5aWOawCFRp9R/MudM=
github.com/tdewolff/parse/v2 v2.7.12/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/wailsapp/task/v3 v3.40.1-patched3/go.mod h1:jIP48r8ftoSQNlxFP4+aEnkvGQqQXqCnRi/B7ROaecE=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.17/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
gitlab.com/digitalxero/go-conventional-commit v1.0.7/go.mod h1:05Xc2BFsSyC5tKhK0y+P3bs0AwUtNuTp+mTpbCU/DZ0=
go.etcd.io/gofail v0.2.0/go.mod h1:nL3ILMGfkXTekKI3clMBNazKnjUZjYLKmBHzsVAnC1o=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80=
golang.org/x/exp/typeparams v0.0.0-20260112195511-716be5621a96/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/telemetry v0.0.0-20260811182544-a038080d80e5/go.mod h1:LVehoXe41cL5SCVQilsV7Gg6BNG+Js6P9PhSbYTIUkQ=
golang.org/x/telemetry v0.0.0-20260924152758-ed294f943157/go.mod h1:i+ivNqjDnTF3WTElsdk5g9V5DTSBYgdNo7xTU9SDwYA=
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
howett.net/plist v1.0.2-0.20250314012144-ee69052608d9/go.mod h1:fyFX5Hj5tP1Mpk8obqA9MZgXT416Q5711SDT7dQLTLk=
modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
mvdan.cc/sh/v3 v3.12.0/go.mod h1:Se6Cj17eYSn+sNooLZiEUnNNmNxg0imoYlTu4CyaGyg=