diff --git a/Database/pb_migrations/1763300000_push_devices.js b/Database/pb_migrations/1763300000_push_devices.js new file mode 100644 index 0000000..4eff4d9 --- /dev/null +++ b/Database/pb_migrations/1763300000_push_devices.js @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +/// + +// 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")); + }, +); diff --git a/Packages/api-client/src/schema.d.ts b/Packages/api-client/src/schema.d.ts index 09904c6..1be208f 100644 --- a/Packages/api-client/src/schema.d.ts +++ b/Packages/api-client/src/schema.d.ts @@ -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/?comment= */ + 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; diff --git a/Packages/editor-bridge/dist/index.html b/Packages/editor-bridge/dist/index.html index e6628cc..f2653a5 100644 --- a/Packages/editor-bridge/dist/index.html +++ b/Packages/editor-bridge/dist/index.html @@ -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=n:en){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{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.dirty0&&(a=Ta(a,0,t,r));for(let e=0;e{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;break}}if(!t.contentElement){let n=e&&e.find(t=>O(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>s.empty}}return t}matchesNode(e,t,n){return this.dirty==Zi&&e.eq(this.node)&&_a(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new ya(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;Sa(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?d.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==$i)&&(a&&this.protectLocalComposition(e,a),ua(this.contentDOM,this.children,e),pi&&Ca(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof w)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=wa(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new ra(this,i,t,r);e.input.compositionNodes.push(a),this.children=Ta(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==ea||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Zi}updateOuterDeco(e){if(_a(e,this.outerDeco))return;let t=!O(this.nodeDOM),n=this.dom;this.dom=ma(this.dom,this.nodeDOM,pa(this.outerDeco,this.node,t),pa(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){O(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function oa(e,t,n,r,i){ga(r,t,e);let a=new aa(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var sa=class e extends aa{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==ea||this.dirty!=Zi&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Zi||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Zi,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ea)}get domAtom(){return!1}isText(e){return this.node.text==e}},ca=class extends ta{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Zi&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},la=class extends aa{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==ea)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function ua(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=ia.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof ia)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function xa(e,t){return e.type.side-t.type.side}function Sa(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function Ca(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function wa(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Ta(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function Ea(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Xr(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&T.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Jr(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new T(o==e?s:r.resolve(e))}else if(ci&&t==`key`&&o>e.state.selection.to&&O(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=C.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!O(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Da(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Pa(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,Fr(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&oi&&si<=11&&(n.disabled=!0,n.disabled=!1)}function Fa(e,t){if(t instanceof T){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Ia(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Ia(e)}function Ia(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function La(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||w.between(t,n,r)}function Ra(e){return e.editable&&!e.hasFocus()?!1:za(e)}function za(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Gr(e.dom,t.anchorNode)&&(e.editable||Gr(e.dom,t.focusNode))}catch{return!1}}function Ba(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Br(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Va(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&C.findFrom(a,t)}function Ha(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ua(e,t,n){let r=e.state.selection;if(r instanceof w){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Ha(e,new w(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Va(e.state,t);return n&&n instanceof T?Ha(e,n):!1}if(!mi||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?T.isSelectable(i)?Ha(e,new T(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Ha(e,new w(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof T&&r.node.isInline)return Ha(e,new w(t>0?r.$to:r.$from));else{let n=Va(e.state,t);return n?Ha(e,n):!1}}function Wa(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):O(e)&&e.contentEditable==`false`}function Ga(e,t){return t<0?Ka(e):qa(e)}function Ka(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(ci&&O(n)&&r0){if(!O(n))break;let e=n.childNodes[r-1];if(Wa(e,-1))i=n,a=--r;else if(Wr(e))n=e,r=n.nodeValue.length;else break}else if(Ja(n))break;else{let t=n.previousSibling;for(;t&&Wa(t,-1);)i=n.parentNode,a=Fr(t),t=t.previousSibling;if(t)n=t,r=Ur(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Za(e,n,r):i&&Za(e,i,a)}function qa(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Ur(n),a,o;for(;;)if(r{e.state==a&&Oa(e)},50)}function Qa(e,t){let n=e.state.doc.resolve(t);if(!(ui||hi)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function $a(e,t,n){let r=e.state.selection;if(r instanceof w&&!r.empty||n.indexOf(`s`)>-1||mi&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Va(e.state,t);if(n&&n instanceof T)return Ha(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof On?C.near(n,t):C.findFrom(n,t);return o?Ha(e,o):!1}return!1}function eo(e,t){if(!(e.state.selection instanceof w))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function to(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function no(e){if(!fi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&O(t)&&n==0&&t.firstChild&&O(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;to(e,n,`true`),setTimeout(()=>to(e,n,`false`),20)}return!1}function ro(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function io(e,t){let n=t.keyCode,r=ro(t);if(n==8||mi&&n==72&&r==`c`)return eo(e,-1)||Ga(e,-1);if(n==46&&!t.shiftKey||mi&&n==68&&r==`c`)return eo(e,1)||Ga(e,1);if(n==13||n==27)return!0;if(n==37||mi&&n==66&&r==`c`){let t=n==37?Qa(e,e.state.selection.from)==`ltr`?-1:1:-1;return Ua(e,t,r)||Ga(e,t)}if(n==39||mi&&n==70&&r==`c`){let t=n==39?Qa(e,e.state.selection.from)==`ltr`?1:-1:1;return Ua(e,t,r)||Ga(e,t)}return n==38||mi&&n==80&&r==`c`?$a(e,-1,r)||Ga(e,-1):n==40||mi&&n==78&&r==`c`?no(e)||$a(e,1,r)||Ga(e,1):!(r!=(mi?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function ao(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Qe.fromSchema(e.state.schema),s=go(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&O(l)&&(u=ho[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&O(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` `),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=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(i1&&(a=0),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 te})}return _o.createHTML(e)}function yo(e){let t=/^(\s*]*>)*/.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=>``).reverse().join(``)),r.innerHTML=vo(e),a)for(let e=0;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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Eo(e){for(let t in So){let n=So[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{jo(e,t)&&!Ao(e,t)&&(e.editable||!(t.type in Co))&&n(e,t)},wo[t]?{passive:!0}:void 0)}fi&&e.dom.addEventListener(`input`,()=>null),ko(e)}function Do(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Oo(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ko(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ao(e,t))})}function Ao(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function jo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Mo(e,t){!Ao(e,t)&&So[t.type]&&(e.editable||!(t.type in Co))&&So[t.type](e,t)}Co.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Yo(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(gi&&ui&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),pi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||io(e,n)?n.preventDefault():Do(e,`key`)}},Co.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Co.keypress=(e,t)=>{let n=t;if(Yo(e)||!n.charCode||n.ctrlKey&&!n.altKey||mi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function No(e){return{left:e.clientX,top:e.clientY}}function Po(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Fo(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Io(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Lo(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(Io(e,new T(n)),!0):!1}function Ro(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof T&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(T.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Io(e,T.create(e.state.doc,i)),!0)}function zo(e,t,n,r,i){return Fo(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Ro(e,n):Lo(e,n))}function Bo(e,t,n,r){return Fo(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Vo(e,t,n,r){return Fo(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Ho(e,n,r)}function Ho(e,t,n){if(n.button!=0)return!1;let r=Uo(e,t,!0),i=e.state.doc;return r?(Io(e,r),r instanceof w&&i.eq(e.state.doc)&&(e.input.mouseDown=new Jo(e,r)),!0):!1}function Uo(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?w.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return w.create(r,a+1,a+1+t.content.size);if(n&&T.isSelectable(t))return T.create(r,a)}return null}function Wo(e){return ts(e)}var Go=mi?`metaKey`:`ctrlKey`;So.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Wo(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Po(n,e.input.lastClick)&&!n[Go]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(No(n));o&&(a==`singleClick`?e.input.mouseDown=new qo(e,o,n,!!r):(a==`doubleClick`?Bo:Vo)(e,o.pos,o.inside,n)?n.preventDefault():Do(e,`pointer`))};var Ko=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},qo=class extends Ko{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Go],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&O(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof T&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&ci&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),Do(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Oa(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(No(e))),this.updateAllowDefault(e),this.allowDefault||!t?Do(this.view,`pointer`):zo(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||fi&&this.mightDrag&&!this.mightDrag.node.isAtom||ui&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Io(this.view,C.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Do(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Do(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Jo=class extends Ko{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Do(this.view,`pointer`);let t=this.view.posAtCoords(No(e)),n=t&&Uo(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),Wo(e),Do(e,`pointer`)},So.touchmove=e=>{e.input.lastTouch=Date.now(),Do(e,`pointer`)},So.contextmenu=e=>Wo(e);function Yo(e,t){return e.composing?!0:fi&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Xo=gi?5e3:-1;Co.compositionstart=Co.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof w&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||ui&&hi&&Zo(e)))e.markCursor=e.state.storedMarks||n.marks(),ts(e,!0),e.markCursor=null;else if(ts(e,!t.selection.empty),ci&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&O(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Wr(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Qo(e,Xo)};function Zo(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!O(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return O(r)&&r.contentEditable==`false`}Co.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Qo(e,20))};function Qo(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>ts(e),t))}function $o(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function es(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Kr(t.focusNode,t.focusOffset),r=qr(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function ts(e,t=!1){if(!(gi&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),$o(e),t||e.docView&&e.docView.dirty){let n=Ea(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function ns(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var rs=oi&&si<15||pi&&vi<604;So.copy=Co.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=rs?null:n.clipboardData,{dom:o,text:s}=ao(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ns(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function is(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function as(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ss(e,r.value,null,i,t):ss(e,r.textContent,r.innerHTML,i,t)},50)}function ss(e,t,n,r,i){let a=oo(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||p.empty)))return!0;if(!a)return!1;let o=is(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function cs(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}Co.paste=(e,t)=>{let n=t;if(e.composing&&!gi)return;let r=rs?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&ss(e,cs(r),r.getData(`text/html`),i,n)?n.preventDefault():as(e,n)};var ls=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},us=mi?`altKey`:`ctrlKey`;function ds(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[us]:!n}So.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(No(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof T?i.to-1:i.to))){if(r&&r.mightDrag)o=T.create(e.state.doc,r.mightDrag.pos);else if(n.target&&O(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=T.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=ao(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!ui||di>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rs?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,rs||n.dataTransfer.setData(`text/plain`,c),e.dragging=new ls(l,ds(e,n),o)},So.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Co.dragover=Co.dragenter=(e,t)=>t.preventDefault(),Co.drop=(e,t)=>{try{fs(e,t,e.dragging)}finally{e.dragging=null}};function fs(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(No(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=oo(e,cs(t.dataTransfer),rs?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&ds(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||p.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?en(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&T.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new T(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(La(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}So.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Oa(e)},20))},So.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},So.beforeinput=(e,t)=>{if(gi&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Zr(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Co)So[e]=Co[e];function ps(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ms=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new vs(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==xs||e.maps.length==0?this:this.mapInner(e,t,0,0,n||bs)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new ms(n.content);for(let s=0;s{let o=t+r,s;if(s=Es(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof gs){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,bs));return e.from(r)}forChild(t,n){if(n.isLeaf)return k.empty;let r=[];for(let i=0;ie instanceof k)?t:t.reduce((e,t)=>e.concat(t instanceof k?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==xs?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Os(Ts(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=Es(e,t,o+n);if(s){a=!0;let e=Os(s,t,n+o+1,r);e!=xs&&i.push(o,o+t.nodeSize,e)}});let o=ws(a?Ds(e):e,-n).sort(ks);if(o.length){let e=new ms(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function Ms(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=xs&&t.push(r)}),e.cursorWrapper&&t.push(k.create(e.state.doc,[e.cursorWrapper.deco])),Ss.from(t)}var Ns={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ps=oi&&si<=11,Fs=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Is=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Fs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():fi&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ps&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ns)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ra(this.view)){if(this.suppressingSelectionUpdates)return Oa(this.view);if(oi&&si<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Br(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Ir(n))t.add(n);for(let r=e.anchorNode;r;r=Ir(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:Wr(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&Ra(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ui&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&O(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ci&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Hs(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),zs(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Us(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&Oa(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||Re.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Gs(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Gs=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(fi&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||fi&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Ks=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function qs(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Ea(e,t);if(n&&!e.state.selection.eq(n)){if(ui&&gi&&e.input.lastKeyCode===13&&Date.now()-100t(e,Zr(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Ws(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||gi)&&i.some(e=>O(e)&&!Ks.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof w&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Js(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),oi&&si<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((pi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Zs(l.doc,h.pos,g.pos))&&e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Xs(u,m.start,m.endA,h,g))&&e.someProp(`handleKeyDown`,t=>t(e,Zr(8,`Backspace`)))){gi&&ui&&e.domObserver.suppressSelectionUpdates();return}ui&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),gi&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Zr(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Js(e,n.doc,l.sel);t&&!(ui&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteOa(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Ys(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Js(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:La(e,t.resolve(n.anchor),t.resolve(n.head))}function Ys(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,c,l;for(let e=0;ee.mark(c.addToSet(e.marks));else if(i.length==0&&a.length==1)c=a[0],o=`remove`,l=e=>e.mark(c.removeFromSet(e.marks));else return null;let u=[];for(let e=0;en||Qs(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function $s(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var ec=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new To,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(sc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=rc(this),nc(this),this.nodeViews=ac(this),this.docView=oa(this.state.doc,tc(this),Ms(this),this.dom,this),this.domObserver=new Is(this,(e,t,n,r)=>qs(this,e,t,n,r)),this.domObserver.start(),Eo(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ko(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&($o(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=ac(this);oc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ko(this),this.editable=rc(this),nc(this);let o=Ms(this),s=tc(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Ci(this);if(i){this.domObserver.stop();let t=l&&(oi||ui)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&ic(n.selection,e.selection);if(l){let n=ui?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=es(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=oa(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ba(this)&&i.delaySelUpdate())?Oa(this,t):(Fa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Ti(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Gr(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof T){let t=this.docView.domAfterPos(this.state.selection.from);O(t)&&Si(this,t.getBoundingClientRect(),e)}else Si(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ii(this,e)}coordsAtPos(e,t=1){return Bi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Xi(this,t||this.state,e)}pasteHTML(e,t){return ss(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return ss(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return ao(this,e)}destroy(){this.docView&&(Oo(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ms(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zr())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Mo(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?fi&&this.root.nodeType===11&&Qr(this.dom.ownerDocument)==this.dom&&Vs(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ec.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function tc(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[vs.node(0,e.state.doc.content.size,t)]}function nc(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:vs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function rc(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function ic(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function ac(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function oc(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function sc(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var cc={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},lc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},uc=typeof navigator<`u`&&/Mac/.test(navigator.platform),dc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fc=0;fc<10;fc++)cc[48+fc]=cc[96+fc]=String(fc);for(var fc=1;fc<=24;fc++)cc[fc+111]=`F`+fc;for(var fc=65;fc<=90;fc++)cc[fc]=String.fromCharCode(fc+32),lc[fc]=String.fromCharCode(fc);for(var pc in cc)lc.hasOwnProperty(pc)||(lc[pc]=cc[pc]);function mc(e){var t=!(uc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||dc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?lc:cc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var hc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),gc=typeof navigator<`u`&&/Win/.test(navigator.platform);function _c(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?Cc.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Cc.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Cc.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Cc.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Cc.from=function(e){return e instanceof Cc?e:e&&e.length?new wc(e):Cc.empty};var wc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Sc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Sc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Cc);Cc.empty=new wc([]);var Tc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Cc),Ec=500,Dc=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new kc(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new kc(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;ejc&&(s=Oc(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new gt;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new kc(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new kc(i,o,l))}else r.push(new kc(i))},i);let l=[];for(let e=n;eEc&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new kc(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Cc.from(i.reverse()),a)}};Dc.empty=new Dc(Cc.empty,0);function Oc(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var kc=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Ac=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},jc=20;function Mc(e,t,n,r){let i=n.getMeta(Vc),a;if(i)return i.historyState;n.getMeta(Hc)&&(e=new Ac(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Vc))return o.getMeta(Vc).redo?new Ac(e.done.addTransform(n,void 0,r,zc(t)),e.undone,Pc(n.mapping.maps),e.prevTime,e.prevComposition):new Ac(e.done,e.undone.addTransform(n,void 0,r,zc(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Nc(n,e.prevRanges)),s=o?Fc(e.prevRanges,n.mapping):Pc(n.mapping.maps);return new Ac(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,zc(t)),Dc.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new Ac(e.done.rebased(n,a),e.undone.rebased(n,a),Fc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ac(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Fc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Nc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function Pc(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Fc(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=Vc.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Ic(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Gc=Wc(!1,!0),Kc=Wc(!0,!0);function qc(e){return e.getMeta(Vc)!=null}function Jc(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Yc=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Jc({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Xc=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Zc=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Qc=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=Pt(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},$c=e=>t=>e(t),el=()=>({state:e,dispatch:t})=>lr(e,t),tl=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new w(r.doc.resolve(Math.max(o-1,0)))),!0},nl=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function rl(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var il=e=>({tr:t,state:n,dispatch:r})=>{let i=rl(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},al=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},ol=e=>e.content?/^text(\*|\+)/.test(e.content):!1,sl=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:sl(e,n,`left`),to:sl(t,n,`right`)}),ll=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof w?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=cl(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(w.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},ul=()=>({commands:e})=>e.keyboardShortcut(`Enter`),dl=()=>({state:e,dispatch:t})=>cr(e,t);function fl(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function pl(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:fl(t[r])?t[r].test(e[r]):t[r]===e[r])}function ml(e,t,n={}){return e.find(e=>e.type===t&&pl(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function hl(e,t,n={}){return!!ml(e,t,n)}function gl(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!ml([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&hl([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=_l(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=gl(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=w.create(o,e.from,e.to);n.setSelection(t)}}return!0},yl=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(wl()||Cl())&&r.dom.focus(),Tl()&&!wl()&&!Cl()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!bl(n.state.selection))return o(),!0;let s=Sl(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Dl=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Ol=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),kl=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&kl(r)}return e};function Al(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return kl(n)}function jl(e){return typeof e?.nodesBetween==`function`}function Ml(e,t,n){if(jl(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return s.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),Ml(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Pe({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Re.fromSchema(a).parseSlice(Al(e),n.parseOptions):Re.fromSchema(a).parse(Al(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Re.fromSchema(t);return n.slice?r.parseSlice(Al(e),n.parseOptions).content:r.parse(Al(e),n.parseOptions)}return Ml(``,t,n)}function Nl(e){return!(`type`in e)}function Pl(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(C.near(e.doc.resolve(o),n))}var Fl=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ml(t,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=Ml(t,a.schema,{parseOptions:c,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:l,to:u}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},d=!0,f=!0,p=Nl(i)?i.content:[i];if(p.forEach(e=>{e.check(),d=d?e.isText&&e.marks.length===0:!1,f=f?e.isBlock:!1}),l===u&&f){let{parent:e}=r.doc.resolve(l);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--l,u+=1)}let m;if(d)m=Array.isArray(t)?t.map(e=>e.text||``).join(``):jl(t)?p.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(m,l,u);else{m=s.from(p);let e=r.doc.resolve(l),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&f&&(l=Math.max(0,l-1)),r.replaceWith(l,u,p)}n.updateSelection&&Pl(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:l,text:m}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:l,text:m})}return!0};function Il(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=Il(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=Ml(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&Pl(t,t.steps.length-1,-1)),!0):!1},Rl=()=>({state:e,dispatch:t})=>rr(e,t),zl=()=>({state:e,dispatch:t})=>ir(e,t),Bl=()=>({state:e,dispatch:t})=>Kn(e,t),Vl=()=>({state:e,dispatch:t})=>er(e,t),Hl=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Ul=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Zt(e.doc,e.selection.$from.pos,-1);return r==null||!Hl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Wl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Zt(e.doc,e.selection.$from.pos,1);return r==null||!Hl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Gl=()=>({state:e,dispatch:t})=>qn(e,t),Kl=()=>({state:e,dispatch:t})=>Jn(e,t);function ql(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function Jl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=Jl(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Xl(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?rl(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>pl(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Zl=(e,t={})=>({state:n,dispatch:r})=>Xl(n,rl(e,n.schema),t)?ar(n,r):!1,Ql=()=>({state:e,dispatch:t})=>ur(e,t),$l=e=>({state:t,dispatch:n})=>jr(rl(e,t.schema))(t,n),eu=()=>({state:e,dispatch:t})=>or(e,t);function tu(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function nu(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var ru=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=tu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=rl(e,r.schema)),s===`mark`&&(o=_l(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,nu(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(nu(a.attrs,t))))})})}),c},iu=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),au=()=>({tr:e,dispatch:t})=>{if(t){let t=new On(e.doc);e.setSelection(t)}return!0},ou=()=>({state:e,dispatch:t})=>Zn(e,t),su=()=>({state:e,dispatch:t})=>tr(e,t),cu=()=>({state:e,dispatch:t})=>pr(e,t),lu=()=>({state:e,dispatch:t})=>yr(e,t),uu=()=>({state:e,dispatch:t})=>vr(e,t);function du(e,t,n={},r={}){return Ml(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var fu=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=du(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=Nl(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function pu(e,t){let n=_l(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function mu(e,t){let n=new xn(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function hu(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function gu(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function _u(e){return t=>gu(t.$from,e)}function A(e,t,n){return e.config[t]===void 0&&e.parent?A(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?A(e.parent,t,n):null}):e.config[t]}function vu(e){return e.map(e=>{let t=A(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...vu(t())]:e}).flat(10)}function yu(e,t){let n=Qe.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function bu(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var xu={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},Su={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function Cu(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function wu(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...Cu(n,r,e),attrs:n.attrs}}function Tu(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function Eu(e,t){Tu(e.nodes,t.nodes,`node`),Tu(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,wu(t,e.nodes[t],r,xu))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,wu(t,e.marks[t],n,Su))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function Du(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function Ou(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function ku(e){let t=[],{nodeExtensions:n,markExtensions:r}=Ou(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=A(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=A(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function Au(e){return typeof e==`function`}function ju(e,t=void 0,...n){return Au(e)?t?e.bind(t)(...n):e(...n):e}function Mu(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Nu(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function Pu(e){let t=[],n=Nu(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...Pu(n[e]),...Pu(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function Iu(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>Fu(e,t),{})}function Lu(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function Ru(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):Lu(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function zu(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&Mu(t)?!1:t!=null))}function Bu(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Vu(e,t,n=ku(e)){let{nodeExtensions:r,markExtensions:i}=Ou(e);return{topNode:r.find(e=>A(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=zu({...e.reduce((e,t)=>{let n=A(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:ju(A(r,`content`,a)),marks:ju(A(r,`marks`,a)),group:ju(A(r,`group`,a)),inline:ju(A(r,`inline`,a)),atom:ju(A(r,`atom`,a)),selectable:ju(A(r,`selectable`,a)),draggable:ju(A(r,`draggable`,a)),code:ju(A(r,`code`,a)),whitespace:ju(A(r,`whitespace`,a)),linebreakReplacement:ju(A(r,`linebreakReplacement`,a)),defining:ju(A(r,`defining`,a)),isolating:ju(A(r,`isolating`,a)),attrs:Object.fromEntries(i.map(Bu))}),s=ju(A(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Ru(e,i)));let c=A(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:Iu(e,i)}));let l=A(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=zu({...e.reduce((e,t)=>{let n=A(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:ju(A(r,`inclusive`,a)),excludes:ju(A(r,`excludes`,a)),group:ju(A(r,`group`,a)),spanning:ju(A(r,`spanning`,a)),code:ju(A(r,`code`,a)),attrs:Object.fromEntries(i.map(Bu))}),s=ju(A(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Ru(e,i)));let c=A(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:Iu(e,i)})),[r.name,o]}))}}function Hu(e,t,n){if(n===void 0)return new Pe(Vu(e,t));let r=Du(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new Pe(n);return new Pe(Eu(Vu(e,t,bu(ku(e),i)),i))}function Uu(e){return e.sort((e,t)=>{let n=A(e,`priority`)||100,r=A(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Gu(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` +`))),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=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(i1&&(a=0),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 te})}return _o.createHTML(e)}function yo(e){let t=/^(\s*]*>)*/.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=>``).reverse().join(``)),r.innerHTML=vo(e),a)for(let e=0;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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Eo(e){for(let t in So){let n=So[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{jo(e,t)&&!Ao(e,t)&&(e.editable||!(t.type in Co))&&n(e,t)},wo[t]?{passive:!0}:void 0)}fi&&e.dom.addEventListener(`input`,()=>null),ko(e)}function Do(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Oo(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ko(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ao(e,t))})}function Ao(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function jo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Mo(e,t){!Ao(e,t)&&So[t.type]&&(e.editable||!(t.type in Co))&&So[t.type](e,t)}Co.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Yo(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(gi&&ui&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),pi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||io(e,n)?n.preventDefault():Do(e,`key`)}},Co.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Co.keypress=(e,t)=>{let n=t;if(Yo(e)||!n.charCode||n.ctrlKey&&!n.altKey||mi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function No(e){return{left:e.clientX,top:e.clientY}}function Po(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Fo(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Io(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Lo(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(Io(e,new T(n)),!0):!1}function Ro(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof T&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(T.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Io(e,T.create(e.state.doc,i)),!0)}function zo(e,t,n,r,i){return Fo(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Ro(e,n):Lo(e,n))}function Bo(e,t,n,r){return Fo(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Vo(e,t,n,r){return Fo(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Ho(e,n,r)}function Ho(e,t,n){if(n.button!=0)return!1;let r=Uo(e,t,!0),i=e.state.doc;return r?(Io(e,r),r instanceof w&&i.eq(e.state.doc)&&(e.input.mouseDown=new Jo(e,r)),!0):!1}function Uo(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?w.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return w.create(r,a+1,a+1+t.content.size);if(n&&T.isSelectable(t))return T.create(r,a)}return null}function Wo(e){return ts(e)}var Go=mi?`metaKey`:`ctrlKey`;So.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Wo(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Po(n,e.input.lastClick)&&!n[Go]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(No(n));o&&(a==`singleClick`?e.input.mouseDown=new qo(e,o,n,!!r):(a==`doubleClick`?Bo:Vo)(e,o.pos,o.inside,n)?n.preventDefault():Do(e,`pointer`))};var Ko=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},qo=class extends Ko{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Go],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&O(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof T&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&ci&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),Do(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Oa(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(No(e))),this.updateAllowDefault(e),this.allowDefault||!t?Do(this.view,`pointer`):zo(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||fi&&this.mightDrag&&!this.mightDrag.node.isAtom||ui&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Io(this.view,C.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Do(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Do(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Jo=class extends Ko{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Do(this.view,`pointer`);let t=this.view.posAtCoords(No(e)),n=t&&Uo(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),Wo(e),Do(e,`pointer`)},So.touchmove=e=>{e.input.lastTouch=Date.now(),Do(e,`pointer`)},So.contextmenu=e=>Wo(e);function Yo(e,t){return e.composing?!0:fi&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Xo=gi?5e3:-1;Co.compositionstart=Co.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof w&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||ui&&hi&&Zo(e)))e.markCursor=e.state.storedMarks||n.marks(),ts(e,!0),e.markCursor=null;else if(ts(e,!t.selection.empty),ci&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&O(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Wr(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Qo(e,Xo)};function Zo(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!O(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return O(r)&&r.contentEditable==`false`}Co.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Qo(e,20))};function Qo(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>ts(e),t))}function $o(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function es(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Kr(t.focusNode,t.focusOffset),r=qr(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function ts(e,t=!1){if(!(gi&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),$o(e),t||e.docView&&e.docView.dirty){let n=Ea(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function ns(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var rs=oi&&si<15||pi&&vi<604;So.copy=Co.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=rs?null:n.clipboardData,{dom:o,text:s}=ao(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ns(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function is(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function as(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ss(e,r.value,null,i,t):ss(e,r.textContent,r.innerHTML,i,t)},50)}function ss(e,t,n,r,i){let a=oo(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||p.empty)))return!0;if(!a)return!1;let o=is(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function cs(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}Co.paste=(e,t)=>{let n=t;if(e.composing&&!gi)return;let r=rs?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&ss(e,cs(r),r.getData(`text/html`),i,n)?n.preventDefault():as(e,n)};var ls=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},us=mi?`altKey`:`ctrlKey`;function ds(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[us]:!n}So.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(No(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof T?i.to-1:i.to))){if(r&&r.mightDrag)o=T.create(e.state.doc,r.mightDrag.pos);else if(n.target&&O(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=T.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=ao(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!ui||di>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rs?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,rs||n.dataTransfer.setData(`text/plain`,c),e.dragging=new ls(l,ds(e,n),o)},So.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Co.dragover=Co.dragenter=(e,t)=>t.preventDefault(),Co.drop=(e,t)=>{try{fs(e,t,e.dragging)}finally{e.dragging=null}};function fs(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(No(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=oo(e,cs(t.dataTransfer),rs?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&ds(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||p.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?en(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&T.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new T(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(La(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}So.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Oa(e)},20))},So.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},So.beforeinput=(e,t)=>{if(gi&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Zr(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Co)So[e]=Co[e];function ps(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ms=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new vs(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Ss||e.maps.length==0?this:this.mapInner(e,t,0,0,n||bs)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new ms(n.content);for(let s=0;s{let o=t+r,s;if(s=Ds(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof gs){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,bs));return e.from(r)}forChild(t,n){if(n.isLeaf)return xs.empty;let r=[];for(let i=0;ie instanceof xs)?t:t.reduce((e,t)=>e.concat(t instanceof xs?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==Ss?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=ks(Es(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=Ds(e,t,o+n);if(s){a=!0;let e=ks(s,t,n+o+1,r);e!=Ss&&i.push(o,o+t.nodeSize,e)}});let o=Ts(a?Os(e):e,-n).sort(As);if(o.length){let e=new ms(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function Ns(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Ss&&t.push(r)}),e.cursorWrapper&&t.push(xs.create(e.state.doc,[e.cursorWrapper.deco])),Cs.from(t)}var Ps={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fs=oi&&si<=11,Is=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Ls=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Is,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():fi&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Fs&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ps)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ra(this.view)){if(this.suppressingSelectionUpdates)return Oa(this.view);if(oi&&si<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Br(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Ir(n))t.add(n);for(let r=e.anchorNode;r;r=Ir(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:Wr(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&Ra(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ui&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&O(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ci&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Us(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Bs(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ws(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&Oa(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||Re.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Ks(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Ks=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(fi&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||fi&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},qs=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Js(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Ea(e,t);if(n&&!e.state.selection.eq(n)){if(ui&&gi&&e.input.lastKeyCode===13&&Date.now()-100t(e,Zr(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Gs(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||gi)&&i.some(e=>O(e)&&!qs.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof w&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Ys(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),oi&&si<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((pi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Qs(l.doc,h.pos,g.pos))&&e.someProp(`handleKeyDown`,t=>t(e,Zr(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Zs(u,m.start,m.endA,h,g))&&e.someProp(`handleKeyDown`,t=>t(e,Zr(8,`Backspace`)))){gi&&ui&&e.domObserver.suppressSelectionUpdates();return}ui&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),gi&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Zr(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Ys(e,n.doc,l.sel);t&&!(ui&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteOa(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Xs(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Ys(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:La(e,t.resolve(n.anchor),t.resolve(n.head))}function Xs(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,c,l;for(let e=0;ee.mark(c.addToSet(e.marks));else if(i.length==0&&a.length==1)c=a[0],o=`remove`,l=e=>e.mark(c.removeFromSet(e.marks));else return null;let u=[];for(let e=0;en||$s(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function ec(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var tc=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new To,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(cc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ic(this),rc(this),this.nodeViews=oc(this),this.docView=oa(this.state.doc,nc(this),Ns(this),this.dom,this),this.domObserver=new Ls(this,(e,t,n,r)=>Js(this,e,t,n,r)),this.domObserver.start(),Eo(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ko(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&($o(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=oc(this);sc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ko(this),this.editable=ic(this),rc(this);let o=Ns(this),s=nc(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Ci(this);if(i){this.domObserver.stop();let t=l&&(oi||ui)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&ac(n.selection,e.selection);if(l){let n=ui?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=es(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=oa(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ba(this)&&i.delaySelUpdate())?Oa(this,t):(Fa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Ti(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Gr(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof T){let t=this.docView.domAfterPos(this.state.selection.from);O(t)&&Si(this,t.getBoundingClientRect(),e)}else Si(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ii(this,e)}coordsAtPos(e,t=1){return Bi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Xi(this,t||this.state,e)}pasteHTML(e,t){return ss(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return ss(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return ao(this,e)}destroy(){this.docView&&(Oo(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ns(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zr())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Mo(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?fi&&this.root.nodeType===11&&Qr(this.dom.ownerDocument)==this.dom&&Hs(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};tc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function nc(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[vs.node(0,e.state.doc.content.size,t)]}function rc(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:vs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function ic(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function ac(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function oc(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function sc(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function cc(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var lc={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},uc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},dc=typeof navigator<`u`&&/Mac/.test(navigator.platform),fc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),pc=0;pc<10;pc++)lc[48+pc]=lc[96+pc]=String(pc);for(var pc=1;pc<=24;pc++)lc[pc+111]=`F`+pc;for(var pc=65;pc<=90;pc++)lc[pc]=String.fromCharCode(pc+32),uc[pc]=String.fromCharCode(pc);for(var mc in lc)uc.hasOwnProperty(mc)||(uc[mc]=lc[mc]);function hc(e){var t=!(dc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||fc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?uc:lc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var gc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_c=typeof navigator<`u`&&/Win/.test(navigator.platform);function vc(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?wc.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},wc.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},wc.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},wc.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},wc.from=function(e){return e instanceof wc?e:e&&e.length?new Tc(e):wc.empty};var Tc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Cc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Cc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(wc);wc.empty=new Tc([]);var Ec=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(wc),Dc=500,Oc=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new Ac(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Ac(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;eMc&&(s=kc(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new gt;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Ac(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Ac(i,o,l))}else r.push(new Ac(i))},i);let l=[];for(let e=n;eDc&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Ac(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(wc.from(i.reverse()),a)}};Oc.empty=new Oc(wc.empty,0);function kc(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Ac=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},jc=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Mc=20;function Nc(e,t,n,r){let i=n.getMeta(Hc),a;if(i)return i.historyState;n.getMeta(Uc)&&(e=new jc(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Hc))return o.getMeta(Hc).redo?new jc(e.done.addTransform(n,void 0,r,Bc(t)),e.undone,Fc(n.mapping.maps),e.prevTime,e.prevComposition):new jc(e.done,e.undone.addTransform(n,void 0,r,Bc(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Pc(n,e.prevRanges)),s=o?Ic(e.prevRanges,n.mapping):Fc(n.mapping.maps);return new jc(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Bc(t)),Oc.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new jc(e.done.rebased(n,a),e.undone.rebased(n,a),Ic(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new jc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ic(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Pc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function Fc(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ic(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=Hc.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Lc(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Kc=Gc(!1,!0),qc=Gc(!0,!0);function Jc(e){return e.getMeta(Hc)!=null}function Yc(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Xc=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Yc({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Zc=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Qc=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),$c=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=Pt(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},el=e=>t=>e(t),tl=()=>({state:e,dispatch:t})=>lr(e,t),nl=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new w(r.doc.resolve(Math.max(o-1,0)))),!0},rl=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function il(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var al=e=>({tr:t,state:n,dispatch:r})=>{let i=il(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},ol=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},sl=e=>e.content?/^text(\*|\+)/.test(e.content):!1,cl=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:cl(e,n,`left`),to:cl(t,n,`right`)}),ul=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof w?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=ll(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(w.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},dl=()=>({commands:e})=>e.keyboardShortcut(`Enter`),fl=()=>({state:e,dispatch:t})=>cr(e,t);function pl(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function ml(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:pl(t[r])?t[r].test(e[r]):t[r]===e[r])}function hl(e,t,n={}){return e.find(e=>e.type===t&&ml(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function gl(e,t,n={}){return!!hl(e,t,n)}function _l(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!hl([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&gl([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=vl(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=_l(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=w.create(o,e.from,e.to);n.setSelection(t)}}return!0},bl=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(Tl()||wl())&&r.dom.focus(),El()&&!Tl()&&!wl()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!xl(n.state.selection))return o(),!0;let s=Cl(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Ol=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),kl=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Al=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&Al(r)}return e};function jl(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return Al(n)}function Ml(e){return typeof e?.nodesBetween==`function`}function Nl(e,t,n){if(Ml(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return s.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),Nl(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Pe({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Re.fromSchema(a).parseSlice(jl(e),n.parseOptions):Re.fromSchema(a).parse(jl(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Re.fromSchema(t);return n.slice?r.parseSlice(jl(e),n.parseOptions).content:r.parse(jl(e),n.parseOptions)}return Nl(``,t,n)}function Pl(e){return!(`type`in e)}function Fl(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(C.near(e.doc.resolve(o),n))}var Il=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Nl(t,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=Nl(t,a.schema,{parseOptions:c,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:l,to:u}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},d=!0,f=!0,p=Pl(i)?i.content:[i];if(p.forEach(e=>{e.check(),d=d?e.isText&&e.marks.length===0:!1,f=f?e.isBlock:!1}),l===u&&f){let{parent:e}=r.doc.resolve(l);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--l,u+=1)}let m;if(d)m=Array.isArray(t)?t.map(e=>e.text||``).join(``):Ml(t)?p.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(m,l,u);else{m=s.from(p);let e=r.doc.resolve(l),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&f&&(l=Math.max(0,l-1)),r.replaceWith(l,u,p)}n.updateSelection&&Fl(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:l,text:m}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:l,text:m})}return!0};function Ll(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=Ll(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=Nl(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&Fl(t,t.steps.length-1,-1)),!0):!1},zl=()=>({state:e,dispatch:t})=>rr(e,t),Bl=()=>({state:e,dispatch:t})=>ir(e,t),Vl=()=>({state:e,dispatch:t})=>Kn(e,t),Hl=()=>({state:e,dispatch:t})=>er(e,t),Ul=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Wl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Zt(e.doc,e.selection.$from.pos,-1);return r==null||!Ul(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Gl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Zt(e.doc,e.selection.$from.pos,1);return r==null||!Ul(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Kl=()=>({state:e,dispatch:t})=>qn(e,t),ql=()=>({state:e,dispatch:t})=>Jn(e,t);function Jl(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function Yl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=Yl(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Zl(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?il(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>ml(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Ql=(e,t={})=>({state:n,dispatch:r})=>Zl(n,il(e,n.schema),t)?ar(n,r):!1,$l=()=>({state:e,dispatch:t})=>ur(e,t),eu=e=>({state:t,dispatch:n})=>jr(il(e,t.schema))(t,n),tu=()=>({state:e,dispatch:t})=>or(e,t);function nu(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function ru(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var iu=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=nu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=il(e,r.schema)),s===`mark`&&(o=vl(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,ru(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(ru(a.attrs,t))))})})}),c},au=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),ou=()=>({tr:e,dispatch:t})=>{if(t){let t=new On(e.doc);e.setSelection(t)}return!0},su=()=>({state:e,dispatch:t})=>Zn(e,t),cu=()=>({state:e,dispatch:t})=>tr(e,t),lu=()=>({state:e,dispatch:t})=>pr(e,t),uu=()=>({state:e,dispatch:t})=>yr(e,t),du=()=>({state:e,dispatch:t})=>vr(e,t);function fu(e,t,n={},r={}){return Nl(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var pu=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=fu(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=Pl(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function mu(e,t){let n=vl(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function hu(e,t){let n=new xn(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function gu(e,t){let n=[];return e.descendants((e,r)=>{t(e)&&n.push({node:e,pos:r})}),n}function _u(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function vu(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function yu(e){return t=>vu(t.$from,e)}function k(e,t,n){return e.config[t]===void 0&&e.parent?k(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?k(e.parent,t,n):null}):e.config[t]}function bu(e){return e.map(e=>{let t=k(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...bu(t())]:e}).flat(10)}function xu(e,t){let n=Qe.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function Su(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var Cu={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},wu={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function Tu(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function Eu(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...Tu(n,r,e),attrs:n.attrs}}function Du(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function Ou(e,t){Du(e.nodes,t.nodes,`node`),Du(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,Eu(t,e.nodes[t],r,Cu))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,Eu(t,e.marks[t],n,wu))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function ku(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function Au(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function ju(e){let t=[],{nodeExtensions:n,markExtensions:r}=Au(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=k(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=k(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function Mu(e){return typeof e==`function`}function Nu(e,t=void 0,...n){return Mu(e)?t?e.bind(t)(...n):e(...n):e}function Pu(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Fu(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function Iu(e){let t=[],n=Fu(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...Iu(n[e]),...Iu(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function Lu(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>A(e,t),{})}function Ru(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function zu(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):Ru(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function Bu(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&Pu(t)?!1:t!=null))}function Vu(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Hu(e,t,n=ju(e)){let{nodeExtensions:r,markExtensions:i}=Au(e);return{topNode:r.find(e=>k(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Bu({...e.reduce((e,t)=>{let n=k(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:Nu(k(r,`content`,a)),marks:Nu(k(r,`marks`,a)),group:Nu(k(r,`group`,a)),inline:Nu(k(r,`inline`,a)),atom:Nu(k(r,`atom`,a)),selectable:Nu(k(r,`selectable`,a)),draggable:Nu(k(r,`draggable`,a)),code:Nu(k(r,`code`,a)),whitespace:Nu(k(r,`whitespace`,a)),linebreakReplacement:Nu(k(r,`linebreakReplacement`,a)),defining:Nu(k(r,`defining`,a)),isolating:Nu(k(r,`isolating`,a)),attrs:Object.fromEntries(i.map(Vu))}),s=Nu(k(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>zu(e,i)));let c=k(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:Lu(e,i)}));let l=k(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Bu({...e.reduce((e,t)=>{let n=k(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:Nu(k(r,`inclusive`,a)),excludes:Nu(k(r,`excludes`,a)),group:Nu(k(r,`group`,a)),spanning:Nu(k(r,`spanning`,a)),code:Nu(k(r,`code`,a)),attrs:Object.fromEntries(i.map(Vu))}),s=Nu(k(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>zu(e,i)));let c=k(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:Lu(e,i)})),[r.name,o]}))}}function Uu(e,t,n){if(n===void 0)return new Pe(Hu(e,t));let r=ku(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new Pe(n);return new Pe(Ou(Hu(e,t,Su(ju(e),i)),i))}function Wu(e){return e.sort((e,t)=>{let n=k(e,`priority`)||100,r=k(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Ku(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` -`,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{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 _d(e){return new hd(e)}function vd(e,t,n){let{selection:r}=t,i=null;if(bl(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var yd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=_l(e,r.schema);if(i){if(o){let e=pu(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return vd(r,n,c)},bd=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),xd=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=rl(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>xr(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>xr(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},Sd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=xl(e,0,n.content.size),i=T.create(n,r);t.setSelection(i)}return!0},Cd=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},wd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=w.atStart(n).from,o=w.atEnd(n).to,s=xl(r,a,o),c=xl(i,a,o),l=w.create(n,s,c);t.setSelection(l)}return!0},Td=e=>({state:t,dispatch:n})=>Pr(rl(e,t.schema))(t,n);function Ed(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var Dd=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=rd(l,s.node().type.name,s.node().attrs);if(a instanceof T&&a.node.isBlock)return!s.parentOffset||!Kt(o,s.pos)?!1:(r&&(e&&Ed(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:Il(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof w&&!a.empty?Bn.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=Kt(h,g,1,p);if(!p&&!_&&Kt(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof w&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&Ed(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},Od=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=rl(e,r.schema),{$from:c,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(l))return!1;let d=c.node(-1);if(d.type!==o)return!1;let f=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let e=s.empty,r=c.index(-1)?1:c.index(-2)?2:3;for(let t=c.depth-r;t>=c.depth-3;--t)e=s.from(c.node(t).copy(e));let i=c.indexAfter(-1){if(d>-1)return!1;e.isTextblock&&e.content.size===0&&(d=t+1)}),d>-1&&n.setSelection(w.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}let m=l.pos===c.end()?d.contentMatchAt(0).defaultType:null,h={...rd(f,d.type.name,d.attrs),...t},g={...rd(f,c.node().type.name,c.node().attrs),...t},_=c.parentOffset===0&&c.index(-1)===0,v=c.before(-1);n.delete(c.pos,l.pos);let y=_?d.attrs:h,b=m?[{type:o,attrs:y},{type:m,attrs:g}]:[{type:o,attrs:y}];if(!Kt(n.doc,c.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,s=t||e.$to.parentOffset&&e.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),_&&n.setNodeMarkup(v,void 0,h),!s||!i)return!0;let l=s.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function kd(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function Ad(e,t){if(e.pendingContent.length===0)return!0;let n=kd(t,s.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function jd(e,t,n){return n.validContent(s.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!Ad(t,n)||!n.validContent(s.from(e))?!1:(t.pendingContent.push(e),!0)}function Md(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=kd(n.listType,s.from(i),e.attrs);return a?n.itemType.validContent(s.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):Ad(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function Nd(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function Id(e){return!e||e===`1`?null:e}function Ld(e,t){return Id(e)===Id(t)}var Rd=(e,t)=>{let n=_u(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Jt(e.doc,n.pos))||!Ld(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},zd=(e,t)=>{let n=_u(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Jt(e.doc,r))||!Ld(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function Bd(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return w.between(r,i)}var Vd=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:c,chain:l,commands:u,can:d})=>{let{extensions:f,splittableMarks:p}=i.extensionManager,m=rl(e,o.schema),h=rl(t,o.schema),{selection:g,storedMarks:_}=o,{$from:v,$to:y}=g,b=v.blockRange(y),x=_||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;let S=_u(e=>ud(e.type.name,f))(g),ee=g.from===0&&g.to===o.doc.content.size,te=o.doc.content.content,ne=te.length===1?te[0]:null,re=ee&&ne&&ud(ne.type.name,f)?{node:ne,pos:0,depth:0}:null,ie=S??re,ae=!!S&&b.depth>=1&&b.depth-S.depth<=1,oe=!!re;if((ae||oe)&&ie){if(ie.node.type===m)return ee&&oe?l().command(({tr:e,dispatch:t})=>{let n=Bd(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(ud(ie.node.type.name,f)&&m.validContent(ie.node.content))return l().command(()=>(a.setNodeMarkup(ie.pos,m),!0)).command(()=>Rd(a,m)).command(()=>zd(a,m)).run();if(ud(ie.node.type.name,f)){let e=ie.node.firstChild?.type;if(e&&e!==h){let e=Pd(ie.node,{listType:m,itemType:h,isListNode:e=>ud(e.type.name,f)}),t=e?s.from(e):null;return!t||!m.validContent(t)?!1:l().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=m.create(r,t)}catch{return!1}if(a.replaceWith(ie.pos,ie.pos+ie.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=Fd(l,i),t=Fd(l,o);if(e!==null&&t!==null){let n=ie.pos+e+2+s,r=ie.pos+t+2+c;a.setSelection(w.create(a.doc,n,r))}}return!0}).command(()=>Rd(a,m)).command(()=>zd(a,m)).run()}}}return!n||!x||!c?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>Rd(a,m)).command(()=>zd(a,m)).run():l().command(()=>{let e=d().wrapInList(m,r),t=x.filter(e=>p.includes(e.type.name));return a.ensureMarks(t),e?!0:u.clearNodes()}).wrapInList(m,r).command(()=>Rd(a,m)).command(()=>zd(a,m)).run()},Hd=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=_l(e,r.schema);return ad(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Ud=(e,t,n={})=>({state:r,commands:i})=>{let a=rl(e,r.schema),o=rl(t,r.schema),s=Xl(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Wd=(e,t={})=>({state:n,commands:r})=>{let i=rl(e,n.schema);return Xl(n,i,t)?r.lift(i):r.wrapIn(i,t)},Gd=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},Kd=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},qd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=_l(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=gl(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},Jd=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Yd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=tu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=rl(e,r.schema)),s===`mark`&&(o=_l(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Xd=new D(`__tiptap_decorations__`),Zd=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Xd,{type:`force`,name:e}),!0),Qd=(e,t={})=>({state:n,dispatch:r})=>br(rl(e,n.schema),t)(n,r),$d=(e,t={})=>({state:n,dispatch:r})=>Dr(rl(e,n.schema),t)(n,r),ef=t({blur:()=>Xc,clearContent:()=>Zc,clearNodes:()=>Qc,command:()=>$c,createParagraphNear:()=>el,cut:()=>tl,deleteCurrentNode:()=>nl,deleteNode:()=>il,deleteRange:()=>al,deleteSelection:()=>ll,enter:()=>ul,exitCode:()=>dl,extendMarkRange:()=>vl,first:()=>yl,focus:()=>El,forEach:()=>Dl,insertContent:()=>Ol,insertContentAt:()=>Fl,insertDefaultBlock:()=>Ll,joinBackward:()=>Bl,joinDown:()=>zl,joinForward:()=>Vl,joinItemBackward:()=>Ul,joinItemForward:()=>Wl,joinTextblockBackward:()=>Gl,joinTextblockForward:()=>Kl,joinUp:()=>Rl,keyboardShortcut:()=>Yl,lift:()=>Zl,liftEmptyBlock:()=>Ql,liftListItem:()=>$l,newlineInCode:()=>eu,resetAttributes:()=>ru,scrollIntoView:()=>iu,selectAll:()=>au,selectNodeBackward:()=>ou,selectNodeForward:()=>su,selectParentNode:()=>cu,selectTextblockEnd:()=>lu,selectTextblockStart:()=>uu,setContent:()=>fu,setMark:()=>yd,setMeta:()=>bd,setNode:()=>xd,setNodeSelection:()=>Sd,setTextDirection:()=>Cd,setTextSelection:()=>wd,sinkListItem:()=>Td,splitBlock:()=>Dd,splitListItem:()=>Od,toggleList:()=>Vd,toggleMark:()=>Hd,toggleNode:()=>Ud,toggleWrap:()=>Wd,undoInputRule:()=>Gd,unsetAllMarks:()=>Kd,unsetMark:()=>qd,unsetTextDirection:()=>Jd,updateAttributes:()=>Yd,updateDecorations:()=>Zd,wrapIn:()=>Qd,wrapInList:()=>$d}),tf=new WeakMap;function nf(e,t){tf.set(e,(tf.get(e)??0)+1);try{return t()}finally{let t=(tf.get(e)??1)-1;t>0?tf.set(e,t):tf.delete(e)}}function rf(e){return tf.has(e)}var af=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},of=typeof process<`u`&&!1;function sf(e){return e.kind===`widget`}function cf(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&sf(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function lf(e,t,n){let{decorations:r,widgetKeys:i}=cf(t,n);return{set:k.create(e,r),widgetKeys:i}}function uf({position:e,from:t,to:n,docSize:r}){return euf({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function ff(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function pf(e){let t=new Map,n=new Map;for(let r of e.find()){let e=ff(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function mf(e){return e.jsonID===`attr`}function hf(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||mf(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function gf(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function _f(e,t){if(e.steps.some(e=>!hf(e)))return{type:`full`};let n=Qu(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!mf(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=gf(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function vf(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function yf(e,t,n){let r=t.decorationSetsByExtension[e]??k.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:vf(r,n.mapping,n.doc,i),widgetKeys:i}}function bf(e,t){let n=Object.values(t).flatMap(e=>e.find());return k.create(e,n)}function xf(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function Sf(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function Cf(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var wf=new Set,Tf=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Xd.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>Sf(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Xd.getState(this.editor.state)?.widgetKeys??wf}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new E({key:Xd,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:xf(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Xd),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return nf(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!Cf(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=yf(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:xf(u)}}},props:{decorations(e){return Xd.getState(e)?.mergedDecorationSet??k.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=_f(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??k.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=vf(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>uf({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=ff(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=cf(df({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return lf(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!of)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=pf(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:bf(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):bf(n.doc,r)}};function Ef(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof T){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function Df(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function Of(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)}function kf(e){return typeof e==`number`}function Af(e){return Object.prototype.toString.call(e).slice(8,-1)}function jf(e){return Af(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Mf(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function Nf(e){return/\s/.test(e)}function Pf(e){return/^[a-zA-Z]$/.test(e)}function Ff(e){return/^\w$/.test(e)}function If(e,t){for(;t=e.length));){let i=Uf(e,r,t);i.token&&n.push(i.token),r=i.nextIndex}return n}function Gf(e){let t={};return Wf(e,`shortcode`).forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),t}function Kf(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=Gf,serializeAttributes:a=Kf,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 Jf(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 Yf(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function Xf(e,t,n){let r=t.split(` -`),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{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 vd(e){return new gd(e)}function yd(e,t,n){let{selection:r}=t,i=null;if(xl(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var bd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=vl(e,r.schema);if(i){if(o){let e=mu(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return yd(r,n,c)},xd=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Sd=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=il(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>xr(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>xr(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},Cd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=Sl(e,0,n.content.size),i=T.create(n,r);t.setSelection(i)}return!0},wd=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},Td=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=w.atStart(n).from,o=w.atEnd(n).to,s=Sl(r,a,o),c=Sl(i,a,o),l=w.create(n,s,c);t.setSelection(l)}return!0},Ed=e=>({state:t,dispatch:n})=>Pr(il(e,t.schema))(t,n);function Dd(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var Od=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=id(l,s.node().type.name,s.node().attrs);if(a instanceof T&&a.node.isBlock)return!s.parentOffset||!Kt(o,s.pos)?!1:(r&&(e&&Dd(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:Ll(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof w&&!a.empty?Bn.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=Kt(h,g,1,p);if(!p&&!_&&Kt(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof w&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&Dd(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},kd=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=il(e,r.schema),{$from:c,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(l))return!1;let d=c.node(-1);if(d.type!==o)return!1;let f=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let e=s.empty,r=c.index(-1)?1:c.index(-2)?2:3;for(let t=c.depth-r;t>=c.depth-3;--t)e=s.from(c.node(t).copy(e));let i=c.indexAfter(-1){if(d>-1)return!1;e.isTextblock&&e.content.size===0&&(d=t+1)}),d>-1&&n.setSelection(w.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}let m=l.pos===c.end()?d.contentMatchAt(0).defaultType:null,h={...id(f,d.type.name,d.attrs),...t},g={...id(f,c.node().type.name,c.node().attrs),...t},_=c.parentOffset===0&&c.index(-1)===0,v=c.before(-1);n.delete(c.pos,l.pos);let y=_?d.attrs:h,b=m?[{type:o,attrs:y},{type:m,attrs:g}]:[{type:o,attrs:y}];if(!Kt(n.doc,c.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,s=t||e.$to.parentOffset&&e.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),_&&n.setNodeMarkup(v,void 0,h),!s||!i)return!0;let l=s.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function Ad(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function jd(e,t){if(e.pendingContent.length===0)return!0;let n=Ad(t,s.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function Md(e,t,n){return n.validContent(s.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!jd(t,n)||!n.validContent(s.from(e))?!1:(t.pendingContent.push(e),!0)}function Nd(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=Ad(n.listType,s.from(i),e.attrs);return a?n.itemType.validContent(s.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):jd(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function Pd(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function Ld(e){return!e||e===`1`?null:e}function Rd(e,t){return Ld(e)===Ld(t)}var zd=(e,t)=>{let n=yu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Jt(e.doc,n.pos))||!Rd(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},Bd=(e,t)=>{let n=yu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Jt(e.doc,r))||!Rd(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function Vd(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return w.between(r,i)}var Hd=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:c,chain:l,commands:u,can:d})=>{let{extensions:f,splittableMarks:p}=i.extensionManager,m=il(e,o.schema),h=il(t,o.schema),{selection:g,storedMarks:_}=o,{$from:v,$to:y}=g,b=v.blockRange(y),x=_||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;let S=yu(e=>dd(e.type.name,f))(g),ee=g.from===0&&g.to===o.doc.content.size,te=o.doc.content.content,ne=te.length===1?te[0]:null,re=ee&&ne&&dd(ne.type.name,f)?{node:ne,pos:0,depth:0}:null,ie=S??re,ae=!!S&&b.depth>=1&&b.depth-S.depth<=1,oe=!!re;if((ae||oe)&&ie){if(ie.node.type===m)return ee&&oe?l().command(({tr:e,dispatch:t})=>{let n=Vd(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(dd(ie.node.type.name,f)&&m.validContent(ie.node.content))return l().command(()=>(a.setNodeMarkup(ie.pos,m),!0)).command(()=>zd(a,m)).command(()=>Bd(a,m)).run();if(dd(ie.node.type.name,f)){let e=ie.node.firstChild?.type;if(e&&e!==h){let e=Fd(ie.node,{listType:m,itemType:h,isListNode:e=>dd(e.type.name,f)}),t=e?s.from(e):null;return!t||!m.validContent(t)?!1:l().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=m.create(r,t)}catch{return!1}if(a.replaceWith(ie.pos,ie.pos+ie.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=Id(l,i),t=Id(l,o);if(e!==null&&t!==null){let n=ie.pos+e+2+s,r=ie.pos+t+2+c;a.setSelection(w.create(a.doc,n,r))}}return!0}).command(()=>zd(a,m)).command(()=>Bd(a,m)).run()}}}return!n||!x||!c?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>zd(a,m)).command(()=>Bd(a,m)).run():l().command(()=>{let e=d().wrapInList(m,r),t=x.filter(e=>p.includes(e.type.name));return a.ensureMarks(t),e?!0:u.clearNodes()}).wrapInList(m,r).command(()=>zd(a,m)).command(()=>Bd(a,m)).run()},Ud=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=vl(e,r.schema);return od(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Wd=(e,t,n={})=>({state:r,commands:i})=>{let a=il(e,r.schema),o=il(t,r.schema),s=Zl(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Gd=(e,t={})=>({state:n,commands:r})=>{let i=il(e,n.schema);return Zl(n,i,t)?r.lift(i):r.wrapIn(i,t)},Kd=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},qd=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},Jd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=vl(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=_l(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},Yd=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Xd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=nu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=il(e,r.schema)),s===`mark`&&(o=vl(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Zd=new D(`__tiptap_decorations__`),Qd=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Zd,{type:`force`,name:e}),!0),$d=(e,t={})=>({state:n,dispatch:r})=>br(il(e,n.schema),t)(n,r),ef=(e,t={})=>({state:n,dispatch:r})=>Dr(il(e,n.schema),t)(n,r),tf=t({blur:()=>Zc,clearContent:()=>Qc,clearNodes:()=>$c,command:()=>el,createParagraphNear:()=>tl,cut:()=>nl,deleteCurrentNode:()=>rl,deleteNode:()=>al,deleteRange:()=>ol,deleteSelection:()=>ul,enter:()=>dl,exitCode:()=>fl,extendMarkRange:()=>yl,first:()=>bl,focus:()=>Dl,forEach:()=>Ol,insertContent:()=>kl,insertContentAt:()=>Il,insertDefaultBlock:()=>Rl,joinBackward:()=>Vl,joinDown:()=>Bl,joinForward:()=>Hl,joinItemBackward:()=>Wl,joinItemForward:()=>Gl,joinTextblockBackward:()=>Kl,joinTextblockForward:()=>ql,joinUp:()=>zl,keyboardShortcut:()=>Xl,lift:()=>Ql,liftEmptyBlock:()=>$l,liftListItem:()=>eu,newlineInCode:()=>tu,resetAttributes:()=>iu,scrollIntoView:()=>au,selectAll:()=>ou,selectNodeBackward:()=>su,selectNodeForward:()=>cu,selectParentNode:()=>lu,selectTextblockEnd:()=>uu,selectTextblockStart:()=>du,setContent:()=>pu,setMark:()=>bd,setMeta:()=>xd,setNode:()=>Sd,setNodeSelection:()=>Cd,setTextDirection:()=>wd,setTextSelection:()=>Td,sinkListItem:()=>Ed,splitBlock:()=>Od,splitListItem:()=>kd,toggleList:()=>Hd,toggleMark:()=>Ud,toggleNode:()=>Wd,toggleWrap:()=>Gd,undoInputRule:()=>Kd,unsetAllMarks:()=>qd,unsetMark:()=>Jd,unsetTextDirection:()=>Yd,updateAttributes:()=>Xd,updateDecorations:()=>Qd,wrapIn:()=>$d,wrapInList:()=>ef}),nf=new WeakMap;function rf(e,t){nf.set(e,(nf.get(e)??0)+1);try{return t()}finally{let t=(nf.get(e)??1)-1;t>0?nf.set(e,t):nf.delete(e)}}function af(e){return nf.has(e)}var of=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},sf=typeof process<`u`&&!1;function cf(e){return e.kind===`widget`}function lf(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&cf(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function uf(e,t,n){let{decorations:r,widgetKeys:i}=lf(t,n);return{set:xs.create(e,r),widgetKeys:i}}function df({position:e,from:t,to:n,docSize:r}){return edf({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function pf(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function mf(e){let t=new Map,n=new Map;for(let r of e.find()){let e=pf(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function hf(e){return e.jsonID===`attr`}function gf(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||hf(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function _f(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function vf(e,t){if(e.steps.some(e=>!gf(e)))return{type:`full`};let n=$u(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!hf(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=_f(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function yf(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function bf(e,t,n){let r=t.decorationSetsByExtension[e]??xs.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:yf(r,n.mapping,n.doc,i),widgetKeys:i}}function xf(e,t){let n=Object.values(t).flatMap(e=>e.find());return xs.create(e,n)}function Sf(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function Cf(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function wf(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var Tf=new Set,Ef=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Zd.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>Cf(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Zd.getState(this.editor.state)?.widgetKeys??Tf}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new E({key:Zd,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:Sf(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Zd),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return rf(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!wf(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=bf(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:Sf(u)}}},props:{decorations(e){return Zd.getState(e)?.mergedDecorationSet??xs.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=vf(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??xs.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=yf(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>df({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=pf(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=lf(ff({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return uf(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!sf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=mf(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:xf(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):xf(n.doc,r)}};function Df(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof T){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function Of(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function kf(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Af(e){return typeof e==`number`}function jf(e){return Object.prototype.toString.call(e).slice(8,-1)}function Mf(e){return jf(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Nf(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function Pf(e){return/\s/.test(e)}function Ff(e){return/^[a-zA-Z]$/.test(e)}function If(e){return/^\w$/.test(e)}function Lf(e,t){for(;t=e.length));){let i=Wf(e,r,t);i.token&&n.push(i.token),r=i.nextIndex}return n}function Kf(e){let t={},n=e.filter(e=>e.type===`class`).map(e=>e.name),r=e.find(e=>e.type===`id`);return n.length>0&&(t.class=n.join(` `)),r&&(t.id=r.name),e.forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),e.forEach(e=>{e.type===`boolean`&&(t[e.name]=!0)}),t}function qf(e){return e?.trim()?Kf(Gf(e,`pandoc`)):{}}function Jf(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e!==`class`&&e!==`id`&&(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function Yf(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=qf,serializeAttributes:a=Jf,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m){if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m)}return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=u(e.attrs||{}),r=a(n),i=r?` {${r}}`:``,o=t.renderChildren(e.content||[],` + +`);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(;o0)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;oe.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(;o0)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;oe.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){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=bc(a);r.push(o);let s=A(t,`addInputRules`,n);if(ld(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=lp({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=A(t,`addPasteRules`,n);if(ld(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=_p({editor:e,rules:t});r.push(...n)}}let l=A(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=A(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:nd(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new Tf({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=ku(this.extensions);return this.hasSchemaSpec?bu(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Ou(this.extensions);return Object.fromEntries(t.filter(e=>!!A(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=A(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:rl(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=Iu(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Uu([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:nd(n.name,this.schema)},i=A(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Uu([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:nd(n.name,this.schema)},i=A(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=Ou(this.extensions);return Object.fromEntries(t.filter(e=>!!A(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=A(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:_l(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=Iu(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{np(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:nd(e.name,this.schema)};e.type===`mark`&&((ju(A(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(ju(A(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=A(e,`onBeforeCreate`,t),r=A(e,`onCreate`,t),i=A(e,`onUpdate`,t),a=A(e,`onSelectionUpdate`,t),o=A(e,`onTransaction`,t),s=A(e,`onFocus`,t),c=A(e,`onBlur`,t),l=A(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};vp.resolve=Wu,vp.sort=Uu,vp.flatten=vu;var yp=class e extends up{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},bp=yp.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new E({key:new D(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=qu(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Gu(r,{from:e.pos,to:t.pos},s)).join(o??` +`);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){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=xc(a);r.push(o);let s=k(t,`addInputRules`,n);if(ud(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=mp({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=k(t,`addPasteRules`,n);if(ud(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=Sp({editor:e,rules:t});r.push(...n)}}let l=k(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=k(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:rd(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new Ef({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=ju(this.extensions);return this.hasSchemaSpec?Su(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Au(this.extensions);return Object.fromEntries(t.filter(e=>!!k(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=k(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:il(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=Lu(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Wu([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:rd(n.name,this.schema)},i=k(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Wu([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:rd(n.name,this.schema)},i=k(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=Au(this.extensions);return Object.fromEntries(t.filter(e=>!!k(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=k(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:vl(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=Lu(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{sp(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:rd(e.name,this.schema)};e.type===`mark`&&((Nu(k(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(Nu(k(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=k(e,`onBeforeCreate`,t),r=k(e,`onCreate`,t),i=k(e,`onUpdate`,t),a=k(e,`onSelectionUpdate`,t),o=k(e,`onTransaction`,t),s=k(e,`onFocus`,t),c=k(e,`onBlur`,t),l=k(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};Cp.resolve=Gu,Cp.sort=Wu,Cp.flatten=bu;var wp=class e extends hp{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Tp=wp.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new E({key:new D(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=Ju(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Ku(r,{from:e.pos,to:t.pos},s)).join(o??` -`)}}})]}}),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,{from:0,to:0});if(!md(n))return;t=n.slice.content}catch{return}t instanceof s||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var Np=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Pp=`.ProseMirror { +`)}}})]}}),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,{from:0,to:0});if(!hd(n))return;t=n.slice.content}catch{return}t instanceof s||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var Rp=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},zp=`.ProseMirror { 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.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[wp,bp.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),xp,Ep,Dp,kp.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),Cp,Op,Sp,Ap.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new vp(n,this)}createCommandManager(){this.commandManager=new Yc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=du(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=du(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Bn.create({doc:t,schema:this.schema,selection:Sl(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return Au(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new ec(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Yu(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return od(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yu(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`,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.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[kp,Tp.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ep,jp,Mp,Pp.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),Op,Np,Dp,Fp.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new Cp(n,this)}createCommandManager(){this.commandManager=new Xc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=fu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=fu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Bn.create({doc:t,schema:this.schema,selection:Cl(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return Mu(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new tc(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Xu(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return sd(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return xu(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,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;ln.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.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,Bp(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}},Hp=class e extends up{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function Up(e){return new fp({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=ju(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.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>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var Wp=()=>new Map,Gp=e=>{let t=Wp();return e.forEach((e,n)=>{t.set(n,e)}),t},Kp=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},qp=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Jp=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Yp=()=>new Set,Xp=e=>e[e.length-1],Zp=(e,t)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{let n=Array(e);for(let r=0;r{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Qp((this._observers.get(e)||Wp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wp()}},im=class{constructor(){this._observers=Wp()}on(e,t){Kp(this._observers,e,Yp).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Qp((this._observers.get(e)||Wp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Wp()}},am=Math.floor,om=Math.abs,sm=(e,t)=>ee>t?e:t;Number.isNaN;var lm=e=>e===0?1/e<0:e<0,um=1<<29,dm=2**53-1,fm=-(2**53-1),pm=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&am(e)===e);Number.isNaN,Number.parseInt;var mm=String.fromCharCode;String.fromCodePoint,mm(65535);var hm=e=>e.toLowerCase(),gm=/^\s*/g,_m=e=>e.replace(gm,``),vm=/([A-Z])/g,ym=(e,t)=>_m(e.replace(vm,e=>`${t}${hm(e)}`)),bm=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;exm.encode(e):bm,Cm=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Cm&&Cm.decode(new Uint8Array).length===1&&(Cm=null);var wm=(e,t)=>tm(t,()=>e).join(``),Tm=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Em=()=>new Tm,Dm=e=>{let t=Em();return e(t),km(t)},Om=e=>{let t=e.cpos;for(let n=0;n{let t=new Uint8Array(Om(e)),n=0;for(let r=0;r{let n=e.cbuf.length;n-e.cpos{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Mm=jm,j=(e,t)=>{for(;t>127;)jm(e,128|127&t),t=am(t/128);jm(e,127&t)},Nm=(e,t)=>{let n=lm(t);for(n&&(t=-t),jm(e,(t>63?128:0)|(n?64:0)|63&t),t=am(t/64);t>0;)jm(e,(t>127?128:0)|127&t),t=am(t/128)},Pm=new Uint8Array(3e4),Fm=Pm.length/3,Im=xm&&xm.encodeInto?(e,t)=>{if(t.length{let n=unescape(encodeURIComponent(t)),r=n.length;j(e,r);for(let t=0;t{let n=e.cbuf.length,r=e.cpos,i=sm(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(cm(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Rm=(e,t)=>{j(e,t.byteLength),Lm(e,t)},zm=(e,t)=>{Am(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Bm=(e,t)=>zm(e,4).setFloat32(0,t,!1),Vm=(e,t)=>zm(e,8).setFloat64(0,t,!1),Hm=(e,t)=>zm(e,8).setBigInt64(0,t,!1),Um=new DataView(new ArrayBuffer(4)),Wm=e=>(Um.setFloat32(0,e),Um.getFloat32(0)===e),Gm=(e,t)=>{switch(typeof t){case`string`:jm(e,119),Im(e,t);break;case`number`:pm(t)&&om(t)<=2147483647?(jm(e,125),Nm(e,t)):Wm(t)?(jm(e,124),Bm(e,t)):(jm(e,123),Vm(e,t));break;case`bigint`:jm(e,122),Hm(e,t);break;case`object`:if(t===null)jm(e,126);else if(nm(t)){jm(e,117),j(e,t.length);for(let n=0;n0&&j(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},qm=e=>{e.count>0&&(Nm(e.encoder,e.count===1?e.s:-e.s),e.count>1&&j(e.encoder,e.count-2))},Jm=class{constructor(){this.encoder=new Tm,this.s=0,this.count=0}write(e){this.s===e?this.count++:(qm(this),this.count=1,this.s=e)}toUint8Array(){return qm(this),km(this.encoder)}},Ym=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Nm(e.encoder,t),e.count>1&&j(e.encoder,e.count-2)}},Xm=class{constructor(){this.encoder=new Tm,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ym(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ym(this),km(this.encoder)}},Zm=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Jm}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Tm;return this.sarr.push(this.s),this.s=``,Im(e,this.sarr.join(``)),Lm(e,this.lensE.toUint8Array()),km(e)}},Qm=e=>Error(e),$m=()=>{throw Qm(`Method unimplemented`)},eh=()=>{throw Qm(`Unexpected case`)},th=Qm(`Unexpected end of array`),nh=Qm(`Integer out of Range`),rh=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw th;return new Uint8Array(e.buffer,e.byteOffset+t,n)},ih=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw th;return new DataView(e.buffer,e.byteOffset+t,n)},ah=class{constructor(e){this.arr=e,this.pos=0}},oh=e=>new ah(e),sh=e=>e.pos!==e.arr.length,ch=(e,t)=>{let n=rh(e.arr,e.pos,t);return e.pos+=t,n},lh=e=>ch(e,M(e)),uh=e=>e.arr[e.pos++],M=e=>{let t=0,n=1,r=e.arr.length;for(;e.posdm)throw nh}throw th},dh=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.posdm)throw nh}throw th},fh=Cm?e=>Cm.decode(lh(e)):e=>{let t=M(e);if(t===0)return``;{let n=String.fromCodePoint(uh(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(uh(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},ph=(e,t)=>{let n=ih(e.arr,e.pos,t);return e.pos+=t,n},mh=[e=>void 0,e=>null,dh,e=>ph(e,4).getFloat32(0,!1),e=>ph(e,8).getFloat64(0,!1),e=>ph(e,8).getBigInt64(0,!1),e=>!1,e=>!0,fh,e=>{let t=M(e),n={};for(let r=0;r{let t=M(e),n=[];for(let r=0;rmh[127-uh(e)](e),gh=class extends ah{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=sh(this)?M(this)+1:-1),this.count--,this.s}},_h=class extends ah{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=dh(this);let e=lm(this.s);this.count=1,e&&(this.s=-this.s,this.count=M(this)+2)}return this.count--,this.s}},vh=class extends ah{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=dh(this),t=e&1;this.diff=am(e/2),this.count=1,t&&(this.count=M(this)+2)}return this.s+=this.diff,this.count--,this.s}},yh=class{constructor(e){this.decoder=new _h(e),this.str=fh(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var bh=crypto.getRandomValues.bind(crypto),xh=Math.random,Sh=()=>bh(new Uint32Array(1))[0],Ch=e=>e[am(xh()*e.length)],wh=`10000000-1000-4000-8000-100000000000`,Th=()=>wh.replace(/[018]/g,e=>(e^Sh()&15>>e/4).toString(16)),Eh=Date.now,Dh=e=>new Promise(e);Promise.all.bind(Promise);var Oh=e=>e===void 0?null:e,kh=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(kh=localStorage)}catch{}var Ah=kh,jh=Symbol(`Equality`),Mh=(e,t)=>e===t||!!e?.[jh]?.(t)||!1,Nh=e=>typeof e==`object`,Ph=Object.assign,Fh=Object.keys,Ih=(e,t)=>{for(let n in e)t(e[n],n)},Lh=e=>Fh(e).length,Rh=e=>{for(let t in e)return!1;return!0},zh=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Bh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Vh=(e,t)=>e===t||Lh(e)===Lh(t)&&zh(e,(e,n)=>(e!==void 0||Bh(t,n))&&Mh(t[n],e)),Hh=Object.freeze,Uh=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Uh(e[t])}return Hh(e)},Wh=(e,t,n=0)=>{try{for(;ne,Kh=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[jh]!=null)return e[jh](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;nt.includes(e),Jh=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Yh=typeof window<`u`&&typeof document<`u`&&!Jh;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Xh,Zh=[],Qh=()=>{if(Xh===void 0){if(Jh){Xh=Wp();let e=process.argv,t=null;for(let n=0;n{if(e.length!==0){let[t,n]=e.split(`=`);Xh.set(`--${ym(t,`-`)}`,n),Xh.set(`-${ym(t,`-`)}`,n)}})):Xh=Wp()}return Xh},$h=e=>Qh().has(e),eg=e=>Oh(Jh?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Ah.getItem(e)),tg=e=>$h(`--`+e)||eg(e)!==null,ng=tg(`production`),rg=Jh&&qh({}.FORCE_COLOR,[`true`,`1`,`2`])||!$h(`--no-colors`)&&!tg(`no-color`)&&(!Jh||process.stdout.isTTY)&&(!Jh||$h(`--color`)||eg(`COLORTERM`)!==null||(eg(`TERM`)||``).includes(`color`)),ig=e=>new Uint8Array(e),ag=e=>{let t=``;for(let n=0;nBuffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),sg=e=>{let t=atob(e),n=ig(t.length);for(let e=0;enew Uint8Array(Buffer.from(e,`base64`)),lg=Yh?ag:og,ug=Yh?sg:cg,dg=e=>{let t=ig(e.byteLength);return t.set(e),t},fg=e=>Dm(t=>Gm(t,e)),pg=class{constructor(e,t){this.left=e,this.right=t}},mg=(e,t)=>new pg(e,t),hg=e=>e.next()>=.5,gg=(e,t,n)=>am(e.next()*(n+1-t)+t),_g=(e,t,n)=>am(e.next()*(n+1-t)+t),vg=(e,t,n)=>_g(e,t,n),yg=e=>mm(vg(e,97,122)),bg=(e,t=0,n=20)=>{let r=vg(e,t,n),i=``;for(let t=0;tt[vg(e,0,t.length-1)],Sg=Symbol(`0schema`),Cg=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(wm(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(` -`)}},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;if(Hg.check(e)){let t={};for(let n in e)t[n]=S_(e[n]);return Bg(t)}if(Zg.check(e))return i_(...e.map(S_));if(x_.check(e))return jg(e);if(n_.check(e))return Dg(e);eh()},C_=ng?()=>{}:(e,t)=>{let n=new Cg;if(!t.check(e,n))throw Qm(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},w_=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:S_(e),h:t}),this}else(e){return this.if(s_,e)}done(){return(e,t)=>{for(let n=0;nnew w_(e))(s_).if(p_,(e,t)=>gg(t,fm,dm)).if(h_,(e,t)=>bg(t)).if(__,(e,t)=>hg(t)).if(u_,(e,t)=>BigInt(gg(t,fm,dm))).if(a_,(e,t)=>E_(t,xg(t,e.shape))).if(Vg,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Lg.check(i)){if(hg(t))continue;i=i.shape}n[r]=T_(i,t)}return n}).if(Xg,(e,t)=>{let n=[],r=_g(t,0,42);for(let i=0;ixg(t,e.shape)).if(b_,(e,t)=>null).if(t_,(e,t)=>{let n=E_(t,e.res);return()=>n}).if(c_,(e,t)=>E_(t,xg(t,[f_,m_,y_,v_,l_,g_,Yg(f_),Wg(i_(`a`,`b`,`c`),f_)]))).if(Gg,(e,t)=>{let n={},r=gg(t,0,3);for(let i=0;iT_(S_(t),e),D_=typeof document<`u`?document:{};kg(e=>e.nodeType===M_),typeof DOMParser<`u`&&new DOMParser,kg(e=>e.nodeType===k_),kg(e=>e.nodeType===A_);var O_=e=>qp(e,(e,t)=>`${t}:${e};`).join(``),k_=D_.ELEMENT_NODE,A_=D_.TEXT_NODE;D_.CDATA_SECTION_NODE,D_.COMMENT_NODE;var j_=D_.DOCUMENT_NODE;D_.DOCUMENT_TYPE_NODE;var M_=D_.DOCUMENT_FRAGMENT_NODE;kg(e=>e.nodeType===j_);var N_=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),P_=(e,t)=>new N_(setTimeout(t,e)),F_=Symbol,I_=F_(),L_=F_(),R_=F_(),z_=F_(),B_=F_(),V_=F_(),H_=F_(),U_=F_(),W_=F_(),G_=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r0&&n.push(t.join(``));r{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Wp(),i=[],a=0;for(;a0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a{console.log(...q_(e)),X_.forEach(t=>t.print(e))},Y_=(...e)=>{console.warn(...q_(e)),e.unshift(U_),X_.forEach(t=>t.print(e))},X_=Yp(),Z_=e=>({[Symbol.iterator](){return this},next:e}),Q_=(e,t)=>Z_(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),$_=(e,t)=>Z_(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),ev=class{constructor(e,t){this.clock=e,this.len=t}},tv=class{constructor(){this.clients=new Map}},nv=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r{let n=0,r=e.length-1;for(;n<=r;){let i=am((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t{let n=e.clients.get(t.client);return n!==void 0&&rv(n,t.clock)!==null},av=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t=i.clock?e[n-1]=new ev(r.clock,cm(r.len,i.clock+i.len-r.clock)):(n{let t=new tv;for(let n=0;n{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t{Kp(e.clients,t,()=>[]).push(new ev(n,r))},cv=()=>new tv,lv=e=>{let t=cv();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t0&&t.clients.set(n,r)}),t},uv=(e,t)=>{j(e.restEncoder,t.clients.size),Qp(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),j(e.restEncoder,t);let r=n.length;j(e.restEncoder,r);for(let t=0;t{let t=new tv,n=M(e.restDecoder);for(let r=0;r0){let i=Kp(t.clients,n,()=>[]);for(let t=0;t{let r=new tv,i=M(e.restDecoder);for(let a=0;a0){let e=new Sv;return j(e.restEncoder,0),uv(e,r),e.toUint8Array()}return null},pv=Sh,mv=class e extends rm{constructor({guid:e=Th(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=pv(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new py,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Dh(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Dh(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&jy(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Qp(this.subdocs).map(e=>e.guid))}transact(e,t=null){return jy(this,e,t)}get(e,t=sb){let n=Kp(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==sb&&r!==t){if(r===sb){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,Ob)}getText(e=``){return this.get(e,Yb)}getMap(e=``){return this.get(e,jb)}getXmlElement(e=``){return this.get(e,ex)}getXmlFragment(e=``){return this.get(e,Qb)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Qp(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,jy(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},hv=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return M(this.restDecoder)}readDsLen(){return M(this.restDecoder)}},gv=class extends hv{readLeftID(){return N(M(this.restDecoder),M(this.restDecoder))}readRightID(){return N(M(this.restDecoder),M(this.restDecoder))}readClient(){return M(this.restDecoder)}readInfo(){return uh(this.restDecoder)}readString(){return fh(this.restDecoder)}readParentInfo(){return M(this.restDecoder)===1}readTypeRef(){return M(this.restDecoder)}readLen(){return M(this.restDecoder)}readAny(){return hh(this.restDecoder)}readBuf(){return dg(lh(this.restDecoder))}readJSON(){return JSON.parse(fh(this.restDecoder))}readKey(){return fh(this.restDecoder)}},_v=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=M(this.restDecoder),this.dsCurrVal}readDsLen(){let e=M(this.restDecoder)+1;return this.dsCurrVal+=e,e}},vv=class extends _v{constructor(e){super(e),this.keys=[],M(e),this.keyClockDecoder=new vh(lh(e)),this.clientDecoder=new _h(lh(e)),this.leftClockDecoder=new vh(lh(e)),this.rightClockDecoder=new vh(lh(e)),this.infoDecoder=new gh(lh(e),uh),this.stringDecoder=new yh(lh(e)),this.parentInfoDecoder=new gh(lh(e),uh),this.typeRefDecoder=new _h(lh(e)),this.lenDecoder=new _h(lh(e))}readLeftID(){return new Gv(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Gv(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return hh(this.restDecoder)}readBuf(){return lh(this.restDecoder)}readJSON(){return hh(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e{r=cm(r,t[0].id.clock);let i=_y(t,r);j(e.restEncoder,t.length-i),e.writeClient(n),j(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n{let r=new Map;n.forEach((e,n)=>{hy(t,n)>e&&r.set(n,e)}),my(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),j(e.restEncoder,r.size),Qp(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Cv(e,t.clients.get(n),n,r)})},Tv=(e,t)=>{let n=Wp(),r=M(e.restDecoder);for(let i=0;i{let r=[],i=Qp(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new py,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==qx){let i=Kp(d,u.id.client,()=>hy(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,hy(t,a)),f();else{u=e.refs[e.i++];continue}}else(i===0||i0)u=r.pop();else if(o!==null&&o.i0){let e=new Sv;return wv(e,s,new Map),j(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Dv=(e,t)=>wv(e,t.doc.store,t.beforeState),Ov=(e,t,n,r=new vv(e))=>jy(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Ev(e,i,Tv(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(nt)&&o.missing.set(e,t)}o.update=Vy([o.update,a.update])}}else i.pendingStructs=a;let s=fv(r,e,i);if(i.pendingDs){let t=new vv(oh(i.pendingDs));M(t.restDecoder);let n=fv(t,e,i);i.pendingDs=s&&n?Vy([s,n]):s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,kv(e.doc,t)}},n,!1),kv=(e,t,n,r=vv)=>{let i=oh(t);Ov(i,e,n,new r(i))},Av=(e,t,n)=>kv(e,t,n,gv),jv=(e,t,n=new Map)=>{wv(e,t.store,n),uv(e,lv(t.store))},Mv=(e,t=new Uint8Array([0]),n=new Sv)=>{jv(n,e,Fv(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Hy(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===bv)return zy(r.map((e,t)=>t===0?e:qy(e)));if(n.constructor===Sv)return Vy(r)}return r[0]},Nv=(e,t)=>Mv(e,t,new bv),Pv=e=>{let t=new Map,n=M(e.restDecoder);for(let r=0;rPv(new hv(oh(e))),Iv=(e,t)=>(j(e.restEncoder,t.size),Qp(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{j(e.restEncoder,t),j(e.restEncoder,n)}),e),Lv=(e,t)=>Iv(e,my(t.store)),Rv=(e,t=new xv)=>(e instanceof Map?Iv(t,e):Lv(t,e),t.toUint8Array()),zv=e=>Rv(e,new yv),Bv=class{constructor(){this.l=[]}},Vv=()=>new Bv,Hv=(e,t)=>e.l.push(t),Uv=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Wv=(e,t,n)=>Wh(e.l,[t,n]),Gv=class{constructor(e,t){this.client=e,this.clock=t}},Kv=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,N=(e,t)=>new Gv(e,t),qv=e=>N(M(e),M(e)),Jv=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw eh()},Yv=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Xv=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Zv=e=>new Xv(e.type==null?null:N(e.type.client,e.type.clock),e.tname??null,e.item==null?null:N(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Qv=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},$v=(e,t,n=0)=>new Qv(e,t,n),ey=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Jv(e):r=N(e._item.id.client,e._item.id.clock),new Xv(r,i,t,n)},ty=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ey(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ey(e,N(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ey(e,r.lastId,n);r=r.right}return ey(e,null,n)},ny=e=>{let t=null,n=null,r=null;switch(M(e)){case 0:r=qv(e);break;case 1:n=fh(e);break;case 2:t=qv(e)}let i=sh(e)?dh(e):0;return new Xv(t,n,r,i)},ry=e=>ny(oh(e)),iy=(e,t)=>{let n=vy(e,t);return{item:n,diff:t.clock-n.id.clock}},ay=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(hy(r,i.client)<=i.clock)return null;let e=n?Rx(r,i):iy(r,i),t=e.item;if(!(t instanceof Ux))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(hy(r,a.client)<=a.clock)return null;let{item:e}=n?Rx(r,a):{item:vy(r,a)};if(e instanceof Ux&&e.content instanceof Ix)c=e.content.type;else return null}else throw eh();l=s>=0?c._length:0}return $v(c,l,e.assoc)},oy=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Kv(e.item,t.item)&&Kv(e.type,t.type)&&e.assoc===t.assoc,sy=class{constructor(e,t){this.ds=e,this.sv=t}},cy=(e,t)=>new sy(e,t),ly=cy(cv(),new Map),uy=e=>cy(lv(e.store),my(e.store)),dy=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!iv(t.ds,e.id),fy=(e,t)=>{let n=Kp(e.meta,fy,Yp),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t{}),n.add(t))},py=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},my=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},hy=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},gy=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw eh()}n.push(t)},_y=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=am(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t{let n=e.clients.get(t.client);return n[_y(n,t.clock)]},yy=(e,t,n)=>{let r=_y(t,n),i=t[r];return i.id.clock{let n=e.doc.store.clients.get(t.client);return n[yy(e,n,t.clock)]},xy=(e,t,n)=>{let r=t.clients.get(n.client),i=_y(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==lx&&r.splice(i+1,0,Bx(e,a,n.clock-a.id.clock+1)),a},Sy=(e,t,n)=>{let r=e.clients.get(t.id.client);r[_y(r,t.id.clock)]=n},Cy=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=yy(e,t,n),s;do s=t[o++],at.deleteSet.clients.size===0&&!Jp(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(av(t.deleteSet),Dv(e,t),uv(e,t.deleteSet),!0),Ey=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kp(e.changed,t,Yp).add(n)},Dy=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0&&r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n);n=r,r=e[--i-1])n instanceof Ux&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);let a=t-i;return a&&e.splice(t+1-a,a),a},Oy=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=_y(e,a.clock),i=e[r];r{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=sm(r.length-1,1+_y(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Dy(r,e)}})},Ay=(e,t)=>{if(te.push(()=>{r._item!==null&&r._item.deleted||r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&e.push(()=>{t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),Wv(r._dEH,t,n)})}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Kb(n)})}),Wh(e,[])}finally{r.gc&&Oy(a,i,r.gcFilter),ky(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=cm(_y(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Dy(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=_y(r,n);a+11||a>0&&Dy(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(J_(U_,I_,`[yjs] `,L_,V_,`Changed the client-id because another client seems to be using it.`),r.clientID=pv()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new bv;Ty(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Sv;Ty(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Ay(e,t+1)}}},jy=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new wy(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Ay(i,0)}}return o},My=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ny=(e,t,n)=>{nv(e,n.deletions,n=>{n instanceof Ux&&t.scope.some(t=>t===e.doc||Yv(t,n))&&zx(n,!1)})},Py=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;jy(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;nv(n,o.insertions,e=>{if(e instanceof Ux){if(e.redone!==null){let{item:t,diff:i}=Rx(r,e.id);i>0&&(t=by(n,N(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Yv(t,e))&&c.push(e)}}),nv(n,o.deletions,e=>{e instanceof Ux&&a.some(t=>t===n.doc||Yv(t,e))&&!iv(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Hx(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Fy=class extends rm{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=nm(e)?e[0].doc:e instanceof mv?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new tv;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&sv(i,n,r,a)});let a=Eh(),o=!1;if(this.lastChange>0&&a-this.lastChange0&&!t&&!n){let t=r[r.length-1];t.deletions=ov([t.deletions,e.deleteSet]),t.insertions=ov([t.insertions,i])}else r.push(new My(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),nv(e,e.deleteSet,t=>{t instanceof Ux&&this.scope.some(n=>n===e.doc||Yv(n,t))&&zx(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.destroy=this.destroy.bind(this),this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,this.destroy)}addToScope(e){let t=new Set(this.scope);e=nm(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof sb?e.doc!==this.doc:e!==this.doc)&&Y_(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ny(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ny(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Py(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Py(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),this.doc.off(`destroy`,this.destroy),super.destroy()}};function*Iy(e){let t=M(e.restDecoder);for(let n=0;nVy(e,gv,bv),By=(e,t)=>{if(e.constructor===lx){let{client:n,clock:r}=e.id;return new lx(N(n,r+t),e.length-t)}if(e.constructor===qx){let{client:n,clock:r}=e.id;return new qx(N(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Ux(N(r,i+t),null,N(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Vy=(e,t=vv,n=Sv)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(oh(e))),i=r.map(e=>new Ly(e,!0)),a=null,o=new n,s=new Ry(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===qx?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Wy(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length0&&(a.struct.constructor===qx?a.struct.length-=t:n=By(n,t)),a.struct.mergeWith(n)||(Wy(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==qx;n=e.next())Wy(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Wy(s,a.struct,a.offset),a=null),Gy(s),uv(o,ov(r.map(e=>dv(e)))),o.toUint8Array()},Hy=(e,t,n=vv,r=Sv)=>{let i=Fv(t),a=new r,o=new Ry(a),s=new n(oh(e)),c=new Ly(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===qx)c.next();else if(e.id.clock+e.length>n)for(Wy(o,e,cm(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Wy(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Gy(o),uv(a,dv(s)),a.toUint8Array()},Uy=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:km(e.encoder.restEncoder)}),e.encoder.restEncoder=Em(),e.written=0)},Wy=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Uy(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),j(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Gy=e=>{Uy(e);let t=e.encoder.restEncoder;j(t,e.clientStructs.length);for(let n=0;n{let i=new n(oh(e)),a=new Ly(i,!1),o=new r,s=new Ry(o);for(let e=a.curr;e!==null;e=a.next())Wy(s,t(e),0);return Gy(s),uv(o,dv(i)),o.toUint8Array()},qy=e=>Ky(e,Gh,vv,bv),Jy=`You must not compute changes after the event-handler fired.`,Yy=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Xy(this.currentTarget,this.target)}deletes(e){return iv(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Qm(Jy);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=Xp(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=Xp(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Xp(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Qm(Jy);let t=this.target,n=Yp(),r=Yp(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Xy=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Zy=()=>{Y_(`Invalid access: Add Yjs type to a document before reading data.`)},Qy=80,$y=0,eb=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=$y++}},tb=e=>{e.timestamp=$y++},nb=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=$y++},rb=(e,t,n)=>{if(e.length>=Qy){let r=e.reduce((e,t)=>e.timestamp{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>om(t-e.index)t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&om(n.index-i){for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t0&&t===i.index)&&(i.index=cm(t,i.index+n))}},ob=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Kp(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Wv(r._eH,n,t)},sb=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Vv(),this._dEH=Vv(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw $m()}clone(){throw $m()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Hv(this._eH,e)}observeDeep(e){Hv(this._dEH,e)}unobserve(e){Uv(this._eH,e)}unobserveDeep(e){Uv(this._dEH,e)}toJSON(){}},cb=(e,t,n)=>{e.doc??Zy(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},lb=e=>{e.doc??Zy();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n{let n=[],r=e._start;for(;r!==null;){if(r.countable&&dy(r,t)){let e=r.content.getContent();for(let t=0;t{let n=0,r=e._start;for(e.doc??Zy();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r{let n=[];return db(e,(r,i)=>{n.push(t(r,i,e))}),n},pb=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},mb=(e,t)=>{e.doc??Zy();let n=ib(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Ux(N(o,hy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new wx(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Ux(N(o,hy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ux(new Uint8Array(n))),i.integrate(e,0);break;case mv:i=new Ux(N(o,hy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new hx(n)),i.integrate(e,0);break;default:if(n instanceof sb)i=new Ux(N(o,hy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ix(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},gb=()=>Qm(`Length exceeded!`),_b=(e,t,n,r)=>{if(n>t._length)throw gb();if(n===0)return t._searchMarker&&ab(t._searchMarker,n,r.length),hb(e,t,null,r);let i=n,a=ib(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return hb(e,t,r,n)},yb=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=ib(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n0&&s!==null;)s.deleted||(r0)throw gb();t._searchMarker&&ab(t._searchMarker,i,-a+r)},bb=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},xb=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new wx([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new wx([r]);break;case Uint8Array:s=new ux(r);break;case mv:s=new hx(r);break;default:if(r instanceof sb)s=new Ix(r);else throw Error(`Unexpected content type`)}new Ux(N(o,hy(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Sb=(e,t)=>{e.doc??Zy();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Cb=e=>{let t={};return e.doc??Zy(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},wb=(e,t)=>{e.doc??Zy();let n=e._map.get(t);return n!==void 0&&!n.deleted},Tb=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&dy(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Eb=e=>(e.doc??Zy(),Q_(e._map.entries(),e=>!e[1].deleted)),Db=class extends Yy{},Ob=class e extends sb{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_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._length}_callObserver(e,t){super._callObserver(e,t),ob(this,e,new Db(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):jy(this.doc,n=>{_b(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):jy(this.doc,t=>{vb(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):jy(this.doc,n=>{yb(n,this,e,t)})}get(e){return mb(this,e)}toArray(){return lb(this)}slice(e=0,t=this.length){return cb(this,e,t)}toJSON(){return this.map(e=>e instanceof sb?e.toJSON():e)}map(e){return fb(this,e)}forEach(e){db(this,e)}[Symbol.iterator](){return pb(this)}_write(e){e.writeTypeRef(kx)}},kb=e=>new Ob,Ab=class extends Yy{constructor(e,t,n){super(e,t),this.keysChanged=n}},jb=class e extends sb{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof sb?e.clone():e)}),t}_callObserver(e,t){ob(this,e,new Ab(this,e,t))}toJSON(){this.doc??Zy();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof sb?r.toJSON():r}}),e}get size(){return[...Eb(this)].length}keys(){return $_(Eb(this),e=>e[0])}values(){return $_(Eb(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return $_(Eb(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Zy(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):jy(this.doc,t=>{bb(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):jy(this.doc,n=>{xb(n,this,e,t)}),t}get(e){return Sb(this,e)}has(e){return wb(this,e)}clear(){this.doc===null?this._prelimContent.clear():jy(this.doc,e=>{this.forEach(function(t,n,r){bb(e,r,n)})})}_write(e){e.writeTypeRef(Ax)}},Mb=e=>new jb,Nb=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Vh(e,t),Pb=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&eh(),this.right.content.constructor){case yx:this.right.deleted||Rb(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}},Fb=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case yx:t.right.deleted||Rb(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n{let i=new Map,a=r?ib(t,n):null;return a?Fb(e,new Pb(a.p.left,a.p,a.index,i),n-a.index):Fb(e,new Pb(null,t._start,0,i),n)},Lb=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===yx&&Nb(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Ux(N(a,hy(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new yx(o,r));l.integrate(e,0),n.right=l,n.forward()})},Rb=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},zb=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===yx&&Nb(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Bb=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Nb(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Ux(N(a,hy(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new yx(s,c)),n.right.integrate(e,0),n.forward()}}return o},Vb=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;zb(n,i);let s=Bb(e,t,n,i),c=r.constructor===String?new Ex(r):r instanceof sb?new Ix(r):new _x(r),{left:l,right:u,index:d}=n;t._searchMarker&&ab(t._searchMarker,n.index,c.getLength()),u=new Ux(N(o,hy(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Lb(e,t,n,s)},Hb=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;zb(n,i);let s=Bb(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===yx));){if(!n.right.deleted)switch(n.right.content.constructor){case yx:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Nb(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r0){let i=``;for(;r>0;r--)i+=` -`;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{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;i0)&&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=>e instanceof sb?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i0?` `+t.join(` `):``}>${super.toString()}`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):jy(this.doc,t=>{bb(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):jy(this.doc,n=>{xb(n,this,e,t)})}getAttribute(e){return Sb(this,e)}hasAttribute(e){return wb(this,e)}getAttributes(e){return e?Tb(this,e):Cb(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return db(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Mx),e.writeKey(this.nodeName)}},tx=e=>new ex(e.readKey()),nx=class extends Yy{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},rx=class e extends jb{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Px),e.writeKey(this.hookName)}},ix=e=>new rx(e.readKey()),ax=class e extends Yb{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}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.keye.nodeName`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=``;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Fx)}},ox=e=>new ax,sx=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw $m()}mergeWith(e){return!1}write(e,t,n){throw $m()}integrate(e,t){throw $m()}},cx=0,lx=class extends sx{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),gy(e.doc.store,this)}write(e,t){e.writeInfo(cx),e.writeLen(this.length-t)}getMissing(e,t){return null}},ux=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw $m()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},dx=e=>new ux(e.readBuf()),fx=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){sv(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},px=e=>new fx(e.readLen()),mx=(e,t)=>new mv({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),hx=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(mx(this.doc.guid,this.opts))}splice(e){throw $m()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},gx=e=>new hx(mx(e.readString(),e.readAny())),_x=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw $m()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},vx=e=>new _x(e.readJSON()),yx=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw $m()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},bx=e=>new yx(e.readKey(),e.readJSON()),xx=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r{let t=e.readLen(),n=[];for(let r=0;r{let t=e.readLen(),n=[];for(let r=0;r=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Dx=e=>new Ex(e.readString()),Ox=[kb,Mb,Xb,tx,$b,ix,ox],kx=0,Ax=1,jx=2,Mx=3,Nx=4,Px=5,Fx=6,Ix=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw $m()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Lx=e=>new Ix(Ox[e.readTypeRef()](e)),Rx=(e,t)=>{let n=t,r=0,i;do r>0&&(n=N(n.client,n.clock+r)),i=vy(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Ux);return{item:i,diff:r}},zx=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Bx=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Ux(N(r,i+n),t,N(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=N(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Vx=(e,t)=>em(e,e=>iv(e.deletions,t)),Hx=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return by(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Hx(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=by(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:by(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:by(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||iv(r,d.right.id)||Vx(a.undoStack,d.right.id)||Vx(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=by(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=N(c,hy(s,c)),h=new Ux(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,zx(h,!0),h.integrate(e,0),h},Ux=class e extends sx{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=hy(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=hy(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Gv&&this.id.client!==this.parent.client&&this.parent.clock>=hy(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=xy(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=by(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===lx||this.right&&this.right.constructor===lx)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Gv){let e=vy(n,this.parent);this.parent=e.constructor===lx?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=xy(e,e.doc.store,N(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),Kv(this.origin,n.origin)){if(n.id.client{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),sv(e.deleteSet,this.id.client,this.id.clock,this.length),Ey(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw eh();this.content.gc(e),t?Sy(e,this,new lx(this.id,this.length)):this.content=new fx(this.length)}write(e,t){let n=t>0?N(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Jv(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Gv?(e.writeParentInfo(!1),e.writeLeftID(t)):eh();i!==null&&e.writeString(i)}this.content.write(e,t)}},Wx=(e,t)=>Gx[t&31](e),Gx=[()=>{eh()},px,Sx,dx,Dx,vx,bx,Lx,Tx,gx,()=>{eh()}],Kx=10,qx=class extends sx{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){eh()}write(e,t){e.writeInfo(Kx),j(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Jx=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Yx=`__ $YJS$ __`;Jx[Yx]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Jx[Yx]=!0;var Xx=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},Zx=(e,t)=>e>>>t|e<<32-t,Qx=e=>Zx(e,2)^Zx(e,13)^Zx(e,22),$x=e=>Zx(e,6)^Zx(e,11)^Zx(e,25),eS=e=>Zx(e,7)^Zx(e,18)^e>>>3,tS=e=>Zx(e,17)^Zx(e,19)^e>>>10,nS=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rS=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),iS=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(rS),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=tS(t[e-2])+t[e-7]+eS(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+$x(o)+(o&s^~o&c)+nS[e]+t[e]>>>0,d=Qx(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3=0&&t>>(3-t)*8;return i}},aS=e=>new iS().digest(e),oS=/[\uD800-\uDBFF]/,sS=/[\uDC00-\uDFFF]/,cS=(e,t)=>{let n=0,r=0;for(;n0&&oS.test(e[n-1])&&n--;r+n0&&sS.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}};function lS(e){if(!e||!(e.content instanceof Ix))return null;let t=e.content.type;if(!(t instanceof Qb||t instanceof Yb||t instanceof rx))throw Error(`Expected a Yjs XML type`);return t}function uS(e){if(e===null)return null;if(!(e.parent instanceof sb))throw Error(`Expected an integrated Yjs parent`);let t=e.parent;if(!(t instanceof Qb||t instanceof Yb||t instanceof rx))throw Error(`Expected a Yjs XML type`);return t}var dS=(e,t)=>{let n=null,r=null;return e._item===null?r=Jv(e):n=N(e._item.id.client,e._item.id.clock),new Xv(n,r,t.id)},fS=(e,t,n)=>{if(e===0)return ty(t,0,-1);let r=lS(t._first);for(;r!==null&&t!==r;){if(r instanceof ax){if(r._length>=e)return ty(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=lS(r._item.next);else{do r=uS(r._item),e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:lS(r._item.next))}}else{let i=n.get(r),a=i instanceof le?i.nodeSize:0;if(r._first!==null&&e1)return new Xv(r._item===null?null:r._item.id,r._item===null?Jv(r):null,null);if(e-=a,r._item!==null&&r._item.next!==null)r=lS(r._item.next);else{if(e===0){if(r=r._item===null?r:uS(r._item),r===null)throw eh();return new Xv(r._item===null?null:r._item.id,r._item===null?Jv(r):null,null)}do{if(r=uS(r._item),r===null)throw eh();e--}while(r!==t&&r._item?.next===null);r!==t&&(r=lS(r._item?.next))}}}if(r===null)throw eh();if(e===0&&r.constructor!==ax&&r!==t){let e=r._item,t=uS(e);if(e===null||t===null)throw eh();return dS(t,e)}}return ty(t,t._length,-1)},pS=(e,t)=>{if(!e.docChanged)return!1;if(e.doc.childCount!==t.childCount)return!0;for(let n of e.steps)if(n instanceof Dt){if(n.from===0&&n.to===t.content.size)return!0;if(n.slice.content.size>0){let e=!1;if(n.slice.content.forEach(t=>{t.isBlock&&(e=!0)}),e)return!0}else if(n.to>n.from){let e=t.resolve(n.from),r=t.resolve(n.to);if(e.depth===0&&r.depth===0&&e.index()!==r.index())return!0}}return!1};function mS(e,t){if(e instanceof ax)return e._length;let n=t.get(e);return n instanceof le?n.nodeSize:null}function hS(e,t,n){let r=0,i=e._first;for(;i!==null;){let e=lS(i);if(e===t)break;let a=i.deleted;if(i=i.right,a)continue;if(e===null)return null;let o=mS(e,n);if(o===null)return null;r+=o}return r}function gS(e,t,n){let r=0,i=0,a=e._first;for(;i{if(n===null)return!1;let r=ay(t,e);return r!==null&&r.type instanceof ax&&t.item!==null&&r.type._item?.deleted===!0},vS=e=>{if(!e.doc)throw Error(`The Yjs fragment must belong to a document`);let t=e._item?`item:${e._item.id.client}:${e._item.id.clock}`:`root:${Jv(e)}`;return e.doc.getMap(`__tiptap_position_migrations:${t}`)},yS=new WeakMap,bS=(e,t)=>{let n=t.item??t.type;if(!n)return[];let r;t.item||(r=t.assoc<0?`start`:`end`);let i=yS.get(e);if(!i||i.size!==e.size){let t=new Map;e.forEach(e=>e.transfers.forEach(n=>{let r=t.get(n.source.client)??[];r.push({migration:e,transfer:n}),t.set(n.source.client,r)})),i={size:e.size,clients:t},yS.set(e,i)}let a=(i.clients.get(n.client)??[]).filter(({transfer:e})=>e.source.boundary===r&&e.source.clock<=n.clock&&n.clock!a.some(t=>t.migration!==e.migration&&t.migration.seen.some(([t,n])=>t===e.migration.client&&n>e.migration.clock)))},xS=(e,t,n)=>{let{source:r,target:i}=e.transfer;return i?new Xv(i.boundary?N(i.client,i.clock):i.type,i.tname??null,i.boundary?null:N(i.client,i.clock+t.clock-r.clock),i.assoc??n):null},SS=(e,t,n)=>{let r=xS(e[0],t,n);return!r||e.some(e=>{let i=xS(e,t,n);return!i||!oy(r,i)})?null:r},CS=e=>{let t=e.item??e.type;if(!t)return null;let n=e.assoc<0?`start`:`end`;return e.item&&(n=`item`),`${t.client}:${t.clock}:${n}`},wS=(e,t)=>{let n=vS(e),r=new Set,i=t,a=i.item??i.type;for(;a;){let e=CS(i);if(r.has(e))return null;r.add(e);let t=bS(n,i);if(t.length===0)return i;let o=SS(t,a,i.assoc);if(!o)return null;if(CS(o)===e)return o;i=o,a=o.item??o.type}return i},TS=(e,t,n,r)=>{let i=wS(t,n);if(!i)return null;n=i;let a=ay(n,e);if(a===null||a.type!==t&&!Yv(t,a.type._item))return null;let o=a.type,s=0;if(o.constructor===ax)s=a.index;else if(!o._item?.deleted){let e=gS(o,a.index,r);if(e===null)return null;s=e+1}for(;o!==t&&o._item!==null;){let e=uS(o._item);if(e===null)return null;if(e._item?.deleted){o=e;continue}let t=hS(e,o,r);if(t===null)return null;s+=t+1,o=e}let c=s-1;return _S(e,n,c)?null:c},ES=new D(`y-sync`),DS=new D(`y-undo`),OS=new D(`yjs-cursor`),kS=null;function AS(){let e=kS;kS=null;let t=[];return e?.forEach((e,n)=>{e.forEach((e,r)=>t.push({view:n,key:r,value:e}))}),t}function jS(e=AS(),t=!1){let n=!0;for(;e.length>0;){let{view:r,key:i,value:a}=e[0];try{let e=ES.getState(r.state);e&&e.binding.prosemirrorView!==null&&r.dispatch(r.state.tr.setMeta(i,a))}catch(r){if(!(r instanceof RangeError))throw r;t&&n&&e.shift(),e.length>0&&P_(0,()=>jS(e,!0));return}n=!1,e.shift()}}function MS(e,t,n){kS===null&&(kS=new Map,P_(0,jS));let r=kS.get(e);r||(r=new Map,kS.set(e,r)),r.set(t,n)}var NS=(e,t,n)=>e!==t,PS=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},FS=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),IS=/^#[0-9a-fA-F]{6}$/,LS=e=>typeof e.name==`string`&&typeof e.color==`string`,RS=(e,t,n,r,i)=>{let a=ES.getState(e);if(a==null||a.doc==null||a.binding==null)return k.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?k.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t&&t.cursor!=null){let n={...t.user};if(n.color==null?n.color=`#ffa500`:IS.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`,!LS(n))return;let l=TS(o,a.type,Zv(t.cursor.anchor),a.binding.mapping),u=TS(o,a.type,Zv(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=cm(e.doc.content.size-1,0);l=sm(l,t),u=sm(u,t),s.push(vs.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=sm(l,u),o=cm(l,u);s.push(vs.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),k.create(e.doc,s))},zS=(e,{awarenessStateFilter:t=NS,cursorBuilder:n=PS,selectionBuilder:r=FS,getSelection:i=e=>e.selection}={},a=`cursor`)=>new E({key:OS,state:{init(i,a){return RS(a,e,t,n,r)},apply(i,a,o,s){let c=ES.getState(s),l=i.getMeta(OS),u=c&&c.isChangeOrigin;return i.docChanged&&!u&&pS(i,o.doc)?k.empty:u||l&&l.awarenessUpdated?RS(s,e,t,n,r):i.docChanged?a.map(i.mapping,i.doc):a}},props:{decorations:e=>OS.getState(e)??k.empty},view:t=>{let n=()=>{t.isDestroyed||MS(t,OS,{awarenessUpdated:!0})},r=t=>{let n=ES.getState(t.state);if(!n||!n.binding)return;let r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=fS(o.anchor,n.type,n.binding.mapping),c=fS(o.head,n.type,n.binding.mapping);r.cursor!=null&&oy(Zv(r.cursor.anchor),s)&&oy(Zv(r.cursor.head),c)||e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&TS(n.doc,n.type,Zv(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)},o=()=>r(t);return e.on(`change`,n),t.dom.addEventListener(`focusin`,o),t.dom.addEventListener(`focusout`,o),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,o),t.dom.removeEventListener(`focusout`,o),e.off(`change`,n),e.setLocalStateField(a,null)}}}});function BS(e){let t=ES.getState(e);if(!t)throw Error(`The editor requires ySyncPlugin`);return t}var VS=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)??0)>e.id.clock&&!iv(t.ds,e.id),HS=(e,t,n)=>{if(!e.has(n)){if(e.sizen.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Ch(t))}let r=e.get(n);if(!r)throw Error(`At least one snapshot color is required`);return r},US=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])},WS=e=>{let t=e.type.spec.attrs||{};return Object.keys(e.attrs).some(n=>{let r=t[n];return r==null||!Object.prototype.hasOwnProperty.call(r,`default`)||r.default!==e.attrs[n]})},GS=(e,t,n)=>{let r=0,i=0;for(;in)break;r+=t.nodeSize}if(i>=e.childCount)return null;let a=e.child(i),o=e.resolve(n),s=(e,t)=>{if(o.depth===0){let i=e+(n-r),a=e+1,o=e+t.nodeSize-1;return Math.max(a,Math.min(i,o))}if(o.depth>1){let n=GS(o.node(1),t,o.pos-o.start(1));return n===null?null:e+1+n}return t.isTextblock?e+1+Math.min(o.parentOffset,t.content.size):null},c=(n,r=!1)=>{let a=0;for(let t=0;t<=i;t++)n(e.child(t))&&a++;let o=0,c=-1,l=null,u=0;for(let e=0;ee.type===a.type&&US(e.attrs,a.attrs),u=a.textContent,d=c(e=>l(e)&&e.textContent===u);if(d!==null)return d;let f=c(e=>e.type===a.type&&e.textContent===u);if(f!==null)return f;if(!a.isTextblock||WS(a)){let e=c(l,!0);if(e!==null)return e}return c(e=>l(e)&&u!==``&&e.textContent!==``&&(u.startsWith(e.textContent)||e.textContent.startsWith(u)),!0)},KS=(e,t,n,r)=>{if(r===null)return!1;let i=e.resolve(n),a=t.resolve(r);if(!i.parent.isTextblock)return!1;if(!a.parent.isTextblock||i.parent.textContent!==a.parent.textContent||i.parentOffset!==0&&a.parentOffset===0)return!0;let o=i.parentOffset===0&&a.parentOffset===0,s=i.parentOffset!==a.parentOffset||i.parent.type!==a.parent.type||!US(i.parent.attrs,a.parent.attrs);if(o||s){let i=GS(e,t,n);return i!==null&&i!==r}return!1},qS=(e,t,n,r)=>{if(n==null||n<0||n>t.content.size||!(r===null||n>1&&r<=1||KS(t,e,n,r)))return r;let i=GS(t,e,n);return i===null?r:i},JS=(e,t,n,r)=>{if(t!==null&&t.anchor!==null&&t.head!==null){if(t.type===`all`)e.setSelection(new On(e.doc));else if(t.type===`node`){let r=TS(n.doc,n.type,t.anchor,n.mapping);r!==null&&e.setSelection(YS(e,r))}else if(t.type===`nodeRange`){let r=XS(e,TS(n.doc,n.type,t.anchor,n.mapping),TS(n.doc,n.type,t.head,n.mapping),t.depth);r!==null&&e.setSelection(r)}else{let i=TS(n.doc,n.type,t.anchor,n.mapping),a=TS(n.doc,n.type,t.head,n.mapping);r!=null&&(wS(n.type,t.anchor)===t.anchor&&(i=qS(e.doc,r,t.absAnchor,i)),wS(n.type,t.head)===t.head&&(a=qS(e.doc,r,t.absHead,a))),i===null&&(i=a),a===null&&(a=i),i!==null&&a!==null&&e.setSelection(w.between(e.doc.resolve(i),e.doc.resolve(a)))}}},YS=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?T.create(e.doc,t):w.near(n)},XS=(e,t,n,r)=>{if(t===null||n===null)return null;let i=Math.min(Math.max(t,0),e.doc.content.size),a=Math.min(Math.max(n,0),e.doc.content.size);try{let t=C.fromJSON(e.doc,{type:`nodeRange`,anchor:i,head:a,depth:r});return t.ranges.length?t:w.near(e.doc.resolve(i))}catch{return w.near(e.doc.resolve(i))}},ZS=(e,t)=>{let n=t.selection,r=n.toJSON(),i=typeof r.type==`string`?r.type:`text`;return{type:i,depth:i===`nodeRange`&&`depth`in n&&typeof n.depth==`number`?n.depth:void 0,anchor:fS(t.selection.anchor,e.type,e.mapping),head:fS(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},QS=new WeakMap,$S=(e,t)=>{var n;(t instanceof Qb||t instanceof Yb||t instanceof rx)&&(e.delete(t),(n=QS.get(e))==null||n.delete(t))},eC=/(.*)(--[a-zA-Z0-9+/=]{8})$/,tC=e=>eC.exec(e)?.[1]??e,nC=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(tC(r),e[r]));return n},rC=e=>{let t=e.doc,n=e._item;if(!t||!n)throw eh();t.transact(e=>{n.delete(e)},ES)},iC=(e,t,n,r,i,a)=>{let o=e.toDelta(r,i,a);try{return o.map(e=>t.text(e.insert,nC(e.attributes,t)))}catch{return rC(e),null}},aC=e=>{var t;let n=(t=e._item)==null||(t=t.right)==null?void 0:t.content,r=n instanceof Ix?n.type:null;if(!(r instanceof Yb))return;let i=r._item,a=r.doc;i&&a&&!i.deleted&&i.id.client===a.clientID&&(e.applyDelta([{retain:e.length},...r.toDelta()]),a.transact(e=>{i.delete(e)}))},oC=(e,t,n,r)=>{if(e._item){if(!VS(e._item,t))return r?r(`removed`,e._item.id):{type:`removed`};if(!VS(e._item,n))return r?r(`added`,e._item.id):{type:`added`}}},sC=(e,t,n)=>{e.mapping.set(t,n);let r=QS.get(e.mapping);r===void 0&&(r=new WeakMap,QS.set(e.mapping,r)),r.set(t,n)},cC=(e,t,n,r,i,a)=>{let o=n.mapping.get(e),s=Array.isArray(o)?void 0:o;if(s!==void 0&&QS.get(n.mapping)?.get(e)===s)return s;let c=[],l=e=>{if(e instanceof ex){let o=cC(e,t,n,r,i,a);o!==null&&c.push(o)}else e instanceof ax&&(aC(e),iC(e,t,n,r,i,a)?.forEach(e=>c.push(e)))};r===void 0||i===void 0?e.toArray().forEach(l):ub(e,new sy(i.ds,r.sv)).forEach(l);try{let o=e.getAttributes(r),l=r?oC(e,r,i,a):void 0;l!==void 0&&(o.ychange=l);let u=t.node(e.nodeName,o,c);return s?.eq(u)&&(u=s),sC(n,e,u),u}catch{return rC(e),$S(n.mapping,e),null}},lC=e=>{for(let t=6;tlg(lC(aS(fg(e)))),dC=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Kp(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${uC(e.toJSON())}`:e.type.name]=e.attrs}}),n},fC=(e,t)=>{let n=new ax,r=e.map(e=>({insert:e.text??``,attributes:dC(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},pC=e=>{let t=e.content.content,n=[];for(let e=0;ee instanceof Array?fC(e,t):hC(e,t),hC=(e,t)=>{let n=new ex(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,pC(e).map(e=>mC(e,t))),t.mapping.set(n,e),n},gC=e=>typeof e==`object`&&!!e,_C=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Fh(e.attributes||{}).length===t[n].marks.length&&Object.entries(e.attributes??{}).every(([e,r])=>{let i=tC(e),a=t[n].marks.find(e=>e.type.name===i);return a?_C(r,a.attrs):!1}))},yC=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,bC=(e,t)=>{if(e instanceof ex&&!(t instanceof Array)&&yC(e,t)){let n=pC(t);return e._length===n.length&&_C(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>bC(e,n[t]))}return e instanceof ax&&t instanceof Array&&vC(e,t)},xC=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),SC=(e,t,n)=>{let r=new Map;t.forEach((e,t)=>{r.has(e)||r.set(e,t)});let i=[];if(e.forEach((e,a)=>{let o=n.mapping.get(e),s=o===void 0?void 0:r.get(o);s!==void 0&&xC(o,t[s])&&i.push({yIndex:a,pIndex:s,yChild:e})}),i.length===0)return[];let a=[],o=[];for(let e=0;e>1;i[o[r]].pIndex0?o[t-1]:-1,o[t]=e}let s=[];for(let e=o[o.length-1];e!==-1;e=a[e])s.push(i[e]);return s.reverse()},CC=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ex?t+=n.content.str:n.content instanceof yx&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},wC=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=CC(e),a=t.map(e=>({insert:e.text??``,attributes:Object.assign({},r,dC(e.marks,n))})),{insert:o,remove:s,index:c}=cS(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},TC=(e,t,n,r,i)=>t instanceof ax&&n instanceof Array?(vC(t,n)?r.mapping.set(t,n):wC(t,n,r),!0):t instanceof ex&&!(n instanceof Array)&&yC(t,n)?(bC(t,n)?r.mapping.set(t,n):i(e,t,n,r),!0):!1,EC=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>$S(r.mapping,e)),e.delete(t,n))},DC=(e,t,n,r,i,a)=>{if(r{let u=sm(a-i,s-o);for(let a=0;a{let o=SC(r,n,i);if(o.length<2||!o.some(e=>e.yIndex!==e.pIndex)||o.some(e=>{let t=n[e.pIndex];return!(e.yChild instanceof ax&&t instanceof Array||e.yChild instanceof ex&&!(t instanceof Array))}))return!1;let s=0,c=0;for(let l of o){OC(e,t,n,r,s,l.yIndex,c,l.pIndex,i,a);let o=n[l.pIndex];TC(e,l.yChild,o,i,a),s=l.yIndex+1,c=l.pIndex+1}return OC(e,t,n,r,s,r.length,c,n.length,i,a),!0},AC=(e,t,n)=>{let r=e.toArray(),i=pC(t),a=i.length,o=r.length,s=sm(o,a),c=0,l=0,u=!1;for(;c{if(t instanceof ex&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ex){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=pC(n),a=i.length,o=t.toArray(),s=o.length,c=sm(a,s),l=!1;if(e.transact(()=>{l=kC(e,t,i,o,r,jC)},ES),l)return;let u=0,d=0;for(;u{for(;s-u-d>0&&a-u-d>0;){let n=o[u],c=i[u],l=o[s-d-1],f=i[a-d-1];if(n instanceof ax&&c instanceof Array){vC(n,c)||wC(n,c,r),u+=1;continue}let p=n instanceof ex&&yC(n,c),m=l instanceof ex&&yC(l,f);if(p&&m&&n instanceof ex&&l instanceof ex&&!Array.isArray(c)&&!Array.isArray(f)){let e=AC(n,c,r),t=AC(l,f,r);e.foundMappedChild&&!t.foundMappedChild?m=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor0&&(t.slice(u,u+n).forEach(e=>$S(r.mapping,e)),t.delete(u,n)),u+d>=a)return;let c=[];for(let e=u;e{let n=[];if(!e._item)throw Error(`Position tracking requires integrated text`);for(let r=e._start;r;r=r.right)if(!r.deleted&&r.countable){if(!(r.content instanceof Ex))throw Error(`Position tracking requires string text content`);for(let i=0;i{let r=[{current:-1,target:-1}];return e.forEach((e,n)=>{let i=t.get(`${e.client}:${e.clock}`);i!==void 0&&i>r[r.length-1].target&&r.push({current:n,target:i})}),r.push({current:e.length,target:n}),r},PC=(e,t,n,r,i)=>{let a=MC(e),o=new Map;for(let e=0;e0;--n){let r=s[n-1],o=s[n],c=a.slice(r.current+1,o.current),l=t.slice(r.target+1,o.target);(c.some(e=>i.has(`${e.client}:${e.clock}`))||c.map(e=>e.text).join(``)!==l)&&(e.delete(r.current+1,c.length),e.insert(r.current+1,l))}return MC(e,n)},FC=(e,t)=>!e.target||!t.target?e.target===t.target:e.target.client===t.target.client&&e.target.assoc===t.target.assoc&&e.target.boundary===t.target.boundary&&e.target.tname===t.target.tname&&e.target.clock+e.source.length===t.target.clock&&Kv(e.target.type,t.target.type),IC=e=>{let t=[];return e.forEach(e=>{let n=t[t.length-1];n&&n.source.client===e.source.client&&n.source.boundary===e.source.boundary&&n.source.clock+n.source.length===e.source.clock&&FC(n,e)?n.source.length+=e.source.length:t.push({...e,source:{...e.source}})}),t},LC=(e,t)=>{let n=e.doc;if(!n||t.length===0)return;let r=hy(n.store,n.clientID);e.set(`${n.clientID}:${r}`,{version:1,client:n.clientID,clock:r,seen:[...Fv(zv(n))],transfers:IC(t)})},RC=(e,t)=>{let n=new Map;e.forEach(e=>{let t=`${e.type.client}:${e.type.clock}`,r=n.get(t)??[];r.push(e),n.set(t,r)});let r=[];return n.forEach(e=>{let n=e[0],i=e[e.length-1],a=n.position===null?void 0:t.get(n.position),o=i.position===null?void 0:t.get(i.position);a&&Kv(n.type,a.type)||r.push({source:{...n.type,length:1,boundary:`start`},target:a?{...a,assoc:0}:null}),o&&Kv(i.type,o.type)||r.push({source:{...n.type,length:1,boundary:`end`},target:o?{...o,assoc:-1}:null})}),r},zC=(e,t,n,r)=>{let i=[];e.forEach(e=>{let n=e.position===null?null:t.get(e.position)??null;n&&Kv(e.id,n)||i.push({source:{...e.id,length:1},target:n})});let a=[...e,...r];for(let e of[`start`,`end`]){let r=e===`start`?t:n;a.forEach(t=>{let n=e===`start`?t.position:t.end,a=n===null?null:r.get(n)??null;a&&Kv(t.id,a)||i.push({source:{...t.id,length:1,boundary:e},target:a?{client:a.client,clock:a.clock,type:null,boundary:e}:null})})}return i},BC=(e,t,n,r,i,a)=>{let o=e.get(t);if(!(o instanceof ex)||!o._item)throw Error(`Position migration requires synchronized elements`);let s=i.get(`${o._item.id.client}:${o._item.id.clock}`);if(s&&s.position!==r&&($S(a.mapping,o),e.delete(t,1),o=mC(n,a),e.insert(t,[o])),!(o instanceof ex)||!o._item)throw Error(`Position migration requires integrated elements`);return o},VC=(e,t,n,r)=>{let i=new Map(t.characters.map(e=>[e.position,e])),a=new Set(t.characters.map(e=>`${e.client}:${e.clock}`)),o=new Map,s=new Map(t.nodes.map(e=>[`${e.id.client}:${e.id.clock}`,e])),c=new Map,l=new Map,u=(e,t,r)=>{let d=e.toArray(),f=r;pC(t).forEach((t,r)=>{let p=d[r];if(Array.isArray(t)){if(!(p instanceof ax)||!p._item)throw Error(`Position migration requires integrated text`);let e=t.map(e=>e.text??``).join(``),r=PC(p,e,f,i,a),s=p._item.id;r.forEach(e=>o.set(e.position,{client:e.client,clock:e.clock,type:s})),wC(p,t,n),f+=e.length;return}let m=BC(e,r,t,f,s,n),h=m._item.id,g={client:h.client,clock:h.clock,type:e._item?.id??null,...e._item?{}:{tname:Jv(e)}};c.set(f,g),l.set(f+t.nodeSize-1,g),t.isLeaf||u(m,t,f+1),f+=t.nodeSize})};u(e,t.doc,0);let d=[];t.characters.forEach(e=>{let t=e.position===null?null:o.get(e.position)??null;t&&Kv(e,t)&&Kv(e.type,t.type)||d.push({source:{client:e.client,clock:e.clock,length:1},target:t})}),d.push(...RC(t.characters,o)),d.push(...zC(t.nodes,c,l,t.emptyTexts)),LC(r,d)},HC=(e,t)=>{let n=e.doc.content,r=0,i=0;for(;rr&&o>r&&n.child(a-1)===t.child(o-1);)s+=n.child(a-1).nodeSize,a--,o--;if(r===a&&r===o)return e;let c=new p(t.cut(i,t.size-s),0,0),l=tn(e.doc,i,n.size-s,c);return l!==null&&l.apply(e.doc).doc?.content.eq(t)?e.step(l):e.replace(0,n.size,new p(t,0,0))},UC=class{constructor(e,t=new Map){if(this.prosemirrorView=null,this.mux=Xx(),this.isOMark=new Map,this.beforeTransactionSelection=null,this._domSelectionInView=null,this.syncedDoc=null,this.type=e,this.mapping=t,this._observeFunction=this._typeChanged.bind(this),e.doc===null)throw Error(`The Yjs fragment must belong to a document`);this.doc=e.doc,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=ZS(this,this.view.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null}}get view(){if(!this.prosemirrorView)throw Error(`The binding has no editor view`);return this.prosemirrorView}get _tr(){return this.view.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.view.hasFocus()?(Yh&&this._domSelectionInView===null&&(P_(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.view.root,t=`getSelection`in e&&typeof e.getSelection==`function`?e.getSelection():this.view.dom.ownerDocument.getSelection();if(t==null||t.anchorNode==null||t.focusNode==null)return!1;let n=this.view.dom.ownerDocument.createRange();n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);let r=n.getBoundingClientRect(),i=D_.documentElement;return r.bottom>=0&&r.right>=0&&r.left<=(window.innerWidth||i.clientWidth||0)&&r.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,t){t||=cy(cv(),new Map),this.view.dispatch(this._tr.setMeta(ES,{snapshot:e,prevSnapshot:t}))}createDocumentTransaction(){let e=this.type.toArray().map(e=>{if(!(e instanceof ex))throw $m();return cC(e,this.view.state.schema,this)}).filter(e=>e!==null);return this._tr.replace(0,this.view.state.doc.content.size,new p(s.from(e),0,0))}unrenderSnapshot(){this.mapping.clear(),QS.delete(this.mapping),this.mux(()=>{let e=this.createDocumentTransaction();e.setMeta(ES,{snapshot:null,prevSnapshot:null}),this.view.dispatch(e)})}_forceRerender(){this.mapping.clear(),QS.delete(this.mapping),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.view.state.selection:null,t=this.createDocumentTransaction();if(e){let n=sm(cm(e.anchor,0),t.doc.content.size),r=sm(cm(e.head,0),t.doc.content.size);t.setSelection(w.create(t.doc,n,r))}this.view.dispatch(t.setMeta(ES,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=uy(this.doc),e instanceof Uint8Array||t instanceof Uint8Array){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw eh();if(r=new mv({gc:!1}),kv(r,t),t=uy(r),kv(r,e),e=uy(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>Object.is(this.doc.share.get(e),i));i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[],t=e[_y(e,i._item.id.clock)];if(!(t instanceof Ux&&t.content instanceof Ix&&t.content.type instanceof Qb))throw eh();i=t.content.type}}let a=e,o=t??ly;this.mapping.clear(),QS.delete(this.mapping),this.mux(()=>{r.transact(e=>{let t=n.permanentUserData;t&&t.dss.forEach(t=>{nv(e,t,e=>{})});let r=(e,r)=>{let i=t?e===`added`?t.getUserByClientId(r.client):t.getUserByDeletedId(r):null;return{user:i,type:e,color:HS(n.colorMapping,n.colors,i)}},c=ub(i,new sy(o.ds,a.sv)).map(e=>!(e instanceof ex)||!e._item?null:!e._item.deleted||VS(e._item,a)||VS(e._item,o)?cC(e,this.view.state.schema,{mapping:new Map,isOMark:new Map},a,o,r):null).filter(e=>e!==null),l=this._tr.replace(0,this.view.state.doc.content.size,new p(s.from(c),0,0));this.view.dispatch(l.setMeta(ES,{isChangeOrigin:!0}))},ES)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=BS(this.view.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}let r=t.origin instanceof Fy,i=r?t.origin.currStackItem?.meta.get(this):void 0,a=i||this.beforeTransactionSelection,o=i?void 0:this.view.state.doc;this.mux(()=>{let e=(e,t)=>$S(this.mapping,t);nv(t,t.deleteSet,e=>{e instanceof Ux&&e.content instanceof Ix&&$S(this.mapping,e.content.type)}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>{if(!(e instanceof ex))throw $m();return cC(e,this.view.state.schema,this)}).filter(e=>e!==null),i=HC(this._tr,s.from(n));JS(i,a,this,o),i=i.setMeta(ES,{isChangeOrigin:!0,isUndoRedoOperation:r}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.view.dispatch(i)})}_prosemirrorChanged(e,t=null){let n=BS(this.view.state);n.snapshot==null&&n.prevSnapshot==null&&this.doc.transact(()=>{jC(this.doc,this.type,e,this),t?.doc===e&&VC(this.type,t,this,vS(this.type)),this.syncedDoc=e,this.beforeTransactionSelection=ZS(this,this.view.state)},ES)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},WC=(e,t)=>{let n=[],r=[],i=[];if(e.length===0)return{characters:n,nodes:r,emptyTexts:i};let a=(e,t,o)=>{let s=e.toArray(),c=pC(t),l=o;t.content.size===0&&s.forEach(e=>{e instanceof ax&&e._item&&i.push({id:e._item.id,position:o-1,end:o})}),c.forEach((e,t)=>{let i=s[t];if(!Array.isArray(e)){if(!(i instanceof ex)||!i._item)throw Error(`Position tracking requires synchronized editor content`);r.push({id:i._item.id,position:l,end:l+e.nodeSize-1}),e.isLeaf||a(i,e,l+1),l+=e.nodeSize;return}if(!(i instanceof ax))throw Error(`Position tracking requires synchronized editor text`);let o=MC(i,l);n.push(...o),l+=o.length})};return a(e,t,0),{characters:n,nodes:r,emptyTexts:i}},GC=(e,t,n,r)=>{let i=e.toJSON();if(i.stepType!==`replace`&&i.stepType!==`replaceAround`||r!==i.from&&r!==i.to-1)return!1;let a=t.nodeAt(i.from),o=n.nodeAt(i.from);return!a||!o||a.nodeSize!==i.to-i.from?!1:KC(a,o)},KC=(e,t)=>e.type===t.type&&e.content.eq(t.content)&&!e.sameMarkup(t),qC=(e,t)=>{let n=e.toJSON(),r=n.slice??{content:[]};if(n.stepType!==`replace`||r.openStart>0||r.openEnd>0)return!1;let i=t.resolve(n.from),a=t.resolve(n.to);return r.content.every(e=>e.type===`text`)&&i.parent.isTextblock&&i.sameParent(a)},JC=e=>{let t=new Map;return e.descendants((e,n)=>{let r=t.get(e)??[];r.push(n),t.set(e,r)}),t},YC=(e,t,n,r)=>{if(r[n].get(e)?.length!==1)return null;for(let i=n+1;i{let i=n[t].resolve(e),a=[],o=n[t].nodeAt(e);o&&!o.isText&&a.push({node:o,offset:0});for(let t=i.depth;t>0;--t)a.push({node:i.node(t),offset:e-i.before(t)});for(let e of a){let n=YC(e.node,e.offset,t,r);if(n)return n}return null},ZC=(e,t,n,r)=>{for(let i=0;i{let r=n?.doc===e.before&&n.doc!==t.syncedDoc?n:null;if(!e.docChanged||!t.prosemirrorView||!r&&e.steps.every((t,n)=>qC(t,e.docs[n])))return r;let i=r??WC(t.type,e.before),a=[...e.docs,e.doc],o=a.map(JC),s=i.characters.map(t=>({...t,position:t.position===null?null:ZC(t.position,e,a,o)})),c=t=>({...t,position:t.position===null?null:ZC(t.position,e,a,o),end:t.end===null?null:ZC(t.end,e,a,o)});return{doc:e.doc,characters:s,nodes:i.nodes.map(c),emptyTexts:i.emptyTexts.map(c)}},$C=[{light:`#ecd44433`,dark:`#ecd444`}],ew=(e,{colors:t=$C,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new UC(e,a);return new E({props:{editable:e=>{let t=BS(e);return t.snapshot==null&&t.prevSnapshot==null}},key:ES,state:{init:(i,a)=>({type:e,doc:s.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r,positionMigration:null}),apply:(e,t)=>{let n=e.getMeta(ES);return n!==void 0&&(t=Object.assign({},t,n)),e.docChanged&&(t.addToHistory=e.getMeta(`addToHistory`)!==!1),t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,t={...t,positionMigration:t.isChangeOrigin||t.snapshot||t.prevSnapshot||n?.snapshot!==void 0||n?.prevSnapshot!==void 0?null:QC(e,s,t.positionMigration??null)},s.prosemirrorView===null||n===void 0||n.snapshot==null&&n.prevSnapshot==null||P_(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),s.mux(()=>{let e=s.prosemirrorView;e&&(e.dispatch(s._tr.setMeta(ES,{restore:!1,snapshot:null,prevSnapshot:null,isChangeOrigin:!0})),s._prosemirrorChanged(e.state.doc))})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=BS(e.state);if(t.snapshot==null&&t.prevSnapshot==null){let n=e.state.doc.type.createAndFill();if(!n)throw Error(`The schema cannot create an empty document`);if(o||e.state.doc.content.findDiffStart(n.content)!==null){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=DS.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc,t.positionMigration??null)},ES)})}}},destroy:()=>{s.destroy()}})})};function tw(e){let t=DS.getState(e);if(!t)throw Error(`The editor requires yUndoPlugin`);return t}var nw=e=>{let t=new Map,n=e=>{e.toArray().forEach(r=>{if(r instanceof ex){let i=r._item.id;t.set(`${i.client}:${i.clock}`,{client:i.client,clock:i.clock,type:e._item?.id??null,...e._item?{}:{tname:Jv(e)}}),n(r);return}if(!(r instanceof ax)||!r._item)return;let i=r._item.id;MC(r).forEach(e=>{t.set(`${e.client}:${e.clock}`,{client:e.client,clock:e.clock,type:i})})})};return n(e),t},rw=(e,t)=>{let n=e.doc;if(!n)return;let r=nw(e),i=new Map,a=new Map,o=(e,t)=>{let n=`${e.client}:${e.clock}`,r=`${t.client}:${t.clock}`;i.set(n,e),i.set(r,t);let o=a.get(n)??new Set,s=a.get(r)??new Set;o.add(r),s.add(n),a.set(n,o),a.set(r,s)};t.forEach(e=>e.transfers.forEach(({source:e,target:t})=>{if(t&&!e.boundary)for(let n=0;ne.forEach(e=>{if(e instanceof Ux&&e.redone&&(e.content instanceof Ex||e.content instanceof Ix))for(let t=0;t{if(c.has(t))return;let o=[t],l=[],u=[];for(;o.length>0;){let e=o.pop();if(c.has(e))continue;c.add(e),l.push(e);let t=r.get(e);t&&u.push(t),o.push(...a.get(e)??[])}u.length===1&&l.forEach(e=>{if(r.has(e))return;let t=i.get(e);s.push({source:{client:t.client,clock:t.clock,length:1},target:u[0]});let a=vy(n.store,t);if(a.content instanceof Ix&&a.content.type instanceof ex)for(let e of[`start`,`end`])s.push({source:{client:t.client,clock:t.clock,length:1,boundary:e},target:{client:u[0].client,clock:u[0].clock,type:null,boundary:e}})})}),LC(t,s)},iw=(e,t,n)=>{let r=vS(e);if(r.size===0)return t[n]();let i=n===`undo`?`undoing`:`redoing`,a=null,o=({stackItem:e})=>{a=e};t.on(`stack-item-popped`,o);try{t.doc.transact(()=>{t[n](),t[i]=!0,t.currStackItem=a,a&&rw(e,r)},t)}finally{t.off(`stack-item-popped`,o),t[i]=!1,t.currStackItem=null}return a},aw=(e,t)=>{let n=BS(e);if(n.snapshot!=null||n.prevSnapshot!=null)return!1;let r=tw(e).undoManager;if(r!=null)return iw(n.type,r,t),!0},ow=e=>aw(e,`undo`),sw=e=>aw(e,`redo`),cw=new Set([`paragraph`]),lw=(e,t)=>!(e instanceof Ux)||!(e.content instanceof Ix)||!(e.content.type instanceof Yb||e.content.type instanceof ex&&t.has(e.content.type.nodeName))||e.content.type._length===0,uw=({protectedNodes:e=cw,trackedOrigins:t=[],undoManager:n=null}={})=>new E({key:DS,state:{init:(r,i)=>{let a=BS(i),o=new Set,s=n;if(!s){let n=new Set(a.doc._observers.get(`destroy`));s=new Fy(a.type,{trackedOrigins:new Set([ES,...t]),deleteFilter:t=>lw(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1}),(a.doc._observers.get(`destroy`)??new Set).forEach(e=>{n.has(e)||o.add(e)})}return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0,destroyListeners:o}},apply:(e,t,n,r)=>{let i=BS(r).binding;return{...t,prevSel:i?ZS(i,n):t.prevSel,hasUndoOps:t.undoManager.undoStack.length>0,hasRedoOps:t.undoManager.redoStack.length>0}}},view:e=>{let t=BS(e.state),{undoManager:n,destroyListeners:r}=tw(e.state);return n.on(`stack-item-added`,({stackItem:r})=>{let i=t.binding;if(i){let t=n.undoing||n.redoing?i.beforeTransactionSelection:tw(e.state).prevSel;r.meta.set(i,t)}}),{destroy:()=>{n.destroy(),r.forEach(e=>n.doc.off(`destroy`,e)),r.clear()}}}});function dw(e){return!!e.getMeta(ES)}function fw(e,t){if(t===null)return 0;let n=mw(e);return TS(n.doc,n.type,t,n.binding.mapping)||0}function pw(e,t){let n=mw(e);return fS(t,n.type,n.binding.mapping)}function mw(e){let t=ES.getState(e);if(!t)throw Error(`Collaboration requires the Yjs sync plugin`);return t}var hw=class e extends hd{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function gw(e,t){return new hw(e,pw(t,e))}function _w(e,t,n){let r=e instanceof hw?e.yRelativePosition:null;if(dw(t)&&r)return{position:new hw(fw(n,r),r),mapResult:null};let i=gd(e,t),a=i.position.position;return{position:new hw(a,r??pw(n,a)),mapResult:i.mapResult}}function vw(e){let t=DS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs undo plugin`);return t.undoManager}var yw=yp.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>_w(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>gw(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),vw(t).undoStack.length===0?!1:n?ow(t)??!1:!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),vw(t).redoStack.length===0?!1:n?sw(t)??!1:!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=uw(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let t=vw(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[ew(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,new E({filterTransaction:(e,t)=>(e.getMeta(`inputRule`)&&vw(t).stopCapturing(),!0)}),this.editor.options.enableContentCheck&&new E({key:new D(`filterInvalidContent`),filterTransaction:t=>{if(!dw(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!0}}})].filter(e=>e!==!1)}}),bw=e=>Array.from(e.entries()).map(([e,t])=>t&&t.user?{clientId:e,...t.user}:{clientId:e}),xw=()=>null,Sw=e=>Mf(e)&&/^#[0-9a-fA-F]{6}$/.test(e),Cw=e=>({...e,color:Sw(e.color)?e.color:`transparent`}),ww=yp.create({name:`collaborationCaret`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`),{color:n}=Cw(e);t.classList.add(`collaboration-carets__caret`),t.style.borderColor=n;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.style.backgroundColor=n,r.insertBefore(document.createTextNode(e.name),null),t.insertBefore(r,null),t},selectionRender:e=>Sw(e.color)?FS({name:e.name,color:e.color}):{},onUpdate:xw}},onCreate(){if(this.options.onUpdate!==xw&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),!this.options.provider)throw Error(`The "provider" option is required for the CollaborationCaret extension`)},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.provider.awareness.setLocalStateField(`user`,e),!0),user:e=>({editor:t})=>(console.warn(`[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret`),t.commands.updateUser(e))}},addProseMirrorPlugins(){let{provider:e}=this.options,t=this.storage,n=this.options.user;return[new E({key:new D(`collaborationCaretAwarenessListener`),view:()=>{let r=()=>{t.users=bw(e.awareness.states)};return e.awareness.setLocalStateField(`user`,n),t.users=bw(e.awareness.states),e.awareness.on(`update`,r),{destroy:()=>{e.awareness.off(`update`,r),t.users=[]}}}}),zS(e.awareness,{cursorBuilder:e=>this.options.render(Cw(e)),selectionBuilder:e=>this.options.selectionRender(Cw(e))})]}});function Tw(e={}){return new E({view(t){return new Ew(t,e)}})}var Ew=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=en(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},Dw=class e extends C{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):C.near(r)}content(){return p.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Ow(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Aw(e)||!jw(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!T.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};Dw.prototype.visible=!1,Dw.findFrom=Dw.findGapCursorFrom,C.jsonID(`gapcursor`,Dw);var Ow=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Dw.valid(t)?new Dw(t):C.near(t)}};function kw(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Aw(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||kw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function jw(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||kw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Mw(){return new E({props:{decorations:Lw,createSelectionBetween(e,t,n){return t.pos==n.pos&&Dw.valid(n)?new Dw(n):null},handleClick:Fw,handleKeyDown:Nw,handleDOMEvents:{beforeinput:Iw}}})}var Nw=xc({ArrowLeft:Pw(`horiz`,-1),ArrowRight:Pw(`horiz`,1),ArrowUp:Pw(`vert`,-1),ArrowDown:Pw(`vert`,1)});function Pw(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof w){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=Dw.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Dw(c))),!0):!1}}function Fw(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Dw.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&T.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Dw(r))),!0)}function Iw(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Dw))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=s.empty;for(let e=r.length-1;e>=0;e--)i=s.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new p(i,0,0));return a.setSelection(w.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Lw(e){if(!(e.selection instanceof Dw))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,k.create(e.doc,[vs.widget(e.selection.head,t,{key:`gapcursor`})])}yp.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new E({key:new D(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Rw=yp.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Tw(this.options)]}});yp.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new E({key:new D(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return k.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(vs.node(t,t+e.nodeSize,{class:this.options.className}))}),k.create(e,a)}}})]}});var zw=yp.create({name:`gapCursor`,addProseMirrorPlugins(){return[Mw()]},extendNodeSchema(e){return{allowGapCursor:ju(A(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Bw=`placeholder`,Vw=new D(`tiptap__placeholder`);function Hw(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),vs.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Uw(e,t){return typeof e==`function`?e(t):e}function Ww({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&dd(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Hw({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Uw(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Gw({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&dd(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Hw({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Uw(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Ww({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return k.create(r,o)}function Kw(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function qw(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function Jw(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function Yw(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(qw(e,Kw(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Ww({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function eT({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Gw({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??k.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:$w({decorations:i.map(r.mapping,r.doc),ranges:Zw(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function tT(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function nT({editor:e,options:t}){let n=t.dataAttribute?`data-${tT(t.dataAttribute)}`:`data-${Bw}`,r=t.showOnlyCurrent&&!t.includeChildren;return new E({key:Vw,...r?{}:{state:eT({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Gw({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?k.empty:Vw.getState(n)??k.empty}})}var rT=yp.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Bw,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[nT({editor:this.editor,options:this.options})]}});function iT(e,t){return!e.selection.empty&&!fd(e.selection)&&t.isEditable}function aT(e,t){return iT(e,t)&&!t.isFocused&&!t.view.dragging}function oT(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function sT(e){e.focus()}yp.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new E({key:new D(`selection`),props:{decorations(n){return aT(n,e)?k.create(n.doc,[vs.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return iT(t.state,e)&&oT(),!1},focus(t){return iT(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&sT(t)}),!1}}}})]}});function cT({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var lT=yp.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new D(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new E({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!cT({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!cT({node:r,types:n})}}})]}}),uT=yp.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Gc(e,t),redo:()=>({state:e,dispatch:t})=>Kc(e,t)}},addProseMirrorPlugins(){return[Uc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),dT=new WeakSet,fT=new WeakSet;function pT(e){let t=e;return dT.add(t),t}function mT(e){return Array.isArray(e)&&dT.has(e)}function hT(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&fT.has(e)&&!mT(e)?hT(e):[e])}function gT(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!mT(n)&&!fT.has(n)?pT(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(mT(n))return pT([e,r,n]);if(n.length===0)return pT([e,r]);let t=hT(n);return t.length===0?pT([e,r]):pT([e,r,...t])}return pT(n==null?[e,r]:[e,r,n])}var _T=(e,t)=>gT(e,t),vT=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new p(n,0,0);return e.replace(l,i.after(),r),e.setSelection(w.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},yT=/^\s*>\s$/,bT=Hp.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return _T(`blockquote`,{...Fu(this.options.HTMLAttributes,e),children:_T(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` +`,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;ln.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.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,Gp(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}},qp=class e extends hp{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function Jp(e){return new _p({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=Nu(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.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>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var Yp=()=>new Map,Xp=e=>{let t=Yp();return e.forEach((e,n)=>{t.set(n,e)}),t},Zp=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Qp=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},$p=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},em=()=>new Set,tm=e=>e[e.length-1],nm=(e,t)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{let n=Array(e);for(let r=0;r{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return rm((this._observers.get(e)||Yp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Yp()}},lm=class{constructor(){this._observers=Yp()}on(e,t){Zp(this._observers,e,em).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return rm((this._observers.get(e)||Yp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Yp()}},um=Math.floor,dm=Math.abs,fm=(e,t)=>ee>t?e:t;Number.isNaN;var mm=e=>e===0?1/e<0:e<0,hm=1<<29,gm=2**53-1,_m=-(2**53-1),vm=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&um(e)===e);Number.isNaN,Number.parseInt;var ym=String.fromCharCode;String.fromCodePoint,ym(65535);var bm=e=>e.toLowerCase(),xm=/^\s*/g,Sm=e=>e.replace(xm,``),Cm=/([A-Z])/g,wm=(e,t)=>Sm(e.replace(Cm,e=>`${t}${bm(e)}`)),Tm=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;eEm.encode(e):Tm,Om=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Om&&Om.decode(new Uint8Array).length===1&&(Om=null);var km=(e,t)=>om(t,()=>e).join(``),Am=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},jm=()=>new Am,Mm=e=>{let t=jm();return e(t),Pm(t)},Nm=e=>{let t=e.cpos;for(let n=0;n{let t=new Uint8Array(Nm(e)),n=0;for(let r=0;r{let n=e.cbuf.length;n-e.cpos{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Lm=Im,j=(e,t)=>{for(;t>127;)Im(e,128|127&t),t=um(t/128);Im(e,127&t)},Rm=(e,t)=>{let n=mm(t);for(n&&(t=-t),Im(e,(t>63?128:0)|(n?64:0)|63&t),t=um(t/64);t>0;)Im(e,(t>127?128:0)|127&t),t=um(t/128)},zm=new Uint8Array(3e4),Bm=zm.length/3,Vm=Em&&Em.encodeInto?(e,t)=>{if(t.length{let n=unescape(encodeURIComponent(t)),r=n.length;j(e,r);for(let t=0;t{let n=e.cbuf.length,r=e.cpos,i=fm(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(pm(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Um=(e,t)=>{j(e,t.byteLength),Hm(e,t)},Wm=(e,t)=>{Fm(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Gm=(e,t)=>Wm(e,4).setFloat32(0,t,!1),Km=(e,t)=>Wm(e,8).setFloat64(0,t,!1),qm=(e,t)=>Wm(e,8).setBigInt64(0,t,!1),Jm=new DataView(new ArrayBuffer(4)),Ym=e=>(Jm.setFloat32(0,e),Jm.getFloat32(0)===e),Xm=(e,t)=>{switch(typeof t){case`string`:Im(e,119),Vm(e,t);break;case`number`:vm(t)&&dm(t)<=2147483647?(Im(e,125),Rm(e,t)):Ym(t)?(Im(e,124),Gm(e,t)):(Im(e,123),Km(e,t));break;case`bigint`:Im(e,122),qm(e,t);break;case`object`:if(t===null)Im(e,126);else if(sm(t)){Im(e,117),j(e,t.length);for(let n=0;n0&&j(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Qm=e=>{e.count>0&&(Rm(e.encoder,e.count===1?e.s:-e.s),e.count>1&&j(e.encoder,e.count-2))},$m=class{constructor(){this.encoder=new Am,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Qm(this),this.count=1,this.s=e)}toUint8Array(){return Qm(this),Pm(this.encoder)}},eh=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Rm(e.encoder,t),e.count>1&&j(e.encoder,e.count-2)}},th=class{constructor(){this.encoder=new Am,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(eh(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return eh(this),Pm(this.encoder)}},nh=class{constructor(){this.sarr=[],this.s=``,this.lensE=new $m}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Am;return this.sarr.push(this.s),this.s=``,Vm(e,this.sarr.join(``)),Hm(e,this.lensE.toUint8Array()),Pm(e)}},rh=e=>Error(e),ih=()=>{throw rh(`Method unimplemented`)},ah=()=>{throw rh(`Unexpected case`)},oh=rh(`Unexpected end of array`),sh=rh(`Integer out of Range`),ch=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw oh;return new Uint8Array(e.buffer,e.byteOffset+t,n)},lh=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw oh;return new DataView(e.buffer,e.byteOffset+t,n)},uh=class{constructor(e){this.arr=e,this.pos=0}},dh=e=>new uh(e),fh=e=>e.pos!==e.arr.length,ph=(e,t)=>{let n=ch(e.arr,e.pos,t);return e.pos+=t,n},mh=e=>ph(e,M(e)),hh=e=>e.arr[e.pos++],M=e=>{let t=0,n=1,r=e.arr.length;for(;e.posgm)throw sh}throw oh},gh=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.posgm)throw sh}throw oh},_h=Om?e=>Om.decode(mh(e)):e=>{let t=M(e);if(t===0)return``;{let n=String.fromCodePoint(hh(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(hh(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},vh=(e,t)=>{let n=lh(e.arr,e.pos,t);return e.pos+=t,n},yh=[e=>void 0,e=>null,gh,e=>vh(e,4).getFloat32(0,!1),e=>vh(e,8).getFloat64(0,!1),e=>vh(e,8).getBigInt64(0,!1),e=>!1,e=>!0,_h,e=>{let t=M(e),n={};for(let r=0;r{let t=M(e),n=[];for(let r=0;ryh[127-hh(e)](e),xh=class extends uh{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=fh(this)?M(this)+1:-1),this.count--,this.s}},Sh=class extends uh{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=gh(this);let e=mm(this.s);this.count=1,e&&(this.s=-this.s,this.count=M(this)+2)}return this.count--,this.s}},Ch=class extends uh{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=gh(this),t=e&1;this.diff=um(e/2),this.count=1,t&&(this.count=M(this)+2)}return this.s+=this.diff,this.count--,this.s}},wh=class{constructor(e){this.decoder=new Sh(e),this.str=_h(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Th=crypto.getRandomValues.bind(crypto),Eh=Math.random,Dh=()=>Th(new Uint32Array(1))[0],Oh=e=>e[um(Eh()*e.length)],kh=`10000000-1000-4000-8000-100000000000`,Ah=()=>kh.replace(/[018]/g,e=>(e^Dh()&15>>e/4).toString(16)),jh=Date.now,Mh=e=>new Promise(e);Promise.all.bind(Promise);var Nh=e=>e===void 0?null:e,Ph=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Ph=localStorage)}catch{}var Fh=Ph,Ih=Symbol(`Equality`),Lh=(e,t)=>e===t||!!e?.[Ih]?.(t)||!1,Rh=e=>typeof e==`object`,zh=Object.assign,Bh=Object.keys,Vh=(e,t)=>{for(let n in e)t(e[n],n)},Hh=e=>Bh(e).length,Uh=e=>{for(let t in e)return!1;return!0},Wh=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Gh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Kh=(e,t)=>e===t||Hh(e)===Hh(t)&&Wh(e,(e,n)=>(e!==void 0||Gh(t,n))&&Lh(t[n],e)),qh=Object.freeze,Jh=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Jh(e[t])}return qh(e)},Yh=(e,t,n=0)=>{try{for(;ne,Zh=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ih]!=null)return e[Ih](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;nt.includes(e),$h=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,eg=typeof window<`u`&&typeof document<`u`&&!$h;typeof navigator<`u`&&/Mac/.test(navigator.platform);var tg,ng=[],rg=()=>{if(tg===void 0){if($h){tg=Yp();let e=process.argv,t=null;for(let n=0;n{if(e.length!==0){let[t,n]=e.split(`=`);tg.set(`--${wm(t,`-`)}`,n),tg.set(`-${wm(t,`-`)}`,n)}})):tg=Yp()}return tg},ig=e=>rg().has(e),ag=e=>Nh($h?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Fh.getItem(e)),og=e=>ig(`--`+e)||ag(e)!==null,sg=og(`production`),cg=$h&&Qh({}.FORCE_COLOR,[`true`,`1`,`2`])||!ig(`--no-colors`)&&!og(`no-color`)&&(!$h||process.stdout.isTTY)&&(!$h||ig(`--color`)||ag(`COLORTERM`)!==null||(ag(`TERM`)||``).includes(`color`)),lg=e=>new Uint8Array(e),ug=e=>{let t=``;for(let n=0;nBuffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),fg=e=>{let t=atob(e),n=lg(t.length);for(let e=0;enew Uint8Array(Buffer.from(e,`base64`)),mg=eg?ug:dg,hg=eg?fg:pg,gg=e=>{let t=lg(e.byteLength);return t.set(e),t},_g=e=>Mm(t=>Xm(t,e)),vg=class{constructor(e,t){this.left=e,this.right=t}},yg=(e,t)=>new vg(e,t),bg=e=>e.next()>=.5,xg=(e,t,n)=>um(e.next()*(n+1-t)+t),Sg=(e,t,n)=>um(e.next()*(n+1-t)+t),Cg=(e,t,n)=>Sg(e,t,n),wg=e=>ym(Cg(e,97,122)),Tg=(e,t=0,n=20)=>{let r=Cg(e,t,n),i=``;for(let t=0;tt[Cg(e,0,t.length-1)],Dg=Symbol(`0schema`),Og=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(km(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(` +`)}},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;if(qg.check(e)){let t={};for(let n in e)t[n]=D_(e[n]);return Gg(t)}if(n_.check(e))return l_(...e.map(D_));if(E_.check(e))return Ig(e);if(s_.check(e))return Mg(e);ah()},O_=sg?()=>{}:(e,t)=>{let n=new Og;if(!t.check(e,n))throw rh(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},k_=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:D_(e),h:t}),this}else(e){return this.if(f_,e)}done(){return(e,t)=>{for(let n=0;nnew k_(e))(f_).if(v_,(e,t)=>xg(t,_m,gm)).if(b_,(e,t)=>Tg(t)).if(S_,(e,t)=>bg(t)).if(h_,(e,t)=>BigInt(xg(t,_m,gm))).if(u_,(e,t)=>j_(t,Eg(t,e.shape))).if(Kg,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Hg.check(i)){if(bg(t))continue;i=i.shape}n[r]=A_(i,t)}return n}).if(t_,(e,t)=>{let n=[],r=Sg(t,0,42);for(let i=0;iEg(t,e.shape)).if(T_,(e,t)=>null).if(o_,(e,t)=>{let n=j_(t,e.res);return()=>n}).if(p_,(e,t)=>j_(t,Eg(t,[__,y_,w_,C_,m_,x_,e_(__),Yg(l_(`a`,`b`,`c`),__)]))).if(Xg,(e,t)=>{let n={},r=xg(t,0,3);for(let i=0;iA_(D_(t),e),M_=typeof document<`u`?document:{};Pg(e=>e.nodeType===L_),typeof DOMParser<`u`&&new DOMParser,Pg(e=>e.nodeType===P_),Pg(e=>e.nodeType===F_);var N_=e=>Qp(e,(e,t)=>`${t}:${e};`).join(``),P_=M_.ELEMENT_NODE,F_=M_.TEXT_NODE;M_.CDATA_SECTION_NODE,M_.COMMENT_NODE;var I_=M_.DOCUMENT_NODE;M_.DOCUMENT_TYPE_NODE;var L_=M_.DOCUMENT_FRAGMENT_NODE;Pg(e=>e.nodeType===I_);var R_=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),z_=(e,t)=>new R_(setTimeout(t,e)),B_=Symbol,V_=B_(),H_=B_(),U_=B_(),W_=B_(),G_=B_(),K_=B_(),q_=B_(),J_=B_(),Y_=B_(),X_=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r0&&n.push(t.join(``));r{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Yp(),i=[],a=0;for(;a0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a{console.log(...Q_(e)),tv.forEach(t=>t.print(e))},ev=(...e)=>{console.warn(...Q_(e)),e.unshift(J_),tv.forEach(t=>t.print(e))},tv=em(),nv=e=>({[Symbol.iterator](){return this},next:e}),rv=(e,t)=>nv(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),iv=(e,t)=>nv(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),av=class{constructor(e,t){this.clock=e,this.len=t}},ov=class{constructor(){this.clients=new Map}},sv=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r{let n=0,r=e.length-1;for(;n<=r;){let i=um((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t{let n=e.clients.get(t.client);return n!==void 0&&cv(n,t.clock)!==null},uv=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t=i.clock?e[n-1]=new av(r.clock,pm(r.len,i.clock+i.len-r.clock)):(n{let t=new ov;for(let n=0;n{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t{Zp(e.clients,t,()=>[]).push(new av(n,r))},pv=()=>new ov,mv=e=>{let t=pv();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t0&&t.clients.set(n,r)}),t},hv=(e,t)=>{j(e.restEncoder,t.clients.size),rm(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),j(e.restEncoder,t);let r=n.length;j(e.restEncoder,r);for(let t=0;t{let t=new ov,n=M(e.restDecoder);for(let r=0;r0){let i=Zp(t.clients,n,()=>[]);for(let t=0;t{let r=new ov,i=M(e.restDecoder);for(let a=0;a0){let e=new Dv;return j(e.restEncoder,0),hv(e,r),e.toUint8Array()}return null},vv=Dh,yv=class e extends cm{constructor({guid:e=Ah(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=vv(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new vy,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Mh(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Mh(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Iy(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(rm(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Iy(this,e,t)}get(e,t=fb){let n=Zp(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==fb&&r!==t){if(r===fb){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,Nb)}getText(e=``){return this.get(e,ex)}getMap(e=``){return this.get(e,Ib)}getXmlElement(e=``){return this.get(e,ax)}getXmlFragment(e=``){return this.get(e,rx)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,rm(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Iy(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},bv=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return M(this.restDecoder)}readDsLen(){return M(this.restDecoder)}},xv=class extends bv{readLeftID(){return N(M(this.restDecoder),M(this.restDecoder))}readRightID(){return N(M(this.restDecoder),M(this.restDecoder))}readClient(){return M(this.restDecoder)}readInfo(){return hh(this.restDecoder)}readString(){return _h(this.restDecoder)}readParentInfo(){return M(this.restDecoder)===1}readTypeRef(){return M(this.restDecoder)}readLen(){return M(this.restDecoder)}readAny(){return bh(this.restDecoder)}readBuf(){return gg(mh(this.restDecoder))}readJSON(){return JSON.parse(_h(this.restDecoder))}readKey(){return _h(this.restDecoder)}},Sv=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=M(this.restDecoder),this.dsCurrVal}readDsLen(){let e=M(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Cv=class extends Sv{constructor(e){super(e),this.keys=[],M(e),this.keyClockDecoder=new Ch(mh(e)),this.clientDecoder=new Sh(mh(e)),this.leftClockDecoder=new Ch(mh(e)),this.rightClockDecoder=new Ch(mh(e)),this.infoDecoder=new xh(mh(e),hh),this.stringDecoder=new wh(mh(e)),this.parentInfoDecoder=new xh(mh(e),hh),this.typeRefDecoder=new Sh(mh(e)),this.lenDecoder=new Sh(mh(e))}readLeftID(){return new Xv(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Xv(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return bh(this.restDecoder)}readBuf(){return mh(this.restDecoder)}readJSON(){return bh(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e{r=pm(r,t[0].id.clock);let i=Sy(t,r);j(e.restEncoder,t.length-i),e.writeClient(n),j(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n{let r=new Map;n.forEach((e,n)=>{by(t,n)>e&&r.set(n,e)}),yy(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),j(e.restEncoder,r.size),rm(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Ov(e,t.clients.get(n),n,r)})},Av=(e,t)=>{let n=Yp(),r=M(e.restDecoder);for(let i=0;i{let r=[],i=rm(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new vy,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Qx){let i=Zp(d,u.id.client,()=>by(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,by(t,a)),f();else{u=e.refs[e.i++];continue}}else(i===0||i0)u=r.pop();else if(o!==null&&o.i0){let e=new Dv;return kv(e,s,new Map),j(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Mv=(e,t)=>kv(e,t.doc.store,t.beforeState),Nv=(e,t,n,r=new Cv(e))=>Iy(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=jv(e,i,Av(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(nt)&&o.missing.set(e,t)}o.update=Ky([o.update,a.update])}}else i.pendingStructs=a;let s=_v(r,e,i);if(i.pendingDs){let t=new Cv(dh(i.pendingDs));M(t.restDecoder);let n=_v(t,e,i);i.pendingDs=s&&n?Ky([s,n]):s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Pv(e.doc,t)}},n,!1),Pv=(e,t,n,r=Cv)=>{let i=dh(t);Nv(i,e,n,new r(i))},Fv=(e,t,n)=>Pv(e,t,n,xv),Iv=(e,t,n=new Map)=>{kv(e,t.store,n),hv(e,mv(t.store))},Lv=(e,t=new Uint8Array([0]),n=new Dv)=>{Iv(n,e,Bv(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(qy(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Tv)return Wy(r.map((e,t)=>t===0?e:Qy(e)));if(n.constructor===Dv)return Ky(r)}return r[0]},Rv=(e,t)=>Lv(e,t,new Tv),zv=e=>{let t=new Map,n=M(e.restDecoder);for(let r=0;rzv(new bv(dh(e))),Vv=(e,t)=>(j(e.restEncoder,t.size),rm(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{j(e.restEncoder,t),j(e.restEncoder,n)}),e),Hv=(e,t)=>Vv(e,yy(t.store)),Uv=(e,t=new Ev)=>(e instanceof Map?Vv(t,e):Hv(t,e),t.toUint8Array()),Wv=e=>Uv(e,new wv),Gv=class{constructor(){this.l=[]}},Kv=()=>new Gv,qv=(e,t)=>e.l.push(t),Jv=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Yv=(e,t,n)=>Yh(e.l,[t,n]),Xv=class{constructor(e,t){this.client=e,this.clock=t}},Zv=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,N=(e,t)=>new Xv(e,t),Qv=e=>N(M(e),M(e)),$v=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw ah()},ey=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ty=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ny=e=>new ty(e.type==null?null:N(e.type.client,e.type.clock),e.tname??null,e.item==null?null:N(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),ry=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},iy=(e,t,n=0)=>new ry(e,t,n),ay=(e,t,n)=>{let r=null,i=null;return e._item===null?i=$v(e):r=N(e._item.id.client,e._item.id.clock),new ty(r,i,t,n)},oy=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ay(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ay(e,N(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ay(e,r.lastId,n);r=r.right}return ay(e,null,n)},sy=e=>{let t=null,n=null,r=null;switch(M(e)){case 0:r=Qv(e);break;case 1:n=_h(e);break;case 2:t=Qv(e)}let i=fh(e)?gh(e):0;return new ty(t,n,r,i)},cy=e=>sy(dh(e)),ly=(e,t)=>{let n=Cy(e,t);return{item:n,diff:t.clock-n.id.clock}},uy=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(by(r,i.client)<=i.clock)return null;let e=n?Ux(r,i):ly(r,i),t=e.item;if(!(t instanceof Jx))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(by(r,a.client)<=a.clock)return null;let{item:e}=n?Ux(r,a):{item:Cy(r,a)};if(e instanceof Jx&&e.content instanceof Vx)c=e.content.type;else return null}else throw ah();l=s>=0?c._length:0}return iy(c,l,e.assoc)},dy=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Zv(e.item,t.item)&&Zv(e.type,t.type)&&e.assoc===t.assoc,fy=class{constructor(e,t){this.ds=e,this.sv=t}},py=(e,t)=>new fy(e,t),my=py(pv(),new Map),hy=e=>py(mv(e.store),yy(e.store)),gy=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!lv(t.ds,e.id),_y=(e,t)=>{let n=Zp(e.meta,_y,em),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t{}),n.add(t))},vy=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},yy=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},by=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},xy=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw ah()}n.push(t)},Sy=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=um(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t{let n=e.clients.get(t.client);return n[Sy(n,t.clock)]},wy=(e,t,n)=>{let r=Sy(t,n),i=t[r];return i.id.clock{let n=e.doc.store.clients.get(t.client);return n[wy(e,n,t.clock)]},Ey=(e,t,n)=>{let r=t.clients.get(n.client),i=Sy(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==mx&&r.splice(i+1,0,Gx(e,a,n.clock-a.id.clock+1)),a},Dy=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Sy(r,t.id.clock)]=n},Oy=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=wy(e,t,n),s;do s=t[o++],at.deleteSet.clients.size===0&&!$p(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(uv(t.deleteSet),Mv(e,t),hv(e,t.deleteSet),!0),jy=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Zp(e.changed,t,em).add(n)},My=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0&&r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n);n=r,r=e[--i-1])n instanceof Jx&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);let a=t-i;return a&&e.splice(t+1-a,a),a},Ny=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Sy(e,a.clock),i=e[r];r{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=fm(r.length-1,1+Sy(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+My(r,e)}})},Fy=(e,t)=>{if(te.push(()=>{r._item!==null&&r._item.deleted||r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&e.push(()=>{t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),Yv(r._dEH,t,n)})}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Zb(n)})}),Yh(e,[])}finally{r.gc&&Ny(a,i,r.gcFilter),Py(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=pm(Sy(e,r),1);for(let t=e.length-1;t>=n;)t-=1+My(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Sy(r,n);a+11||a>0&&My(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&($_(J_,V_,`[yjs] `,H_,K_,`Changed the client-id because another client seems to be using it.`),r.clientID=vv()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Tv;Ay(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Dv;Ay(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Fy(e,t+1)}}},Iy=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new ky(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Fy(i,0)}}return o},Ly=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ry=(e,t,n)=>{sv(e,n.deletions,n=>{n instanceof Jx&&t.scope.some(t=>t===e.doc||ey(t,n))&&Wx(n,!1)})},zy=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Iy(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;sv(n,o.insertions,e=>{if(e instanceof Jx){if(e.redone!==null){let{item:t,diff:i}=Ux(r,e.id);i>0&&(t=Ty(n,N(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ey(t,e))&&c.push(e)}}),sv(n,o.deletions,e=>{e instanceof Jx&&a.some(t=>t===n.doc||ey(t,e))&&!lv(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=qx(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},By=class extends cm{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=sm(e)?e[0].doc:e instanceof yv?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new ov;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&fv(i,n,r,a)});let a=jh(),o=!1;if(this.lastChange>0&&a-this.lastChange0&&!t&&!n){let t=r[r.length-1];t.deletions=dv([t.deletions,e.deleteSet]),t.insertions=dv([t.insertions,i])}else r.push(new Ly(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),sv(e,e.deleteSet,t=>{t instanceof Jx&&this.scope.some(n=>n===e.doc||ey(n,t))&&Wx(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.destroy=this.destroy.bind(this),this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,this.destroy)}addToScope(e){let t=new Set(this.scope);e=sm(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof fb?e.doc!==this.doc:e!==this.doc)&&ev(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ry(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ry(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=zy(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=zy(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),this.doc.off(`destroy`,this.destroy),super.destroy()}};function*Vy(e){let t=M(e.restDecoder);for(let n=0;nKy(e,xv,Tv),Gy=(e,t)=>{if(e.constructor===mx){let{client:n,clock:r}=e.id;return new mx(N(n,r+t),e.length-t)}if(e.constructor===Qx){let{client:n,clock:r}=e.id;return new Qx(N(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Jx(N(r,i+t),null,N(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ky=(e,t=Cv,n=Dv)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(dh(e))),i=r.map(e=>new Hy(e,!0)),a=null,o=new n,s=new Uy(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Qx?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Yy(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length0&&(a.struct.constructor===Qx?a.struct.length-=t:n=Gy(n,t)),a.struct.mergeWith(n)||(Yy(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Qx;n=e.next())Yy(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Yy(s,a.struct,a.offset),a=null),Xy(s),hv(o,dv(r.map(e=>gv(e)))),o.toUint8Array()},qy=(e,t,n=Cv,r=Dv)=>{let i=Bv(t),a=new r,o=new Uy(a),s=new n(dh(e)),c=new Hy(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Qx)c.next();else if(e.id.clock+e.length>n)for(Yy(o,e,pm(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Yy(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Xy(o),hv(a,gv(s)),a.toUint8Array()},Jy=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Pm(e.encoder.restEncoder)}),e.encoder.restEncoder=jm(),e.written=0)},Yy=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Jy(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),j(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Xy=e=>{Jy(e);let t=e.encoder.restEncoder;j(t,e.clientStructs.length);for(let n=0;n{let i=new n(dh(e)),a=new Hy(i,!1),o=new r,s=new Uy(o);for(let e=a.curr;e!==null;e=a.next())Yy(s,t(e),0);return Xy(s),hv(o,gv(i)),o.toUint8Array()},Qy=e=>Zy(e,Xh,Cv,Tv),$y=`You must not compute changes after the event-handler fired.`,eb=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=tb(this.currentTarget,this.target)}deletes(e){return lv(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw rh($y);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=tm(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=tm(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=tm(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw rh($y);let t=this.target,n=em(),r=em(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},tb=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},nb=()=>{ev(`Invalid access: Add Yjs type to a document before reading data.`)},rb=80,ib=0,ab=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ib++}},ob=e=>{e.timestamp=ib++},sb=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ib++},cb=(e,t,n)=>{if(e.length>=rb){let r=e.reduce((e,t)=>e.timestamp{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>dm(t-e.index)t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&dm(n.index-i){for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t0&&t===i.index)&&(i.index=pm(t,i.index+n))}},db=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Zp(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Yv(r._eH,n,t)},fb=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Kv(),this._dEH=Kv(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw ih()}clone(){throw ih()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){qv(this._eH,e)}observeDeep(e){qv(this._dEH,e)}unobserve(e){Jv(this._eH,e)}unobserveDeep(e){Jv(this._dEH,e)}toJSON(){}},pb=(e,t,n)=>{e.doc??nb(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},mb=e=>{e.doc??nb();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n{let n=[],r=e._start;for(;r!==null;){if(r.countable&&gy(r,t)){let e=r.content.getContent();for(let t=0;t{let n=0,r=e._start;for(e.doc??nb();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r{let n=[];return gb(e,(r,i)=>{n.push(t(r,i,e))}),n},vb=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},yb=(e,t)=>{e.doc??nb();let n=lb(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Jx(N(o,by(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new kx(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Jx(N(o,by(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new hx(new Uint8Array(n))),i.integrate(e,0);break;case yv:i=new Jx(N(o,by(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new bx(n)),i.integrate(e,0);break;default:if(n instanceof fb)i=new Jx(N(o,by(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Vx(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},xb=()=>rh(`Length exceeded!`),Sb=(e,t,n,r)=>{if(n>t._length)throw xb();if(n===0)return t._searchMarker&&ub(t._searchMarker,n,r.length),bb(e,t,null,r);let i=n,a=lb(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return bb(e,t,r,n)},wb=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=lb(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n0&&s!==null;)s.deleted||(r0)throw xb();t._searchMarker&&ub(t._searchMarker,i,-a+r)},Tb=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Eb=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new kx([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new kx([r]);break;case Uint8Array:s=new hx(r);break;case yv:s=new bx(r);break;default:if(r instanceof fb)s=new Vx(r);else throw Error(`Unexpected content type`)}new Jx(N(o,by(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Db=(e,t)=>{e.doc??nb();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ob=e=>{let t={};return e.doc??nb(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},kb=(e,t)=>{e.doc??nb();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ab=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&gy(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},jb=e=>(e.doc??nb(),rv(e._map.entries(),e=>!e[1].deleted)),Mb=class extends eb{},Nb=class e extends fb{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_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._length}_callObserver(e,t){super._callObserver(e,t),db(this,e,new Mb(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Iy(this.doc,n=>{Sb(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Iy(this.doc,t=>{Cb(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Iy(this.doc,n=>{wb(n,this,e,t)})}get(e){return yb(this,e)}toArray(){return mb(this)}slice(e=0,t=this.length){return pb(this,e,t)}toJSON(){return this.map(e=>e instanceof fb?e.toJSON():e)}map(e){return _b(this,e)}forEach(e){gb(this,e)}[Symbol.iterator](){return vb(this)}_write(e){e.writeTypeRef(Px)}},Pb=e=>new Nb,Fb=class extends eb{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ib=class e extends fb{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof fb?e.clone():e)}),t}_callObserver(e,t){db(this,e,new Fb(this,e,t))}toJSON(){this.doc??nb();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof fb?r.toJSON():r}}),e}get size(){return[...jb(this)].length}keys(){return iv(jb(this),e=>e[0])}values(){return iv(jb(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return iv(jb(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??nb(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Iy(this.doc,t=>{Tb(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Iy(this.doc,n=>{Eb(n,this,e,t)}),t}get(e){return Db(this,e)}has(e){return kb(this,e)}clear(){this.doc===null?this._prelimContent.clear():Iy(this.doc,e=>{this.forEach(function(t,n,r){Tb(e,r,n)})})}_write(e){e.writeTypeRef(Fx)}},Lb=e=>new Ib,Rb=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Kh(e,t),zb=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&ah(),this.right.content.constructor){case wx:this.right.deleted||Ub(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}},Bb=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case wx:t.right.deleted||Ub(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n{let i=new Map,a=r?lb(t,n):null;return a?Bb(e,new zb(a.p.left,a.p,a.index,i),n-a.index):Bb(e,new zb(null,t._start,0,i),n)},Hb=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===wx&&Rb(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Jx(N(a,by(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new wx(o,r));l.integrate(e,0),n.right=l,n.forward()})},Ub=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Wb=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===wx&&Rb(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Gb=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Rb(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Jx(N(a,by(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new wx(s,c)),n.right.integrate(e,0),n.forward()}}return o},Kb=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Wb(n,i);let s=Gb(e,t,n,i),c=r.constructor===String?new jx(r):r instanceof fb?new Vx(r):new Sx(r),{left:l,right:u,index:d}=n;t._searchMarker&&ub(t._searchMarker,n.index,c.getLength()),u=new Jx(N(o,by(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Hb(e,t,n,s)},qb=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Wb(n,i);let s=Gb(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===wx));){if(!n.right.deleted)switch(n.right.content.constructor){case wx:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Rb(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r0){let i=``;for(;r>0;r--)i+=` +`;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{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;i0)&&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=>e instanceof fb?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i0?` `+t.join(` `):``}>${super.toString()}`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Iy(this.doc,t=>{Tb(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Iy(this.doc,n=>{Eb(n,this,e,t)})}getAttribute(e){return Db(this,e)}hasAttribute(e){return kb(this,e)}getAttributes(e){return e?Ab(this,e):Ob(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return gb(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Lx),e.writeKey(this.nodeName)}},ox=e=>new ax(e.readKey()),sx=class extends eb{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},cx=class e extends Ib{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(zx),e.writeKey(this.hookName)}},lx=e=>new cx(e.readKey()),ux=class e extends ex{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}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.keye.nodeName`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=``;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Bx)}},dx=e=>new ux,fx=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ih()}mergeWith(e){return!1}write(e,t,n){throw ih()}integrate(e,t){throw ih()}},px=0,mx=class extends fx{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),xy(e.doc.store,this)}write(e,t){e.writeInfo(px),e.writeLen(this.length-t)}getMissing(e,t){return null}},hx=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw ih()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},gx=e=>new hx(e.readBuf()),_x=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){fv(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},vx=e=>new _x(e.readLen()),yx=(e,t)=>new yv({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),bx=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(yx(this.doc.guid,this.opts))}splice(e){throw ih()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},xx=e=>new bx(yx(e.readString(),e.readAny())),Sx=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw ih()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Cx=e=>new Sx(e.readJSON()),wx=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw ih()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Tx=e=>new wx(e.readKey(),e.readJSON()),Ex=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r{let t=e.readLen(),n=[];for(let r=0;r{let t=e.readLen(),n=[];for(let r=0;r=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Mx=e=>new jx(e.readString()),Nx=[Pb,Lb,tx,ox,ix,lx,dx],Px=0,Fx=1,Ix=2,Lx=3,Rx=4,zx=5,Bx=6,Vx=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw ih()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Hx=e=>new Vx(Nx[e.readTypeRef()](e)),Ux=(e,t)=>{let n=t,r=0,i;do r>0&&(n=N(n.client,n.clock+r)),i=Cy(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Jx);return{item:i,diff:r}},Wx=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Gx=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Jx(N(r,i+n),t,N(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=N(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Kx=(e,t)=>am(e,e=>lv(e.deletions,t)),qx=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Ty(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||qx(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Ty(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Ty(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Ty(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||lv(r,d.right.id)||Kx(a.undoStack,d.right.id)||Kx(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ty(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=N(c,by(s,c)),h=new Jx(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Wx(h,!0),h.integrate(e,0),h},Jx=class e extends fx{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=by(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=by(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Xv&&this.id.client!==this.parent.client&&this.parent.clock>=by(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Ey(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Ty(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===mx||this.right&&this.right.constructor===mx)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Xv){let e=Cy(n,this.parent);this.parent=e.constructor===mx?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Ey(e,e.doc.store,N(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),Zv(this.origin,n.origin)){if(n.id.client{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),fv(e.deleteSet,this.id.client,this.id.clock,this.length),jy(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw ah();this.content.gc(e),t?Dy(e,this,new mx(this.id,this.length)):this.content=new _x(this.length)}write(e,t){let n=t>0?N(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=$v(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Xv?(e.writeParentInfo(!1),e.writeLeftID(t)):ah();i!==null&&e.writeString(i)}this.content.write(e,t)}},Yx=(e,t)=>Xx[t&31](e),Xx=[()=>{ah()},vx,Dx,gx,Mx,Cx,Tx,Hx,Ax,xx,()=>{ah()}],Zx=10,Qx=class extends fx{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){ah()}write(e,t){e.writeInfo(Zx),j(e.restEncoder,this.length-t)}getMissing(e,t){return null}},$x=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},eS=`__ $YJS$ __`;$x[eS]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),$x[eS]=!0;var tS=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},nS=(e,t)=>e>>>t|e<<32-t,rS=e=>nS(e,2)^nS(e,13)^nS(e,22),iS=e=>nS(e,6)^nS(e,11)^nS(e,25),aS=e=>nS(e,7)^nS(e,18)^e>>>3,oS=e=>nS(e,17)^nS(e,19)^e>>>10,sS=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),cS=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),lS=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(cS),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=oS(t[e-2])+t[e-7]+aS(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+iS(o)+(o&s^~o&c)+sS[e]+t[e]>>>0,d=rS(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3=0&&t>>(3-t)*8;return i}},uS=e=>new lS().digest(e),dS=/[\uD800-\uDBFF]/,fS=/[\uDC00-\uDFFF]/,pS=(e,t)=>{let n=0,r=0;for(;n0&&dS.test(e[n-1])&&n--;r+n0&&fS.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}};function mS(e){if(!e||!(e.content instanceof Vx))return null;let t=e.content.type;if(!(t instanceof rx||t instanceof ex||t instanceof cx))throw Error(`Expected a Yjs XML type`);return t}function hS(e){if(e===null)return null;if(!(e.parent instanceof fb))throw Error(`Expected an integrated Yjs parent`);let t=e.parent;if(!(t instanceof rx||t instanceof ex||t instanceof cx))throw Error(`Expected a Yjs XML type`);return t}var gS=(e,t)=>{let n=null,r=null;return e._item===null?r=$v(e):n=N(e._item.id.client,e._item.id.clock),new ty(n,r,t.id)},_S=(e,t,n)=>{if(e===0)return oy(t,0,-1);let r=mS(t._first);for(;r!==null&&t!==r;){if(r instanceof ux){if(r._length>=e)return oy(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=mS(r._item.next);else{do r=hS(r._item),e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:mS(r._item.next))}}else{let i=n.get(r),a=i instanceof le?i.nodeSize:0;if(r._first!==null&&e1)return new ty(r._item===null?null:r._item.id,r._item===null?$v(r):null,null);if(e-=a,r._item!==null&&r._item.next!==null)r=mS(r._item.next);else{if(e===0){if(r=r._item===null?r:hS(r._item),r===null)throw ah();return new ty(r._item===null?null:r._item.id,r._item===null?$v(r):null,null)}do{if(r=hS(r._item),r===null)throw ah();e--}while(r!==t&&r._item?.next===null);r!==t&&(r=mS(r._item?.next))}}}if(r===null)throw ah();if(e===0&&r.constructor!==ux&&r!==t){let e=r._item,t=hS(e);if(e===null||t===null)throw ah();return gS(t,e)}}return oy(t,t._length,-1)},vS=(e,t)=>{if(!e.docChanged)return!1;if(e.doc.childCount!==t.childCount)return!0;for(let n of e.steps)if(n instanceof Dt){if(n.from===0&&n.to===t.content.size)return!0;if(n.slice.content.size>0){let e=!1;if(n.slice.content.forEach(t=>{t.isBlock&&(e=!0)}),e)return!0}else if(n.to>n.from){let e=t.resolve(n.from),r=t.resolve(n.to);if(e.depth===0&&r.depth===0&&e.index()!==r.index())return!0}}return!1};function yS(e,t){if(e instanceof ux)return e._length;let n=t.get(e);return n instanceof le?n.nodeSize:null}function bS(e,t,n){let r=0,i=e._first;for(;i!==null;){let e=mS(i);if(e===t)break;let a=i.deleted;if(i=i.right,a)continue;if(e===null)return null;let o=yS(e,n);if(o===null)return null;r+=o}return r}function xS(e,t,n){let r=0,i=0,a=e._first;for(;i{if(n===null)return!1;let r=uy(t,e);return r!==null&&r.type instanceof ux&&t.item!==null&&r.type._item?.deleted===!0},CS=e=>{if(!e.doc)throw Error(`The Yjs fragment must belong to a document`);let t=e._item?`item:${e._item.id.client}:${e._item.id.clock}`:`root:${$v(e)}`;return e.doc.getMap(`__tiptap_position_migrations:${t}`)},wS=new WeakMap,TS=(e,t)=>{let n=t.item??t.type;if(!n)return[];let r;t.item||(r=t.assoc<0?`start`:`end`);let i=wS.get(e);if(!i||i.size!==e.size){let t=new Map;e.forEach(e=>e.transfers.forEach(n=>{let r=t.get(n.source.client)??[];r.push({migration:e,transfer:n}),t.set(n.source.client,r)})),i={size:e.size,clients:t},wS.set(e,i)}let a=(i.clients.get(n.client)??[]).filter(({transfer:e})=>e.source.boundary===r&&e.source.clock<=n.clock&&n.clock!a.some(t=>t.migration!==e.migration&&t.migration.seen.some(([t,n])=>t===e.migration.client&&n>e.migration.clock)))},ES=(e,t,n)=>{let{source:r,target:i}=e.transfer;return i?new ty(i.boundary?N(i.client,i.clock):i.type,i.tname??null,i.boundary?null:N(i.client,i.clock+t.clock-r.clock),i.assoc??n):null},DS=(e,t,n)=>{let r=ES(e[0],t,n);return!r||e.some(e=>{let i=ES(e,t,n);return!i||!dy(r,i)})?null:r},OS=e=>{let t=e.item??e.type;if(!t)return null;let n=e.assoc<0?`start`:`end`;return e.item&&(n=`item`),`${t.client}:${t.clock}:${n}`},kS=(e,t)=>{let n=CS(e),r=new Set,i=t,a=i.item??i.type;for(;a;){let e=OS(i);if(r.has(e))return null;r.add(e);let t=TS(n,i);if(t.length===0)return i;let o=DS(t,a,i.assoc);if(!o)return null;if(OS(o)===e)return o;i=o,a=o.item??o.type}return i},AS=(e,t,n,r)=>{let i=kS(t,n);if(!i)return null;n=i;let a=uy(n,e);if(a===null||a.type!==t&&!ey(t,a.type._item))return null;let o=a.type,s=0;if(o.constructor===ux)s=a.index;else if(!o._item?.deleted){let e=xS(o,a.index,r);if(e===null)return null;s=e+1}for(;o!==t&&o._item!==null;){let e=hS(o._item);if(e===null)return null;if(e._item?.deleted){o=e;continue}let t=bS(e,o,r);if(t===null)return null;s+=t+1,o=e}let c=s-1;return SS(e,n,c)?null:c},jS=new D(`y-sync`),MS=new D(`y-undo`),NS=new D(`yjs-cursor`),PS=null;function FS(){let e=PS;PS=null;let t=[];return e?.forEach((e,n)=>{e.forEach((e,r)=>t.push({view:n,key:r,value:e}))}),t}function IS(e=FS(),t=!1){let n=!0;for(;e.length>0;){let{view:r,key:i,value:a}=e[0];try{let e=jS.getState(r.state);e&&e.binding.prosemirrorView!==null&&r.dispatch(r.state.tr.setMeta(i,a))}catch(r){if(!(r instanceof RangeError))throw r;t&&n&&e.shift(),e.length>0&&z_(0,()=>IS(e,!0));return}n=!1,e.shift()}}function LS(e,t,n){PS===null&&(PS=new Map,z_(0,IS));let r=PS.get(e);r||(r=new Map,PS.set(e,r)),r.set(t,n)}var RS=(e,t,n)=>e!==t,zS=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},BS=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),VS=/^#[0-9a-fA-F]{6}$/,HS=e=>typeof e.name==`string`&&typeof e.color==`string`,US=(e,t,n,r,i)=>{let a=jS.getState(e);if(a==null||a.doc==null||a.binding==null)return xs.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?xs.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t&&t.cursor!=null){let n={...t.user};if(n.color==null?n.color=`#ffa500`:VS.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`,!HS(n))return;let l=AS(o,a.type,ny(t.cursor.anchor),a.binding.mapping),u=AS(o,a.type,ny(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=pm(e.doc.content.size-1,0);l=fm(l,t),u=fm(u,t),s.push(vs.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=fm(l,u),o=pm(l,u);s.push(vs.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),xs.create(e.doc,s))},WS=(e,{awarenessStateFilter:t=RS,cursorBuilder:n=zS,selectionBuilder:r=BS,getSelection:i=e=>e.selection}={},a=`cursor`)=>new E({key:NS,state:{init(i,a){return US(a,e,t,n,r)},apply(i,a,o,s){let c=jS.getState(s),l=i.getMeta(NS),u=c&&c.isChangeOrigin;return i.docChanged&&!u&&vS(i,o.doc)?xs.empty:u||l&&l.awarenessUpdated?US(s,e,t,n,r):i.docChanged?a.map(i.mapping,i.doc):a}},props:{decorations:e=>NS.getState(e)??xs.empty},view:t=>{let n=()=>{t.isDestroyed||LS(t,NS,{awarenessUpdated:!0})},r=t=>{let n=jS.getState(t.state);if(!n||!n.binding)return;let r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=_S(o.anchor,n.type,n.binding.mapping),c=_S(o.head,n.type,n.binding.mapping);r.cursor!=null&&dy(ny(r.cursor.anchor),s)&&dy(ny(r.cursor.head),c)||e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&AS(n.doc,n.type,ny(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)},o=()=>r(t);return e.on(`change`,n),t.dom.addEventListener(`focusin`,o),t.dom.addEventListener(`focusout`,o),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,o),t.dom.removeEventListener(`focusout`,o),e.off(`change`,n),e.setLocalStateField(a,null)}}}});function GS(e){let t=jS.getState(e);if(!t)throw Error(`The editor requires ySyncPlugin`);return t}var KS=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)??0)>e.id.clock&&!lv(t.ds,e.id),qS=(e,t,n)=>{if(!e.has(n)){if(e.sizen.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Oh(t))}let r=e.get(n);if(!r)throw Error(`At least one snapshot color is required`);return r},JS=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])},YS=e=>{let t=e.type.spec.attrs||{};return Object.keys(e.attrs).some(n=>{let r=t[n];return r==null||!Object.prototype.hasOwnProperty.call(r,`default`)||r.default!==e.attrs[n]})},XS=(e,t,n)=>{let r=0,i=0;for(;in)break;r+=t.nodeSize}if(i>=e.childCount)return null;let a=e.child(i),o=e.resolve(n),s=(e,t)=>{if(o.depth===0){let i=e+(n-r),a=e+1,o=e+t.nodeSize-1;return Math.max(a,Math.min(i,o))}if(o.depth>1){let n=XS(o.node(1),t,o.pos-o.start(1));return n===null?null:e+1+n}return t.isTextblock?e+1+Math.min(o.parentOffset,t.content.size):null},c=(n,r=!1)=>{let a=0;for(let t=0;t<=i;t++)n(e.child(t))&&a++;let o=0,c=-1,l=null,u=0;for(let e=0;ee.type===a.type&&JS(e.attrs,a.attrs),u=a.textContent,d=c(e=>l(e)&&e.textContent===u);if(d!==null)return d;let f=c(e=>e.type===a.type&&e.textContent===u);if(f!==null)return f;if(!a.isTextblock||YS(a)){let e=c(l,!0);if(e!==null)return e}return c(e=>l(e)&&u!==``&&e.textContent!==``&&(u.startsWith(e.textContent)||e.textContent.startsWith(u)),!0)},ZS=(e,t,n,r)=>{if(r===null)return!1;let i=e.resolve(n),a=t.resolve(r);if(!i.parent.isTextblock)return!1;if(!a.parent.isTextblock||i.parent.textContent!==a.parent.textContent||i.parentOffset!==0&&a.parentOffset===0)return!0;let o=i.parentOffset===0&&a.parentOffset===0,s=i.parentOffset!==a.parentOffset||i.parent.type!==a.parent.type||!JS(i.parent.attrs,a.parent.attrs);if(o||s){let i=XS(e,t,n);return i!==null&&i!==r}return!1},QS=(e,t,n,r)=>{if(n==null||n<0||n>t.content.size||!(r===null||n>1&&r<=1||ZS(t,e,n,r)))return r;let i=XS(t,e,n);return i===null?r:i},$S=(e,t,n,r)=>{if(t!==null&&t.anchor!==null&&t.head!==null){if(t.type===`all`)e.setSelection(new On(e.doc));else if(t.type===`node`){let r=AS(n.doc,n.type,t.anchor,n.mapping);r!==null&&e.setSelection(eC(e,r))}else if(t.type===`nodeRange`){let r=tC(e,AS(n.doc,n.type,t.anchor,n.mapping),AS(n.doc,n.type,t.head,n.mapping),t.depth);r!==null&&e.setSelection(r)}else{let i=AS(n.doc,n.type,t.anchor,n.mapping),a=AS(n.doc,n.type,t.head,n.mapping);r!=null&&(kS(n.type,t.anchor)===t.anchor&&(i=QS(e.doc,r,t.absAnchor,i)),kS(n.type,t.head)===t.head&&(a=QS(e.doc,r,t.absHead,a))),i===null&&(i=a),a===null&&(a=i),i!==null&&a!==null&&e.setSelection(w.between(e.doc.resolve(i),e.doc.resolve(a)))}}},eC=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?T.create(e.doc,t):w.near(n)},tC=(e,t,n,r)=>{if(t===null||n===null)return null;let i=Math.min(Math.max(t,0),e.doc.content.size),a=Math.min(Math.max(n,0),e.doc.content.size);try{let t=C.fromJSON(e.doc,{type:`nodeRange`,anchor:i,head:a,depth:r});return t.ranges.length?t:w.near(e.doc.resolve(i))}catch{return w.near(e.doc.resolve(i))}},nC=(e,t)=>{let n=t.selection,r=n.toJSON(),i=typeof r.type==`string`?r.type:`text`;return{type:i,depth:i===`nodeRange`&&`depth`in n&&typeof n.depth==`number`?n.depth:void 0,anchor:_S(t.selection.anchor,e.type,e.mapping),head:_S(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},rC=new WeakMap,iC=(e,t)=>{var n;(t instanceof rx||t instanceof ex||t instanceof cx)&&(e.delete(t),(n=rC.get(e))==null||n.delete(t))},aC=/(.*)(--[a-zA-Z0-9+/=]{8})$/,oC=e=>aC.exec(e)?.[1]??e,sC=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(oC(r),e[r]));return n},cC=e=>{let t=e.doc,n=e._item;if(!t||!n)throw ah();t.transact(e=>{n.delete(e)},jS)},lC=(e,t,n,r,i,a)=>{let o=e.toDelta(r,i,a);try{return o.map(e=>t.text(e.insert,sC(e.attributes,t)))}catch{return cC(e),null}},uC=e=>{var t;let n=(t=e._item)==null||(t=t.right)==null?void 0:t.content,r=n instanceof Vx?n.type:null;if(!(r instanceof ex))return;let i=r._item,a=r.doc;i&&a&&!i.deleted&&i.id.client===a.clientID&&(e.applyDelta([{retain:e.length},...r.toDelta()]),a.transact(e=>{i.delete(e)}))},dC=(e,t,n,r)=>{if(e._item){if(!KS(e._item,t))return r?r(`removed`,e._item.id):{type:`removed`};if(!KS(e._item,n))return r?r(`added`,e._item.id):{type:`added`}}},fC=(e,t,n)=>{e.mapping.set(t,n);let r=rC.get(e.mapping);r===void 0&&(r=new WeakMap,rC.set(e.mapping,r)),r.set(t,n)},pC=(e,t,n,r,i,a)=>{let o=n.mapping.get(e),s=Array.isArray(o)?void 0:o;if(s!==void 0&&rC.get(n.mapping)?.get(e)===s)return s;let c=[],l=e=>{if(e instanceof ax){let o=pC(e,t,n,r,i,a);o!==null&&c.push(o)}else e instanceof ux&&(uC(e),lC(e,t,n,r,i,a)?.forEach(e=>c.push(e)))};r===void 0||i===void 0?e.toArray().forEach(l):hb(e,new fy(i.ds,r.sv)).forEach(l);try{let o=e.getAttributes(r),l=r?dC(e,r,i,a):void 0;l!==void 0&&(o.ychange=l);let u=t.node(e.nodeName,o,c);return s?.eq(u)&&(u=s),fC(n,e,u),u}catch{return cC(e),iC(n.mapping,e),null}},mC=e=>{for(let t=6;tmg(mC(uS(_g(e)))),gC=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Zp(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${hC(e.toJSON())}`:e.type.name]=e.attrs}}),n},_C=(e,t)=>{let n=new ux,r=e.map(e=>({insert:e.text??``,attributes:gC(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},vC=e=>{let t=e.content.content,n=[];for(let e=0;ee instanceof Array?_C(e,t):bC(e,t),bC=(e,t)=>{let n=new ax(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,vC(e).map(e=>yC(e,t))),t.mapping.set(n,e),n},xC=e=>typeof e==`object`&&!!e,SC=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Bh(e.attributes||{}).length===t[n].marks.length&&Object.entries(e.attributes??{}).every(([e,r])=>{let i=oC(e),a=t[n].marks.find(e=>e.type.name===i);return a?SC(r,a.attrs):!1}))},wC=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,TC=(e,t)=>{if(e instanceof ax&&!(t instanceof Array)&&wC(e,t)){let n=vC(t);return e._length===n.length&&SC(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>TC(e,n[t]))}return e instanceof ux&&t instanceof Array&&CC(e,t)},EC=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),DC=(e,t,n)=>{let r=new Map;t.forEach((e,t)=>{r.has(e)||r.set(e,t)});let i=[];if(e.forEach((e,a)=>{let o=n.mapping.get(e),s=o===void 0?void 0:r.get(o);s!==void 0&&EC(o,t[s])&&i.push({yIndex:a,pIndex:s,yChild:e})}),i.length===0)return[];let a=[],o=[];for(let e=0;e>1;i[o[r]].pIndex0?o[t-1]:-1,o[t]=e}let s=[];for(let e=o[o.length-1];e!==-1;e=a[e])s.push(i[e]);return s.reverse()},OC=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof jx?t+=n.content.str:n.content instanceof wx&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},kC=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=OC(e),a=t.map(e=>({insert:e.text??``,attributes:Object.assign({},r,gC(e.marks,n))})),{insert:o,remove:s,index:c}=pS(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},AC=(e,t,n,r,i)=>t instanceof ux&&n instanceof Array?(CC(t,n)?r.mapping.set(t,n):kC(t,n,r),!0):t instanceof ax&&!(n instanceof Array)&&wC(t,n)?(TC(t,n)?r.mapping.set(t,n):i(e,t,n,r),!0):!1,jC=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>iC(r.mapping,e)),e.delete(t,n))},MC=(e,t,n,r,i,a)=>{if(r{let u=fm(a-i,s-o);for(let a=0;a{let o=DC(r,n,i);if(o.length<2||!o.some(e=>e.yIndex!==e.pIndex)||o.some(e=>{let t=n[e.pIndex];return!(e.yChild instanceof ux&&t instanceof Array||e.yChild instanceof ax&&!(t instanceof Array))}))return!1;let s=0,c=0;for(let l of o){NC(e,t,n,r,s,l.yIndex,c,l.pIndex,i,a);let o=n[l.pIndex];AC(e,l.yChild,o,i,a),s=l.yIndex+1,c=l.pIndex+1}return NC(e,t,n,r,s,r.length,c,n.length,i,a),!0},FC=(e,t,n)=>{let r=e.toArray(),i=vC(t),a=i.length,o=r.length,s=fm(o,a),c=0,l=0,u=!1;for(;c{if(t instanceof ax&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ax){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=vC(n),a=i.length,o=t.toArray(),s=o.length,c=fm(a,s),l=!1;if(e.transact(()=>{l=PC(e,t,i,o,r,IC)},jS),l)return;let u=0,d=0;for(;u{for(;s-u-d>0&&a-u-d>0;){let n=o[u],c=i[u],l=o[s-d-1],f=i[a-d-1];if(n instanceof ux&&c instanceof Array){CC(n,c)||kC(n,c,r),u+=1;continue}let p=n instanceof ax&&wC(n,c),m=l instanceof ax&&wC(l,f);if(p&&m&&n instanceof ax&&l instanceof ax&&!Array.isArray(c)&&!Array.isArray(f)){let e=FC(n,c,r),t=FC(l,f,r);e.foundMappedChild&&!t.foundMappedChild?m=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor0&&(t.slice(u,u+n).forEach(e=>iC(r.mapping,e)),t.delete(u,n)),u+d>=a)return;let c=[];for(let e=u;e{let n=[];if(!e._item)throw Error(`Position tracking requires integrated text`);for(let r=e._start;r;r=r.right)if(!r.deleted&&r.countable){if(!(r.content instanceof jx))throw Error(`Position tracking requires string text content`);for(let i=0;i{let r=[{current:-1,target:-1}];return e.forEach((e,n)=>{let i=t.get(`${e.client}:${e.clock}`);i!==void 0&&i>r[r.length-1].target&&r.push({current:n,target:i})}),r.push({current:e.length,target:n}),r},zC=(e,t,n,r,i)=>{let a=LC(e),o=new Map;for(let e=0;e0;--n){let r=s[n-1],o=s[n],c=a.slice(r.current+1,o.current),l=t.slice(r.target+1,o.target);(c.some(e=>i.has(`${e.client}:${e.clock}`))||c.map(e=>e.text).join(``)!==l)&&(e.delete(r.current+1,c.length),e.insert(r.current+1,l))}return LC(e,n)},BC=(e,t)=>!e.target||!t.target?e.target===t.target:e.target.client===t.target.client&&e.target.assoc===t.target.assoc&&e.target.boundary===t.target.boundary&&e.target.tname===t.target.tname&&e.target.clock+e.source.length===t.target.clock&&Zv(e.target.type,t.target.type),VC=e=>{let t=[];return e.forEach(e=>{let n=t[t.length-1];n&&n.source.client===e.source.client&&n.source.boundary===e.source.boundary&&n.source.clock+n.source.length===e.source.clock&&BC(n,e)?n.source.length+=e.source.length:t.push({...e,source:{...e.source}})}),t},HC=(e,t)=>{let n=e.doc;if(!n||t.length===0)return;let r=by(n.store,n.clientID);e.set(`${n.clientID}:${r}`,{version:1,client:n.clientID,clock:r,seen:[...Bv(Wv(n))],transfers:VC(t)})},UC=(e,t)=>{let n=new Map;e.forEach(e=>{let t=`${e.type.client}:${e.type.clock}`,r=n.get(t)??[];r.push(e),n.set(t,r)});let r=[];return n.forEach(e=>{let n=e[0],i=e[e.length-1],a=n.position===null?void 0:t.get(n.position),o=i.position===null?void 0:t.get(i.position);a&&Zv(n.type,a.type)||r.push({source:{...n.type,length:1,boundary:`start`},target:a?{...a,assoc:0}:null}),o&&Zv(i.type,o.type)||r.push({source:{...n.type,length:1,boundary:`end`},target:o?{...o,assoc:-1}:null})}),r},WC=(e,t,n,r)=>{let i=[];e.forEach(e=>{let n=e.position===null?null:t.get(e.position)??null;n&&Zv(e.id,n)||i.push({source:{...e.id,length:1},target:n})});let a=[...e,...r];for(let e of[`start`,`end`]){let r=e===`start`?t:n;a.forEach(t=>{let n=e===`start`?t.position:t.end,a=n===null?null:r.get(n)??null;a&&Zv(t.id,a)||i.push({source:{...t.id,length:1,boundary:e},target:a?{client:a.client,clock:a.clock,type:null,boundary:e}:null})})}return i},GC=(e,t,n,r,i,a)=>{let o=e.get(t);if(!(o instanceof ax)||!o._item)throw Error(`Position migration requires synchronized elements`);let s=i.get(`${o._item.id.client}:${o._item.id.clock}`);if(s&&s.position!==r&&(iC(a.mapping,o),e.delete(t,1),o=yC(n,a),e.insert(t,[o])),!(o instanceof ax)||!o._item)throw Error(`Position migration requires integrated elements`);return o},KC=(e,t,n,r)=>{let i=new Map(t.characters.map(e=>[e.position,e])),a=new Set(t.characters.map(e=>`${e.client}:${e.clock}`)),o=new Map,s=new Map(t.nodes.map(e=>[`${e.id.client}:${e.id.clock}`,e])),c=new Map,l=new Map,u=(e,t,r)=>{let d=e.toArray(),f=r;vC(t).forEach((t,r)=>{let p=d[r];if(Array.isArray(t)){if(!(p instanceof ux)||!p._item)throw Error(`Position migration requires integrated text`);let e=t.map(e=>e.text??``).join(``),r=zC(p,e,f,i,a),s=p._item.id;r.forEach(e=>o.set(e.position,{client:e.client,clock:e.clock,type:s})),kC(p,t,n),f+=e.length;return}let m=GC(e,r,t,f,s,n),h=m._item.id,g={client:h.client,clock:h.clock,type:e._item?.id??null,...e._item?{}:{tname:$v(e)}};c.set(f,g),l.set(f+t.nodeSize-1,g),t.isLeaf||u(m,t,f+1),f+=t.nodeSize})};u(e,t.doc,0);let d=[];t.characters.forEach(e=>{let t=e.position===null?null:o.get(e.position)??null;t&&Zv(e,t)&&Zv(e.type,t.type)||d.push({source:{client:e.client,clock:e.clock,length:1},target:t})}),d.push(...UC(t.characters,o)),d.push(...WC(t.nodes,c,l,t.emptyTexts)),HC(r,d)},qC=(e,t)=>{let n=e.doc.content,r=0,i=0;for(;rr&&o>r&&n.child(a-1)===t.child(o-1);)s+=n.child(a-1).nodeSize,a--,o--;if(r===a&&r===o)return e;let c=new p(t.cut(i,t.size-s),0,0),l=tn(e.doc,i,n.size-s,c);return l!==null&&l.apply(e.doc).doc?.content.eq(t)?e.step(l):e.replace(0,n.size,new p(t,0,0))},JC=class{constructor(e,t=new Map){if(this.prosemirrorView=null,this.mux=tS(),this.isOMark=new Map,this.beforeTransactionSelection=null,this._domSelectionInView=null,this.syncedDoc=null,this.type=e,this.mapping=t,this._observeFunction=this._typeChanged.bind(this),e.doc===null)throw Error(`The Yjs fragment must belong to a document`);this.doc=e.doc,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=nC(this,this.view.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null}}get view(){if(!this.prosemirrorView)throw Error(`The binding has no editor view`);return this.prosemirrorView}get _tr(){return this.view.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.view.hasFocus()?(eg&&this._domSelectionInView===null&&(z_(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.view.root,t=`getSelection`in e&&typeof e.getSelection==`function`?e.getSelection():this.view.dom.ownerDocument.getSelection();if(t==null||t.anchorNode==null||t.focusNode==null)return!1;let n=this.view.dom.ownerDocument.createRange();n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);let r=n.getBoundingClientRect(),i=M_.documentElement;return r.bottom>=0&&r.right>=0&&r.left<=(window.innerWidth||i.clientWidth||0)&&r.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,t){t||=py(pv(),new Map),this.view.dispatch(this._tr.setMeta(jS,{snapshot:e,prevSnapshot:t}))}createDocumentTransaction(){let e=this.type.toArray().map(e=>{if(!(e instanceof ax))throw ih();return pC(e,this.view.state.schema,this)}).filter(e=>e!==null);return this._tr.replace(0,this.view.state.doc.content.size,new p(s.from(e),0,0))}unrenderSnapshot(){this.mapping.clear(),rC.delete(this.mapping),this.mux(()=>{let e=this.createDocumentTransaction();e.setMeta(jS,{snapshot:null,prevSnapshot:null}),this.view.dispatch(e)})}_forceRerender(){this.mapping.clear(),rC.delete(this.mapping),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.view.state.selection:null,t=this.createDocumentTransaction();if(e){let n=fm(pm(e.anchor,0),t.doc.content.size),r=fm(pm(e.head,0),t.doc.content.size);t.setSelection(w.create(t.doc,n,r))}this.view.dispatch(t.setMeta(jS,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=hy(this.doc),e instanceof Uint8Array||t instanceof Uint8Array){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw ah();if(r=new yv({gc:!1}),Pv(r,t),t=hy(r),Pv(r,e),e=hy(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>Object.is(this.doc.share.get(e),i));i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[],t=e[Sy(e,i._item.id.clock)];if(!(t instanceof Jx&&t.content instanceof Vx&&t.content.type instanceof rx))throw ah();i=t.content.type}}let a=e,o=t??my;this.mapping.clear(),rC.delete(this.mapping),this.mux(()=>{r.transact(e=>{let t=n.permanentUserData;t&&t.dss.forEach(t=>{sv(e,t,e=>{})});let r=(e,r)=>{let i=t?e===`added`?t.getUserByClientId(r.client):t.getUserByDeletedId(r):null;return{user:i,type:e,color:qS(n.colorMapping,n.colors,i)}},c=hb(i,new fy(o.ds,a.sv)).map(e=>!(e instanceof ax)||!e._item?null:!e._item.deleted||KS(e._item,a)||KS(e._item,o)?pC(e,this.view.state.schema,{mapping:new Map,isOMark:new Map},a,o,r):null).filter(e=>e!==null),l=this._tr.replace(0,this.view.state.doc.content.size,new p(s.from(c),0,0));this.view.dispatch(l.setMeta(jS,{isChangeOrigin:!0}))},jS)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=GS(this.view.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}let r=t.origin instanceof By,i=r?t.origin.currStackItem?.meta.get(this):void 0,a=i||this.beforeTransactionSelection,o=i?void 0:this.view.state.doc;this.mux(()=>{let e=(e,t)=>iC(this.mapping,t);sv(t,t.deleteSet,e=>{e instanceof Jx&&e.content instanceof Vx&&iC(this.mapping,e.content.type)}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>{if(!(e instanceof ax))throw ih();return pC(e,this.view.state.schema,this)}).filter(e=>e!==null),i=qC(this._tr,s.from(n));$S(i,a,this,o),i=i.setMeta(jS,{isChangeOrigin:!0,isUndoRedoOperation:r}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.view.dispatch(i)})}_prosemirrorChanged(e,t=null){let n=GS(this.view.state);n.snapshot==null&&n.prevSnapshot==null&&this.doc.transact(()=>{IC(this.doc,this.type,e,this),t?.doc===e&&KC(this.type,t,this,CS(this.type)),this.syncedDoc=e,this.beforeTransactionSelection=nC(this,this.view.state)},jS)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},YC=(e,t)=>{let n=[],r=[],i=[];if(e.length===0)return{characters:n,nodes:r,emptyTexts:i};let a=(e,t,o)=>{let s=e.toArray(),c=vC(t),l=o;t.content.size===0&&s.forEach(e=>{e instanceof ux&&e._item&&i.push({id:e._item.id,position:o-1,end:o})}),c.forEach((e,t)=>{let i=s[t];if(!Array.isArray(e)){if(!(i instanceof ax)||!i._item)throw Error(`Position tracking requires synchronized editor content`);r.push({id:i._item.id,position:l,end:l+e.nodeSize-1}),e.isLeaf||a(i,e,l+1),l+=e.nodeSize;return}if(!(i instanceof ux))throw Error(`Position tracking requires synchronized editor text`);let o=LC(i,l);n.push(...o),l+=o.length})};return a(e,t,0),{characters:n,nodes:r,emptyTexts:i}},XC=(e,t,n,r)=>{let i=e.toJSON();if(i.stepType!==`replace`&&i.stepType!==`replaceAround`||r!==i.from&&r!==i.to-1)return!1;let a=t.nodeAt(i.from),o=n.nodeAt(i.from);return!a||!o||a.nodeSize!==i.to-i.from?!1:ZC(a,o)},ZC=(e,t)=>e.type===t.type&&e.content.eq(t.content)&&!e.sameMarkup(t),QC=(e,t)=>{let n=e.toJSON(),r=n.slice??{content:[]};if(n.stepType!==`replace`||r.openStart>0||r.openEnd>0)return!1;let i=t.resolve(n.from),a=t.resolve(n.to);return r.content.every(e=>e.type===`text`)&&i.parent.isTextblock&&i.sameParent(a)},$C=e=>{let t=new Map;return e.descendants((e,n)=>{let r=t.get(e)??[];r.push(n),t.set(e,r)}),t},ew=(e,t,n,r)=>{if(r[n].get(e)?.length!==1)return null;for(let i=n+1;i{let i=n[t].resolve(e),a=[],o=n[t].nodeAt(e);o&&!o.isText&&a.push({node:o,offset:0});for(let t=i.depth;t>0;--t)a.push({node:i.node(t),offset:e-i.before(t)});for(let e of a){let n=ew(e.node,e.offset,t,r);if(n)return n}return null},nw=(e,t,n,r)=>{for(let i=0;i{let r=n?.doc===e.before&&n.doc!==t.syncedDoc?n:null;if(!e.docChanged||!t.prosemirrorView||!r&&e.steps.every((t,n)=>QC(t,e.docs[n])))return r;let i=r??YC(t.type,e.before),a=[...e.docs,e.doc],o=a.map($C),s=i.characters.map(t=>({...t,position:t.position===null?null:nw(t.position,e,a,o)})),c=t=>({...t,position:t.position===null?null:nw(t.position,e,a,o),end:t.end===null?null:nw(t.end,e,a,o)});return{doc:e.doc,characters:s,nodes:i.nodes.map(c),emptyTexts:i.emptyTexts.map(c)}},iw=[{light:`#ecd44433`,dark:`#ecd444`}],aw=(e,{colors:t=iw,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new JC(e,a);return new E({props:{editable:e=>{let t=GS(e);return t.snapshot==null&&t.prevSnapshot==null}},key:jS,state:{init:(i,a)=>({type:e,doc:s.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r,positionMigration:null}),apply:(e,t)=>{let n=e.getMeta(jS);return n!==void 0&&(t=Object.assign({},t,n)),e.docChanged&&(t.addToHistory=e.getMeta(`addToHistory`)!==!1),t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,t={...t,positionMigration:t.isChangeOrigin||t.snapshot||t.prevSnapshot||n?.snapshot!==void 0||n?.prevSnapshot!==void 0?null:rw(e,s,t.positionMigration??null)},s.prosemirrorView===null||n===void 0||n.snapshot==null&&n.prevSnapshot==null||z_(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),s.mux(()=>{let e=s.prosemirrorView;e&&(e.dispatch(s._tr.setMeta(jS,{restore:!1,snapshot:null,prevSnapshot:null,isChangeOrigin:!0})),s._prosemirrorChanged(e.state.doc))})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=GS(e.state);if(t.snapshot==null&&t.prevSnapshot==null){let n=e.state.doc.type.createAndFill();if(!n)throw Error(`The schema cannot create an empty document`);if(o||e.state.doc.content.findDiffStart(n.content)!==null){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=MS.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc,t.positionMigration??null)},jS)})}}},destroy:()=>{s.destroy()}})})};function ow(e){let t=MS.getState(e);if(!t)throw Error(`The editor requires yUndoPlugin`);return t}var sw=e=>{let t=new Map,n=e=>{e.toArray().forEach(r=>{if(r instanceof ax){let i=r._item.id;t.set(`${i.client}:${i.clock}`,{client:i.client,clock:i.clock,type:e._item?.id??null,...e._item?{}:{tname:$v(e)}}),n(r);return}if(!(r instanceof ux)||!r._item)return;let i=r._item.id;LC(r).forEach(e=>{t.set(`${e.client}:${e.clock}`,{client:e.client,clock:e.clock,type:i})})})};return n(e),t},cw=(e,t)=>{let n=e.doc;if(!n)return;let r=sw(e),i=new Map,a=new Map,o=(e,t)=>{let n=`${e.client}:${e.clock}`,r=`${t.client}:${t.clock}`;i.set(n,e),i.set(r,t);let o=a.get(n)??new Set,s=a.get(r)??new Set;o.add(r),s.add(n),a.set(n,o),a.set(r,s)};t.forEach(e=>e.transfers.forEach(({source:e,target:t})=>{if(t&&!e.boundary)for(let n=0;ne.forEach(e=>{if(e instanceof Jx&&e.redone&&(e.content instanceof jx||e.content instanceof Vx))for(let t=0;t{if(c.has(t))return;let o=[t],l=[],u=[];for(;o.length>0;){let e=o.pop();if(c.has(e))continue;c.add(e),l.push(e);let t=r.get(e);t&&u.push(t),o.push(...a.get(e)??[])}u.length===1&&l.forEach(e=>{if(r.has(e))return;let t=i.get(e);s.push({source:{client:t.client,clock:t.clock,length:1},target:u[0]});let a=Cy(n.store,t);if(a.content instanceof Vx&&a.content.type instanceof ax)for(let e of[`start`,`end`])s.push({source:{client:t.client,clock:t.clock,length:1,boundary:e},target:{client:u[0].client,clock:u[0].clock,type:null,boundary:e}})})}),HC(t,s)},lw=(e,t,n)=>{let r=CS(e);if(r.size===0)return t[n]();let i=n===`undo`?`undoing`:`redoing`,a=null,o=({stackItem:e})=>{a=e};t.on(`stack-item-popped`,o);try{t.doc.transact(()=>{t[n](),t[i]=!0,t.currStackItem=a,a&&cw(e,r)},t)}finally{t.off(`stack-item-popped`,o),t[i]=!1,t.currStackItem=null}return a},uw=(e,t)=>{let n=GS(e);if(n.snapshot!=null||n.prevSnapshot!=null)return!1;let r=ow(e).undoManager;if(r!=null)return lw(n.type,r,t),!0},dw=e=>uw(e,`undo`),fw=e=>uw(e,`redo`),pw=new Set([`paragraph`]),mw=(e,t)=>!(e instanceof Jx)||!(e.content instanceof Vx)||!(e.content.type instanceof ex||e.content.type instanceof ax&&t.has(e.content.type.nodeName))||e.content.type._length===0,hw=({protectedNodes:e=pw,trackedOrigins:t=[],undoManager:n=null}={})=>new E({key:MS,state:{init:(r,i)=>{let a=GS(i),o=new Set,s=n;if(!s){let n=new Set(a.doc._observers.get(`destroy`));s=new By(a.type,{trackedOrigins:new Set([jS,...t]),deleteFilter:t=>mw(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1}),(a.doc._observers.get(`destroy`)??new Set).forEach(e=>{n.has(e)||o.add(e)})}return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0,destroyListeners:o}},apply:(e,t,n,r)=>{let i=GS(r).binding;return{...t,prevSel:i?nC(i,n):t.prevSel,hasUndoOps:t.undoManager.undoStack.length>0,hasRedoOps:t.undoManager.redoStack.length>0}}},view:e=>{let t=GS(e.state),{undoManager:n,destroyListeners:r}=ow(e.state);return n.on(`stack-item-added`,({stackItem:r})=>{let i=t.binding;if(i){let t=n.undoing||n.redoing?i.beforeTransactionSelection:ow(e.state).prevSel;r.meta.set(i,t)}}),{destroy:()=>{n.destroy(),r.forEach(e=>n.doc.off(`destroy`,e)),r.clear()}}}});function gw(e){return!!e.getMeta(jS)}function _w(e,t){if(t===null)return 0;let n=yw(e);return AS(n.doc,n.type,t,n.binding.mapping)||0}function vw(e,t){let n=yw(e);return _S(t,n.type,n.binding.mapping)}function yw(e){let t=jS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs sync plugin`);return t}var bw=class e extends gd{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function xw(e,t){return new bw(e,vw(t,e))}function Sw(e,t,n){let r=e instanceof bw?e.yRelativePosition:null;if(gw(t)&&r)return{position:new bw(_w(n,r),r),mapResult:null};let i=_d(e,t),a=i.position.position;return{position:new bw(a,r??vw(n,a)),mapResult:i.mapResult}}function Cw(e){let t=MS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs undo plugin`);return t.undoManager}var ww=wp.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>Sw(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>xw(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Cw(t).undoStack.length===0?!1:n?dw(t)??!1:!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Cw(t).redoStack.length===0?!1:n?fw(t)??!1:!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=hw(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let t=Cw(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[aw(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,new E({filterTransaction:(e,t)=>(e.getMeta(`inputRule`)&&Cw(t).stopCapturing(),!0)}),this.editor.options.enableContentCheck&&new E({key:new D(`filterInvalidContent`),filterTransaction:t=>{if(!gw(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!0}}})].filter(e=>e!==!1)}}),Tw=e=>Array.from(e.entries()).map(([e,t])=>t&&t.user?{clientId:e,...t.user}:{clientId:e}),Ew=()=>null,Dw=e=>Nf(e)&&/^#[0-9a-fA-F]{6}$/.test(e),Ow=e=>({...e,color:Dw(e.color)?e.color:`transparent`}),kw=wp.create({name:`collaborationCaret`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`),{color:n}=Ow(e);t.classList.add(`collaboration-carets__caret`),t.style.borderColor=n;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.style.backgroundColor=n,r.insertBefore(document.createTextNode(e.name),null),t.insertBefore(r,null),t},selectionRender:e=>Dw(e.color)?BS({name:e.name,color:e.color}):{},onUpdate:Ew}},onCreate(){if(this.options.onUpdate!==Ew&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),!this.options.provider)throw Error(`The "provider" option is required for the CollaborationCaret extension`)},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.provider.awareness.setLocalStateField(`user`,e),!0),user:e=>({editor:t})=>(console.warn(`[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret`),t.commands.updateUser(e))}},addProseMirrorPlugins(){let{provider:e}=this.options,t=this.storage,n=this.options.user;return[new E({key:new D(`collaborationCaretAwarenessListener`),view:()=>{let r=()=>{t.users=Tw(e.awareness.states)};return e.awareness.setLocalStateField(`user`,n),t.users=Tw(e.awareness.states),e.awareness.on(`update`,r),{destroy:()=>{e.awareness.off(`update`,r),t.users=[]}}}}),WS(e.awareness,{cursorBuilder:e=>this.options.render(Ow(e)),selectionBuilder:e=>this.options.selectionRender(Ow(e))})]}});function Aw(e={}){return new E({view(t){return new jw(t,e)}})}var jw=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=en(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},Mw=class e extends C{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):C.near(r)}content(){return p.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Nw(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Fw(e)||!Iw(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!T.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};Mw.prototype.visible=!1,Mw.findFrom=Mw.findGapCursorFrom,C.jsonID(`gapcursor`,Mw);var Nw=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Mw.valid(t)?new Mw(t):C.near(t)}};function Pw(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Fw(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Pw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Iw(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Pw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Lw(){return new E({props:{decorations:Hw,createSelectionBetween(e,t,n){return t.pos==n.pos&&Mw.valid(n)?new Mw(n):null},handleClick:Bw,handleKeyDown:Rw,handleDOMEvents:{beforeinput:Vw}}})}var Rw=Sc({ArrowLeft:zw(`horiz`,-1),ArrowRight:zw(`horiz`,1),ArrowUp:zw(`vert`,-1),ArrowDown:zw(`vert`,1)});function zw(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof w){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=Mw.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Mw(c))),!0):!1}}function Bw(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Mw.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&T.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Mw(r))),!0)}function Vw(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Mw))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=s.empty;for(let e=r.length-1;e>=0;e--)i=s.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new p(i,0,0));return a.setSelection(w.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Hw(e){if(!(e.selection instanceof Mw))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,xs.create(e.doc,[vs.widget(e.selection.head,t,{key:`gapcursor`})])}wp.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new E({key:new D(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Uw=wp.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Aw(this.options)]}});wp.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new E({key:new D(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return xs.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(vs.node(t,t+e.nodeSize,{class:this.options.className}))}),xs.create(e,a)}}})]}});var Ww=wp.create({name:`gapCursor`,addProseMirrorPlugins(){return[Lw()]},extendNodeSchema(e){return{allowGapCursor:Nu(k(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Gw=`placeholder`,Kw=new D(`tiptap__placeholder`);function qw(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),vs.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Jw(e,t){return typeof e==`function`?e(t):e}function Yw({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&fd(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(qw({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Jw(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Xw({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&fd(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(qw({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Jw(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Yw({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return xs.create(r,o)}function Zw(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function Qw(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function $w(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function eT(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(Qw(e,Zw(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Yw({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function aT({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Xw({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??xs.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:iT({decorations:i.map(r.mapping,r.doc),ranges:nT(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function oT(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function sT({editor:e,options:t}){let n=t.dataAttribute?`data-${oT(t.dataAttribute)}`:`data-${Gw}`,r=t.showOnlyCurrent&&!t.includeChildren;return new E({key:Kw,...r?{}:{state:aT({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Xw({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?xs.empty:Kw.getState(n)??xs.empty}})}var cT=wp.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Gw,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[sT({editor:this.editor,options:this.options})]}});function lT(e,t){return!e.selection.empty&&!pd(e.selection)&&t.isEditable}function uT(e,t){return lT(e,t)&&!t.isFocused&&!t.view.dragging}function dT(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function fT(e){e.focus()}wp.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new E({key:new D(`selection`),props:{decorations(n){return uT(n,e)?xs.create(n.doc,[vs.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return lT(t.state,e)&&dT(),!1},focus(t){return lT(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&fT(t)}),!1}}}})]}});function pT({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var mT=wp.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new D(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new E({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!pT({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!pT({node:r,types:n})}}})]}}),hT=wp.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Kc(e,t),redo:()=>({state:e,dispatch:t})=>qc(e,t)}},addProseMirrorPlugins(){return[Wc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),gT=new WeakSet,_T=new WeakSet;function vT(e){let t=e;return gT.add(t),t}function yT(e){return Array.isArray(e)&&gT.has(e)}function bT(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&_T.has(e)&&!yT(e)?bT(e):[e])}function xT(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!yT(n)&&!_T.has(n)?vT(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(yT(n))return vT([e,r,n]);if(n.length===0)return vT([e,r]);let t=bT(n);return t.length===0?vT([e,r]):vT([e,r,...t])}return vT(n==null?[e,r]:[e,r,n])}var ST=(e,t)=>xT(e,t),CT=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new p(n,0,0);return e.replace(l,i.after(),r),e.setSelection(w.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},wT=/^\s*>\s$/,TT=qp.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return ST(`blockquote`,{...A(this.options.HTMLAttributes,e),children:ST(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` `).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:``,close:``}},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:``,close:``}},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=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{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:``,close:``}},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=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,WT=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,GT=`numeric`,KT=`ascii`,qT=`alpha`,JT=`asciinumeric`,YT=`alphanumeric`,XT=`domain`,ZT=`emoji`,QT=`scheme`,$T=`slashscheme`,eE=`whitespace`;function tE(e,t){return e in t||(t[e]=[]),t[e]}function nE(e,t,n){t[GT]&&(t[JT]=!0,t[YT]=!0),t[KT]&&(t[JT]=!0,t[qT]=!0),t[JT]&&(t[YT]=!0),t[qT]&&(t[YT]=!0),t[YT]&&(t[XT]=!0),t[ZT]&&(t[XT]=!0);for(let r in t){let t=tE(r,n);t.indexOf(e)<0&&t.push(e)}}function rE(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function iE(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}iE.groups={},iE.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),aE=(e,t,n,r,i)=>e.tr(t,n,r,i),oE=(e,t,n,r,i)=>e.ts(t,n,r,i),F=(e,t,n,r,i)=>e.tt(t,n,r,i),sE=`WORD`,cE=`UWORD`,lE=`ASCIINUMERICAL`,uE=`ALPHANUMERICAL`,dE=`LOCALHOST`,fE=`TLD`,pE=`UTLD`,mE=`SCHEME`,hE=`SLASH_SCHEME`,gE=`NUM`,_E=`WS`,vE=`NL`,yE=`OPENBRACE`,bE=`CLOSEBRACE`,xE=`OPENBRACKET`,SE=`CLOSEBRACKET`,CE=`OPENPAREN`,wE=`CLOSEPAREN`,TE=`OPENANGLEBRACKET`,EE=`CLOSEANGLEBRACKET`,DE=`FULLWIDTHLEFTPAREN`,OE=`FULLWIDTHRIGHTPAREN`,kE=`LEFTCORNERBRACKET`,AE=`RIGHTCORNERBRACKET`,jE=`LEFTWHITECORNERBRACKET`,ME=`RIGHTWHITECORNERBRACKET`,NE=`FULLWIDTHLESSTHAN`,PE=`FULLWIDTHGREATERTHAN`,FE=`AMPERSAND`,IE=`APOSTROPHE`,LE=`ASTERISK`,RE=`AT`,zE=`BACKSLASH`,BE=`BACKTICK`,VE=`CARET`,HE=`COLON`,UE=`COMMA`,WE=`DOLLAR`,GE=`DOT`,KE=`EQUALS`,qE=`EXCLAMATION`,JE=`HYPHEN`,YE=`PERCENT`,XE=`PIPE`,ZE=`PLUS`,QE=`POUND`,$E=`QUERY`,eD=`QUOTE`,tD=`FULLWIDTHMIDDLEDOT`,nD=`SEMI`,rD=`SLASH`,iD=`TILDE`,aD=`UNDERSCORE`,oD=`EMOJI`,sD=`SYM`,cD=Object.freeze({__proto__:null,ALPHANUMERICAL:uE,AMPERSAND:FE,APOSTROPHE:IE,ASCIINUMERICAL:lE,ASTERISK:LE,AT:RE,BACKSLASH:zE,BACKTICK:BE,CARET:VE,CLOSEANGLEBRACKET:EE,CLOSEBRACE:bE,CLOSEBRACKET:SE,CLOSEPAREN:wE,COLON:HE,COMMA:UE,DOLLAR:WE,DOT:GE,EMOJI:oD,EQUALS:KE,EXCLAMATION:qE,FULLWIDTHGREATERTHAN:PE,FULLWIDTHLEFTPAREN:DE,FULLWIDTHLESSTHAN:NE,FULLWIDTHMIDDLEDOT:tD,FULLWIDTHRIGHTPAREN:OE,HYPHEN:JE,LEFTCORNERBRACKET:kE,LEFTWHITECORNERBRACKET:jE,LOCALHOST:dE,NL:vE,NUM:gE,OPENANGLEBRACKET:TE,OPENBRACE:yE,OPENBRACKET:xE,OPENPAREN:CE,PERCENT:YE,PIPE:XE,PLUS:ZE,POUND:QE,QUERY:$E,QUOTE:eD,RIGHTCORNERBRACKET:AE,RIGHTWHITECORNERBRACKET:ME,SCHEME:mE,SEMI:nD,SLASH:rD,SLASH_SCHEME:hE,SYM:sD,TILDE:iD,TLD:fE,UNDERSCORE:aD,UTLD:pE,UWORD:cE,WORD:sE,WS:_E}),lD=/[a-z]/,uD=/[a-z]/i,dD=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{uD=RegExp(`\\p{L}`,`u`),dD=RegExp(`\\p{Emoji}`,`u`)}catch{}var fD=/\d/,pD=/\s/,mD=`\r`,hD=` -`,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;ee[0]>t[0]?1:-1);for(let t=0;t=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=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(;r56319||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=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=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);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function AD(e,t){class n extends kD{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var jD=AD(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),MD=AD(`text`),ND=AD(`nl`),PD=AD(`url`,{isLink:!0,toHref(e=ED.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==dE&&e[1].t===HE}}),FD=e=>new iE(e);function ID({groups:e}){let t=e.domain.concat([FE,LE,RE,zE,BE,VE,WE,KE,JE,gE,YE,XE,ZE,QE,rD,sD,iD,aD]),n=[IE,HE,UE,GE,qE,YE,$E,eD,nD,TE,EE,yE,bE,SE,xE,CE,wE,DE,OE,kE,AE,jE,ME,NE,PE],r=[FE,IE,LE,zE,BE,VE,WE,KE,JE,yE,bE,YE,XE,ZE,QE,$E,rD,sD,iD,aD],i=FD(),a=F(i,iD);P(a,r,a),P(a,e.domain,a);let o=FD(),s=FD(),c=FD();P(i,e.domain,o),P(i,e.scheme,s),P(i,e.slashscheme,c),P(o,r,a),P(o,e.domain,o);let l=F(o,RE);F(a,RE,l),F(s,RE,l),F(c,RE,l);let u=F(a,GE);P(u,r,a),P(u,e.domain,a);let d=FD();P(l,e.domain,d),P(d,e.domain,d);let f=F(d,GE);P(f,e.domain,d);let p=FD(jD);P(f,e.tld,p),P(f,e.utld,p),F(l,dE,p);let m=F(d,JE);F(m,JE,m),P(m,e.domain,d),P(p,e.domain,d),F(p,GE,f),F(p,JE,m);let h=F(o,JE),g=F(o,GE);F(h,JE,h),P(h,e.domain,o),P(g,r,a),P(g,e.domain,o);let _=FD(PD);P(g,e.tld,_),P(g,e.utld,_),P(_,e.domain,o),P(_,r,a),F(_,GE,g),F(_,JE,h),F(_,RE,l);let v=F(_,HE),y=FD(PD);P(v,e.numeric,y);let b=FD(PD),x=FD();P(b,t,b),P(b,n,x),P(x,t,b),P(x,n,x),F(_,rD,b),F(y,rD,b),F(_,$E,x),F(_,QE,b),F(y,$E,x),F(y,QE,b);let S=F(s,HE),ee=F(F(F(c,HE),rD),rD);P(s,e.domain,o),F(s,GE,g),F(s,JE,h),P(c,e.domain,o),F(c,GE,g),F(c,JE,h),P(S,e.domain,b),F(S,rD,b),F(S,$E,b),P(ee,e.domain,b),P(ee,t,b),F(ee,rD,b);let te=[[yE,bE],[xE,SE],[CE,wE],[TE,EE],[DE,OE],[kE,AE],[jE,ME],[NE,PE]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(RD(MD,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(RD(e,t,r))}}return o.length>0&&a.push(RD(MD,t,o)),a}function RD(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var zD=typeof console<`u`&&console&&console.warn||(()=>{}),BD=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,VD={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function HD(){return iE.groups={},VD.scanner=null,VD.parser=null,VD.tokenQueue=[],VD.pluginQueue=[],VD.customSchemes=[],VD.initialized=!1,VD}function UD(e,t=!1){if(VD.initialized&&zD(`linkifyjs: already initialized - will not register custom scheme "${e}" ${BD}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. +`,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:``,close:``}},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=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,YT=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,XT=`numeric`,ZT=`ascii`,QT=`alpha`,$T=`asciinumeric`,eE=`alphanumeric`,tE=`domain`,nE=`emoji`,rE=`scheme`,iE=`slashscheme`,aE=`whitespace`;function oE(e,t){return e in t||(t[e]=[]),t[e]}function sE(e,t,n){t[XT]&&(t[$T]=!0,t[eE]=!0),t[ZT]&&(t[$T]=!0,t[QT]=!0),t[$T]&&(t[eE]=!0),t[QT]&&(t[eE]=!0),t[eE]&&(t[tE]=!0),t[nE]&&(t[tE]=!0);for(let r in t){let t=oE(r,n);t.indexOf(e)<0&&t.push(e)}}function cE(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function lE(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}lE.groups={},lE.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),uE=(e,t,n,r,i)=>e.tr(t,n,r,i),dE=(e,t,n,r,i)=>e.ts(t,n,r,i),F=(e,t,n,r,i)=>e.tt(t,n,r,i),fE=`WORD`,pE=`UWORD`,mE=`ASCIINUMERICAL`,hE=`ALPHANUMERICAL`,gE=`LOCALHOST`,_E=`TLD`,vE=`UTLD`,yE=`SCHEME`,bE=`SLASH_SCHEME`,xE=`NUM`,SE=`WS`,CE=`NL`,wE=`OPENBRACE`,TE=`CLOSEBRACE`,EE=`OPENBRACKET`,DE=`CLOSEBRACKET`,OE=`OPENPAREN`,kE=`CLOSEPAREN`,AE=`OPENANGLEBRACKET`,jE=`CLOSEANGLEBRACKET`,ME=`FULLWIDTHLEFTPAREN`,NE=`FULLWIDTHRIGHTPAREN`,PE=`LEFTCORNERBRACKET`,FE=`RIGHTCORNERBRACKET`,IE=`LEFTWHITECORNERBRACKET`,LE=`RIGHTWHITECORNERBRACKET`,RE=`FULLWIDTHLESSTHAN`,zE=`FULLWIDTHGREATERTHAN`,BE=`AMPERSAND`,VE=`APOSTROPHE`,HE=`ASTERISK`,UE=`AT`,WE=`BACKSLASH`,GE=`BACKTICK`,KE=`CARET`,qE=`COLON`,JE=`COMMA`,YE=`DOLLAR`,XE=`DOT`,ZE=`EQUALS`,QE=`EXCLAMATION`,$E=`HYPHEN`,eD=`PERCENT`,tD=`PIPE`,nD=`PLUS`,rD=`POUND`,iD=`QUERY`,aD=`QUOTE`,oD=`FULLWIDTHMIDDLEDOT`,sD=`SEMI`,cD=`SLASH`,lD=`TILDE`,uD=`UNDERSCORE`,dD=`EMOJI`,fD=`SYM`,pD=Object.freeze({__proto__:null,ALPHANUMERICAL:hE,AMPERSAND:BE,APOSTROPHE:VE,ASCIINUMERICAL:mE,ASTERISK:HE,AT:UE,BACKSLASH:WE,BACKTICK:GE,CARET:KE,CLOSEANGLEBRACKET:jE,CLOSEBRACE:TE,CLOSEBRACKET:DE,CLOSEPAREN:kE,COLON:qE,COMMA:JE,DOLLAR:YE,DOT:XE,EMOJI:dD,EQUALS:ZE,EXCLAMATION:QE,FULLWIDTHGREATERTHAN:zE,FULLWIDTHLEFTPAREN:ME,FULLWIDTHLESSTHAN:RE,FULLWIDTHMIDDLEDOT:oD,FULLWIDTHRIGHTPAREN:NE,HYPHEN:$E,LEFTCORNERBRACKET:PE,LEFTWHITECORNERBRACKET:IE,LOCALHOST:gE,NL:CE,NUM:xE,OPENANGLEBRACKET:AE,OPENBRACE:wE,OPENBRACKET:EE,OPENPAREN:OE,PERCENT:eD,PIPE:tD,PLUS:nD,POUND:rD,QUERY:iD,QUOTE:aD,RIGHTCORNERBRACKET:FE,RIGHTWHITECORNERBRACKET:LE,SCHEME:yE,SEMI:sD,SLASH:cD,SLASH_SCHEME:bE,SYM:fD,TILDE:lD,TLD:_E,UNDERSCORE:uD,UTLD:vE,UWORD:pE,WORD:fE,WS:SE}),mD=/[a-z]/,hD=/[a-z]/i,gD=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{hD=RegExp(`\\p{L}`,`u`),gD=RegExp(`\\p{Emoji}`,`u`)}catch{}var _D=/\d/,vD=/\s/,yD=`\r`,bD=` +`,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;ee[0]>t[0]?1:-1);for(let t=0;t=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=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(;r56319||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=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=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);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function FD(e,t){class n extends PD{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var ID=FD(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),LD=FD(`text`),RD=FD(`nl`),zD=FD(`url`,{isLink:!0,toHref(e=jD.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==gE&&e[1].t===qE}}),BD=e=>new lE(e);function VD({groups:e}){let t=e.domain.concat([BE,HE,UE,WE,GE,KE,YE,ZE,$E,xE,eD,tD,nD,rD,cD,fD,lD,uD]),n=[VE,qE,JE,XE,QE,eD,iD,aD,sD,AE,jE,wE,TE,DE,EE,OE,kE,ME,NE,PE,FE,IE,LE,RE,zE],r=[BE,VE,HE,WE,GE,KE,YE,ZE,$E,wE,TE,eD,tD,nD,rD,iD,cD,fD,lD,uD],i=BD(),a=F(i,lD);P(a,r,a),P(a,e.domain,a);let o=BD(),s=BD(),c=BD();P(i,e.domain,o),P(i,e.scheme,s),P(i,e.slashscheme,c),P(o,r,a),P(o,e.domain,o);let l=F(o,UE);F(a,UE,l),F(s,UE,l),F(c,UE,l);let u=F(a,XE);P(u,r,a),P(u,e.domain,a);let d=BD();P(l,e.domain,d),P(d,e.domain,d);let f=F(d,XE);P(f,e.domain,d);let p=BD(ID);P(f,e.tld,p),P(f,e.utld,p),F(l,gE,p);let m=F(d,$E);F(m,$E,m),P(m,e.domain,d),P(p,e.domain,d),F(p,XE,f),F(p,$E,m);let h=F(o,$E),g=F(o,XE);F(h,$E,h),P(h,e.domain,o),P(g,r,a),P(g,e.domain,o);let _=BD(zD);P(g,e.tld,_),P(g,e.utld,_),P(_,e.domain,o),P(_,r,a),F(_,XE,g),F(_,$E,h),F(_,UE,l);let v=F(_,qE),y=BD(zD);P(v,e.numeric,y);let b=BD(zD),x=BD();P(b,t,b),P(b,n,x),P(x,t,b),P(x,n,x),F(_,cD,b),F(y,cD,b),F(_,iD,x),F(_,rD,b),F(y,iD,x),F(y,rD,b);let S=F(s,qE),ee=F(F(F(c,qE),cD),cD);P(s,e.domain,o),F(s,XE,g),F(s,$E,h),P(c,e.domain,o),F(c,XE,g),F(c,$E,h),P(S,e.domain,b),F(S,cD,b),F(S,iD,b),P(ee,e.domain,b),P(ee,t,b),F(ee,cD,b);let te=[[wE,TE],[EE,DE],[OE,kE],[AE,jE],[ME,NE],[PE,FE],[IE,LE],[RE,zE]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(UD(LD,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(UD(e,t,r))}}return o.length>0&&a.push(UD(LD,t,o)),a}function UD(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var WD=typeof console<`u`&&console&&console.warn||(()=>{}),GD=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,KD={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function qD(){return lE.groups={},KD.scanner=null,KD.parser=null,KD.tokenQueue=[],KD.pluginQueue=[],KD.customSchemes=[],KD.initialized=!1,KD}function JD(e,t=!1){if(KD.initialized&&WD(`linkifyjs: already initialized - will not register custom scheme "${e}" ${GD}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. 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;ee.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);it.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(;r0}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{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,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function pO(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(ZD,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var mO=dp.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?UD(e):UD(e.scheme,e.optionalSlashes)})},onDestroy(){HD()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!pO(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,Fu(this.options.HTMLAttributes,e),0]:[`a`,Fu(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[uO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;KD(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!pO(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[dO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!pO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Up({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(eO({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!pO(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(tO({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(fO({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),hO=`listItem`,gO=`textStyle`,_O=/^\s*([-+*])\s$/,vO=Hp.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,Fu(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,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(;n0?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?.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):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:zO(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return RO((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=ep(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!BO(e)||!UO(n))return i;let a=r(n);return`${a}${VO}${i.slice(a.length)}`},addExtensions(){return[SO(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),qO=(e,t)=>{let{$from:n}=t.selection,r=rl(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},JO=(e,t)=>{let n=qO(e,t);if(!n)return!1;let[,r]=ed(t,e,n.$pos.pos+4);return r},YO=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},XO=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Xl(e.state,t)&&YO(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(w.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(qn(e,t),!0)).run()}if(!Xl(e.state,t)||!cd(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},ZO=(e,t)=>{let n=JO(e,t),r=qO(e,t);return!r||!n?!1:n>r.depth},QO=(e,t)=>{let n=JO(e,t),r=qO(e,t);return!r||!n?!1:n!Xl(e.state,t)||!sd(e.state,t)||!e.state.selection.empty?!1:ZO(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():QO(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Jn(e,t)):e.commands.joinItemForward(),ek=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Xl(r,t))return!1;let o=td(a);if(!o||!n.includes(o.type.name))return!1;let c=o.lastChild;if(!c||c.type.name!==t)return!1;let l=a.parent;if(!c.canReplace(c.childCount,c.childCount,s.from(l)))return!1;let u=a.before(),d=a.after(),f=u-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(u,d).insert(f,s.from(l)),e.setSelection(w.create(e.doc,f+1)),e.scrollIntoView()),!0))},tk=yp.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&$O(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&$O(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&XO(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&XO(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&ek(e,t,n))return!0;return!1}}}}),nk=RegExp(`^(\\s*)(${TO})([.)])\\s+(.*)$`),rk=/^\s/,ik={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function ak(e){return nk.test(e.trimStart())}function ok(e){let t=e.trimStart();return ik.bulletItem.test(t)||ak(t)||ik.heading.test(t)||ik.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||ik.codeFence.test(t)||ik.blockMath.test(t)}function sk(e){return Object.values(ik).some(t=>t.test(e))}function ck(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&ok(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function lk(e){let t=[],n=0,r=0;for(;ne.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);it.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(;r0}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{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,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function vO(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(nO,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var yO=gp.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?JD(e):JD(e.scheme,e.optionalSlashes)})},onDestroy(){qD()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!vO(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,A(this.options.HTMLAttributes,e),0]:[`a`,A(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[hO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;ZD(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!vO(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[gO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!vO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Jp({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(aO({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!vO(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(oO({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(_O({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),bO=`listItem`,xO=`textStyle`,SO=/^\s*([-+*])\s$/,CO=qp.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,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(;n0?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?.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):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:WO(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return UO((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=ap(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!GO(e)||!JO(n))return i;let a=r(n);return`${a}${KO}${i.slice(a.length)}`},addExtensions(){return[DO(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),QO=(e,t)=>{let{$from:n}=t.selection,r=il(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},$O=(e,t)=>{let n=QO(e,t);if(!n)return!1;let[,r]=td(t,e,n.$pos.pos+4);return r},ek=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},tk=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Zl(e.state,t)&&ek(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(w.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(qn(e,t),!0)).run()}if(!Zl(e.state,t)||!ld(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},nk=(e,t)=>{let n=$O(e,t),r=QO(e,t);return!r||!n?!1:n>r.depth},rk=(e,t)=>{let n=$O(e,t),r=QO(e,t);return!r||!n?!1:n!Zl(e.state,t)||!cd(e.state,t)||!e.state.selection.empty?!1:nk(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():rk(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Jn(e,t)):e.commands.joinItemForward(),ak=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Zl(r,t))return!1;let o=nd(a);if(!o||!n.includes(o.type.name))return!1;let c=o.lastChild;if(!c||c.type.name!==t)return!1;let l=a.parent;if(!c.canReplace(c.childCount,c.childCount,s.from(l)))return!1;let u=a.before(),d=a.after(),f=u-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(u,d).insert(f,s.from(l)),e.setSelection(w.create(e.doc,f+1)),e.scrollIntoView()),!0))},ok=wp.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&ik(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&ik(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&tk(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&tk(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&ak(e,t,n))return!0;return!1}}}}),sk=RegExp(`^(\\s*)(${AO})([.)])\\s+(.*)$`),ck=/^\s/,lk={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function uk(e){return sk.test(e.trimStart())}function dk(e){let t=e.trimStart();return lk.bulletItem.test(t)||uk(t)||lk.heading.test(t)||lk.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||lk.codeFence.test(t)||lk.blockMath.test(t)}function fk(e){return Object.values(lk).some(t=>t.test(e))}function pk(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&dk(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function mk(e){let t=[],n=0,r=0;for(;ne.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(;ie.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(;it;)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.lengthe.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:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,Fu(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,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=` `,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`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/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),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Fk=yp.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(TT.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(bT.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(vO.configure(this.options.bulletList)),this.options.code!==!1&&e.push(kT.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(NT.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(PT.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Rw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(zw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(FT.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(IT.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(uT.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(LT.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(HT.configure(this.options.italic)),this.options.listItem!==!1&&e.push(KO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(tk.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(mO.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(xk.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(kk.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Mk.configure(this.options.strike)),this.options.text!==!1&&e.push(Nk.configure(this.options.text)),this.options.underline!==!1&&e.push(Pk.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(lT.configure(this.options?.trailingNode)),e}});function Ik(e){let t=ES.getState(e);return t?.type&&t.binding&&t.doc?t:null}function Lk(e,t){let n=Ik(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>TS(n.doc,n.type,ry(ug(e)),n.binding.mapping),i=r(t.from),a=r(t.to);return i===null||a===null||a<=i||a>e.doc.content.size?null:{from:i,to:a}}catch{return null}}var Rk=new D(`docwellComments`);function zk(e,t,n){let r=[];for(let i of t){let t=Lk(e,i.anchor);t&&r.push(vs.inline(t.from,t.to,{class:i.id===n?`dw-comment is-active`:`dw-comment`,"data-comment":i.id}))}return k.create(e.doc,r)}var Bk=yp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new E({key:Rk,state:{init:()=>({marks:[],active:``,decos:k.empty}),apply(e,t,n,r){let i=e.getMeta(Rk);if(i)return{...i,decos:zk(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(ES)?.isChangeOrigin;return{...t,decos:a?zk(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>Rk.getState(e)?.decos??k.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}});function Vk(e){let t=document.createElement(`div`);t.className=`dw-diagram-editor`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-modal`,`true`),t.setAttribute(`aria-label`,e);let n=document.createElement(`p`);n.className=`dw-diagram-editor__status`,t.append(n),document.body.append(t);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,{root:t,status:e=>{n.textContent=e,n.hidden=!e},close:()=>{t.remove(),document.body.style.overflow=r}}}async function Hk(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function Uk(e,t){return new File([e],t,{type:`image/svg+xml`})}function Wk(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function Gk(e,t,n){return new Promise(r=>{let i=Vk(n.slash.drawio?.label??`Draw.io`),a=document.createElement(`iframe`),o=new URL(e);for(let[e,t]of Object.entries({embed:`1`,proto:`json`,spin:`1`,saveAndExit:`1`,noExitBtn:`0`}))o.searchParams.set(e,t);a.src=o.toString(),a.className=`dw-diagram-editor__frame`,a.title=n.slash.drawio?.label??`Draw.io`;let s=document.createElement(`div`);s.className=`dw-diagram-editor__bar`;let c=document.createElement(`button`);c.type=`button`,c.className=`dw-source__btn`,c.textContent=n.blocks.cancel,c.addEventListener(`click`,()=>d(null)),s.append(c),i.root.append(s,a),i.status(``);let l=e=>a.contentWindow?.postMessage(JSON.stringify(e),o.origin),u=!1,d=e=>{window.removeEventListener(`message`,f),i.close(),r(e)},f=e=>{if(e.source!==a.contentWindow||e.origin!==o.origin||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}switch(n.event){case`init`:l({action:`load`,autosave:0,xml:t?`data:image/svg+xml;base64,${Wk(t)}`:``});break;case`save`:u=!0,l({action:`export`,format:`xmlsvg`,spinKey:`saving`});break;case`export`:{let e=n.data??``,t=e.indexOf(`,`),r=e.slice(0,t),i=e.slice(t+1),a=r.includes(`;base64`)?new TextDecoder().decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);d(u?a:null);break}case`exit`:d(null)}};window.addEventListener(`message`,f)})}async function Kk(e,t,n){let r=Vk(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var qk=!1;function Jk(e){return Hp.create({name:e,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,loadExcalidraw:void 0,labels:null,drawioUrl:void 0,onError:void 0}},addAttributes(){return{src:{default:``},alt:{default:``}}},parseHTML(){return[{tag:`figure[data-type='${e}']`,getAttrs:e=>({src:e.querySelector(`img`)?.getAttribute(`src`)??``})}]},renderHTML({node:t,HTMLAttributes:n}){return[`figure`,Fu(n,{"data-type":e}),[`img`,{src:String(t.attrs.src),alt:String(t.attrs.alt||e)}]]},addCommands(){return{insertDiagram:e=>({commands:t})=>(qk=!0,t.insertContent({type:e,attrs:{src:``}}))}},addNodeView(){return({node:t,editor:n,getPos:r})=>{let i=this.options,a=i.labels,o=document.createElement(`figure`);o.className=`dw-diagram dw-diagram--${e}`,o.setAttribute(`data-type`,e);let s=document.createElement(`img`);s.className=`dw-diagram__img`;let c=document.createElement(`p`);c.className=`dw-diagram__empty`,c.textContent=e===`drawio`?a.blocks.emptyDrawio:a.blocks.emptyExcalidraw;let l=document.createElement(`button`);l.type=`button`,l.className=`dw-diagram__edit`,l.textContent=a.blocks.edit,o.append(s,c,l);let u=``,d=t=>{u=String(t.attrs.src??``),s.hidden=!u,c.hidden=!!u,u&&(s.src=i.host?i.host.resolve(u):u,s.alt=String(t.attrs.alt||a.slash[e]?.label||e))};d(t);let f=!1,p=async()=>{if(!f&&m()&&i.host?.upload){f=!0;try{let t=u?await Hk(i.host,u):``,o=e===`drawio`?await Gk(i.drawioUrl||`https://embed.diagrams.net`,t,a):await Kk(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(Uk(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&Yk(n,c,e,s.url)}catch(e){i.onError?.(e)}finally{f=!1}}},m=()=>n.isEditable&&!!i.host?.upload&&(e===`drawio`||!!i.loadExcalidraw),h=()=>l.hidden=!m()||!u;return h(),n.on(`update`,h),o.addEventListener(`dblclick`,()=>void p()),c.addEventListener(`click`,()=>void p()),l.addEventListener(`click`,()=>void p()),qk&&(qk=!1,queueMicrotask(()=>void p())),{dom:o,update:t=>t.type.name===e&&(d(t),h(),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target===l||e.target===c,destroy:()=>n.off(`update`,h)}}}})}function Yk(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var Xk=Jk(`drawio`),Zk=Jk(`excalidraw`),Qk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,$k=Hp.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,Fu(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=Fu(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new Vp({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Iu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Lp({find:Qk,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});async function eA(e,t,n,r){if(t.upload)for(let i of n){let n=await t.upload(i),a=n.mime.startsWith(`image/`)?{type:`image`,attrs:{src:n.url,alt:n.name}}:{type:`fileAttachment`,attrs:{url:n.url,name:n.name,size:n.size,mime:n.mime}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var tA=$k.extend({addOptions(){return{...this.parent(),host:void 0,inline:!1,allowBase64:!1}},addNodeView(){return({node:e})=>{let t=document.createElement(`img`),n=e=>{let n=String(e.attrs.src??``);t.src=this.options.host?this.options.host.resolve(n):n,t.alt=String(e.attrs.alt??``),e.attrs.title&&(t.title=String(e.attrs.title))};return n(e),t.draggable=!0,{dom:t,update:t=>t.type===e.type&&(n(t),!0)}}}});function nA(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({url:e.getAttribute(`data-url`)??``,name:e.getAttribute(`data-name`)??e.textContent??`file`,size:Number(e.getAttribute(`data-size`)??0),mime:e.getAttribute(`data-mime`)??``})}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,Fu(t,{"data-type":`file`,"data-url":e.attrs.url,"data-name":e.attrs.name,"data-size":e.attrs.size,"data-mime":e.attrs.mime}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e})=>{let t=document.createElement(`div`);t.className=`dw-file`,t.setAttribute(`data-type`,`file`);let n=document.createElement(`a`);n.className=`dw-file__name`,n.target=`_blank`,n.rel=`noopener`;let r=document.createElement(`span`);r.className=`dw-file__size`;let i=e=>{let t=String(e.attrs.url??``);n.href=this.options.host?this.options.host.resolve(t):t,n.textContent=String(e.attrs.name??`file`),r.textContent=nA(Number(e.attrs.size??0))};return i(e),t.append(n,r),{dom:t,update:t=>t.type===e.type&&(i(t),!0)}}}}),iA=yp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[aA(()=>this.editor,e,this.options.onError)]:[]}});function aA(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(eA(a,t,r,i).catch(n),!0)};return new E({key:new D(`docwellFileDrop`),props:{handlePaste(e,t){return r([...t.clipboardData?.files??[]])},handleDrop(e,t){let n=[...t.dataTransfer?.files??[]];if(!n.length)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return t.preventDefault(),r(n,i?.pos)}}})}var oA={slashMenu:`Insert block`,noMatches:`No matching blocks`,slash:{text:{label:`Text`,description:`Plain paragraph`},h1:{label:`Heading 1`,description:`Big section heading`},h2:{label:`Heading 2`,description:`Medium section heading`},h3:{label:`Heading 3`,description:`Small section heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},quote:{label:`Quote`,description:`Set text apart as a quote`},code:{label:`Code block`,description:`Monospaced code`},divider:{label:`Divider`,description:`A line between sections`},image:{label:`Image`,description:`Upload a picture`},file:{label:`File`,description:`Attach a file to download`},math:{label:`Math block`,description:`A formula on its own line (LaTeX)`},mathInline:{label:`Inline math`,description:`A formula inside the text (LaTeX)`},mermaid:{label:`Mermaid diagram`,description:`Flowcharts and sequences from text`},drawio:{label:`Draw.io diagram`,description:`Draw a diagram with diagrams.net`},excalidraw:{label:`Excalidraw drawing`,description:`Sketch by hand`},toc:{label:`Table of contents`,description:`The page's headings, kept up to date`},pageLink:{label:`Link to page`,description:`Link another page (or type [[)`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`},mentions:`Mention someone`,noPeople:`Nobody found`,pageLinks:`Link to a page`,noPages:`No pages found`,blocks:{edit:`Edit`,done:`Done`,cancel:`Cancel`,save:`Save`,remove:`Remove`,saving:`Saving…`,latex:`LaTeX formula`,mermaid:`Mermaid diagram source`,mermaidError:`This diagram has an error:`,emptyDrawio:`Empty diagram. Click to draw.`,emptyExcalidraw:`Empty drawing. Click to sketch.`,loadFailed:`The editor could not be loaded.`,toc:`Contents`,tocEmpty:`Add headings to the page to fill the table of contents.`}},I=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15e.replace(sA,`-$1`).toLowerCase(),lA={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},uA=/[&><"']/g,dA=e=>String(e).replace(uA,e=>lA[e]),fA=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?fA(e.body[0]):e:e.type===`font`?fA(e.body):e,pA=new Set([`mathord`,`textord`,`atom`]),mA=e=>pA.has(fA(e).type),hA=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},gA={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format `},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color `,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro `,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness `,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size `,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand `,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function _A(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function vA(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:_A(Array.isArray(e.type)?e.type[0]:e.type)}function yA(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?vA(r):a?a(i):i}var bA=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(gA)){var n=gA[t];n&&yA(this,t,e,n)}}reportNonstrict(e,t,n){var r=this.strict;if(typeof r==`function`&&(r=r(e,t,n)),r&&r!==`ignore`){if(r===!0||r===`error`)throw new I(`LaTeX-incompatible input and strict mode is set to 'error': `+(t+` [`+e+`]`),n);r===`warn`?typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)):typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`))}}useStrictBehavior(e,t,n){var r=this.strict;if(typeof r==`function`)try{r=r(e,t,n)}catch{r=`error`}return!r||r===`ignore`?!1:r===!0||r===`error`?!0:r===`warn`?(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)),!1):(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`)),!1)}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=hA(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},xA=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return AA[jA[this.id]]}sub(){return AA[MA[this.id]]}fracNum(){return AA[NA[this.id]]}fracDen(){return AA[PA[this.id]]}cramp(){return AA[FA[this.id]]}text(){return AA[IA[this.id]]}isTight(){return this.size>=2}},SA=0,CA=1,wA=2,TA=3,EA=4,DA=5,OA=6,kA=7,AA=[new xA(SA,0,!1),new xA(CA,0,!0),new xA(wA,1,!1),new xA(TA,1,!0),new xA(EA,2,!1),new xA(DA,2,!0),new xA(OA,3,!1),new xA(kA,3,!0)],jA=[EA,DA,EA,DA,OA,kA,OA,kA],MA=[DA,DA,DA,DA,kA,kA,kA,kA],NA=[wA,TA,EA,DA,OA,kA,OA,kA],PA=[TA,TA,DA,DA,kA,kA,kA,kA],FA=[CA,CA,TA,TA,DA,DA,kA,kA],IA=[SA,CA,wA,TA,wA,TA,wA,TA],L={DISPLAY:AA[SA],TEXT:AA[wA],SCRIPT:AA[EA],SCRIPTSCRIPT:AA[OA]},LA=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function RA(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var zA=[];LA.forEach(e=>e.blocks.forEach(e=>zA.push(...e)));function BA(e){for(var t=0;t=zA[t]&&e<=zA[t+1])return!0;return!1}var VA=e=>e+` `+e,HA=80,UA=function(e,t){return`M95,`+(622+e+t)+` +`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;dt;)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.lengthe.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:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,A(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,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=` `,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`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/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),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Bk=wp.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(AT.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(TT.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(CO.configure(this.options.bulletList)),this.options.code!==!1&&e.push(PT.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(RT.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(zT.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Uw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Ww.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(BT.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(VT.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(hT.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(HT.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(qT.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ZO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ok.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(yO.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Ek.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Pk.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Lk.configure(this.options.strike)),this.options.text!==!1&&e.push(Rk.configure(this.options.text)),this.options.underline!==!1&&e.push(zk.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(mT.configure(this.options?.trailingNode)),e}}),Vk=[`paragraph`,`heading`,`blockquote`,`codeBlock`,`bulletList`,`orderedList`,`details`,`image`,`embed`,`linkCard`,`mermaid`,`blockMath`,`drawio`,`excalidraw`,`fileAttachment`],Hk=/^[a-z0-9]{6,16}$/,Uk=e=>`#b-${e}`;function Wk(){return[...crypto.getRandomValues(new Uint8Array(8))].map(e=>(e%36).toString(36)).join(``)}var Gk=wp.create({name:`blockLinks`,addOptions(){return{labels:null,link:void 0,onCopied:void 0}},addGlobalAttributes(){return[{types:Vk,attributes:{blockId:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-block-id`);return t&&Hk.test(t)?t:null},renderHTML:e=>e.blockId?{"data-block-id":e.blockId}:{}}}}]},addProseMirrorPlugins(){let{link:e,onCopied:t}=this.options,n=this.options.labels;return e?[new E({key:new D(`blockLinks`),view:r=>new Kk(r,n.blocks.copyBlockLink,e,t)})]:[]}}),Kk=class{view;link;onCopied;button=document.createElement(`button`);pos=-1;constructor(e,t,n,r){this.view=e,this.link=n,this.onCopied=r;let i=this.button;i.type=`button`,i.className=`dw-block-handle`,i.setAttribute(`aria-label`,t),i.title=t,i.contentEditable=`false`,i.innerHTML=``,i.hidden=!0,i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,()=>void this.copy()),i.addEventListener(`mouseleave`,this.leave),e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.button.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.button)),e}hide=()=>{this.button.hidden=!0,this.pos=-1};leave=e=>{let t=e.relatedTarget;t&&(this.button.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{let t=e.target;for(;t&&t.parentElement!==this.view.dom;)t=t.parentElement;let n=this.host;if(!t||!n)return this.hide();let r;try{r=this.view.posAtDOM(t,0)}catch{return this.hide()}let i=this.view.state.doc.resolve(Math.min(r,this.view.state.doc.content.size)),a=i.depth>=1?i.before(1):r,o=this.view.state.doc.nodeAt(a);if(!o||!Vk.includes(o.type.name)||!o.attrs.blockId&&!this.view.editable)return this.hide();this.pos=a;let s=t.getBoundingClientRect(),c=n.getBoundingClientRect();this.button.style.top=`${s.top-c.top+Math.min(s.height/2,14)-11}px`,this.button.hidden=!1};async copy(){let e=this.pos>=0?this.view.state.doc.nodeAt(this.pos):null;if(!e)return;let t=e.attrs.blockId;if(!t){if(!this.view.editable)return;t=Wk(),this.view.dispatch(this.view.state.tr.setNodeAttribute(this.pos,`blockId`,t))}let n=this.link(Uk(t));try{await navigator.clipboard.writeText(n),this.onCopied?.(n)}catch{window.prompt(``,n)}}update(){this.pos>=this.view.state.doc.content.size&&this.hide()}destroy(){this.button.parentElement?.classList.remove(`dw-block-host`),this.button.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}};function qk(e){let t=jS.getState(e);return t?.type&&t.binding&&t.doc?t:null}function Jk(e,t){let n=qk(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>AS(n.doc,n.type,cy(hg(e)),n.binding.mapping),i=r(t.from),a=r(t.to);return i===null||a===null||a<=i||a>e.doc.content.size?null:{from:i,to:a}}catch{return null}}var Yk=new D(`docwellComments`);function Xk(e,t,n){let r=[];for(let i of t){let t=Jk(e,i.anchor);t&&r.push(vs.inline(t.from,t.to,{class:i.id===n?`dw-comment is-active`:`dw-comment`,"data-comment":i.id}))}return xs.create(e.doc,r)}var Zk=wp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new E({key:Yk,state:{init:()=>({marks:[],active:``,decos:xs.empty}),apply(e,t,n,r){let i=e.getMeta(Yk);if(i)return{...i,decos:Xk(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(jS)?.isChangeOrigin;return{...t,decos:a?Xk(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>Yk.getState(e)?.decos??xs.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}});function Qk(e){let t=document.createElement(`div`);t.className=`dw-diagram-editor`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-modal`,`true`),t.setAttribute(`aria-label`,e);let n=document.createElement(`p`);n.className=`dw-diagram-editor__status`,t.append(n),document.body.append(t);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,{root:t,status:e=>{n.textContent=e,n.hidden=!e},close:()=>{t.remove(),document.body.style.overflow=r}}}async function $k(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function eA(e,t){return new File([e],t,{type:`image/svg+xml`})}function tA(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function nA(e,t,n){return new Promise(r=>{let i=Qk(n.slash.drawio?.label??`Draw.io`),a=document.createElement(`iframe`),o=new URL(e);for(let[e,t]of Object.entries({embed:`1`,proto:`json`,spin:`1`,saveAndExit:`1`,noExitBtn:`0`}))o.searchParams.set(e,t);a.src=o.toString(),a.className=`dw-diagram-editor__frame`,a.title=n.slash.drawio?.label??`Draw.io`;let s=document.createElement(`div`);s.className=`dw-diagram-editor__bar`;let c=document.createElement(`button`);c.type=`button`,c.className=`dw-source__btn`,c.textContent=n.blocks.cancel,c.addEventListener(`click`,()=>d(null)),s.append(c),i.root.append(s,a),i.status(``);let l=e=>a.contentWindow?.postMessage(JSON.stringify(e),o.origin),u=!1,d=e=>{window.removeEventListener(`message`,f),i.close(),r(e)},f=e=>{if(e.source!==a.contentWindow||e.origin!==o.origin||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}switch(n.event){case`init`:l({action:`load`,autosave:0,xml:t?`data:image/svg+xml;base64,${tA(t)}`:``});break;case`save`:u=!0,l({action:`export`,format:`xmlsvg`,spinKey:`saving`});break;case`export`:{let e=n.data??``,t=e.indexOf(`,`),r=e.slice(0,t),i=e.slice(t+1),a=r.includes(`;base64`)?new TextDecoder().decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);d(u?a:null);break}case`exit`:d(null)}};window.addEventListener(`message`,f)})}async function rA(e,t,n){let r=Qk(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var iA=!1;function aA(e){return qp.create({name:e,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,loadExcalidraw:void 0,labels:null,drawioUrl:void 0,onError:void 0}},addAttributes(){return{src:{default:``},alt:{default:``}}},parseHTML(){return[{tag:`figure[data-type='${e}']`,getAttrs:e=>({src:e.querySelector(`img`)?.getAttribute(`src`)??``})}]},renderHTML({node:t,HTMLAttributes:n}){return[`figure`,A(n,{"data-type":e}),[`img`,{src:String(t.attrs.src),alt:String(t.attrs.alt||e)}]]},addCommands(){return{insertDiagram:e=>({commands:t})=>(iA=!0,t.insertContent({type:e,attrs:{src:``}}))}},addNodeView(){return({node:t,editor:n,getPos:r})=>{let i=this.options,a=i.labels,o=document.createElement(`figure`);o.className=`dw-diagram dw-diagram--${e}`,o.setAttribute(`data-type`,e);let s=document.createElement(`img`);s.className=`dw-diagram__img`;let c=document.createElement(`p`);c.className=`dw-diagram__empty`,c.textContent=e===`drawio`?a.blocks.emptyDrawio:a.blocks.emptyExcalidraw;let l=document.createElement(`button`);l.type=`button`,l.className=`dw-diagram__edit`,l.textContent=a.blocks.edit,o.append(s,c,l);let u=``,d=t=>{u=String(t.attrs.src??``),s.hidden=!u,c.hidden=!!u,u&&(s.src=i.host?i.host.resolve(u):u,s.alt=String(t.attrs.alt||a.slash[e]?.label||e))};d(t);let f=!1,p=async()=>{if(!f&&m()&&i.host?.upload){f=!0;try{let t=u?await $k(i.host,u):``,o=e===`drawio`?await nA(i.drawioUrl||`https://embed.diagrams.net`,t,a):await rA(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(eA(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&oA(n,c,e,s.url)}catch(e){i.onError?.(e)}finally{f=!1}}},m=()=>n.isEditable&&!!i.host?.upload&&(e===`drawio`||!!i.loadExcalidraw),h=()=>l.hidden=!m()||!u;return h(),n.on(`update`,h),o.addEventListener(`dblclick`,()=>void p()),c.addEventListener(`click`,()=>void p()),l.addEventListener(`click`,()=>void p()),iA&&(iA=!1,queueMicrotask(()=>void p())),{dom:o,update:t=>t.type.name===e&&(d(t),h(),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target===l||e.target===c,destroy:()=>n.off(`update`,h)}}}})}function oA(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var sA=aA(`drawio`),cA=aA(`excalidraw`),lA=Math.min,uA=Math.max,dA=Math.round,fA=Math.floor,pA=e=>({x:e,y:e}),mA={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function hA(e,t,n){return uA(e,lA(t,n))}function gA(e,t){return typeof e==`function`?e(t):e}function _A(e){return e.split(`-`)[0]}function vA(e){return e.split(`-`)[1]}function yA(e){return e===`x`?`y`:`x`}function bA(e){return e===`y`?`height`:`width`}function xA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function SA(e){return yA(xA(e))}function CA(e,t,n){n===void 0&&(n=!1);let r=vA(e),i=SA(e),a=bA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=MA(o)),[o,MA(o)]}function wA(e){let t=MA(e);return[TA(e),t,TA(t)]}function TA(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var EA=[`left`,`right`],DA=[`right`,`left`],OA=[`top`,`bottom`],kA=[`bottom`,`top`];function AA(e,t,n){switch(e){case`top`:case`bottom`:return n?t?DA:EA:t?EA:DA;case`left`:case`right`:return t?OA:kA;default:return[]}}function jA(e,t,n,r){let i=vA(e),a=AA(_A(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(TA)))),a}function MA(e){let t=_A(e);return mA[t]+e.slice(t.length)}function NA(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function PA(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:NA(e)}function FA(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function IA(e,t,n){let{reference:r,floating:i}=e,a=xA(t),o=SA(t),s=bA(o),c=_A(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=vA(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function LA(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=gA(t,e),p=PA(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=FA(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=FA(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var RA=50,zA=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:LA},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=IA(l,r,c),f=r,p=0,m={};for(let n=0;ne<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===xA(t)||ne.every(e=>xA(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:ne},reset:{placement:t}};let n=ne.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=ne.filter(e=>{if(x){let t=xA(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},VA=new Set([`left`,`top`]);async function HA(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=_A(n),s=vA(n),c=xA(n)===`y`,l=VA.has(o)?-1:1,u=a&&c?-1:1,d=gA(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var UA=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await HA(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},WA=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=gA(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=xA(i),p=yA(f),m=u[p],h=u[f],g=(e,t)=>hA(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}};function GA(){return typeof window<`u`}function KA(e){return YA(e)?(e.nodeName||``).toLowerCase():`#document`}function qA(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function JA(e){return((YA(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function YA(e){return GA()?e instanceof Node||e instanceof qA(e).Node:!1}function XA(e){return GA()?e instanceof Element||e instanceof qA(e).Element:!1}function ZA(e){return GA()?e instanceof HTMLElement||e instanceof qA(e).HTMLElement:!1}function QA(e){return!GA()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof qA(e).ShadowRoot}function $A(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=uj(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ej(e){return/^(table|td|th)$/.test(KA(e))}function tj(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var nj=/transform|translate|scale|rotate|perspective|filter/,rj=/paint|layout|strict|content/,ij=e=>!!e&&e!==`none`,aj;function oj(e){let t=XA(e)?uj(e):e;return ij(t.transform)||ij(t.translate)||ij(t.scale)||ij(t.rotate)||ij(t.perspective)||!cj()&&(ij(t.backdropFilter)||ij(t.filter))||nj.test(t.willChange||``)||rj.test(t.contain||``)}function sj(e){let t=fj(e);for(;ZA(t)&&!lj(t);){if(oj(t))return t;if(tj(t))return null;t=fj(t)}return null}function cj(){return aj??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),aj}function lj(e){return/^(html|body|#document)$/.test(KA(e))}function uj(e){return qA(e).getComputedStyle(e)}function dj(e){return XA(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fj(e){if(KA(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||QA(e)&&e.host||JA(e);return QA(t)?t.host:t}function pj(e){let t=fj(e);return lj(t)?(e.ownerDocument||e).body:ZA(t)&&$A(t)?t:pj(t)}function mj(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=pj(e),i=r===e.ownerDocument?.body,a=qA(r);if(i){let e=hj(a);return t.concat(a,a.visualViewport||[],$A(r)?r:[],e&&n?mj(e):[])}return t.concat(r,mj(r,[],n))}function hj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gj(e){let t=uj(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ZA(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=dA(n)!==a||dA(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function _j(e){return XA(e)?e:e.contextElement}function vj(e){let t=_j(e);if(!ZA(t))return pA(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=gj(t),o=(a?dA(n.width):n.width)/r,s=(a?dA(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var yj=pA(0);function bj(e){let t=qA(e);return!cj()||!t.visualViewport?yj:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xj(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===qA(e)}function Sj(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=_j(e),o=pA(1);t&&(r?XA(r)&&(o=vj(r)):o=vj(e));let s=xj(a,n,r)?bj(a):pA(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=qA(a),t=XA(r)?qA(r):r,n=e,i=hj(n);for(;i&&t!==n;){let e=vj(i),t=i.getBoundingClientRect(),r=uj(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=qA(i),i=hj(n)}}return FA({width:u,height:d,x:c,y:l})}function Cj(e,t){let n=dj(e).scrollLeft;return t?t.left+n:Sj(JA(e)).left+n}function wj(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Cj(e,n),y:n.top+t.scrollTop}}function Tj(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=JA(r),s=t?tj(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=pA(1),u=pA(0),d=ZA(r);if((d||!a)&&((KA(r)!==`body`||$A(o))&&(c=dj(r)),d)){let e=Sj(r);l=vj(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?wj(o,c):pA(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ej(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Dj(e){let t=dj(e),n=e.ownerDocument.body,r=uA(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=uA(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Cj(e),o=-t.scrollTop;return uj(n).direction===`rtl`&&(a+=uA(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Oj=25;function kj(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=qA(e),a=JA(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!cj()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Cj(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Oj&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Aj(e,t){let n=Sj(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=vj(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function jj(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=kj(e,n,t);else if(t===`document`)r=Dj(JA(e));else if(XA(t))r=Aj(t,n);else{let n=bj(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return FA(r)}function Mj(e,t){let n=t.get(e);if(n)return n;let r=mj(e,[],!1).filter(e=>XA(e)&&KA(e)!==`body`),i=null,a=uj(e).position===`fixed`,o=a?fj(e):e;for(;XA(o)&&!lj(o);){let e=uj(o),t=oj(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=fj(o)}return t.set(e,r),r}function Nj(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?tj(t)?[]:Mj(t,this._c):[].concat(n),r],o=jj(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=qA(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Wj(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=_j(e),u=i||a?[...l?mj(l):[],...t?mj(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Uj(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Sj(e):null;c&&g();function g(){let t=Sj(e);h&&!Hj(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Gj=UA,Kj=WA,qj=BA,Jj=(e,t,n)=>{let r=new Map,i=n??{},a={...Vj,...i.platform,_c:r};return zA(e,t,{...i,platform:a})},Yj=null;function Xj(e){Yj?.();let t=document.createElement(`div`);t.className=`dw-source`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,e.label);let n=document.createElement(e.multiline?`textarea`:`input`);n.className=`dw-source__field`+(e.monospace?` dw-source__field--mono`:``),n.value=e.value,n.setAttribute(`aria-label`,e.label),n.spellcheck=!1,n instanceof HTMLTextAreaElement&&(n.rows=Math.min(16,Math.max(4,e.value.split(` +`).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.target=`_blank`,s.rel=`noopener noreferrer`,s.textContent=eM(r),o.append(s),n.append(a,o)},i=String(e.attrs.url);return r(i),{dom:n,update:e=>e.type.name===`embed`&&(e.attrs.url!==i&&r(i=String(e.attrs.url)),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`)}}}}),oM=qp.create({name:`linkCard`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){let e=e=>({default:``,parseHTML:t=>t.getAttribute(`data-${e}`)??``,renderHTML:t=>({[`data-${e}`]:t[e]})});return{url:e(`url`),title:e(`title`),description:e(`description`),image:e(`image`),site:e(`site`)}},parseHTML(){return[{tag:`div[data-type='link-card']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=$j(String(e.attrs.url));return[`div`,A(t,{"data-type":`link-card`}),[`a`,{href:n},String(e.attrs.title||n)]]},addCommands(){return{insertLinkCard:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e.url,title:e.title??``,description:e.description??``,image:e.image??``,site:e.site??``}})}},addNodeView(){return({node:e})=>{let t=document.createElement(`a`);t.className=`dw-linkcard`,t.setAttribute(`data-type`,`link-card`),t.contentEditable=`false`,t.target=`_blank`,t.rel=`noopener noreferrer`;let n=e=>{let n=$j(String(e.url));t.href=n,t.replaceChildren();let r=document.createElement(`span`);r.className=`dw-linkcard__text`;let i=document.createElement(`span`);if(i.className=`dw-linkcard__title`,i.textContent=String(e.title||``)||eM(n),r.append(i),e.description){let t=document.createElement(`span`);t.className=`dw-linkcard__desc`,t.textContent=String(e.description),r.append(t)}let a=document.createElement(`span`);a.className=`dw-linkcard__site`,a.textContent=String(e.site||``)||eM(n),r.append(a),t.append(r);let o=$j(String(e.image||``));if(o.startsWith(`https:`)){let e=document.createElement(`img`);e.className=`dw-linkcard__image`,e.src=o,e.alt=``,e.loading=`lazy`,e.referrerPolicy=`no-referrer`,e.onerror=()=>e.remove(),t.append(e)}},r=e;return n(e.attrs),t.addEventListener(`click`,e=>{this.editor.view.editable&&!(e.ctrlKey||e.metaKey)&&e.preventDefault()}),{dom:t,update:e=>e.type.name===`linkCard`&&(e.attrs!==r.attrs&&n(e.attrs),r=e,!0),ignoreMutation:()=>!0}}}}),sM=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cM=qp.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,A(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=A(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new Kp({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Lu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Hp({find:sM,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});async function lM(e,t,n,r){if(t.upload)for(let i of n){let n=await t.upload(i),a=n.mime.startsWith(`image/`)?{type:`image`,attrs:{src:n.url,alt:n.name}}:{type:`fileAttachment`,attrs:{url:n.url,name:n.name,size:n.size,mime:n.mime}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var uM=cM.extend({addOptions(){return{...this.parent(),host:void 0,inline:!1,allowBase64:!1}},addNodeView(){return({node:e})=>{let t=document.createElement(`img`),n=e=>{let n=String(e.attrs.src??``);t.src=this.options.host?this.options.host.resolve(n):n,t.alt=String(e.attrs.alt??``),e.attrs.title&&(t.title=String(e.attrs.title))};return n(e),t.draggable=!0,{dom:t,update:t=>t.type===e.type&&(n(t),!0)}}}});function dM(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({url:e.getAttribute(`data-url`)??``,name:e.getAttribute(`data-name`)??e.textContent??`file`,size:Number(e.getAttribute(`data-size`)??0),mime:e.getAttribute(`data-mime`)??``})}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`file`,"data-url":e.attrs.url,"data-name":e.attrs.name,"data-size":e.attrs.size,"data-mime":e.attrs.mime}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e})=>{let t=document.createElement(`div`);t.className=`dw-file`,t.setAttribute(`data-type`,`file`);let n=document.createElement(`a`);n.className=`dw-file__name`,n.target=`_blank`,n.rel=`noopener`;let r=document.createElement(`span`);r.className=`dw-file__size`;let i=e=>{let t=String(e.attrs.url??``);n.href=this.options.host?this.options.host.resolve(t):t,n.textContent=String(e.attrs.name??`file`),r.textContent=dM(Number(e.attrs.size??0))};return i(e),t.append(n,r),{dom:t,update:t=>t.type===e.type&&(i(t),!0)}}}}),pM=wp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[mM(()=>this.editor,e,this.options.onError)]:[]}});function mM(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(lM(a,t,r,i).catch(n),!0)};return new E({key:new D(`docwellFileDrop`),props:{handlePaste(e,t){return r([...t.clipboardData?.files??[]])},handleDrop(e,t){let n=[...t.dataTransfer?.files??[]];if(!n.length)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return t.preventDefault(),r(n,i?.pos)}}})}var hM={slashMenu:`Insert block`,noMatches:`No matching blocks`,slash:{text:{label:`Text`,description:`Plain paragraph`},h1:{label:`Heading 1`,description:`Big section heading`},h2:{label:`Heading 2`,description:`Medium section heading`},h3:{label:`Heading 3`,description:`Small section heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},quote:{label:`Quote`,description:`Set text apart as a quote`},code:{label:`Code block`,description:`Monospaced code`},divider:{label:`Divider`,description:`A line between sections`},image:{label:`Image`,description:`Upload a picture`},file:{label:`File`,description:`Attach a file to download`},math:{label:`Math block`,description:`A formula on its own line (LaTeX)`},mathInline:{label:`Inline math`,description:`A formula inside the text (LaTeX)`},mermaid:{label:`Mermaid diagram`,description:`Flowcharts and sequences from text`},drawio:{label:`Draw.io diagram`,description:`Draw a diagram with diagrams.net`},excalidraw:{label:`Excalidraw drawing`,description:`Sketch by hand`},toc:{label:`Table of contents`,description:`The page's headings, kept up to date`},pageLink:{label:`Link to page`,description:`Link another page (or type [[)`},toggle:{label:`Toggle`,description:`A heading that hides the blocks under it`},embed:{label:`Embed`,description:`A video, design or document from YouTube, Figma and more`},linkCard:{label:`Link card`,description:`A link with its page's title and picture`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`},mentions:`Mention someone`,noPeople:`Nobody found`,pageLinks:`Link to a page`,noPages:`No pages found`,blocks:{edit:`Edit`,done:`Done`,cancel:`Cancel`,save:`Save`,remove:`Remove`,saving:`Saving…`,latex:`LaTeX formula`,mermaid:`Mermaid diagram source`,mermaidError:`This diagram has an error:`,emptyDrawio:`Empty diagram. Click to draw.`,emptyExcalidraw:`Empty drawing. Click to sketch.`,loadFailed:`The editor could not be loaded.`,toc:`Contents`,tocEmpty:`Add headings to the page to fill the table of contents.`,expand:`Show contents`,collapse:`Hide contents`,embed:`Embedded content`,embedUrl:`Address of the video, design or document`,embedInvalid:`This address can't be embedded.`,linkUrl:`Address of the page to link`,copyBlockLink:`Copy link to this block`}},I=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15e.replace(gM,`-$1`).toLowerCase(),vM={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},yM=/[&><"']/g,bM=e=>String(e).replace(yM,e=>vM[e]),xM=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?xM(e.body[0]):e:e.type===`font`?xM(e.body):e,SM=new Set([`mathord`,`textord`,`atom`]),CM=e=>SM.has(xM(e).type),wM=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},TM={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format `},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color `,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro `,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness `,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size `,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand `,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function EM(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function DM(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:EM(Array.isArray(e.type)?e.type[0]:e.type)}function OM(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?DM(r):a?a(i):i}var kM=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(TM)){var n=TM[t];n&&OM(this,t,e,n)}}reportNonstrict(e,t,n){var r=this.strict;if(typeof r==`function`&&(r=r(e,t,n)),r&&r!==`ignore`){if(r===!0||r===`error`)throw new I(`LaTeX-incompatible input and strict mode is set to 'error': `+(t+` [`+e+`]`),n);r===`warn`?typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)):typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`))}}useStrictBehavior(e,t,n){var r=this.strict;if(typeof r==`function`)try{r=r(e,t,n)}catch{r=`error`}return!r||r===`ignore`?!1:r===!0||r===`error`?!0:r===`warn`?(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)),!1):(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`)),!1)}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=wM(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},AM=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return zM[BM[this.id]]}sub(){return zM[VM[this.id]]}fracNum(){return zM[HM[this.id]]}fracDen(){return zM[UM[this.id]]}cramp(){return zM[WM[this.id]]}text(){return zM[GM[this.id]]}isTight(){return this.size>=2}},jM=0,MM=1,NM=2,PM=3,FM=4,IM=5,LM=6,RM=7,zM=[new AM(jM,0,!1),new AM(MM,0,!0),new AM(NM,1,!1),new AM(PM,1,!0),new AM(FM,2,!1),new AM(IM,2,!0),new AM(LM,3,!1),new AM(RM,3,!0)],BM=[FM,IM,FM,IM,LM,RM,LM,RM],VM=[IM,IM,IM,IM,RM,RM,RM,RM],HM=[NM,PM,FM,IM,LM,RM,LM,RM],UM=[PM,PM,IM,IM,RM,RM,RM,RM],WM=[MM,MM,PM,PM,IM,IM,RM,RM],GM=[jM,MM,NM,PM,NM,PM,NM,PM],L={DISPLAY:zM[jM],TEXT:zM[NM],SCRIPT:zM[FM],SCRIPTSCRIPT:zM[LM]},KM=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function qM(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var JM=[];KM.forEach(e=>e.blocks.forEach(e=>JM.push(...e)));function YM(e){for(var t=0;t=JM[t]&&e<=JM[t+1])return!0;return!1}var XM=e=>e+` `+e,ZM=80,QM=function(e,t){return`M95,`+(622+e+t)+` 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{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/=\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`,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=``+dA(this.alt)+``,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=`0&&(n+=`margin-right:`+R(this.italic)+`;`),n+=sj(this.style),n&&(e=!0,t+=` style="`+dA(n)+`"`);var r=dA(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},_j=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var n=0;n`;for(var n=0;n`,e}},vj=class{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return this.alternate?e.setAttribute(`d`,this.alternate):e.setAttribute(`d`,QA[this.pathName]),e}toMarkup(){return this.alternate?``:``}},yj=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e=``,e}};function bj(e){if(e instanceof gj)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function xj(e){if(e instanceof fj)return e;throw Error(`Expected span but got `+String(e)+`.`)}var Sj=e=>e instanceof fj||e instanceof pj||e instanceof tj,Cj={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},wj={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},Tj={Å:`A`,Ð:`D`,Þ:`o`,å:`a`,ð:`d`,þ:`o`,А:`A`,Б:`B`,В:`B`,Г:`F`,Д:`A`,Е:`E`,Ж:`K`,З:`3`,И:`N`,Й:`N`,К:`K`,Л:`N`,М:`M`,Н:`H`,О:`O`,П:`N`,Р:`P`,С:`C`,Т:`T`,У:`y`,Ф:`O`,Х:`X`,Ц:`U`,Ч:`h`,Ш:`W`,Щ:`W`,Ъ:`B`,Ы:`X`,Ь:`B`,Э:`3`,Ю:`X`,Я:`R`,а:`a`,б:`b`,в:`a`,г:`r`,д:`y`,е:`e`,ж:`m`,з:`e`,и:`n`,й:`n`,к:`n`,л:`n`,м:`m`,н:`n`,о:`o`,п:`n`,р:`p`,с:`c`,т:`o`,у:`y`,ф:`b`,х:`x`,ц:`n`,ч:`n`,ш:`w`,щ:`w`,ъ:`a`,ы:`m`,ь:`a`,э:`e`,ю:`m`,я:`r`};function Ej(e,t){Cj[e]=t}function Dj(e,t,n){if(!Cj[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=Cj[t][r];if(!i&&e[0]in Tj&&(r=Tj[e[0]].charCodeAt(0),i=Cj[t][r]),!i&&n===`text`&&BA(r)&&(i=Cj[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var Oj={};function kj(e){var t=e>=5?0:e>=3?1:2;if(!Oj[t]){var n=Oj[t]={cssEmPerMu:wj.quad[t]/18};for(var r of Object.keys(wj))n[r]=wj[r][t]}return Oj[t]}var Aj={math:{},text:{}};function z(e,t,n,r,i,a){Aj[e][i]={font:t,group:n,replace:r},a&&r&&(Aj[e][r]=Aj[e][i])}var B=`math`,V=`text`,H=`main`,U=`ams`,jj=`accent-token`,W=`bin`,Mj=`close`,Nj=`inner`,G=`mathord`,Pj=`op-token`,Fj=`open`,Ij=`punct`,K=`rel`,Lj=`spacing`,q=`textord`;z(B,H,K,`≡`,`\\equiv`,!0),z(B,H,K,`≺`,`\\prec`,!0),z(B,H,K,`≻`,`\\succ`,!0),z(B,H,K,`∼`,`\\sim`,!0),z(B,H,K,`⊥`,`\\perp`),z(B,H,K,`⪯`,`\\preceq`,!0),z(B,H,K,`⪰`,`\\succeq`,!0),z(B,H,K,`≃`,`\\simeq`,!0),z(B,H,K,`∣`,`\\mid`,!0),z(B,H,K,`≪`,`\\ll`,!0),z(B,H,K,`≫`,`\\gg`,!0),z(B,H,K,`≍`,`\\asymp`,!0),z(B,H,K,`∥`,`\\parallel`),z(B,H,K,`⋈`,`\\bowtie`,!0),z(B,H,K,`⌣`,`\\smile`,!0),z(B,H,K,`⊑`,`\\sqsubseteq`,!0),z(B,H,K,`⊒`,`\\sqsupseteq`,!0),z(B,H,K,`≐`,`\\doteq`,!0),z(B,H,K,`⌢`,`\\frown`,!0),z(B,H,K,`∋`,`\\ni`,!0),z(B,H,K,`∝`,`\\propto`,!0),z(B,H,K,`⊢`,`\\vdash`,!0),z(B,H,K,`⊣`,`\\dashv`,!0),z(B,H,K,`∋`,`\\owns`),z(B,H,Ij,`.`,`\\ldotp`),z(B,H,Ij,`⋅`,`\\cdotp`),z(B,H,Ij,`⋅`,`·`),z(V,H,q,`⋅`,`·`),z(B,H,q,`#`,`\\#`),z(V,H,q,`#`,`\\#`),z(B,H,q,`&`,`\\&`),z(V,H,q,`&`,`\\&`),z(B,H,q,`ℵ`,`\\aleph`,!0),z(B,H,q,`∀`,`\\forall`,!0),z(B,H,q,`ℏ`,`\\hbar`,!0),z(B,H,q,`∃`,`\\exists`,!0),z(B,H,q,`∇`,`\\nabla`,!0),z(B,H,q,`♭`,`\\flat`,!0),z(B,H,q,`ℓ`,`\\ell`,!0),z(B,H,q,`♮`,`\\natural`,!0),z(B,H,q,`♣`,`\\clubsuit`,!0),z(B,H,q,`℘`,`\\wp`,!0),z(B,H,q,`♯`,`\\sharp`,!0),z(B,H,q,`♢`,`\\diamondsuit`,!0),z(B,H,q,`ℜ`,`\\Re`,!0),z(B,H,q,`♡`,`\\heartsuit`,!0),z(B,H,q,`ℑ`,`\\Im`,!0),z(B,H,q,`♠`,`\\spadesuit`,!0),z(B,H,q,`§`,`\\S`,!0),z(V,H,q,`§`,`\\S`),z(B,H,q,`¶`,`\\P`,!0),z(V,H,q,`¶`,`\\P`),z(B,H,q,`†`,`\\dag`),z(V,H,q,`†`,`\\dag`),z(V,H,q,`†`,`\\textdagger`),z(B,H,q,`‡`,`\\ddag`),z(V,H,q,`‡`,`\\ddag`),z(V,H,q,`‡`,`\\textdaggerdbl`),z(B,H,Mj,`⎱`,`\\rmoustache`,!0),z(B,H,Fj,`⎰`,`\\lmoustache`,!0),z(B,H,Mj,`⟯`,`\\rgroup`,!0),z(B,H,Fj,`⟮`,`\\lgroup`,!0),z(B,H,W,`∓`,`\\mp`,!0),z(B,H,W,`⊖`,`\\ominus`,!0),z(B,H,W,`⊎`,`\\uplus`,!0),z(B,H,W,`⊓`,`\\sqcap`,!0),z(B,H,W,`∗`,`\\ast`),z(B,H,W,`⊔`,`\\sqcup`,!0),z(B,H,W,`◯`,`\\bigcirc`,!0),z(B,H,W,`∙`,`\\bullet`,!0),z(B,H,W,`‡`,`\\ddagger`),z(B,H,W,`≀`,`\\wr`,!0),z(B,H,W,`⨿`,`\\amalg`),z(B,H,W,`&`,`\\And`),z(B,H,K,`⟵`,`\\longleftarrow`,!0),z(B,H,K,`⇐`,`\\Leftarrow`,!0),z(B,H,K,`⟸`,`\\Longleftarrow`,!0),z(B,H,K,`⟶`,`\\longrightarrow`,!0),z(B,H,K,`⇒`,`\\Rightarrow`,!0),z(B,H,K,`⟹`,`\\Longrightarrow`,!0),z(B,H,K,`↔`,`\\leftrightarrow`,!0),z(B,H,K,`⟷`,`\\longleftrightarrow`,!0),z(B,H,K,`⇔`,`\\Leftrightarrow`,!0),z(B,H,K,`⟺`,`\\Longleftrightarrow`,!0),z(B,H,K,`↦`,`\\mapsto`,!0),z(B,H,K,`⟼`,`\\longmapsto`,!0),z(B,H,K,`↗`,`\\nearrow`,!0),z(B,H,K,`↩`,`\\hookleftarrow`,!0),z(B,H,K,`↪`,`\\hookrightarrow`,!0),z(B,H,K,`↘`,`\\searrow`,!0),z(B,H,K,`↼`,`\\leftharpoonup`,!0),z(B,H,K,`⇀`,`\\rightharpoonup`,!0),z(B,H,K,`↙`,`\\swarrow`,!0),z(B,H,K,`↽`,`\\leftharpoondown`,!0),z(B,H,K,`⇁`,`\\rightharpoondown`,!0),z(B,H,K,`↖`,`\\nwarrow`,!0),z(B,H,K,`⇌`,`\\rightleftharpoons`,!0),z(B,U,K,`≮`,`\\nless`,!0),z(B,U,K,``,`\\@nleqslant`),z(B,U,K,``,`\\@nleqq`),z(B,U,K,`⪇`,`\\lneq`,!0),z(B,U,K,`≨`,`\\lneqq`,!0),z(B,U,K,``,`\\@lvertneqq`),z(B,U,K,`⋦`,`\\lnsim`,!0),z(B,U,K,`⪉`,`\\lnapprox`,!0),z(B,U,K,`⊀`,`\\nprec`,!0),z(B,U,K,`⋠`,`\\npreceq`,!0),z(B,U,K,`⋨`,`\\precnsim`,!0),z(B,U,K,`⪹`,`\\precnapprox`,!0),z(B,U,K,`≁`,`\\nsim`,!0),z(B,U,K,``,`\\@nshortmid`),z(B,U,K,`∤`,`\\nmid`,!0),z(B,U,K,`⊬`,`\\nvdash`,!0),z(B,U,K,`⊭`,`\\nvDash`,!0),z(B,U,K,`⋪`,`\\ntriangleleft`),z(B,U,K,`⋬`,`\\ntrianglelefteq`,!0),z(B,U,K,`⊊`,`\\subsetneq`,!0),z(B,U,K,``,`\\@varsubsetneq`),z(B,U,K,`⫋`,`\\subsetneqq`,!0),z(B,U,K,``,`\\@varsubsetneqq`),z(B,U,K,`≯`,`\\ngtr`,!0),z(B,U,K,``,`\\@ngeqslant`),z(B,U,K,``,`\\@ngeqq`),z(B,U,K,`⪈`,`\\gneq`,!0),z(B,U,K,`≩`,`\\gneqq`,!0),z(B,U,K,``,`\\@gvertneqq`),z(B,U,K,`⋧`,`\\gnsim`,!0),z(B,U,K,`⪊`,`\\gnapprox`,!0),z(B,U,K,`⊁`,`\\nsucc`,!0),z(B,U,K,`⋡`,`\\nsucceq`,!0),z(B,U,K,`⋩`,`\\succnsim`,!0),z(B,U,K,`⪺`,`\\succnapprox`,!0),z(B,U,K,`≆`,`\\ncong`,!0),z(B,U,K,``,`\\@nshortparallel`),z(B,U,K,`∦`,`\\nparallel`,!0),z(B,U,K,`⊯`,`\\nVDash`,!0),z(B,U,K,`⋫`,`\\ntriangleright`),z(B,U,K,`⋭`,`\\ntrianglerighteq`,!0),z(B,U,K,``,`\\@nsupseteqq`),z(B,U,K,`⊋`,`\\supsetneq`,!0),z(B,U,K,``,`\\@varsupsetneq`),z(B,U,K,`⫌`,`\\supsetneqq`,!0),z(B,U,K,``,`\\@varsupsetneqq`),z(B,U,K,`⊮`,`\\nVdash`,!0),z(B,U,K,`⪵`,`\\precneqq`,!0),z(B,U,K,`⪶`,`\\succneqq`,!0),z(B,U,K,``,`\\@nsubseteqq`),z(B,U,W,`⊴`,`\\unlhd`),z(B,U,W,`⊵`,`\\unrhd`),z(B,U,K,`↚`,`\\nleftarrow`,!0),z(B,U,K,`↛`,`\\nrightarrow`,!0),z(B,U,K,`⇍`,`\\nLeftarrow`,!0),z(B,U,K,`⇏`,`\\nRightarrow`,!0),z(B,U,K,`↮`,`\\nleftrightarrow`,!0),z(B,U,K,`⇎`,`\\nLeftrightarrow`,!0),z(B,U,K,`△`,`\\vartriangle`),z(B,U,q,`ℏ`,`\\hslash`),z(B,U,q,`▽`,`\\triangledown`),z(B,U,q,`◊`,`\\lozenge`),z(B,U,q,`Ⓢ`,`\\circledS`),z(B,U,q,`®`,`\\circledR`),z(V,U,q,`®`,`\\circledR`),z(B,U,q,`∡`,`\\measuredangle`,!0),z(B,U,q,`∄`,`\\nexists`),z(B,U,q,`℧`,`\\mho`),z(B,U,q,`Ⅎ`,`\\Finv`,!0),z(B,U,q,`⅁`,`\\Game`,!0),z(B,U,q,`‵`,`\\backprime`),z(B,U,q,`▲`,`\\blacktriangle`),z(B,U,q,`▼`,`\\blacktriangledown`),z(B,U,q,`■`,`\\blacksquare`),z(B,U,q,`⧫`,`\\blacklozenge`),z(B,U,q,`★`,`\\bigstar`),z(B,U,q,`∢`,`\\sphericalangle`,!0),z(B,U,q,`∁`,`\\complement`,!0),z(B,U,q,`ð`,`\\eth`,!0),z(V,H,q,`ð`,`ð`),z(B,U,q,`╱`,`\\diagup`),z(B,U,q,`╲`,`\\diagdown`),z(B,U,q,`□`,`\\square`),z(B,U,q,`□`,`\\Box`),z(B,U,q,`◊`,`\\Diamond`),z(B,U,q,`¥`,`\\yen`,!0),z(V,U,q,`¥`,`\\yen`,!0),z(B,U,q,`✓`,`\\checkmark`,!0),z(V,U,q,`✓`,`\\checkmark`),z(B,U,q,`ℶ`,`\\beth`,!0),z(B,U,q,`ℸ`,`\\daleth`,!0),z(B,U,q,`ℷ`,`\\gimel`,!0),z(B,U,q,`ϝ`,`\\digamma`,!0),z(B,U,q,`ϰ`,`\\varkappa`),z(B,U,Fj,`┌`,`\\@ulcorner`,!0),z(B,U,Mj,`┐`,`\\@urcorner`,!0),z(B,U,Fj,`└`,`\\@llcorner`,!0),z(B,U,Mj,`┘`,`\\@lrcorner`,!0),z(B,U,K,`≦`,`\\leqq`,!0),z(B,U,K,`⩽`,`\\leqslant`,!0),z(B,U,K,`⪕`,`\\eqslantless`,!0),z(B,U,K,`≲`,`\\lesssim`,!0),z(B,U,K,`⪅`,`\\lessapprox`,!0),z(B,U,K,`≊`,`\\approxeq`,!0),z(B,U,W,`⋖`,`\\lessdot`),z(B,U,K,`⋘`,`\\lll`,!0),z(B,U,K,`≶`,`\\lessgtr`,!0),z(B,U,K,`⋚`,`\\lesseqgtr`,!0),z(B,U,K,`⪋`,`\\lesseqqgtr`,!0),z(B,U,K,`≑`,`\\doteqdot`),z(B,U,K,`≓`,`\\risingdotseq`,!0),z(B,U,K,`≒`,`\\fallingdotseq`,!0),z(B,U,K,`∽`,`\\backsim`,!0),z(B,U,K,`⋍`,`\\backsimeq`,!0),z(B,U,K,`⫅`,`\\subseteqq`,!0),z(B,U,K,`⋐`,`\\Subset`,!0),z(B,U,K,`⊏`,`\\sqsubset`,!0),z(B,U,K,`≼`,`\\preccurlyeq`,!0),z(B,U,K,`⋞`,`\\curlyeqprec`,!0),z(B,U,K,`≾`,`\\precsim`,!0),z(B,U,K,`⪷`,`\\precapprox`,!0),z(B,U,K,`⊲`,`\\vartriangleleft`),z(B,U,K,`⊴`,`\\trianglelefteq`),z(B,U,K,`⊨`,`\\vDash`,!0),z(B,U,K,`⊪`,`\\Vvdash`,!0),z(B,U,K,`⌣`,`\\smallsmile`),z(B,U,K,`⌢`,`\\smallfrown`),z(B,U,K,`≏`,`\\bumpeq`,!0),z(B,U,K,`≎`,`\\Bumpeq`,!0),z(B,U,K,`≧`,`\\geqq`,!0),z(B,U,K,`⩾`,`\\geqslant`,!0),z(B,U,K,`⪖`,`\\eqslantgtr`,!0),z(B,U,K,`≳`,`\\gtrsim`,!0),z(B,U,K,`⪆`,`\\gtrapprox`,!0),z(B,U,W,`⋗`,`\\gtrdot`),z(B,U,K,`⋙`,`\\ggg`,!0),z(B,U,K,`≷`,`\\gtrless`,!0),z(B,U,K,`⋛`,`\\gtreqless`,!0),z(B,U,K,`⪌`,`\\gtreqqless`,!0),z(B,U,K,`≖`,`\\eqcirc`,!0),z(B,U,K,`≗`,`\\circeq`,!0),z(B,U,K,`≜`,`\\triangleq`,!0),z(B,U,K,`∼`,`\\thicksim`),z(B,U,K,`≈`,`\\thickapprox`),z(B,U,K,`⫆`,`\\supseteqq`,!0),z(B,U,K,`⋑`,`\\Supset`,!0),z(B,U,K,`⊐`,`\\sqsupset`,!0),z(B,U,K,`≽`,`\\succcurlyeq`,!0),z(B,U,K,`⋟`,`\\curlyeqsucc`,!0),z(B,U,K,`≿`,`\\succsim`,!0),z(B,U,K,`⪸`,`\\succapprox`,!0),z(B,U,K,`⊳`,`\\vartriangleright`),z(B,U,K,`⊵`,`\\trianglerighteq`),z(B,U,K,`⊩`,`\\Vdash`,!0),z(B,U,K,`∣`,`\\shortmid`),z(B,U,K,`∥`,`\\shortparallel`),z(B,U,K,`≬`,`\\between`,!0),z(B,U,K,`⋔`,`\\pitchfork`,!0),z(B,U,K,`∝`,`\\varpropto`),z(B,U,K,`◀`,`\\blacktriangleleft`),z(B,U,K,`∴`,`\\therefore`,!0),z(B,U,K,`∍`,`\\backepsilon`),z(B,U,K,`▶`,`\\blacktriangleright`),z(B,U,K,`∵`,`\\because`,!0),z(B,U,K,`⋘`,`\\llless`),z(B,U,K,`⋙`,`\\gggtr`),z(B,U,W,`⊲`,`\\lhd`),z(B,U,W,`⊳`,`\\rhd`),z(B,U,K,`≂`,`\\eqsim`,!0),z(B,H,K,`⋈`,`\\Join`),z(B,U,K,`≑`,`\\Doteq`,!0),z(B,U,W,`∔`,`\\dotplus`,!0),z(B,U,W,`∖`,`\\smallsetminus`),z(B,U,W,`⋒`,`\\Cap`,!0),z(B,U,W,`⋓`,`\\Cup`,!0),z(B,U,W,`⩞`,`\\doublebarwedge`,!0),z(B,U,W,`⊟`,`\\boxminus`,!0),z(B,U,W,`⊞`,`\\boxplus`,!0),z(B,U,W,`⋇`,`\\divideontimes`,!0),z(B,U,W,`⋉`,`\\ltimes`,!0),z(B,U,W,`⋊`,`\\rtimes`,!0),z(B,U,W,`⋋`,`\\leftthreetimes`,!0),z(B,U,W,`⋌`,`\\rightthreetimes`,!0),z(B,U,W,`⋏`,`\\curlywedge`,!0),z(B,U,W,`⋎`,`\\curlyvee`,!0),z(B,U,W,`⊝`,`\\circleddash`,!0),z(B,U,W,`⊛`,`\\circledast`,!0),z(B,U,W,`⋅`,`\\centerdot`),z(B,U,W,`⊺`,`\\intercal`,!0),z(B,U,W,`⋒`,`\\doublecap`),z(B,U,W,`⋓`,`\\doublecup`),z(B,U,W,`⊠`,`\\boxtimes`,!0),z(B,U,K,`⇢`,`\\dashrightarrow`,!0),z(B,U,K,`⇠`,`\\dashleftarrow`,!0),z(B,U,K,`⇇`,`\\leftleftarrows`,!0),z(B,U,K,`⇆`,`\\leftrightarrows`,!0),z(B,U,K,`⇚`,`\\Lleftarrow`,!0),z(B,U,K,`↞`,`\\twoheadleftarrow`,!0),z(B,U,K,`↢`,`\\leftarrowtail`,!0),z(B,U,K,`↫`,`\\looparrowleft`,!0),z(B,U,K,`⇋`,`\\leftrightharpoons`,!0),z(B,U,K,`↶`,`\\curvearrowleft`,!0),z(B,U,K,`↺`,`\\circlearrowleft`,!0),z(B,U,K,`↰`,`\\Lsh`,!0),z(B,U,K,`⇈`,`\\upuparrows`,!0),z(B,U,K,`↿`,`\\upharpoonleft`,!0),z(B,U,K,`⇃`,`\\downharpoonleft`,!0),z(B,H,K,`⊶`,`\\origof`,!0),z(B,H,K,`⊷`,`\\imageof`,!0),z(B,U,K,`⊸`,`\\multimap`,!0),z(B,U,K,`↭`,`\\leftrightsquigarrow`,!0),z(B,U,K,`⇉`,`\\rightrightarrows`,!0),z(B,U,K,`⇄`,`\\rightleftarrows`,!0),z(B,U,K,`↠`,`\\twoheadrightarrow`,!0),z(B,U,K,`↣`,`\\rightarrowtail`,!0),z(B,U,K,`↬`,`\\looparrowright`,!0),z(B,U,K,`↷`,`\\curvearrowright`,!0),z(B,U,K,`↻`,`\\circlearrowright`,!0),z(B,U,K,`↱`,`\\Rsh`,!0),z(B,U,K,`⇊`,`\\downdownarrows`,!0),z(B,U,K,`↾`,`\\upharpoonright`,!0),z(B,U,K,`⇂`,`\\downharpoonright`,!0),z(B,U,K,`⇝`,`\\rightsquigarrow`,!0),z(B,U,K,`⇝`,`\\leadsto`),z(B,U,K,`⇛`,`\\Rrightarrow`,!0),z(B,U,K,`↾`,`\\restriction`),z(B,H,q,`‘`,"`"),z(B,H,q,`$`,`\\$`),z(V,H,q,`$`,`\\$`),z(V,H,q,`$`,`\\textdollar`),z(B,H,q,`%`,`\\%`),z(V,H,q,`%`,`\\%`),z(B,H,q,`_`,`\\_`),z(V,H,q,`_`,`\\_`),z(V,H,q,`_`,`\\textunderscore`),z(B,H,q,`∠`,`\\angle`,!0),z(B,H,q,`∞`,`\\infty`,!0),z(B,H,q,`′`,`\\prime`),z(B,H,q,`△`,`\\triangle`),z(B,H,q,`Γ`,`\\Gamma`,!0),z(B,H,q,`Δ`,`\\Delta`,!0),z(B,H,q,`Θ`,`\\Theta`,!0),z(B,H,q,`Λ`,`\\Lambda`,!0),z(B,H,q,`Ξ`,`\\Xi`,!0),z(B,H,q,`Π`,`\\Pi`,!0),z(B,H,q,`Σ`,`\\Sigma`,!0),z(B,H,q,`Υ`,`\\Upsilon`,!0),z(B,H,q,`Φ`,`\\Phi`,!0),z(B,H,q,`Ψ`,`\\Psi`,!0),z(B,H,q,`Ω`,`\\Omega`,!0),z(B,H,q,`A`,`Α`),z(B,H,q,`B`,`Β`),z(B,H,q,`E`,`Ε`),z(B,H,q,`Z`,`Ζ`),z(B,H,q,`H`,`Η`),z(B,H,q,`I`,`Ι`),z(B,H,q,`K`,`Κ`),z(B,H,q,`M`,`Μ`),z(B,H,q,`N`,`Ν`),z(B,H,q,`O`,`Ο`),z(B,H,q,`P`,`Ρ`),z(B,H,q,`T`,`Τ`),z(B,H,q,`X`,`Χ`),z(B,H,q,`¬`,`\\neg`,!0),z(B,H,q,`¬`,`\\lnot`),z(B,H,q,`⊤`,`\\top`),z(B,H,q,`⊥`,`\\bot`),z(B,H,q,`∅`,`\\emptyset`),z(B,U,q,`∅`,`\\varnothing`),z(B,H,G,`α`,`\\alpha`,!0),z(B,H,G,`β`,`\\beta`,!0),z(B,H,G,`γ`,`\\gamma`,!0),z(B,H,G,`δ`,`\\delta`,!0),z(B,H,G,`ϵ`,`\\epsilon`,!0),z(B,H,G,`ζ`,`\\zeta`,!0),z(B,H,G,`η`,`\\eta`,!0),z(B,H,G,`θ`,`\\theta`,!0),z(B,H,G,`ι`,`\\iota`,!0),z(B,H,G,`κ`,`\\kappa`,!0),z(B,H,G,`λ`,`\\lambda`,!0),z(B,H,G,`μ`,`\\mu`,!0),z(B,H,G,`ν`,`\\nu`,!0),z(B,H,G,`ξ`,`\\xi`,!0),z(B,H,G,`ο`,`\\omicron`,!0),z(B,H,G,`π`,`\\pi`,!0),z(B,H,G,`ρ`,`\\rho`,!0),z(B,H,G,`σ`,`\\sigma`,!0),z(B,H,G,`τ`,`\\tau`,!0),z(B,H,G,`υ`,`\\upsilon`,!0),z(B,H,G,`ϕ`,`\\phi`,!0),z(B,H,G,`χ`,`\\chi`,!0),z(B,H,G,`ψ`,`\\psi`,!0),z(B,H,G,`ω`,`\\omega`,!0),z(B,H,G,`ε`,`\\varepsilon`,!0),z(B,H,G,`ϑ`,`\\vartheta`,!0),z(B,H,G,`ϖ`,`\\varpi`,!0),z(B,H,G,`ϱ`,`\\varrho`,!0),z(B,H,G,`ς`,`\\varsigma`,!0),z(B,H,G,`φ`,`\\varphi`,!0),z(B,H,W,`∗`,`*`,!0),z(B,H,W,`+`,`+`),z(B,H,W,`−`,`-`,!0),z(B,H,W,`⋅`,`\\cdot`,!0),z(B,H,W,`∘`,`\\circ`,!0),z(B,H,W,`÷`,`\\div`,!0),z(B,H,W,`±`,`\\pm`,!0),z(B,H,W,`×`,`\\times`,!0),z(B,H,W,`∩`,`\\cap`,!0),z(B,H,W,`∪`,`\\cup`,!0),z(B,H,W,`∖`,`\\setminus`,!0),z(B,H,W,`∧`,`\\land`),z(B,H,W,`∨`,`\\lor`),z(B,H,W,`∧`,`\\wedge`,!0),z(B,H,W,`∨`,`\\vee`,!0),z(B,H,q,`√`,`\\surd`),z(B,H,Fj,`⟨`,`\\langle`,!0),z(B,H,Fj,`∣`,`\\lvert`),z(B,H,Fj,`∥`,`\\lVert`),z(B,H,Mj,`?`,`?`),z(B,H,Mj,`!`,`!`),z(B,H,Mj,`⟩`,`\\rangle`,!0),z(B,H,Mj,`∣`,`\\rvert`),z(B,H,Mj,`∥`,`\\rVert`),z(B,H,K,`=`,`=`),z(B,H,K,`:`,`:`),z(B,H,K,`≈`,`\\approx`,!0),z(B,H,K,`≅`,`\\cong`,!0),z(B,H,K,`≥`,`\\ge`),z(B,H,K,`≥`,`\\geq`,!0),z(B,H,K,`←`,`\\gets`),z(B,H,K,`>`,`\\gt`,!0),z(B,H,K,`∈`,`\\in`,!0),z(B,H,K,``,`\\@not`),z(B,H,K,`⊂`,`\\subset`,!0),z(B,H,K,`⊃`,`\\supset`,!0),z(B,H,K,`⊆`,`\\subseteq`,!0),z(B,H,K,`⊇`,`\\supseteq`,!0),z(B,U,K,`⊈`,`\\nsubseteq`,!0),z(B,U,K,`⊉`,`\\nsupseteq`,!0),z(B,H,K,`⊨`,`\\models`),z(B,H,K,`←`,`\\leftarrow`,!0),z(B,H,K,`≤`,`\\le`),z(B,H,K,`≤`,`\\leq`,!0),z(B,H,K,`<`,`\\lt`,!0),z(B,H,K,`→`,`\\rightarrow`,!0),z(B,H,K,`→`,`\\to`),z(B,U,K,`≱`,`\\ngeq`,!0),z(B,U,K,`≰`,`\\nleq`,!0),z(B,H,Lj,`\xA0`,`\\ `),z(B,H,Lj,`\xA0`,`\\space`),z(B,H,Lj,`\xA0`,`\\nobreakspace`),z(V,H,Lj,`\xA0`,`\\ `),z(V,H,Lj,`\xA0`,` `),z(V,H,Lj,`\xA0`,`\\space`),z(V,H,Lj,`\xA0`,`\\nobreakspace`),z(B,H,Lj,``,`\\nobreak`),z(B,H,Lj,``,`\\allowbreak`),z(B,H,Ij,`,`,`,`),z(B,H,Ij,`;`,`;`),z(B,U,W,`⊼`,`\\barwedge`,!0),z(B,U,W,`⊻`,`\\veebar`,!0),z(B,H,W,`⊙`,`\\odot`,!0),z(B,H,W,`⊕`,`\\oplus`,!0),z(B,H,W,`⊗`,`\\otimes`,!0),z(B,H,q,`∂`,`\\partial`,!0),z(B,H,W,`⊘`,`\\oslash`,!0),z(B,U,W,`⊚`,`\\circledcirc`,!0),z(B,U,W,`⊡`,`\\boxdot`,!0),z(B,H,W,`△`,`\\bigtriangleup`),z(B,H,W,`▽`,`\\bigtriangledown`),z(B,H,W,`†`,`\\dagger`),z(B,H,W,`⋄`,`\\diamond`),z(B,H,W,`⋆`,`\\star`),z(B,H,W,`◃`,`\\triangleleft`),z(B,H,W,`▹`,`\\triangleright`),z(B,H,Fj,`{`,`\\{`),z(V,H,q,`{`,`\\{`),z(V,H,q,`{`,`\\textbraceleft`),z(B,H,Mj,`}`,`\\}`),z(V,H,q,`}`,`\\}`),z(V,H,q,`}`,`\\textbraceright`),z(B,H,Fj,`{`,`\\lbrace`),z(B,H,Mj,`}`,`\\rbrace`),z(B,H,Fj,`[`,`\\lbrack`,!0),z(V,H,q,`[`,`\\lbrack`,!0),z(B,H,Mj,`]`,`\\rbrack`,!0),z(V,H,q,`]`,`\\rbrack`,!0),z(B,H,Fj,`(`,`\\lparen`,!0),z(B,H,Mj,`)`,`\\rparen`,!0),z(V,H,q,`<`,`\\textless`,!0),z(V,H,q,`>`,`\\textgreater`,!0),z(B,H,Fj,`⌊`,`\\lfloor`,!0),z(B,H,Mj,`⌋`,`\\rfloor`,!0),z(B,H,Fj,`⌈`,`\\lceil`,!0),z(B,H,Mj,`⌉`,`\\rceil`,!0),z(B,H,q,`\\`,`\\backslash`),z(B,H,q,`∣`,`|`),z(B,H,q,`∣`,`\\vert`),z(V,H,q,`|`,`\\textbar`,!0),z(B,H,q,`∥`,`\\|`),z(B,H,q,`∥`,`\\Vert`),z(V,H,q,`∥`,`\\textbardbl`),z(V,H,q,`~`,`\\textasciitilde`),z(V,H,q,`\\`,`\\textbackslash`),z(V,H,q,`^`,`\\textasciicircum`),z(B,H,K,`↑`,`\\uparrow`,!0),z(B,H,K,`⇑`,`\\Uparrow`,!0),z(B,H,K,`↓`,`\\downarrow`,!0),z(B,H,K,`⇓`,`\\Downarrow`,!0),z(B,H,K,`↕`,`\\updownarrow`,!0),z(B,H,K,`⇕`,`\\Updownarrow`,!0),z(B,H,Pj,`∐`,`\\coprod`),z(B,H,Pj,`⋁`,`\\bigvee`),z(B,H,Pj,`⋀`,`\\bigwedge`),z(B,H,Pj,`⨄`,`\\biguplus`),z(B,H,Pj,`⋂`,`\\bigcap`),z(B,H,Pj,`⋃`,`\\bigcup`),z(B,H,Pj,`∫`,`\\int`),z(B,H,Pj,`∫`,`\\intop`),z(B,H,Pj,`∬`,`\\iint`),z(B,H,Pj,`∭`,`\\iiint`),z(B,H,Pj,`∏`,`\\prod`),z(B,H,Pj,`∑`,`\\sum`),z(B,H,Pj,`⨂`,`\\bigotimes`),z(B,H,Pj,`⨁`,`\\bigoplus`),z(B,H,Pj,`⨀`,`\\bigodot`),z(B,H,Pj,`∮`,`\\oint`),z(B,H,Pj,`∯`,`\\oiint`),z(B,H,Pj,`∰`,`\\oiiint`),z(B,H,Pj,`⨆`,`\\bigsqcup`),z(B,H,Pj,`∫`,`\\smallint`),z(V,H,Nj,`…`,`\\textellipsis`),z(B,H,Nj,`…`,`\\mathellipsis`),z(V,H,Nj,`…`,`\\ldots`,!0),z(B,H,Nj,`…`,`\\ldots`,!0),z(B,H,Nj,`⋯`,`\\@cdots`,!0),z(B,H,Nj,`⋱`,`\\ddots`,!0),z(B,H,q,`⋮`,`\\varvdots`),z(V,H,q,`⋮`,`\\varvdots`),z(B,H,jj,`ˊ`,`\\acute`),z(B,H,jj,`ˋ`,`\\grave`),z(B,H,jj,`¨`,`\\ddot`),z(B,H,jj,`~`,`\\tilde`),z(B,H,jj,`ˉ`,`\\bar`),z(B,H,jj,`˘`,`\\breve`),z(B,H,jj,`ˇ`,`\\check`),z(B,H,jj,`^`,`\\hat`),z(B,H,jj,`⃗`,`\\vec`),z(B,H,jj,`˙`,`\\dot`),z(B,H,jj,`˚`,`\\mathring`),z(B,H,G,``,`\\@imath`),z(B,H,G,``,`\\@jmath`),z(B,H,q,`ı`,`ı`),z(B,H,q,`ȷ`,`ȷ`),z(V,H,q,`ı`,`\\i`,!0),z(V,H,q,`ȷ`,`\\j`,!0),z(V,H,q,`ß`,`\\ss`,!0),z(V,H,q,`æ`,`\\ae`,!0),z(V,H,q,`œ`,`\\oe`,!0),z(V,H,q,`ø`,`\\o`,!0),z(V,H,q,`Æ`,`\\AE`,!0),z(V,H,q,`Œ`,`\\OE`,!0),z(V,H,q,`Ø`,`\\O`,!0),z(V,H,jj,`ˊ`,`\\'`),z(V,H,jj,`ˋ`,"\\`"),z(V,H,jj,`ˆ`,`\\^`),z(V,H,jj,`˜`,`\\~`),z(V,H,jj,`ˉ`,`\\=`),z(V,H,jj,`˘`,`\\u`),z(V,H,jj,`˙`,`\\.`),z(V,H,jj,`¸`,`\\c`),z(V,H,jj,`˚`,`\\r`),z(V,H,jj,`ˇ`,`\\v`),z(V,H,jj,`¨`,`\\"`),z(V,H,jj,`˝`,`\\H`),z(V,H,jj,`◯`,`\\textcircled`);var Rj={"--":!0,"---":!0,"``":!0,"''":!0};z(V,H,q,`–`,`--`,!0),z(V,H,q,`–`,`\\textendash`),z(V,H,q,`—`,`---`,!0),z(V,H,q,`—`,`\\textemdash`),z(V,H,q,`‘`,"`",!0),z(V,H,q,`‘`,`\\textquoteleft`),z(V,H,q,`’`,`'`,!0),z(V,H,q,`’`,`\\textquoteright`),z(V,H,q,`“`,"``",!0),z(V,H,q,`“`,`\\textquotedblleft`),z(V,H,q,`”`,`''`,!0),z(V,H,q,`”`,`\\textquotedblright`),z(B,H,q,`°`,`\\degree`,!0),z(V,H,q,`°`,`\\degree`),z(V,H,q,`°`,`\\textdegree`,!0),z(B,H,q,`£`,`\\pounds`),z(B,H,q,`£`,`\\mathsterling`,!0),z(V,H,q,`£`,`\\pounds`),z(V,H,q,`£`,`\\textsterling`,!0),z(B,U,q,`✠`,`\\maltese`),z(V,U,q,`✠`,`\\maltese`);for(var zj=`0123456789/@."`,Bj=0;Bj{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return pM[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return mM[Math.floor((r-120782)/10)];if(r===120485||r===120486)return pM[0];if(120486{if(oj(e.classes)!==oj(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||e.italic!==0&&e.hasClass(`mathnormal`))return!1;if(e.classes.length===1){var n=e.classes[0];if(n===`mbin`||n===`mord`)return!1}for(var r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(var i of Object.keys(t.style))if(e.style[i]!==t.style[i])return!1;return!0},SM=e=>{for(var t=0;tt&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>r&&(r=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=r},Y=function(e,t,n,r){var i=new fj(e,t,n,r);return CM(i),i},wM=(e,t,n,r)=>new fj(e,t,n,r),TM=function(e,t,n){var r=Y([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=R(r.height),r.maxFontSize=1,r},EM=function(e,t,n,r){var i=new pj(e,t,n,r);return CM(i),i},DM=function(e){var t=new tj(e);return CM(t),t},OM=function(e,t){return e instanceof tj?Y([],[e],t):e},kM=function(e){if(e.positionType===`individualShift`){for(var t=e.children,n=[t[0]],r=-t[0].shift-t[0].elem.depth,i=r,a=1;a{var n=Y([`mspace`],[],t),r=aj(e,t);return n.style.marginRight=R(r),n},MM=(e,t,n)=>{var r,i;switch(e){case`amsrm`:r=`AMS`;break;case`textrm`:r=`Main`;break;case`textsf`:r=`SansSerif`;break;case`texttt`:r=`Typewriter`;break;default:r=e}return i=t===`textbf`&&n===`textit`?`BoldItalic`:t===`textbf`?`Bold`:n===`textit`?`Italic`:`Regular`,r+`-`+i},NM={mathbf:{variant:`bold`,fontName:`Main-Bold`},mathrm:{variant:`normal`,fontName:`Main-Regular`},textit:{variant:`italic`,fontName:`Main-Italic`},mathit:{variant:`italic`,fontName:`Main-Italic`},mathnormal:{variant:`italic`,fontName:`Math-Italic`},mathsfit:{variant:`sans-serif-italic`,fontName:`SansSerif-Italic`},mathbb:{variant:`double-struck`,fontName:`AMS-Regular`},mathcal:{variant:`script`,fontName:`Caligraphic-Regular`},mathfrak:{variant:`fraktur`,fontName:`Fraktur-Regular`},mathscr:{variant:`script`,fontName:`Script-Regular`},mathsf:{variant:`sans-serif`,fontName:`SansSerif-Regular`},mathtt:{variant:`monospace`,fontName:`Typewriter-Regular`}},PM={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},FM=function(e,t){var n=PM[e],r=n[0],i=n[1],a=n[2],o=wM([`katex-overlay`],[new _j([new vj(r)],{width:R(i),height:R(a),style:`width:`+R(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=R(a),o.style.width=R(i),o},IM={number:3,unit:`mu`},LM={number:4,unit:`mu`},RM={number:5,unit:`mu`},zM={mord:{mop:IM,mbin:LM,mrel:RM,minner:IM},mop:{mord:IM,mop:IM,mrel:RM,minner:IM},mbin:{mord:LM,mop:LM,mopen:LM,minner:LM},mrel:{mord:RM,mop:RM,mopen:RM,minner:RM},mopen:{},mclose:{mop:IM,mbin:LM,mrel:RM,minner:IM},mpunct:{mord:IM,mop:IM,mrel:RM,mopen:IM,mclose:IM,mpunct:IM,minner:IM},minner:{mord:IM,mop:IM,mbin:LM,mrel:RM,mopen:IM,mpunct:IM,minner:IM}},BM={mord:{mop:IM},mop:{mord:IM,mop:IM},mbin:{},mrel:{},mopen:{},mclose:{mop:IM},mpunct:{},minner:{mop:IM}},VM={},HM={},UM={};function X(e){for(var t=e.type,n=e.names,r=e.htmlBuilder,i=e.mathmlBuilder,a=0;a{var n=t.classes[0],r=e.classes[0];n===`mbin`&&JM.has(r)?t.classes[0]=`mord`:r===`mbin`&&qM.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),QM(i,(e,t)=>{var n=tN(t),r=tN(e),i=n&&r?e.hasClass(`mtight`)?BM[n]?.[r]:zM[n]?.[r]:null;if(i)return jM(i,c)},{node:u},d,f),i},QM=function(e,t,n,r,i){r&&e.push(r);for(var a=0;an=>{e.splice(t+1,0,n),a++})(a)}}r&&e.pop()},$M=function(e){return e instanceof tj||e instanceof pj||e instanceof fj&&e.hasClass(`enclosing`)?e:null},eN=function(e,t){var n=$M(e);if(n){var r=n.children;if(r.length){if(t===`right`)return eN(r[r.length-1],`right`);if(t===`left`)return eN(r[0],`left`)}}return e},tN=function(e,t){return e?(t&&(e=eN(e,t)),XM[e.classes[0]]||null):null},nN=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return Y(t.concat(n))},rN=function(e,t,n){if(!e)return Y();if(HM[e.type]){var r=HM[e.type](e,t);if(n&&t.size!==n.size){r=Y(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new I(`Got group of unknown type: '`+e.type+`'`)};function iN(e,t){var n=Y([`katex-base`],e,t),r=Y([`katex-strut`]);return r.style.height=R(n.height+n.depth),n.depth&&(r.style.verticalAlign=R(-n.depth)),n.children.unshift(r),n}function aN(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=ZM(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(iN(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(iN(o,t));var l;n?(l=iN(ZM(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=Y([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=R(u.height+u.depth),u.depth&&(d.style.verticalAlign=R(-u.depth))}return u}function oN(e){return new tj(e)}var Z=class{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e.setAttribute(n,r)}this.classes.length>0&&(e.className=oj(this.classes));for(var i=0;i0&&(e+=` class ="`+dA(oj(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},sN=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return dA(this.toText())}toText(){return this.text}},cN=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:e>=-.05556&&e<=-.05555?` ⁣`:e>=-.1667&&e<=-.1666?` ⁣`:e>=-.2223&&e<=-.2222?` ⁣`:e>=-.2778&&e<=-.2777?` ⁣`:null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mspace`);return e.setAttribute(`width`,R(this.width)),e}toMarkup(){return this.character?``+this.character+``:``}toText(){return this.character?this.character:` `}},lN=new Set([`\\imath`,`\\jmath`]),uN=new Set([`mrow`,`mtable`]),dN=function(e,t,n){var r,i;return Aj[t][e]&&Aj[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(Rj,e)||(n==null||(r=n.fontFamily)==null?void 0:r.slice(4,6))!==`tt`&&(n==null||(i=n.font)==null?void 0:i.slice(4,6))!==`tt`)&&(e=Aj[t][e].replace),new sN(e)},fN=function(e){return e.length===1?e[0]:new Z(`mrow`,e)},pN={mathit:`italic`,boldsymbol:e=>e.type===`textord`?`bold`:`bold-italic`,mathbf:`bold`,mathbb:`double-struck`,mathsfit:`sans-serif-italic`,mathfrak:`fraktur`,mathscr:`script`,mathcal:`script`,mathsf:`sans-serif`,mathtt:`monospace`},mN=(e,t)=>{if(e.mode===`text`){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`bold-sans-serif`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`}var n=t.font;if(!n||n===`mathnormal`)return null;var r=e.mode,i=pN[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(lN.has(a))return null;if(Aj[r][a]){var o=Aj[r][a].replace;o&&(a=o)}var s=NM[n].fontName;return Dj(a,s,r)?NM[n].variant:null};function hN(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof sN&&t.text===`.`}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){var n=e.children[0];return n instanceof sN&&n.text===`,`}return!1}var gN=function(e,t,n){if(e.length===1){var r=vN(e[0],t);return n&&r instanceof Z&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o=1&&(a.type===`mn`||hN(a))){var c=s.children[0];c instanceof Z&&c.type===`mn`&&(c.children=[...a.children,...c.children],i.pop())}else if(a.type===`mi`&&a.children.length===1){var l=a.children[0];if(l instanceof sN&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof sN&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},_N=function(e,t,n){return fN(gN(e,t,n))},vN=function(e,t){if(!e)return new Z(`mrow`);if(UM[e.type])return UM[e.type](e,t);throw new I(`Got group of unknown type: '`+e.type+`'`)};function yN(e,t,n,r,i){var a=gN(e,n),o=a.length===1&&a[0]instanceof Z&&uN.has(a[0].type)?a[0]:new Z(`mrow`,a),s=new Z(`annotation`,[new sN(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new Z(`math`,[new Z(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),Y([i?`katex`:`katex-mathml`],[c])}var bN=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],xN=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],SN=function(e,t){return t.size<2?e:bN[e-1][t.size-1]},CN=class e{constructor(t){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=t.style,this.color=t.color,this.size=t.size||e.BASESIZE,this.textSize=t.textSize||this.size,this.phantom=!!t.phantom,this.font=t.font||``,this.fontFamily=t.fontFamily||``,this.fontWeight=t.fontWeight||``,this.fontShape=t.fontShape||``,this.sizeMultiplier=xN[this.size-1],this.maxSize=t.maxSize,this.minRuleThickness=t.minRuleThickness,this._fontMetrics=void 0}extend(t){var n={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(n,t),new e(n)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:SN(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:xN[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=SN(e.BASESIZE,t);return this.size===n&&this.textSize===e.BASESIZE&&this.style===t?this:this.extend({style:t,size:n})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}sizingClasses(e){return e.size===this.size?[]:[`katex-sizing`,`reset-size`+e.size,`size`+this.size]}baseSizingClasses(){return this.size===e.BASESIZE?[]:[`katex-sizing`,`reset-size`+this.size,`size`+e.BASESIZE]}fontMetrics(){return this._fontMetrics||=kj(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};CN.BASESIZE=6;var wN=function(e){return new CN({style:e.displayMode?L.DISPLAY:L.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},TN=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=Y(n,[e])}return e},EN=function(e,t,n){var r=wN(n),i;return n.output===`mathml`?yN(e,t,r,n.displayMode,!0):(i=n.output===`html`?Y([`katex`],[aN(e,r)]):Y([`katex`],[yN(e,t,r,n.displayMode,!1),aN(e,r)]),TN(i,n))},DN=function(e,t,n){return TN(Y([`katex`],[aN(e,wN(n))]),n)},ON={widehat:`^`,widecheck:`ˇ`,widetilde:`~`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,underbracket:`⎵`,overbracket:`⎴`,overgroup:`⏠`,undergroup:`⏡`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xrightleftharpoons:`⇌`,xleftrightharpoons:`⇋`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xtofrom:`⇄`,xrightleftarrows:`⇄`,xrightequilibrium:`⇌`,xleftequilibrium:`⇋`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`},kN=function(e){var t=new Z(`mo`,[new sN(ON[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},AN={overrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],overleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],underrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],underleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],xrightarrow:[[`rightarrow`],1.469,522,`xMaxYMin`],"\\cdrightarrow":[[`rightarrow`],3,522,`xMaxYMin`],xleftarrow:[[`leftarrow`],1.469,522,`xMinYMin`],"\\cdleftarrow":[[`leftarrow`],3,522,`xMinYMin`],Overrightarrow:[[`doublerightarrow`],.888,560,`xMaxYMin`],xRightarrow:[[`doublerightarrow`],1.526,560,`xMaxYMin`],xLeftarrow:[[`doubleleftarrow`],1.526,560,`xMinYMin`],overleftharpoon:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoonup:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoondown:[[`leftharpoondown`],.888,522,`xMinYMin`],overrightharpoon:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoonup:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoondown:[[`rightharpoondown`],.888,522,`xMaxYMin`],xlongequal:[[`longequal`],.888,334,`xMinYMin`],"\\cdlongequal":[[`longequal`],3,334,`xMinYMin`],xtwoheadleftarrow:[[`twoheadleftarrow`],.888,334,`xMinYMin`],xtwoheadrightarrow:[[`twoheadrightarrow`],.888,334,`xMaxYMin`],overleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],overbrace:[[`leftbrace`,`midbrace`,`rightbrace`],1.6,548],underbrace:[[`leftbraceunder`,`midbraceunder`,`rightbraceunder`],1.6,548],underleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],xleftrightarrow:[[`leftarrow`,`rightarrow`],1.75,522],xLeftrightarrow:[[`doubleleftarrow`,`doublerightarrow`],1.75,560],xrightleftharpoons:[[`leftharpoondownplus`,`rightharpoonplus`],1.75,716],xleftrightharpoons:[[`leftharpoonplus`,`rightharpoondownplus`],1.75,716],xhookleftarrow:[[`leftarrow`,`righthook`],1.08,522],xhookrightarrow:[[`lefthook`,`rightarrow`],1.08,522],overlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],underlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],overbracket:[[`leftbracketover`,`rightbracketover`],1.6,440],underbracket:[[`leftbracketunder`,`rightbracketunder`],1.6,410],overgroup:[[`leftgroup`,`rightgroup`],.888,342],undergroup:[[`leftgroupunder`,`rightgroupunder`],.888,342],xmapsto:[[`leftmapsto`,`rightarrow`],1.5,522],xtofrom:[[`leftToFrom`,`rightToFrom`],1.75,528],xrightleftarrows:[[`baraboveleftarrow`,`rightarrowabovebar`],1.75,901],xrightequilibrium:[[`baraboveshortleftharpoon`,`rightharpoonaboveshortbar`],1.75,716],xleftequilibrium:[[`shortbaraboveleftharpoon`,`shortrightharpoonabovebar`],1.75,716]},jN=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),MN=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(jN.has(r)&&`base`in e){var i=e.base.type===`ordgroup`?e.base.body.length:1,a,o,s;if(i>5)r===`widehat`||r===`widecheck`?(a=420,n=2364,s=.42,o=r+`4`):(a=312,n=2340,s=.34,o=`tilde4`);else{var c=[1,1,2,2,3,3][i];r===`widehat`||r===`widecheck`?(n=[0,1062,2364,2364,2364][c],a=[0,239,300,360,420][c],s=[0,.24,.3,.3,.36,.42][c],o=r+c):(n=[0,600,1033,2339,2340][c],a=[0,260,286,306,312][c],s=[0,.26,.286,.3,.306,.34][c],o=`tilde`+c)}return{span:wM([],[new _j([new vj(o)],{width:`100%`,height:R(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=AN[r];if(!u)throw Error(`No SVG data for "`+r+`".`);var d=u[0],f=u[1],p=u[2],m=p/1e3,h=d.length,g,_;if(h===1){if(u.length!==4)throw Error(`Expected 4-tuple for single-path SVG data "`+r+`".`);g=[`hide-tail`],_=[u[3]]}else if(h===2)g=[`halfarrow-left`,`halfarrow-right`],_=[`xMinYMin`,`xMaxYMin`];else if(h===3)g=[`brace-left`,`brace-center`,`brace-right`],_=[`xMinYMin`,`xMidYMin`,`xMaxYMin`];else throw Error(`Correct katexImagesData or update code here to support - `+h+` children.`);for(var v=0;v0&&(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`,`\\xleftrightarrow`,`\\xLeftrightarrow`,`\\xhookleftarrow`,`\\xhookrightarrow`,`\\xmapsto`,`\\xrightharpoondown`,`\\xrightharpoonup`,`\\xleftharpoondown`,`\\xleftharpoonup`,`\\xrightleftharpoons`,`\\xleftrightharpoons`,`\\xlongequal`,`\\xtwoheadrightarrow`,`\\xtwoheadleftarrow`,`\\xtofrom`,`\\xrightleftarrows`,`\\xrightequilibrium`,`\\xleftequilibrium`,`\\\\cdrightarrow`,`\\\\cdleftarrow`,`\\\\cdlongequal`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=e.funcName;return{type:`xArrow`,mode:r.mode,label:i,body:t[0],below:n[0]}},htmlBuilder(e,t){var n=t.style,r=t.havingStyle(n.sup()),i=OM(rN(e.body,r,t),t),a=e.label.slice(0,2)===`\\x`?`x`:`cd`;i.classes.push(a+`-arrow-pad`);var o;e.below&&(r=t.havingStyle(n.sub()),o=OM(rN(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=MN(e,t),c=-t.fontMetrics().axisHeight+.5*s.height,l=-t.fontMetrics().axisHeight-.5*s.height-.111;(i.depth>.25||e.label===`\\xleftequilibrium`)&&(l-=i.depth);var u;if(o){var d=-t.fontMetrics().axisHeight+o.height+.5*s.height+.111;u=AM({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]},{type:`elem`,elem:o,shift:d}]})}else u=AM({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return Y([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=kN(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=KN(vN(e.body,t));r=e.below?new Z(`munderover`,[n,KN(vN(e.below,t)),i]):new Z(`mover`,[n,i])}else e.below?r=new Z(`munder`,[n,KN(vN(e.below,t))]):(r=KN(),r=new Z(`mover`,[n,r]));return r}});function qN(e,t){var n=ZM(e.body,t,!0);return Y([e.mclass],n,t)}function JN(e,t){var n,r=gN(e.body,t);return e.mclass===`minner`?n=new Z(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new Z(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new Z(`mo`,r),e.mclass===`mbin`?(n.attributes.lspace=`0.22em`,n.attributes.rspace=`0.22em`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0.17em`):(e.mclass===`mopen`||e.mclass===`mclose`)&&(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`)),n}X({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],numArgs:1,primitive:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`mclass`,mode:n.mode,mclass:`m`+r.slice(5),body:KM(i),isCharacterBox:mA(i)}},htmlBuilder:qN,mathmlBuilder:JN});var YN=e=>{var t=e.type===`ordgroup`&&e.body.length?e.body[0]:e;return t.type===`atom`&&(t.family===`bin`||t.family===`rel`)?`m`+t.family:`mord`};X({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:YN(t[0]),body:KM(t[1]),isCharacterBox:mA(t[1])}}}),X({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],numArgs:2,handler(e,t){var n=e.parser,r=e.funcName,i=t[1],a=t[0],o=r===`\\stackrel`?`mrel`:YN(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:KM(i)},c=r===`\\underset`?{type:`supsub`,mode:a.mode,base:s,sub:a}:{type:`supsub`,mode:a.mode,base:s,sup:a};return{type:`mclass`,mode:n.mode,mclass:o,body:[c],isCharacterBox:mA(c)}}}),X({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:YN(t[0]),body:KM(t[0])}},htmlBuilder(e,t){var n=ZM(e.body,t,!0),r=Y([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new Z(`mstyle`,gN(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var XN={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},ZN=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),QN=e=>e.type===`textord`&&e.text===`@`,$N=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function eP(e,t,n){var r=XN[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:var i=n.callFunction(`\\\\cdleft`,[t[0]],[]),a={type:`atom`,text:r,mode:`math`,family:`rel`},o={type:`ordgroup`,mode:`math`,body:[i,n.callFunction(`\\Big`,[a],[]),n.callFunction(`\\\\cdright`,[t[1]],[])]};return n.callFunction(`\\\\cdparent`,[o],[]);case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function tP(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();var n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new I(`Expected \\\\ or \\cr or \\end`,e.nextToken)}for(var r=[],i=[r],a=0;aAV`.includes(l))for(var d=0;d<2;d++){for(var f=!0,p=c+1;pAV=|." after @`,o[c])}var m={type:`styling`,body:[eP(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=ZN()}a%2==0?r.push(s):r.shift(),r=[],i.push(r)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:Array(i[0].length).fill({type:`align`,align:`c`,pregap:.25,postgap:.25}),colSeparationType:`CD`,hLinesBeforeRow:Array(i.length+1).fill([])}}X({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`cdlabel`,mode:n.mode,side:r.slice(4),label:t[0]}},htmlBuilder(e,t){var n=t.havingStyle(t.style.sup()),r=OM(rN(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=R(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new Z(`mrow`,[vN(e.label,t)]);return n=new Z(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new Z(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),X({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=OM(rN(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Z(`mrow`,[vN(e.fragment,t)])}}),X({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=VN(Q(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new I(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new I(`\\@char with invalid code point `+r);return i<=65535?a=String.fromCharCode(i):(i-=65536,a=String.fromCharCode((i>>10)+55296,(i&1023)+56320)),{type:`textord`,mode:n.mode,text:a}}}),X({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=Q(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:KM(i)}},htmlBuilder:(e,t)=>DM(ZM(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Z(`mstyle`,gN(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),X({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=Q(t[0],`color-token`).color;n.gullet.macros.set(`\\current@color`,i);var a=n.parseExpression(!0,r);return{type:`color`,mode:n.mode,color:i,body:a}}}),X({type:`cr`,names:[`\\\\`],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,n){var r=e.parser,i=r.gullet.future().text===`[`?r.parseSizeGroup(!0):null,a=!r.settings.displayMode||!r.settings.useStrictBehavior(`newLineInDisplayMode`,`In LaTeX, \\\\ or \\newline does nothing in display mode`);return{type:`cr`,mode:r.mode,newLine:a,size:i&&Q(i,`size`).value}},htmlBuilder(e,t){var n=Y([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=R(aj(e.size,t)))),n},mathmlBuilder(e,t){var n=new Z(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,R(aj(e.size,t)))),n}});var nP={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},rP=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new I(`Expected a control sequence`,e);return t},iP=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},aP=(e,t,n,r)=>{var i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};X({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=e.funcName;t.consumeSpaces();var r=t.fetch();if(nP[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=nP[r.text]),Q(t.parseFunction(),`internal`);throw new I(`Invalid token after macro prefix`,r)}}),X({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=t.gullet.popToken(),i=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new I(`Expected a control sequence`,r);for(var a=0,o,s=[[]];t.gullet.future().text!==`{`;)if(r=t.gullet.popToken(),r.text===`#`){if(t.gullet.future().text===`{`){o=t.gullet.future(),s[a].push(`{`);break}if(r=t.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new I(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new I(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new I(`Expected a macro definition`);else s[a].push(r.text);var c=t.gullet.consumeArg().tokens;return o&&c.unshift(o),(n===`\\edef`||n===`\\xdef`)&&(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(i,{tokens:c,numArgs:a,delimiters:s},n===nP[n]),{type:`internal`,mode:t.mode}}}),X({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=rP(t.gullet.popToken());return t.gullet.consumeSpaces(),aP(t,r,iP(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),X({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=rP(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return aP(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var oP=function(e,t,n){var r=Dj(Aj.math[e]&&Aj.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},sP=function(e,t,n,r){var i=n.havingBaseStyle(t),a=Y(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},cP=function(e,t,n){var r=t.havingBaseStyle(n),i=(1-t.sizeMultiplier/r.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push(`delimcenter`),e.style.top=R(i),e.height-=i,e.depth+=i},lP=function(e,t,n,r,i,a){var o=sP(_M(e,`Main-Regular`,i,r),t,r,a);return n&&cP(o,r,t),o},uP=function(e,t,n,r){return _M(e,`Size`+t+`-Regular`,n,r)},dP=function(e,t,n,r,i,a){var o=uP(e,t,i,r),s=sP(Y([`delimsizing`,`size`+t],[o],r),L.TEXT,r,a);return n&&cP(s,r,L.TEXT),s},fP=function(e,t,n){return{type:`elem`,elem:Y([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[Y([],[_M(e,t,n)])])}},pP=function(e,t,n){var r=Cj[`Size4-Regular`][e.charCodeAt(0)]?Cj[`Size4-Regular`][e.charCodeAt(0)][4]:Cj[`Size1-Regular`][e.charCodeAt(0)][4],i=wM([],[new _j([new vj(`inner`,ZA(e,Math.round(1e3*t)))],{width:R(r),height:R(t),style:`width:`+R(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=R(t),i.style.width=R(r),{type:`elem`,elem:i}},mP=.008,hP={type:`kern`,size:-1*mP},gP=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),_P=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),vP=function(e,t,n,r,i,a){var o,s,c,l,u=``,d=0;o=c=l=e,s=null;var f=`Size1-Regular`;e===`\\uparrow`?c=l=`⏐`:e===`\\Uparrow`?c=l=`‖`:e===`\\downarrow`?o=c=`⏐`:e===`\\Downarrow`?o=c=`‖`:e===`\\updownarrow`?(o=`\\uparrow`,c=`⏐`,l=`\\downarrow`):e===`\\Updownarrow`?(o=`\\Uparrow`,c=`‖`,l=`\\Downarrow`):gP.has(e)?(c=`∣`,u=`vert`,d=333):_P.has(e)?(c=`∥`,u=`doublevert`,d=556):e===`[`||e===`\\lbrack`?(o=`⎡`,c=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lbrack`,d=667):e===`]`||e===`\\rbrack`?(o=`⎤`,c=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rbrack`,d=667):e===`\\lfloor`||e===`⌊`?(c=o=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lfloor`,d=667):e===`\\lceil`||e===`⌈`?(o=`⎡`,c=l=`⎢`,f=`Size4-Regular`,u=`lceil`,d=667):e===`\\rfloor`||e===`⌋`?(c=o=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rfloor`,d=667):e===`\\rceil`||e===`⌉`?(o=`⎤`,c=l=`⎥`,f=`Size4-Regular`,u=`rceil`,d=667):e===`(`||e===`\\lparen`?(o=`⎛`,c=`⎜`,l=`⎝`,f=`Size4-Regular`,u=`lparen`,d=875):e===`)`||e===`\\rparen`?(o=`⎞`,c=`⎟`,l=`⎠`,f=`Size4-Regular`,u=`rparen`,d=875):e===`\\{`||e===`\\lbrace`?(o=`⎧`,s=`⎨`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\}`||e===`\\rbrace`?(o=`⎫`,s=`⎬`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lgroup`||e===`⟮`?(o=`⎧`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\rgroup`||e===`⟯`?(o=`⎫`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lmoustache`||e===`⎰`?(o=`⎧`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):(e===`\\rmoustache`||e===`⎱`)&&(o=`⎫`,l=`⎩`,c=`⎪`,f=`Size4-Regular`);var p=oP(o,f,i),m=p.height+p.depth,h=oP(c,f,i),g=h.height+h.depth,_=oP(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=oP(s,f,i);y=x.height+x.depth,b=2}var S=m+v+y,ee=S+Math.max(0,Math.ceil((t-S)/(b*g)))*b*g,te=r.fontMetrics().axisHeight;n&&(te*=r.sizeMultiplier);var ne=ee/2-te,re=[];if(u.length>0){var ie=ee-m-v,ae=Math.round(ee*1e3),oe=$A(u,Math.round(ie*1e3)),se=new vj(u,oe),ce=R(d/1e3),le=R(ae/1e3),ue=wM([],[new _j([se],{width:ce,height:le,viewBox:`0 0 `+d+` `+ae})],r);ue.height=ae/1e3,ue.style.width=ce,ue.style.height=le,re.push({type:`elem`,elem:ue})}else{if(re.push(fP(l,f,i)),re.push(hP),s===null){var de=ee-m-v+2*mP;re.push(pP(c,de,r))}else{var fe=(ee-m-v-y)/2+2*mP;re.push(pP(c,fe,r)),re.push(hP),re.push(fP(s,f,i)),re.push(hP),re.push(pP(c,fe,r))}re.push(hP),re.push(fP(o,f,i))}var pe=r.havingBaseStyle(L.TEXT);return sP(Y([`delimsizing`,`mult`],[AM({positionType:`bottom`,positionData:ne,children:re})],pe),L.TEXT,r,a)},yP=80,bP=.08,xP=function(e,t,n,r,i){return wM([`hide-tail`],[new _j([new vj(e,XA(e,r,n))],{width:`400em`,height:R(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},SP=function(e,t){var n=t.havingBaseSizing(),r=MP(`\\surd`,e*n.sizeMultiplier,AP,n),i=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,s,c,l,u;return r.type===`small`?(l=1e3+1e3*a+yP,e<1?i=1:e<1.4&&(i=.7),s=(1+a+bP)/i,c=(1+a)/i,o=xP(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+yP)*EP[r.size],c=(EP[r.size]+a)/i,s=(EP[r.size]+a+bP)/i,o=xP(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+bP,c=e+a,l=Math.floor(1e3*e+a)+yP,o=xP(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=R(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},CP=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),wP=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),TP=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),EP=[0,1.2,1.8,2.4,3],DP=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),CP.has(e)||TP.has(e))return dP(e,t,!1,n,r,i);if(wP.has(e))return vP(e,EP[t],!1,n,r,i);throw new I(`Illegal delimiter: '`+e+`'`)},OP=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],kP=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`stack`}],AP=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],jP=function(e){if(e.type===`small`)return`Main-Regular`;if(e.type===`large`)return`Size`+e.size+`-Regular`;if(e.type===`stack`)return`Size4-Regular`;var t=e.type;throw Error(`Add support for delim type '`+t+`' here.`)},MP=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},NP=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=TP.has(e)?OP:CP.has(e)?AP:kP,s=MP(e,t,o,r);return s.type===`small`?lP(e,s.style,n,r,i,a):s.type===`large`?dP(e,s.size,n,r,i,a):vP(e,t,n,r,i,a)},PP=function(e,t,n,r,i,a){var o=r.fontMetrics().axisHeight*r.sizeMultiplier,s=901,c=5/r.fontMetrics().ptPerEm,l=Math.max(t-o,n+o);return NP(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},FP={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},IP=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,/,\\backslash,|,\\vert,\\|,\\Vert,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`));function LP(e){return`isMiddle`in e}function RP(e,t){var n=BN(e);if(n&&IP.has(n.text))return n;throw n?new I(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new I(`Invalid delimiter type '`+e.type+`'`,e)}X({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],numArgs:1,argTypes:[`primitive`],handler:(e,t)=>{var n=RP(GM(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:FP[e.funcName].size,mclass:FP[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?Y([e.mclass]):DP(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(dN(e.delim,e.mode));var n=new Z(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=R(EP[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function zP(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}X({type:`leftright-right`,names:[`\\right`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser.gullet.macros.get(`\\current@color`);if(n&&typeof n!=`string`)throw new I(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:RP(t[0],e).text,color:n}}}),X({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=RP(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=Q(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{zP(e);for(var n=ZM(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{zP(e);var n=gN(e.body,t);if(e.left!==`.`){var r=new Z(`mo`,[dN(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Z(`mo`,[dN(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return fN(n)}}),X({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=RP(t[0],e);if(!e.parser.leftrightDepth)throw new I(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=nN(t,[]):(n=DP(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new Z(`mo`,[e.delim===`\\vert`||e.delim===`|`?dN(`|`,`text`):dN(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),X({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Q(t[0],`color-token`).color,o=t[1];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:a,body:o}},htmlBuilder:(e,t)=>{var n=OM(rN(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=mA(e.body);if(r===`sout`)a=Y([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=aj({number:.6,unit:`pt`},t),l=aj({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=R(d/2+c);var f=Math.floor(1e3*d*i);a=wM([`hide-tail`],[new _j([new vj(`phase`,JA(f))],{width:`400em`,height:R(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=R(d),o=n.depth+c+l}else{/cancel/.test(r)?s||n.classes.push(`cancel-pad`):r===`angl`?n.classes.push(`anglpad`):n.classes.push(`boxpad`);var p,m,h=0;/box/.test(r)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),p=t.fontMetrics().fboxsep+(r===`colorbox`?0:h),m=p):r===`angl`?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),p=4*h,m=Math.max(0,.25-n.depth)):(p=s?.2:0,m=p),a=NN(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=R(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=R(h),a.style.borderRightWidth=R(h)),o=n.depth+m,e.backgroundColor&&(a.style.backgroundColor=e.backgroundColor,e.borderColor&&(a.style.borderColor=e.borderColor))}var g;if(e.backgroundColor)g=AM({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=AM({positionType:`individualShift`,children:[{type:`elem`,elem:n,shift:0},{type:`elem`,elem:a,shift:o,wrapperClasses:_}]})}return/cancel/.test(r)&&(g.height=n.height,g.depth=n.depth),/cancel/.test(r)&&!s?Y([`mord`,`cancel-lap`],[g],t):Y([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new Z(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[vN(e.body,t)]);switch(e.label){case`\\cancel`:r.setAttribute(`notation`,`updiagonalstrike`);break;case`\\bcancel`:r.setAttribute(`notation`,`downdiagonalstrike`);break;case`\\phase`:r.setAttribute(`notation`,`phasorangle`);break;case`\\sout`:r.setAttribute(`notation`,`horizontalstrike`);break;case`\\fbox`:r.setAttribute(`notation`,`box`);break;case`\\angl`:r.setAttribute(`notation`,`actuarial`);break;case`\\fcolorbox`:case`\\colorbox`:if(n=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,r.setAttribute(`width`,`+`+2*n+`pt`),r.setAttribute(`height`,`+`+2*n+`pt`),r.setAttribute(`lspace`,n+`pt`),r.setAttribute(`voffset`,n+`pt`),e.label===`\\fcolorbox`){var i=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);r.setAttribute(`style`,`border: `+R(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),X({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Q(t[0],`color-token`).color,o=Q(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),X({type:`enclose`,names:[`\\fbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\fbox`,body:t[0]}}}),X({type:`enclose`,names:[`\\cancel`,`\\bcancel`,`\\xcancel`,`\\phase`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),X({type:`enclose`,names:[`\\sout`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName;n.mode===`math`&&n.settings.reportNonstrict(`mathVsSout`,`LaTeX's \\sout works only in text mode`);var i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),X({type:`enclose`,names:[`\\angl`],numArgs:1,argTypes:[`hbox`],allowedInText:!1,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\angl`,body:t[0]}}});var BP={};function VP(e){for(var t=e.type,n=e.names,r=e.props,i=e.handler,a=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},c=0;c{if(!e.parser.settings.displayMode)throw new I(`{`+e.envName+`} can be used only in display mode.`)},qP=new Set([`gather`,`gather*`]);function JP(e){if(!e.includes(`ed`))return!e.includes(`*`)}function YP(e,t,n){var r=t.hskipBeforeAndAfter,i=t.addJot,a=t.cols,o=t.arraystretch,s=t.colSeparationType,c=t.autoTag,l=t.singleRow,u=t.emptySingleRow,d=t.maxNumCols,f=t.leqno;if(e.gullet.beginGroup(),l||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),!o){var p=e.gullet.expandMacroAsText(`\\arraystretch`);if(p==null)o=1;else if(o=parseFloat(p),!o||o<0)throw new I(`Invalid \\arraystretch: `+p)}e.gullet.beginGroup();var m=[],h=[m],g=[],_=[],v=c==null?void 0:[];function y(){c&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function b(){v&&(e.gullet.macros.get(`\\df@tag`)?(v.push(e.subparse([new WP(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(GP(e));;){var x=e.parseExpression(!1,l?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup();var S={type:`ordgroup`,mode:e.mode,body:x};n&&(S={type:`styling`,mode:e.mode,style:n,resetFont:!0,body:[S]}),m.push(S);var ee=e.fetch().text;if(ee===`&`){if(d&&m.length===d){if(l||s)throw new I(`Too many tab characters: &`,e.nextToken);e.settings.reportNonstrict(`textEnv`,`Too few columns specified in the {array} column argument.`)}e.consume()}else if(ee===`\\end`){b(),m.length===1&&S.type===`styling`&&S.body.length===1&&S.body[0].type===`ordgroup`&&S.body[0].body.length===0&&(h.length>1||!u)&&!Array.isArray(v?.[v.length-1])&&!(c&&v?.[v.length-1]===!0)&&h.pop(),_.length0&&(_+=.25),c.push({pos:_,isDashed:e[t]})}for(v(a[0]),n=0;n0&&(ne+=g,xe))for(n=0;n=o)){var ye=void 0;(r>0||e.hskipBeforeAndAfter)&&(ye=pe?.pregap??d,ye!==0&&(oe=Y([`arraycolsep`],[]),oe.style.width=R(ye),ae.push(oe)));var be=[];for(n=0;n0){for(var De=TM(`katex-hline`,t,l),Oe=TM(`katex-hdashline`,t,l),ke=[{type:`elem`,elem:Ee,shift:0}];c.length>0;){var Ae=c.pop(),je=Ae.pos-re;Ae.isDashed?ke.push({type:`elem`,elem:Oe,shift:je}):ke.push({type:`elem`,elem:De,shift:je})}Ee=AM({positionType:`individualShift`,children:ke})}if(ce.length===0)return Y([`mord`],[Ee],t);var Me=Y([`katex-tag`],[AM({positionType:`individualShift`,children:ce})],t);return DM([Ee,Me])},QP={c:`center `,l:`left `,r:`right `},$P=function(e,t){for(var n=[],r=new Z(`mtd`,[],[`mtr-glue`]),i=new Z(`mtd`,[],[`mml-eqn-num`]),a=0;a0){var p=e.cols,m=``,h=!1,g=0,_=p.length;p[0].type===`separator`&&(d+=`top `,g=1),p[p.length-1].type===`separator`&&(d+=`bottom `,--_);for(var v=g;v<_;v++){var y=p[v];y.type===`align`?(f+=QP[y.align],h&&(m+=`none `),h=!0):y.type===`separator`&&(h&&=(m+=y.separator===`|`?`solid `:`dashed `,!1))}l.setAttribute(`columnalign`,f.trim()),/[sd]/.test(m)&&l.setAttribute(`columnlines`,m.trim())}if(e.colSeparationType===`align`){for(var b=e.cols||[],x=``,S=1;S0?`left `:``,d+=te[te.length-1].length>0?`right `:``;for(var ne=1;ne0&&u&&(p=1),n[d]={type:`align`,align:f,pregap:p,postgap:0}}return i.colSeparationType=u?`align`:`alignat`,i};VP({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(BN(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=zN(e).text;if(`lcr`.includes(t))return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new I(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return YP(e.parser,r,XP(e.envName))},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={hskipBeforeAndAfter:!1,cols:[{type:`align`,align:n}]};if(e.envName.charAt(e.envName.length-1)===`*`){var i=e.parser;if(i.consumeSpaces(),i.fetch().text===`[`){if(i.consume(),i.consumeSpaces(),n=i.fetch().text,!`lcr`.includes(n))throw new I(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=YP(e.parser,r,XP(e.envName)),o=Math.max(0,...a.body.map(e=>e.length));return a.cols=Array(o).fill({type:`align`,align:n}),t?{type:`leftright`,mode:e.mode,body:[a],left:t[0],right:t[1],rightColor:void 0}:a},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=YP(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(BN(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=zN(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new I(`Unknown column alignment: `+t,e)});if(n.length>1)throw new I(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=YP(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new I(`{subarray} can contain only one column`);return i},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=YP(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},XP(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:eF,htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){qP.has(e.envName)&&KP(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:JP(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return YP(e.parser,t,`display`)},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:eF,htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){KP(e);var t={autoTag:JP(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return YP(e.parser,t,`display`)},htmlBuilder:ZP,mathmlBuilder:$P}),VP({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return KP(e),tP(e.parser)},htmlBuilder:ZP,mathmlBuilder:$P}),$(`\\nonumber`,`\\gdef\\@eqnsw{0}`),$(`\\notag`,`\\nonumber`),X({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new I(e.funcName+` valid only within array environment`)}});var tF=BP;X({type:`environment`,names:[`\\begin`,`\\end`],numArgs:1,argTypes:[`text`],handler(e,t){var n=e.parser,r=e.funcName,i=t[0];if(i.type!==`ordgroup`)throw new I(`Invalid environment name`,i);var a=VN(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(tF,a))throw new I(`No such environment: `+a,i);var o=tF[a],s=n.parseArguments(`\\begin{`+a+`}`,o),c=s.args,l=s.optArgs,u={mode:n.mode,envName:a,parser:n},d=o.handler(u,c,l);n.expect(`\\end`,!1);var f=n.nextToken,p=Q(n.parseFunction(),`environment`);if(p.name!==a)throw new I(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var nF=(e,t)=>{var n=e.font,r=t.withFont(n);return rN(e.body,r)},rF=(e,t)=>{var n=e.font,r=t.withFont(n);return vN(e.body,r)},iF={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};X({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\mathsfit`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathtt`,`\\Bbb`,`\\bold`,`\\frak`],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=GM(t[0]),a=r in iF?iF[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:nF,mathmlBuilder:rF}),X({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:YN(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:mA(r)}}}),X({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=e.breakOnTokenText,a=n.mode,o=n.parseExpression(!0,i);return{type:`font`,mode:a,font:`math`+r.slice(1),body:{type:`ordgroup`,mode:n.mode,body:o}}}});var aF=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=rN(e.numer,a,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,c=3.5/t.fontMetrics().ptPerEm;o.height=o.height0?3*f:7*f,h=t.fontMetrics().denom1):(d>0?(p=t.fontMetrics().num2,m=f):(p=t.fontMetrics().num3,m=3*f),h=t.fontMetrics().denom2);var g;if(u){var _=t.fontMetrics().axisHeight;p-o.depth-(_+.5*d){var n=new Z(`mfrac`,[vN(e.numer,t),vN(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=aj(e.barSize,t);n.setAttribute(`linethickness`,R(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new Z(`mo`,[new sN(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Z(`mo`,[new sN(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return fN(i)}return n},sF=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;X({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0],a=t[1],o,s=null,c=null;switch(r){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:o=!0;break;case`\\\\atopfrac`:o=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=!1,s=`(`,c=`)`;break;case`\\\\bracefrac`:o=!1,s=`\\{`,c=`\\}`;break;case`\\\\brackfrac`:o=!1,s=`[`,c=`]`;break;default:throw Error(`Unrecognized genfrac command`)}var l=r===`\\cfrac`,u=null;return l||r.startsWith(`\\d`)?u=`display`:r.startsWith(`\\t`)&&(u=`text`),sF({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:aF,mathmlBuilder:oF}),X({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],numArgs:0,infix:!0,handler(e){var t=e.parser,n=e.funcName,r=e.token,i;switch(n){case`\\over`:i=`\\frac`;break;case`\\choose`:i=`\\binom`;break;case`\\atop`:i=`\\\\atopfrac`;break;case`\\brace`:i=`\\\\bracefrac`;break;case`\\brack`:i=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:t.mode,replaceWith:i,token:r}}});var cF=[`display`,`text`,`script`,`scriptscript`],lF=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};X({type:`genfrac`,names:[`\\genfrac`],numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`],handler(e,t){var n=e.parser,r=t[4],i=t[5],a=GM(t[0]),o=a.type===`atom`&&a.family===`open`?lF(a.text):null,s=GM(t[1]),c=s.type===`atom`&&s.family===`close`?lF(s.text):null,l=Q(t[2],`size`),u,d=null;l.isBlank?u=!0:(d=l.value,u=d.number>0);var f=null,p=t[3];if(p.type===`ordgroup`){if(p.body.length>0){var m=Q(p.body[0],`textord`);f=cF[Number(m.text)]}}else p=Q(p,`textord`),f=cF[Number(p.text)];return sF({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),X({type:`infix`,names:[`\\above`],numArgs:1,argTypes:[`size`],infix:!0,handler(e,t){var n=e.parser;e.funcName;var r=e.token;return{type:`infix`,mode:n.mode,replaceWith:`\\\\abovefrac`,size:Q(t[0],`size`).value,token:r}}}),X({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=Q(t[1],`infix`).size;if(!i)throw Error(`\\\\abovefrac expected size, but got `+String(i));var a=t[2],o=i.number>0;return{type:`genfrac`,mode:n.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null}}});var uF=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?rN(e.sup,t.havingStyle(n.sup()),t):rN(e.sub,t.havingStyle(n.sub()),t),i=Q(e.base,`horizBrace`)):i=Q(e,`horizBrace`);var a=rN(i.base,t.havingBaseStyle(L.DISPLAY)),o=MN(i,t),s=i.isOver?AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):AM({positionType:`bottom`,positionData:a.depth+.1+o.height,children:[{type:`elem`,elem:o,wrapperClasses:[`svg-align`]},{type:`kern`,size:.1},{type:`elem`,elem:a}]});if(r){var c=Y([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):AM({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return Y([`minner`,i.isOver?`mover`:`munder`],[s],t)};X({type:`horizBrace`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`horizBrace`,mode:n.mode,label:r,isOver:r.includes(`\\over`),base:t[0]}},htmlBuilder:uF,mathmlBuilder:(e,t)=>{var n=kN(e.label);return new Z(e.isOver?`mover`:`munder`,[vN(e.base,t),n])}}),X({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=Q(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:KM(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=ZM(e.body,t,!1);return EM(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=_N(e.body,t);return n instanceof Z||(n=new Z(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),X({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=Q(t[0],`url`).url;if(!n.settings.isTrusted({command:`\\url`,url:r}))return n.formatUnsupportedCmd(`\\url`);for(var i=[],a=0;a{var n=e.parser,r=e.funcName;e.token;var i=Q(t[0],`raw`).string,a=t[1];n.settings.strict&&n.settings.reportNonstrict(`htmlExtension`,`HTML extension is disabled on strict mode`);var o,s={};switch(r){case`\\htmlClass`:s.class=i,o={command:`\\htmlClass`,class:i};break;case`\\htmlId`:s.id=i,o={command:`\\htmlId`,id:i};break;case`\\htmlStyle`:s.style=i,o={command:`\\htmlStyle`,style:i};break;case`\\htmlData`:for(var c=`{,}`,l=[],u=``,d=0;d{var n=ZM(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=Y(r,n,t);for(var a of Object.entries(e.attributes)){var o=a[0],s=a[1];o!==`class`&&i.setAttribute(o,s)}return i},mathmlBuilder:(e,t)=>_N(e.body,t)}),X({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:KM(t[0]),mathml:KM(t[1])}),htmlBuilder:(e,t)=>DM(ZM(e.html,t,!1)),mathmlBuilder:(e,t)=>_N(e.mathml,t)});var dF=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new I(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!ij(n))throw new I(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};X({type:`includegraphics`,names:[`\\includegraphics`],numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1,handler:(e,t,n)=>{var r=e.parser,i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(n[0])for(var c=Q(n[0],`raw`).string.split(`,`),l=0;l{var n=aj(e.height,t),r=0;e.totalheight.number>0&&(r=aj(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=aj(e.width,t));var a={height:R(n+r)};i>0&&(a.width=R(i)),r>0&&(a.verticalAlign=R(-r));var o=new mj(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new Z(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=aj(e.height,t),i=0;if(e.totalheight.number>0&&(i=aj(e.totalheight,t)-r,n.setAttribute(`valign`,R(-i))),n.setAttribute(`height`,R(r+i)),e.width.number>0){var a=aj(e.width,t);n.setAttribute(`width`,R(a))}return n.setAttribute(`src`,e.src),n}}),X({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=Q(t[0],`size`);if(n.settings.strict){var a=r[1]===`m`,o=i.value.unit===`mu`;a?(o||n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` supports only mu units, `+(`not `+i.value.unit+` units`)),n.mode!==`math`&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` works only in math mode`)):o&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` doesn't support mu units`)}return{type:`kern`,mode:n.mode,dimension:i.value}},htmlBuilder(e,t){return jM(e.dimension,t)},mathmlBuilder(e,t){return new cN(aj(e.dimension,t))}}),X({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`lap`,mode:n.mode,alignment:r.slice(5),body:i}},htmlBuilder:(e,t)=>{var n;e.alignment===`clap`?(n=Y([],[rN(e.body,t)]),n=Y([`katex-inner`],[n],t)):n=Y([`katex-inner`],[rN(e.body,t)]);var r=Y([`katex-fix`],[]),i=Y([e.alignment],[n,r],t),a=Y([`katex-strut`]);return a.style.height=R(i.height+i.depth),i.depth&&(a.style.verticalAlign=R(-i.depth)),i.children.unshift(a),i=Y([`katex-thinbox`],[i],t),Y([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new Z(`mpadded`,[vN(e.body,t)]);if(e.alignment!==`rlap`){var r=e.alignment===`llap`?`-1`:`-0.5`;n.setAttribute(`lspace`,r+`width`)}return n.setAttribute(`width`,`0px`),n}}),X({type:`styling`,names:[`\\(`,`$`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var n=e.funcName,r=e.parser,i=r.mode;r.switchMode(`math`);var a=n===`\\(`?`\\)`:`$`,o=r.parseExpression(!1,a);return r.expect(a),r.switchMode(i),{type:`styling`,mode:r.mode,style:`text`,resetFont:!0,body:o}}}),X({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new I(`Mismatched `+e.funcName)}});var fF=(e,t)=>{switch(t.style.size){case L.DISPLAY.size:return e.display;case L.TEXT.size:return e.text;case L.SCRIPT.size:return e.script;case L.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};X({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:KM(t[0]),text:KM(t[1]),script:KM(t[2]),scriptscript:KM(t[3])}),htmlBuilder:(e,t)=>DM(ZM(fF(e,t),t,!1)),mathmlBuilder:(e,t)=>_N(fF(e,t),t)});var pF=(e,t,n,r,i,a,o)=>{e=Y([],[e]);var s=n&&mA(n),c,l;if(t){var u=rN(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=rN(n,r.havingStyle(i.sub()),r);c={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-d.height)}}var f;if(l&&c)f=AM({positionType:`bottom`,positionData:r.fontMetrics().bigOpSpacing5+c.elem.height+c.elem.depth+c.kern+e.depth+o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:R(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:R(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=AM({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:R(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=AM({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:R(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=Y([`mspace`],[],r);m.style.marginRight=R(a),p.unshift(m)}return Y([`mop`,`op-limits`],p,r)},mF=new Set([`\\smallint`]),hF=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Q(e.base,`op`),i=!0):a=Q(e,`op`);var o=t.style,s=!1;o.size===L.DISPLAY.size&&a.symbol&&!mF.has(a.name)&&(s=!0);var c,l;if(a.symbol){var u=s?`Size2-Regular`:`Size1-Regular`,d=``;if((a.name===`\\oiint`||a.name===`\\oiiint`)&&(d=a.name.slice(1),a.name=d===`oiint`?`\\iint`:`\\iiint`),c=_M(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=FM(d+`Size`+(s?`2`:`1`),t);c=AM({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:0},{type:`elem`,elem:f,shift:s?.08:0}]}),a.name=`\\`+d,c.classes.unshift(`mop`),c.italic=l}}else if(a.body){var p=ZM(a.body,t,!0);p.length===1&&p[0]instanceof gj?(c=p[0],c.classes[0]=`mop`):c=Y([`mop`],p,t)}else{for(var m=[],h=1;h{var n;if(e.symbol)n=new Z(`mo`,[dN(e.name,e.mode)]),mF.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Z(`mo`,gN(e.body,t));else{n=new Z(`mi`,[new sN(e.name.slice(1))]);var r=new Z(`mo`,[dN(`⁡`,`text`)]);n=e.parentIsSupSub?new Z(`mrow`,[n,r]):oN([n,r])}return n},_F={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};X({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcap.\\bigcup.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcup.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨄.⨆`.split(`.`),numArgs:0,handler:(e,t)=>{var n=e.parser,r=e.funcName;return r.length===1&&(r=_F[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:hF,mathmlBuilder:gF}),X({type:`op`,names:[`\\mathop`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`op`,mode:n.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:KM(r)}}});var vF={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};X({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\tan.\\tanh.\\tg.\\th`.split(`.`),numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:n}}}),X({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:n}}}),X({type:`op`,names:[`\\int`,`\\iint`,`\\iiint`,`\\oint`,`\\oiint`,`\\oiiint`,`∫`,`∬`,`∭`,`∮`,`∯`,`∰`],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,n=e.funcName;return n.length===1&&(n=vF[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var yF=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Q(e.base,`operatorname`),i=!0):a=Q(e,`operatorname`);var o;if(a.body.length>0){for(var s=ZM(a.body.map(e=>{var t=`text`in e?e.text:void 0;return typeof t==`string`?{type:`textord`,mode:e.mode,text:t}:e}),t.withFont(`mathrm`),!0),c=0;c{var n=e.parser,r=e.funcName,i=t[0];return{type:`operatorname`,mode:n.mode,body:KM(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:yF,mathmlBuilder:(e,t)=>{for(var n=gN(e.body,t.withFont(`mathrm`)),r=!0,i=0;ie.toText()).join(``))]);var s=new Z(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new Z(`mo`,[dN(`⁡`,`text`)]);return e.parentIsSupSub?new Z(`mrow`,[s,c]):oN([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),WM({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?DM(ZM(e.body,t,!1)):Y([`mord`],ZM(e.body,t,!0),t)},mathmlBuilder(e,t){return _N(e.body,t,!0)}}),X({type:`overline`,names:[`\\overline`],numArgs:1,handler(e,t){var n=e.parser,r=t[0];return{type:`overline`,mode:n.mode,body:r}},htmlBuilder(e,t){var n=rN(e.body,t.havingCrampedStyle()),r=TM(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-overline`],[AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:n},{type:`kern`,size:3*i},{type:`elem`,elem:r},{type:`kern`,size:i}]})],t)},mathmlBuilder(e,t){var n=new Z(`mo`,[new sN(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`mover`,[vN(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),X({type:`phantom`,names:[`\\phantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`phantom`,mode:n.mode,body:KM(r)}},htmlBuilder:(e,t)=>DM(ZM(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Z(`mphantom`,gN(e.body,t))}),$(`\\hphantom`,`\\smash{\\phantom{#1}}`),X({type:`vphantom`,names:[`\\vphantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`vphantom`,mode:n.mode,body:r}},htmlBuilder:(e,t)=>Y([`mord`,`rlap`],[Y([`katex-inner`],[rN(e.body,t.withPhantom())]),Y([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Z(`mpadded`,[new Z(`mphantom`,gN(KM(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),X({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=Q(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=rN(e.body,t);return AM({positionType:`shift`,positionData:-aj(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Z(`mpadded`,[vN(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var bF=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});X({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:bF,htmlBuilder(e,t){return Y([`mord`,`reflectbox`],[rN(e.body,t)],t)},mathmlBuilder(e,t){return vN(e.body,t)}}),X({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:bF}),X({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),X({type:`rule`,names:[`\\rule`],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`],handler(e,t,n){var r=e.parser,i=n[0],a=Q(t[0],`size`),o=Q(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&Q(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=Y([`mord`,`katex-rule`],[],t),r=aj(e.width,t),i=aj(e.height,t),a=e.shift?aj(e.shift,t):0;return n.style.borderRightWidth=R(r),n.style.borderTopWidth=R(i),n.style.bottom=R(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=aj(e.width,t),r=aj(e.height,t),i=e.shift?aj(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new Z(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,R(n)),o.setAttribute(`height`,R(r));var s=new Z(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,R(i)):(s.setAttribute(`height`,R(i)),s.setAttribute(`depth`,R(-i))),s.setAttribute(`voffset`,R(i)),s}});function xF(e,t,n){for(var r=ZM(e,t,!1),i=t.sizeMultiplier/n.sizeMultiplier,a=0;a{var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!1,n);return{type:`sizing`,mode:i.mode,size:SF.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return xF(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Z(`mstyle`,gN(e.body,n));return r.setAttribute(`mathsize`,R(n.sizeMultiplier)),r}}),X({type:`smash`,names:[`\\smash`],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,n)=>{var r=e.parser,i=!1,a=!1,o=n[0]&&Q(n[0],`ordgroup`);if(o)for(var s,c=0;c{var n=Y([],[rN(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return n;if(e.smashHeight&&(n.height=0),e.smashDepth&&(n.depth=0),e.smashHeight&&e.smashDepth)return Y([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r{var n=new Z(`mpadded`,[vN(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),X({type:`sqrt`,names:[`\\sqrt`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=n[0],a=t[0];return{type:`sqrt`,mode:r.mode,body:a,index:i}},htmlBuilder(e,t){var n=rN(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=OM(n,t);var r=t.fontMetrics().defaultRuleThickness,i=r;t.style.idn.height+n.depth+a&&(a=(a+u-n.height-n.depth)/2);var d=s.height-n.height-a-c;n.style.paddingLeft=R(l);var f=AM({positionType:`firstBaseline`,children:[{type:`elem`,elem:n,wrapperClasses:[`svg-align`]},{type:`kern`,size:-(n.height+d)},{type:`elem`,elem:s},{type:`kern`,size:c}]});if(e.index){var p=t.havingStyle(L.SCRIPTSCRIPT),m=rN(e.index,p,t);return Y([`mord`,`sqrt`],[Y([`katex-root`],[AM({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return Y([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new Z(`mroot`,[vN(n,t),vN(r,t)]):new Z(`msqrt`,[vN(n,t)])}});var CF={display:L.DISPLAY,text:L.TEXT,script:L.SCRIPT,scriptscript:L.SCRIPTSCRIPT};function wF(e){return e in CF}X({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!0,n),o=r.slice(1,r.length-5);if(!wF(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=CF[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),xF(e.body,r,t)},mathmlBuilder(e,t){var n=CF[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Z(`mstyle`,gN(e.body,r)),a={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]}[e.style];return i.setAttribute(`scriptlevel`,a[0]),i.setAttribute(`displaystyle`,a[1]),i}});var TF=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===L.DISPLAY.size||n.alwaysHandleSupSub)?hF:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===L.DISPLAY.size||n.limits)?yF:null:n.type===`accent`?mA(n.base)?UN:null:n.type===`horizBrace`&&!e.sub===n.isOver?uF:null:null};WM({type:`supsub`,htmlBuilder(e,t){var n=TF(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=rN(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&mA(r);if(i){var p=t.havingStyle(t.style.sup());s=rN(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=rN(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===L.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=R(.5/l.ptPerEm/g),v=null;if(c){var y=e.base&&e.base.type===`op`&&e.base.name&&(e.base.name===`\\oiint`||e.base.name===`\\oiiint`);(o instanceof gj||y)&&(v=R(-(o.italic??0)))}var b;if(s&&c){u=Math.max(u,h,s.depth+.25*l.xHeight),d=Math.max(d,l.sub2);var x=4*l.defaultRuleThickness;if(u-s.depth-(c.height-d)0&&(u+=S,d-=S)}b=AM({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:d,marginRight:_,marginLeft:v},{type:`elem`,elem:s,shift:-u,marginRight:_}]})}else if(c)d=Math.max(d,l.sub1,c.height-.8*l.xHeight),b=AM({positionType:`shift`,positionData:d,children:[{type:`elem`,elem:c,marginLeft:v,marginRight:_}]});else if(s)u=Math.max(u,h,s.depth+.25*l.xHeight),b=AM({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return Y([tN(o,`right`)||`mord`],[o,Y([`msupsub`],[b])],t)},mathmlBuilder(e,t){var n=!1,r,i;e.base&&e.base.type===`horizBrace`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0);var a=[vN(e.base,t)];e.sub&&a.push(vN(e.sub,t)),e.sup&&a.push(vN(e.sup,t));var o;if(n)o=r?`mover`:`munder`;else if(!e.sub){var s=e.base;o=s&&s.type===`op`&&s.limits&&(t.style===L.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===L.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===L.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===L.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===L.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===L.DISPLAY)?`munder`:`msub`}return new Z(o,a)}}),WM({type:`atom`,htmlBuilder(e,t){return vM(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Z(`mo`,[dN(e.text,e.mode)]);if(e.family===`bin`){var r=mN(e,t);r===`bold-italic`&&n.setAttribute(`mathvariant`,r)}else e.family===`punct`?n.setAttribute(`separator`,`true`):(e.family===`open`||e.family===`close`)&&n.setAttribute(`stretchy`,`false`);return n}});var EF={mi:`italic`,mn:`normal`,mtext:`normal`};WM({type:`mathord`,htmlBuilder(e,t){return bM(e,t)},mathmlBuilder(e,t){var n=new Z(`mi`,[dN(e.text,e.mode,t)]),r=mN(e,t)||`italic`;return r!==EF[n.type]&&n.setAttribute(`mathvariant`,r),n}}),WM({type:`textord`,htmlBuilder(e,t){return bM(e,t)},mathmlBuilder(e,t){var n=dN(e.text,e.mode,t),r=mN(e,t)||`normal`,i=e.mode===`text`?new Z(`mtext`,[n]):/[0-9]/.test(e.text)?new Z(`mn`,[n]):e.text===`\\prime`?new Z(`mo`,[n]):new Z(`mi`,[n]);return r!==EF[i.type]&&i.setAttribute(`mathvariant`,r),i}});var DF=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),OF=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);WM({type:`spacing`,htmlBuilder(e,t){var n=OF.get(e.text),r=DF.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=bM(e,t);return a.classes.push(i),a}return Y([`mspace`,i],[vM(e.text,e.mode,t)],t)}if(r)return Y([`mspace`,r],[],t);throw new I(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(OF.has(e.text))n=new Z(`mtext`,[new sN(`\xA0`)]);else if(DF.has(e.text))return new Z(`mspace`);else throw new I(`Unknown type of space "`+e.text+`"`);return n}});var kF=()=>{var e=new Z(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};WM({type:`tag`,mathmlBuilder(e,t){var n=new Z(`mtable`,[new Z(`mtr`,[kF(),new Z(`mtd`,[_N(e.body,t)]),kF(),new Z(`mtd`,[_N(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var AF={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},jF={"\\textbf":`textbf`,"\\textmd":`textmd`},MF={"\\textit":`textit`,"\\textup":`textup`},NF=(e,t)=>{var n=e.font;return n?AF[n]?t.withTextFontFamily(AF[n]):jF[n]?t.withTextFontWeight(jF[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(MF[n]):t};X({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`text`,mode:n.mode,body:KM(i),font:r}},htmlBuilder(e,t){var n=NF(e,t);return Y([`mord`,`text`],ZM(e.body,n,!0),n)},mathmlBuilder(e,t){var n=NF(e,t);return _N(e.body,n)}}),X({type:`underline`,names:[`\\underline`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`underline`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=rN(e.body,t),r=TM(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-underline`],[AM({positionType:`top`,positionData:n.height,children:[{type:`kern`,size:i},{type:`elem`,elem:r},{type:`kern`,size:3*i},{type:`elem`,elem:n}]})],t)},mathmlBuilder(e,t){var n=new Z(`mo`,[new sN(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`munder`,[vN(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),X({type:`vcenter`,names:[`\\vcenter`],numArgs:1,argTypes:[`original`],allowedInText:!1,handler(e,t){return{type:`vcenter`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=rN(e.body,t),r=t.fontMetrics().axisHeight;return AM({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new Z(`mrow`,[new Z(`mpadded`,[vN(e.body,t)],[`vcenter`])])}}),X({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new I(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=PF(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),FF=VM,IF=`[ \r - ]`,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{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/=\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`,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=``+bM(this.alt)+``,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=`0&&(n+=`margin-right:`+R(this.italic)+`;`),n+=gN(this.style),n&&(e=!0,t+=` style="`+bM(n)+`"`);var r=bM(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},EN=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var n=0;n`;for(var n=0;n`,e}},DN=class{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return this.alternate?e.setAttribute(`d`,this.alternate):e.setAttribute(`d`,sN[this.pathName]),e}toMarkup(){return this.alternate?``:``}},ON=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e=``,e}};function kN(e){if(e instanceof TN)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function AN(e){if(e instanceof xN)return e;throw Error(`Expected span but got `+String(e)+`.`)}var jN=e=>e instanceof xN||e instanceof SN||e instanceof uN,MN={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},NN={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},PN={Å:`A`,Ð:`D`,Þ:`o`,å:`a`,ð:`d`,þ:`o`,А:`A`,Б:`B`,В:`B`,Г:`F`,Д:`A`,Е:`E`,Ж:`K`,З:`3`,И:`N`,Й:`N`,К:`K`,Л:`N`,М:`M`,Н:`H`,О:`O`,П:`N`,Р:`P`,С:`C`,Т:`T`,У:`y`,Ф:`O`,Х:`X`,Ц:`U`,Ч:`h`,Ш:`W`,Щ:`W`,Ъ:`B`,Ы:`X`,Ь:`B`,Э:`3`,Ю:`X`,Я:`R`,а:`a`,б:`b`,в:`a`,г:`r`,д:`y`,е:`e`,ж:`m`,з:`e`,и:`n`,й:`n`,к:`n`,л:`n`,м:`m`,н:`n`,о:`o`,п:`n`,р:`p`,с:`c`,т:`o`,у:`y`,ф:`b`,х:`x`,ц:`n`,ч:`n`,ш:`w`,щ:`w`,ъ:`a`,ы:`m`,ь:`a`,э:`e`,ю:`m`,я:`r`};function FN(e,t){MN[e]=t}function IN(e,t,n){if(!MN[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=MN[t][r];if(!i&&e[0]in PN&&(r=PN[e[0]].charCodeAt(0),i=MN[t][r]),!i&&n===`text`&&YM(r)&&(i=MN[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var LN={};function RN(e){var t=e>=5?0:e>=3?1:2;if(!LN[t]){var n=LN[t]={cssEmPerMu:NN.quad[t]/18};for(var r of Object.keys(NN))n[r]=NN[r][t]}return LN[t]}var zN={math:{},text:{}};function z(e,t,n,r,i,a){zN[e][i]={font:t,group:n,replace:r},a&&r&&(zN[e][r]=zN[e][i])}var B=`math`,V=`text`,H=`main`,U=`ams`,BN=`accent-token`,W=`bin`,VN=`close`,HN=`inner`,G=`mathord`,UN=`op-token`,WN=`open`,GN=`punct`,K=`rel`,KN=`spacing`,q=`textord`;z(B,H,K,`≡`,`\\equiv`,!0),z(B,H,K,`≺`,`\\prec`,!0),z(B,H,K,`≻`,`\\succ`,!0),z(B,H,K,`∼`,`\\sim`,!0),z(B,H,K,`⊥`,`\\perp`),z(B,H,K,`⪯`,`\\preceq`,!0),z(B,H,K,`⪰`,`\\succeq`,!0),z(B,H,K,`≃`,`\\simeq`,!0),z(B,H,K,`∣`,`\\mid`,!0),z(B,H,K,`≪`,`\\ll`,!0),z(B,H,K,`≫`,`\\gg`,!0),z(B,H,K,`≍`,`\\asymp`,!0),z(B,H,K,`∥`,`\\parallel`),z(B,H,K,`⋈`,`\\bowtie`,!0),z(B,H,K,`⌣`,`\\smile`,!0),z(B,H,K,`⊑`,`\\sqsubseteq`,!0),z(B,H,K,`⊒`,`\\sqsupseteq`,!0),z(B,H,K,`≐`,`\\doteq`,!0),z(B,H,K,`⌢`,`\\frown`,!0),z(B,H,K,`∋`,`\\ni`,!0),z(B,H,K,`∝`,`\\propto`,!0),z(B,H,K,`⊢`,`\\vdash`,!0),z(B,H,K,`⊣`,`\\dashv`,!0),z(B,H,K,`∋`,`\\owns`),z(B,H,GN,`.`,`\\ldotp`),z(B,H,GN,`⋅`,`\\cdotp`),z(B,H,GN,`⋅`,`·`),z(V,H,q,`⋅`,`·`),z(B,H,q,`#`,`\\#`),z(V,H,q,`#`,`\\#`),z(B,H,q,`&`,`\\&`),z(V,H,q,`&`,`\\&`),z(B,H,q,`ℵ`,`\\aleph`,!0),z(B,H,q,`∀`,`\\forall`,!0),z(B,H,q,`ℏ`,`\\hbar`,!0),z(B,H,q,`∃`,`\\exists`,!0),z(B,H,q,`∇`,`\\nabla`,!0),z(B,H,q,`♭`,`\\flat`,!0),z(B,H,q,`ℓ`,`\\ell`,!0),z(B,H,q,`♮`,`\\natural`,!0),z(B,H,q,`♣`,`\\clubsuit`,!0),z(B,H,q,`℘`,`\\wp`,!0),z(B,H,q,`♯`,`\\sharp`,!0),z(B,H,q,`♢`,`\\diamondsuit`,!0),z(B,H,q,`ℜ`,`\\Re`,!0),z(B,H,q,`♡`,`\\heartsuit`,!0),z(B,H,q,`ℑ`,`\\Im`,!0),z(B,H,q,`♠`,`\\spadesuit`,!0),z(B,H,q,`§`,`\\S`,!0),z(V,H,q,`§`,`\\S`),z(B,H,q,`¶`,`\\P`,!0),z(V,H,q,`¶`,`\\P`),z(B,H,q,`†`,`\\dag`),z(V,H,q,`†`,`\\dag`),z(V,H,q,`†`,`\\textdagger`),z(B,H,q,`‡`,`\\ddag`),z(V,H,q,`‡`,`\\ddag`),z(V,H,q,`‡`,`\\textdaggerdbl`),z(B,H,VN,`⎱`,`\\rmoustache`,!0),z(B,H,WN,`⎰`,`\\lmoustache`,!0),z(B,H,VN,`⟯`,`\\rgroup`,!0),z(B,H,WN,`⟮`,`\\lgroup`,!0),z(B,H,W,`∓`,`\\mp`,!0),z(B,H,W,`⊖`,`\\ominus`,!0),z(B,H,W,`⊎`,`\\uplus`,!0),z(B,H,W,`⊓`,`\\sqcap`,!0),z(B,H,W,`∗`,`\\ast`),z(B,H,W,`⊔`,`\\sqcup`,!0),z(B,H,W,`◯`,`\\bigcirc`,!0),z(B,H,W,`∙`,`\\bullet`,!0),z(B,H,W,`‡`,`\\ddagger`),z(B,H,W,`≀`,`\\wr`,!0),z(B,H,W,`⨿`,`\\amalg`),z(B,H,W,`&`,`\\And`),z(B,H,K,`⟵`,`\\longleftarrow`,!0),z(B,H,K,`⇐`,`\\Leftarrow`,!0),z(B,H,K,`⟸`,`\\Longleftarrow`,!0),z(B,H,K,`⟶`,`\\longrightarrow`,!0),z(B,H,K,`⇒`,`\\Rightarrow`,!0),z(B,H,K,`⟹`,`\\Longrightarrow`,!0),z(B,H,K,`↔`,`\\leftrightarrow`,!0),z(B,H,K,`⟷`,`\\longleftrightarrow`,!0),z(B,H,K,`⇔`,`\\Leftrightarrow`,!0),z(B,H,K,`⟺`,`\\Longleftrightarrow`,!0),z(B,H,K,`↦`,`\\mapsto`,!0),z(B,H,K,`⟼`,`\\longmapsto`,!0),z(B,H,K,`↗`,`\\nearrow`,!0),z(B,H,K,`↩`,`\\hookleftarrow`,!0),z(B,H,K,`↪`,`\\hookrightarrow`,!0),z(B,H,K,`↘`,`\\searrow`,!0),z(B,H,K,`↼`,`\\leftharpoonup`,!0),z(B,H,K,`⇀`,`\\rightharpoonup`,!0),z(B,H,K,`↙`,`\\swarrow`,!0),z(B,H,K,`↽`,`\\leftharpoondown`,!0),z(B,H,K,`⇁`,`\\rightharpoondown`,!0),z(B,H,K,`↖`,`\\nwarrow`,!0),z(B,H,K,`⇌`,`\\rightleftharpoons`,!0),z(B,U,K,`≮`,`\\nless`,!0),z(B,U,K,``,`\\@nleqslant`),z(B,U,K,``,`\\@nleqq`),z(B,U,K,`⪇`,`\\lneq`,!0),z(B,U,K,`≨`,`\\lneqq`,!0),z(B,U,K,``,`\\@lvertneqq`),z(B,U,K,`⋦`,`\\lnsim`,!0),z(B,U,K,`⪉`,`\\lnapprox`,!0),z(B,U,K,`⊀`,`\\nprec`,!0),z(B,U,K,`⋠`,`\\npreceq`,!0),z(B,U,K,`⋨`,`\\precnsim`,!0),z(B,U,K,`⪹`,`\\precnapprox`,!0),z(B,U,K,`≁`,`\\nsim`,!0),z(B,U,K,``,`\\@nshortmid`),z(B,U,K,`∤`,`\\nmid`,!0),z(B,U,K,`⊬`,`\\nvdash`,!0),z(B,U,K,`⊭`,`\\nvDash`,!0),z(B,U,K,`⋪`,`\\ntriangleleft`),z(B,U,K,`⋬`,`\\ntrianglelefteq`,!0),z(B,U,K,`⊊`,`\\subsetneq`,!0),z(B,U,K,``,`\\@varsubsetneq`),z(B,U,K,`⫋`,`\\subsetneqq`,!0),z(B,U,K,``,`\\@varsubsetneqq`),z(B,U,K,`≯`,`\\ngtr`,!0),z(B,U,K,``,`\\@ngeqslant`),z(B,U,K,``,`\\@ngeqq`),z(B,U,K,`⪈`,`\\gneq`,!0),z(B,U,K,`≩`,`\\gneqq`,!0),z(B,U,K,``,`\\@gvertneqq`),z(B,U,K,`⋧`,`\\gnsim`,!0),z(B,U,K,`⪊`,`\\gnapprox`,!0),z(B,U,K,`⊁`,`\\nsucc`,!0),z(B,U,K,`⋡`,`\\nsucceq`,!0),z(B,U,K,`⋩`,`\\succnsim`,!0),z(B,U,K,`⪺`,`\\succnapprox`,!0),z(B,U,K,`≆`,`\\ncong`,!0),z(B,U,K,``,`\\@nshortparallel`),z(B,U,K,`∦`,`\\nparallel`,!0),z(B,U,K,`⊯`,`\\nVDash`,!0),z(B,U,K,`⋫`,`\\ntriangleright`),z(B,U,K,`⋭`,`\\ntrianglerighteq`,!0),z(B,U,K,``,`\\@nsupseteqq`),z(B,U,K,`⊋`,`\\supsetneq`,!0),z(B,U,K,``,`\\@varsupsetneq`),z(B,U,K,`⫌`,`\\supsetneqq`,!0),z(B,U,K,``,`\\@varsupsetneqq`),z(B,U,K,`⊮`,`\\nVdash`,!0),z(B,U,K,`⪵`,`\\precneqq`,!0),z(B,U,K,`⪶`,`\\succneqq`,!0),z(B,U,K,``,`\\@nsubseteqq`),z(B,U,W,`⊴`,`\\unlhd`),z(B,U,W,`⊵`,`\\unrhd`),z(B,U,K,`↚`,`\\nleftarrow`,!0),z(B,U,K,`↛`,`\\nrightarrow`,!0),z(B,U,K,`⇍`,`\\nLeftarrow`,!0),z(B,U,K,`⇏`,`\\nRightarrow`,!0),z(B,U,K,`↮`,`\\nleftrightarrow`,!0),z(B,U,K,`⇎`,`\\nLeftrightarrow`,!0),z(B,U,K,`△`,`\\vartriangle`),z(B,U,q,`ℏ`,`\\hslash`),z(B,U,q,`▽`,`\\triangledown`),z(B,U,q,`◊`,`\\lozenge`),z(B,U,q,`Ⓢ`,`\\circledS`),z(B,U,q,`®`,`\\circledR`),z(V,U,q,`®`,`\\circledR`),z(B,U,q,`∡`,`\\measuredangle`,!0),z(B,U,q,`∄`,`\\nexists`),z(B,U,q,`℧`,`\\mho`),z(B,U,q,`Ⅎ`,`\\Finv`,!0),z(B,U,q,`⅁`,`\\Game`,!0),z(B,U,q,`‵`,`\\backprime`),z(B,U,q,`▲`,`\\blacktriangle`),z(B,U,q,`▼`,`\\blacktriangledown`),z(B,U,q,`■`,`\\blacksquare`),z(B,U,q,`⧫`,`\\blacklozenge`),z(B,U,q,`★`,`\\bigstar`),z(B,U,q,`∢`,`\\sphericalangle`,!0),z(B,U,q,`∁`,`\\complement`,!0),z(B,U,q,`ð`,`\\eth`,!0),z(V,H,q,`ð`,`ð`),z(B,U,q,`╱`,`\\diagup`),z(B,U,q,`╲`,`\\diagdown`),z(B,U,q,`□`,`\\square`),z(B,U,q,`□`,`\\Box`),z(B,U,q,`◊`,`\\Diamond`),z(B,U,q,`¥`,`\\yen`,!0),z(V,U,q,`¥`,`\\yen`,!0),z(B,U,q,`✓`,`\\checkmark`,!0),z(V,U,q,`✓`,`\\checkmark`),z(B,U,q,`ℶ`,`\\beth`,!0),z(B,U,q,`ℸ`,`\\daleth`,!0),z(B,U,q,`ℷ`,`\\gimel`,!0),z(B,U,q,`ϝ`,`\\digamma`,!0),z(B,U,q,`ϰ`,`\\varkappa`),z(B,U,WN,`┌`,`\\@ulcorner`,!0),z(B,U,VN,`┐`,`\\@urcorner`,!0),z(B,U,WN,`└`,`\\@llcorner`,!0),z(B,U,VN,`┘`,`\\@lrcorner`,!0),z(B,U,K,`≦`,`\\leqq`,!0),z(B,U,K,`⩽`,`\\leqslant`,!0),z(B,U,K,`⪕`,`\\eqslantless`,!0),z(B,U,K,`≲`,`\\lesssim`,!0),z(B,U,K,`⪅`,`\\lessapprox`,!0),z(B,U,K,`≊`,`\\approxeq`,!0),z(B,U,W,`⋖`,`\\lessdot`),z(B,U,K,`⋘`,`\\lll`,!0),z(B,U,K,`≶`,`\\lessgtr`,!0),z(B,U,K,`⋚`,`\\lesseqgtr`,!0),z(B,U,K,`⪋`,`\\lesseqqgtr`,!0),z(B,U,K,`≑`,`\\doteqdot`),z(B,U,K,`≓`,`\\risingdotseq`,!0),z(B,U,K,`≒`,`\\fallingdotseq`,!0),z(B,U,K,`∽`,`\\backsim`,!0),z(B,U,K,`⋍`,`\\backsimeq`,!0),z(B,U,K,`⫅`,`\\subseteqq`,!0),z(B,U,K,`⋐`,`\\Subset`,!0),z(B,U,K,`⊏`,`\\sqsubset`,!0),z(B,U,K,`≼`,`\\preccurlyeq`,!0),z(B,U,K,`⋞`,`\\curlyeqprec`,!0),z(B,U,K,`≾`,`\\precsim`,!0),z(B,U,K,`⪷`,`\\precapprox`,!0),z(B,U,K,`⊲`,`\\vartriangleleft`),z(B,U,K,`⊴`,`\\trianglelefteq`),z(B,U,K,`⊨`,`\\vDash`,!0),z(B,U,K,`⊪`,`\\Vvdash`,!0),z(B,U,K,`⌣`,`\\smallsmile`),z(B,U,K,`⌢`,`\\smallfrown`),z(B,U,K,`≏`,`\\bumpeq`,!0),z(B,U,K,`≎`,`\\Bumpeq`,!0),z(B,U,K,`≧`,`\\geqq`,!0),z(B,U,K,`⩾`,`\\geqslant`,!0),z(B,U,K,`⪖`,`\\eqslantgtr`,!0),z(B,U,K,`≳`,`\\gtrsim`,!0),z(B,U,K,`⪆`,`\\gtrapprox`,!0),z(B,U,W,`⋗`,`\\gtrdot`),z(B,U,K,`⋙`,`\\ggg`,!0),z(B,U,K,`≷`,`\\gtrless`,!0),z(B,U,K,`⋛`,`\\gtreqless`,!0),z(B,U,K,`⪌`,`\\gtreqqless`,!0),z(B,U,K,`≖`,`\\eqcirc`,!0),z(B,U,K,`≗`,`\\circeq`,!0),z(B,U,K,`≜`,`\\triangleq`,!0),z(B,U,K,`∼`,`\\thicksim`),z(B,U,K,`≈`,`\\thickapprox`),z(B,U,K,`⫆`,`\\supseteqq`,!0),z(B,U,K,`⋑`,`\\Supset`,!0),z(B,U,K,`⊐`,`\\sqsupset`,!0),z(B,U,K,`≽`,`\\succcurlyeq`,!0),z(B,U,K,`⋟`,`\\curlyeqsucc`,!0),z(B,U,K,`≿`,`\\succsim`,!0),z(B,U,K,`⪸`,`\\succapprox`,!0),z(B,U,K,`⊳`,`\\vartriangleright`),z(B,U,K,`⊵`,`\\trianglerighteq`),z(B,U,K,`⊩`,`\\Vdash`,!0),z(B,U,K,`∣`,`\\shortmid`),z(B,U,K,`∥`,`\\shortparallel`),z(B,U,K,`≬`,`\\between`,!0),z(B,U,K,`⋔`,`\\pitchfork`,!0),z(B,U,K,`∝`,`\\varpropto`),z(B,U,K,`◀`,`\\blacktriangleleft`),z(B,U,K,`∴`,`\\therefore`,!0),z(B,U,K,`∍`,`\\backepsilon`),z(B,U,K,`▶`,`\\blacktriangleright`),z(B,U,K,`∵`,`\\because`,!0),z(B,U,K,`⋘`,`\\llless`),z(B,U,K,`⋙`,`\\gggtr`),z(B,U,W,`⊲`,`\\lhd`),z(B,U,W,`⊳`,`\\rhd`),z(B,U,K,`≂`,`\\eqsim`,!0),z(B,H,K,`⋈`,`\\Join`),z(B,U,K,`≑`,`\\Doteq`,!0),z(B,U,W,`∔`,`\\dotplus`,!0),z(B,U,W,`∖`,`\\smallsetminus`),z(B,U,W,`⋒`,`\\Cap`,!0),z(B,U,W,`⋓`,`\\Cup`,!0),z(B,U,W,`⩞`,`\\doublebarwedge`,!0),z(B,U,W,`⊟`,`\\boxminus`,!0),z(B,U,W,`⊞`,`\\boxplus`,!0),z(B,U,W,`⋇`,`\\divideontimes`,!0),z(B,U,W,`⋉`,`\\ltimes`,!0),z(B,U,W,`⋊`,`\\rtimes`,!0),z(B,U,W,`⋋`,`\\leftthreetimes`,!0),z(B,U,W,`⋌`,`\\rightthreetimes`,!0),z(B,U,W,`⋏`,`\\curlywedge`,!0),z(B,U,W,`⋎`,`\\curlyvee`,!0),z(B,U,W,`⊝`,`\\circleddash`,!0),z(B,U,W,`⊛`,`\\circledast`,!0),z(B,U,W,`⋅`,`\\centerdot`),z(B,U,W,`⊺`,`\\intercal`,!0),z(B,U,W,`⋒`,`\\doublecap`),z(B,U,W,`⋓`,`\\doublecup`),z(B,U,W,`⊠`,`\\boxtimes`,!0),z(B,U,K,`⇢`,`\\dashrightarrow`,!0),z(B,U,K,`⇠`,`\\dashleftarrow`,!0),z(B,U,K,`⇇`,`\\leftleftarrows`,!0),z(B,U,K,`⇆`,`\\leftrightarrows`,!0),z(B,U,K,`⇚`,`\\Lleftarrow`,!0),z(B,U,K,`↞`,`\\twoheadleftarrow`,!0),z(B,U,K,`↢`,`\\leftarrowtail`,!0),z(B,U,K,`↫`,`\\looparrowleft`,!0),z(B,U,K,`⇋`,`\\leftrightharpoons`,!0),z(B,U,K,`↶`,`\\curvearrowleft`,!0),z(B,U,K,`↺`,`\\circlearrowleft`,!0),z(B,U,K,`↰`,`\\Lsh`,!0),z(B,U,K,`⇈`,`\\upuparrows`,!0),z(B,U,K,`↿`,`\\upharpoonleft`,!0),z(B,U,K,`⇃`,`\\downharpoonleft`,!0),z(B,H,K,`⊶`,`\\origof`,!0),z(B,H,K,`⊷`,`\\imageof`,!0),z(B,U,K,`⊸`,`\\multimap`,!0),z(B,U,K,`↭`,`\\leftrightsquigarrow`,!0),z(B,U,K,`⇉`,`\\rightrightarrows`,!0),z(B,U,K,`⇄`,`\\rightleftarrows`,!0),z(B,U,K,`↠`,`\\twoheadrightarrow`,!0),z(B,U,K,`↣`,`\\rightarrowtail`,!0),z(B,U,K,`↬`,`\\looparrowright`,!0),z(B,U,K,`↷`,`\\curvearrowright`,!0),z(B,U,K,`↻`,`\\circlearrowright`,!0),z(B,U,K,`↱`,`\\Rsh`,!0),z(B,U,K,`⇊`,`\\downdownarrows`,!0),z(B,U,K,`↾`,`\\upharpoonright`,!0),z(B,U,K,`⇂`,`\\downharpoonright`,!0),z(B,U,K,`⇝`,`\\rightsquigarrow`,!0),z(B,U,K,`⇝`,`\\leadsto`),z(B,U,K,`⇛`,`\\Rrightarrow`,!0),z(B,U,K,`↾`,`\\restriction`),z(B,H,q,`‘`,"`"),z(B,H,q,`$`,`\\$`),z(V,H,q,`$`,`\\$`),z(V,H,q,`$`,`\\textdollar`),z(B,H,q,`%`,`\\%`),z(V,H,q,`%`,`\\%`),z(B,H,q,`_`,`\\_`),z(V,H,q,`_`,`\\_`),z(V,H,q,`_`,`\\textunderscore`),z(B,H,q,`∠`,`\\angle`,!0),z(B,H,q,`∞`,`\\infty`,!0),z(B,H,q,`′`,`\\prime`),z(B,H,q,`△`,`\\triangle`),z(B,H,q,`Γ`,`\\Gamma`,!0),z(B,H,q,`Δ`,`\\Delta`,!0),z(B,H,q,`Θ`,`\\Theta`,!0),z(B,H,q,`Λ`,`\\Lambda`,!0),z(B,H,q,`Ξ`,`\\Xi`,!0),z(B,H,q,`Π`,`\\Pi`,!0),z(B,H,q,`Σ`,`\\Sigma`,!0),z(B,H,q,`Υ`,`\\Upsilon`,!0),z(B,H,q,`Φ`,`\\Phi`,!0),z(B,H,q,`Ψ`,`\\Psi`,!0),z(B,H,q,`Ω`,`\\Omega`,!0),z(B,H,q,`A`,`Α`),z(B,H,q,`B`,`Β`),z(B,H,q,`E`,`Ε`),z(B,H,q,`Z`,`Ζ`),z(B,H,q,`H`,`Η`),z(B,H,q,`I`,`Ι`),z(B,H,q,`K`,`Κ`),z(B,H,q,`M`,`Μ`),z(B,H,q,`N`,`Ν`),z(B,H,q,`O`,`Ο`),z(B,H,q,`P`,`Ρ`),z(B,H,q,`T`,`Τ`),z(B,H,q,`X`,`Χ`),z(B,H,q,`¬`,`\\neg`,!0),z(B,H,q,`¬`,`\\lnot`),z(B,H,q,`⊤`,`\\top`),z(B,H,q,`⊥`,`\\bot`),z(B,H,q,`∅`,`\\emptyset`),z(B,U,q,`∅`,`\\varnothing`),z(B,H,G,`α`,`\\alpha`,!0),z(B,H,G,`β`,`\\beta`,!0),z(B,H,G,`γ`,`\\gamma`,!0),z(B,H,G,`δ`,`\\delta`,!0),z(B,H,G,`ϵ`,`\\epsilon`,!0),z(B,H,G,`ζ`,`\\zeta`,!0),z(B,H,G,`η`,`\\eta`,!0),z(B,H,G,`θ`,`\\theta`,!0),z(B,H,G,`ι`,`\\iota`,!0),z(B,H,G,`κ`,`\\kappa`,!0),z(B,H,G,`λ`,`\\lambda`,!0),z(B,H,G,`μ`,`\\mu`,!0),z(B,H,G,`ν`,`\\nu`,!0),z(B,H,G,`ξ`,`\\xi`,!0),z(B,H,G,`ο`,`\\omicron`,!0),z(B,H,G,`π`,`\\pi`,!0),z(B,H,G,`ρ`,`\\rho`,!0),z(B,H,G,`σ`,`\\sigma`,!0),z(B,H,G,`τ`,`\\tau`,!0),z(B,H,G,`υ`,`\\upsilon`,!0),z(B,H,G,`ϕ`,`\\phi`,!0),z(B,H,G,`χ`,`\\chi`,!0),z(B,H,G,`ψ`,`\\psi`,!0),z(B,H,G,`ω`,`\\omega`,!0),z(B,H,G,`ε`,`\\varepsilon`,!0),z(B,H,G,`ϑ`,`\\vartheta`,!0),z(B,H,G,`ϖ`,`\\varpi`,!0),z(B,H,G,`ϱ`,`\\varrho`,!0),z(B,H,G,`ς`,`\\varsigma`,!0),z(B,H,G,`φ`,`\\varphi`,!0),z(B,H,W,`∗`,`*`,!0),z(B,H,W,`+`,`+`),z(B,H,W,`−`,`-`,!0),z(B,H,W,`⋅`,`\\cdot`,!0),z(B,H,W,`∘`,`\\circ`,!0),z(B,H,W,`÷`,`\\div`,!0),z(B,H,W,`±`,`\\pm`,!0),z(B,H,W,`×`,`\\times`,!0),z(B,H,W,`∩`,`\\cap`,!0),z(B,H,W,`∪`,`\\cup`,!0),z(B,H,W,`∖`,`\\setminus`,!0),z(B,H,W,`∧`,`\\land`),z(B,H,W,`∨`,`\\lor`),z(B,H,W,`∧`,`\\wedge`,!0),z(B,H,W,`∨`,`\\vee`,!0),z(B,H,q,`√`,`\\surd`),z(B,H,WN,`⟨`,`\\langle`,!0),z(B,H,WN,`∣`,`\\lvert`),z(B,H,WN,`∥`,`\\lVert`),z(B,H,VN,`?`,`?`),z(B,H,VN,`!`,`!`),z(B,H,VN,`⟩`,`\\rangle`,!0),z(B,H,VN,`∣`,`\\rvert`),z(B,H,VN,`∥`,`\\rVert`),z(B,H,K,`=`,`=`),z(B,H,K,`:`,`:`),z(B,H,K,`≈`,`\\approx`,!0),z(B,H,K,`≅`,`\\cong`,!0),z(B,H,K,`≥`,`\\ge`),z(B,H,K,`≥`,`\\geq`,!0),z(B,H,K,`←`,`\\gets`),z(B,H,K,`>`,`\\gt`,!0),z(B,H,K,`∈`,`\\in`,!0),z(B,H,K,``,`\\@not`),z(B,H,K,`⊂`,`\\subset`,!0),z(B,H,K,`⊃`,`\\supset`,!0),z(B,H,K,`⊆`,`\\subseteq`,!0),z(B,H,K,`⊇`,`\\supseteq`,!0),z(B,U,K,`⊈`,`\\nsubseteq`,!0),z(B,U,K,`⊉`,`\\nsupseteq`,!0),z(B,H,K,`⊨`,`\\models`),z(B,H,K,`←`,`\\leftarrow`,!0),z(B,H,K,`≤`,`\\le`),z(B,H,K,`≤`,`\\leq`,!0),z(B,H,K,`<`,`\\lt`,!0),z(B,H,K,`→`,`\\rightarrow`,!0),z(B,H,K,`→`,`\\to`),z(B,U,K,`≱`,`\\ngeq`,!0),z(B,U,K,`≰`,`\\nleq`,!0),z(B,H,KN,`\xA0`,`\\ `),z(B,H,KN,`\xA0`,`\\space`),z(B,H,KN,`\xA0`,`\\nobreakspace`),z(V,H,KN,`\xA0`,`\\ `),z(V,H,KN,`\xA0`,` `),z(V,H,KN,`\xA0`,`\\space`),z(V,H,KN,`\xA0`,`\\nobreakspace`),z(B,H,KN,``,`\\nobreak`),z(B,H,KN,``,`\\allowbreak`),z(B,H,GN,`,`,`,`),z(B,H,GN,`;`,`;`),z(B,U,W,`⊼`,`\\barwedge`,!0),z(B,U,W,`⊻`,`\\veebar`,!0),z(B,H,W,`⊙`,`\\odot`,!0),z(B,H,W,`⊕`,`\\oplus`,!0),z(B,H,W,`⊗`,`\\otimes`,!0),z(B,H,q,`∂`,`\\partial`,!0),z(B,H,W,`⊘`,`\\oslash`,!0),z(B,U,W,`⊚`,`\\circledcirc`,!0),z(B,U,W,`⊡`,`\\boxdot`,!0),z(B,H,W,`△`,`\\bigtriangleup`),z(B,H,W,`▽`,`\\bigtriangledown`),z(B,H,W,`†`,`\\dagger`),z(B,H,W,`⋄`,`\\diamond`),z(B,H,W,`⋆`,`\\star`),z(B,H,W,`◃`,`\\triangleleft`),z(B,H,W,`▹`,`\\triangleright`),z(B,H,WN,`{`,`\\{`),z(V,H,q,`{`,`\\{`),z(V,H,q,`{`,`\\textbraceleft`),z(B,H,VN,`}`,`\\}`),z(V,H,q,`}`,`\\}`),z(V,H,q,`}`,`\\textbraceright`),z(B,H,WN,`{`,`\\lbrace`),z(B,H,VN,`}`,`\\rbrace`),z(B,H,WN,`[`,`\\lbrack`,!0),z(V,H,q,`[`,`\\lbrack`,!0),z(B,H,VN,`]`,`\\rbrack`,!0),z(V,H,q,`]`,`\\rbrack`,!0),z(B,H,WN,`(`,`\\lparen`,!0),z(B,H,VN,`)`,`\\rparen`,!0),z(V,H,q,`<`,`\\textless`,!0),z(V,H,q,`>`,`\\textgreater`,!0),z(B,H,WN,`⌊`,`\\lfloor`,!0),z(B,H,VN,`⌋`,`\\rfloor`,!0),z(B,H,WN,`⌈`,`\\lceil`,!0),z(B,H,VN,`⌉`,`\\rceil`,!0),z(B,H,q,`\\`,`\\backslash`),z(B,H,q,`∣`,`|`),z(B,H,q,`∣`,`\\vert`),z(V,H,q,`|`,`\\textbar`,!0),z(B,H,q,`∥`,`\\|`),z(B,H,q,`∥`,`\\Vert`),z(V,H,q,`∥`,`\\textbardbl`),z(V,H,q,`~`,`\\textasciitilde`),z(V,H,q,`\\`,`\\textbackslash`),z(V,H,q,`^`,`\\textasciicircum`),z(B,H,K,`↑`,`\\uparrow`,!0),z(B,H,K,`⇑`,`\\Uparrow`,!0),z(B,H,K,`↓`,`\\downarrow`,!0),z(B,H,K,`⇓`,`\\Downarrow`,!0),z(B,H,K,`↕`,`\\updownarrow`,!0),z(B,H,K,`⇕`,`\\Updownarrow`,!0),z(B,H,UN,`∐`,`\\coprod`),z(B,H,UN,`⋁`,`\\bigvee`),z(B,H,UN,`⋀`,`\\bigwedge`),z(B,H,UN,`⨄`,`\\biguplus`),z(B,H,UN,`⋂`,`\\bigcap`),z(B,H,UN,`⋃`,`\\bigcup`),z(B,H,UN,`∫`,`\\int`),z(B,H,UN,`∫`,`\\intop`),z(B,H,UN,`∬`,`\\iint`),z(B,H,UN,`∭`,`\\iiint`),z(B,H,UN,`∏`,`\\prod`),z(B,H,UN,`∑`,`\\sum`),z(B,H,UN,`⨂`,`\\bigotimes`),z(B,H,UN,`⨁`,`\\bigoplus`),z(B,H,UN,`⨀`,`\\bigodot`),z(B,H,UN,`∮`,`\\oint`),z(B,H,UN,`∯`,`\\oiint`),z(B,H,UN,`∰`,`\\oiiint`),z(B,H,UN,`⨆`,`\\bigsqcup`),z(B,H,UN,`∫`,`\\smallint`),z(V,H,HN,`…`,`\\textellipsis`),z(B,H,HN,`…`,`\\mathellipsis`),z(V,H,HN,`…`,`\\ldots`,!0),z(B,H,HN,`…`,`\\ldots`,!0),z(B,H,HN,`⋯`,`\\@cdots`,!0),z(B,H,HN,`⋱`,`\\ddots`,!0),z(B,H,q,`⋮`,`\\varvdots`),z(V,H,q,`⋮`,`\\varvdots`),z(B,H,BN,`ˊ`,`\\acute`),z(B,H,BN,`ˋ`,`\\grave`),z(B,H,BN,`¨`,`\\ddot`),z(B,H,BN,`~`,`\\tilde`),z(B,H,BN,`ˉ`,`\\bar`),z(B,H,BN,`˘`,`\\breve`),z(B,H,BN,`ˇ`,`\\check`),z(B,H,BN,`^`,`\\hat`),z(B,H,BN,`⃗`,`\\vec`),z(B,H,BN,`˙`,`\\dot`),z(B,H,BN,`˚`,`\\mathring`),z(B,H,G,``,`\\@imath`),z(B,H,G,``,`\\@jmath`),z(B,H,q,`ı`,`ı`),z(B,H,q,`ȷ`,`ȷ`),z(V,H,q,`ı`,`\\i`,!0),z(V,H,q,`ȷ`,`\\j`,!0),z(V,H,q,`ß`,`\\ss`,!0),z(V,H,q,`æ`,`\\ae`,!0),z(V,H,q,`œ`,`\\oe`,!0),z(V,H,q,`ø`,`\\o`,!0),z(V,H,q,`Æ`,`\\AE`,!0),z(V,H,q,`Œ`,`\\OE`,!0),z(V,H,q,`Ø`,`\\O`,!0),z(V,H,BN,`ˊ`,`\\'`),z(V,H,BN,`ˋ`,"\\`"),z(V,H,BN,`ˆ`,`\\^`),z(V,H,BN,`˜`,`\\~`),z(V,H,BN,`ˉ`,`\\=`),z(V,H,BN,`˘`,`\\u`),z(V,H,BN,`˙`,`\\.`),z(V,H,BN,`¸`,`\\c`),z(V,H,BN,`˚`,`\\r`),z(V,H,BN,`ˇ`,`\\v`),z(V,H,BN,`¨`,`\\"`),z(V,H,BN,`˝`,`\\H`),z(V,H,BN,`◯`,`\\textcircled`);var qN={"--":!0,"---":!0,"``":!0,"''":!0};z(V,H,q,`–`,`--`,!0),z(V,H,q,`–`,`\\textendash`),z(V,H,q,`—`,`---`,!0),z(V,H,q,`—`,`\\textemdash`),z(V,H,q,`‘`,"`",!0),z(V,H,q,`‘`,`\\textquoteleft`),z(V,H,q,`’`,`'`,!0),z(V,H,q,`’`,`\\textquoteright`),z(V,H,q,`“`,"``",!0),z(V,H,q,`“`,`\\textquotedblleft`),z(V,H,q,`”`,`''`,!0),z(V,H,q,`”`,`\\textquotedblright`),z(B,H,q,`°`,`\\degree`,!0),z(V,H,q,`°`,`\\degree`),z(V,H,q,`°`,`\\textdegree`,!0),z(B,H,q,`£`,`\\pounds`),z(B,H,q,`£`,`\\mathsterling`,!0),z(V,H,q,`£`,`\\pounds`),z(V,H,q,`£`,`\\textsterling`,!0),z(B,U,q,`✠`,`\\maltese`),z(V,U,q,`✠`,`\\maltese`);for(var JN=`0123456789/@."`,YN=0;YN{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return SP[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return CP[Math.floor((r-120782)/10)];if(r===120485||r===120486)return SP[0];if(120486{if(hN(e.classes)!==hN(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||e.italic!==0&&e.hasClass(`mathnormal`))return!1;if(e.classes.length===1){var n=e.classes[0];if(n===`mbin`||n===`mord`)return!1}for(var r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(var i of Object.keys(t.style))if(e.style[i]!==t.style[i])return!1;return!0},jP=e=>{for(var t=0;tt&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>r&&(r=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=r},Y=function(e,t,n,r){var i=new xN(e,t,n,r);return MP(i),i},NP=(e,t,n,r)=>new xN(e,t,n,r),PP=function(e,t,n){var r=Y([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=R(r.height),r.maxFontSize=1,r},FP=function(e,t,n,r){var i=new SN(e,t,n,r);return MP(i),i},IP=function(e){var t=new uN(e);return MP(t),t},LP=function(e,t){return e instanceof uN?Y([],[e],t):e},RP=function(e){if(e.positionType===`individualShift`){for(var t=e.children,n=[t[0]],r=-t[0].shift-t[0].elem.depth,i=r,a=1;a{var n=Y([`mspace`],[],t),r=mN(e,t);return n.style.marginRight=R(r),n},VP=(e,t,n)=>{var r,i;switch(e){case`amsrm`:r=`AMS`;break;case`textrm`:r=`Main`;break;case`textsf`:r=`SansSerif`;break;case`texttt`:r=`Typewriter`;break;default:r=e}return i=t===`textbf`&&n===`textit`?`BoldItalic`:t===`textbf`?`Bold`:n===`textit`?`Italic`:`Regular`,r+`-`+i},HP={mathbf:{variant:`bold`,fontName:`Main-Bold`},mathrm:{variant:`normal`,fontName:`Main-Regular`},textit:{variant:`italic`,fontName:`Main-Italic`},mathit:{variant:`italic`,fontName:`Main-Italic`},mathnormal:{variant:`italic`,fontName:`Math-Italic`},mathsfit:{variant:`sans-serif-italic`,fontName:`SansSerif-Italic`},mathbb:{variant:`double-struck`,fontName:`AMS-Regular`},mathcal:{variant:`script`,fontName:`Caligraphic-Regular`},mathfrak:{variant:`fraktur`,fontName:`Fraktur-Regular`},mathscr:{variant:`script`,fontName:`Script-Regular`},mathsf:{variant:`sans-serif`,fontName:`SansSerif-Regular`},mathtt:{variant:`monospace`,fontName:`Typewriter-Regular`}},UP={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},WP=function(e,t){var n=UP[e],r=n[0],i=n[1],a=n[2],o=NP([`katex-overlay`],[new EN([new DN(r)],{width:R(i),height:R(a),style:`width:`+R(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=R(a),o.style.width=R(i),o},GP={number:3,unit:`mu`},KP={number:4,unit:`mu`},qP={number:5,unit:`mu`},JP={mord:{mop:GP,mbin:KP,mrel:qP,minner:GP},mop:{mord:GP,mop:GP,mrel:qP,minner:GP},mbin:{mord:KP,mop:KP,mopen:KP,minner:KP},mrel:{mord:qP,mop:qP,mopen:qP,minner:qP},mopen:{},mclose:{mop:GP,mbin:KP,mrel:qP,minner:GP},mpunct:{mord:GP,mop:GP,mrel:qP,mopen:GP,mclose:GP,mpunct:GP,minner:GP},minner:{mord:GP,mop:GP,mbin:KP,mrel:qP,mopen:GP,mpunct:GP,minner:GP}},YP={mord:{mop:GP},mop:{mord:GP,mop:GP},mbin:{},mrel:{},mopen:{},mclose:{mop:GP},mpunct:{},minner:{mop:GP}},XP={},ZP={},QP={};function X(e){for(var t=e.type,n=e.names,r=e.htmlBuilder,i=e.mathmlBuilder,a=0;a{var n=t.classes[0],r=e.classes[0];n===`mbin`&&rF.has(r)?t.classes[0]=`mord`:r===`mbin`&&nF.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),sF(i,(e,t)=>{var n=uF(t),r=uF(e),i=n&&r?e.hasClass(`mtight`)?YP[n]?.[r]:JP[n]?.[r]:null;if(i)return BP(i,c)},{node:u},d,f),i},sF=function(e,t,n,r,i){r&&e.push(r);for(var a=0;an=>{e.splice(t+1,0,n),a++})(a)}}r&&e.pop()},cF=function(e){return e instanceof uN||e instanceof SN||e instanceof xN&&e.hasClass(`enclosing`)?e:null},lF=function(e,t){var n=cF(e);if(n){var r=n.children;if(r.length){if(t===`right`)return lF(r[r.length-1],`right`);if(t===`left`)return lF(r[0],`left`)}}return e},uF=function(e,t){return e?(t&&(e=lF(e,t)),aF[e.classes[0]]||null):null},dF=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return Y(t.concat(n))},fF=function(e,t,n){if(!e)return Y();if(ZP[e.type]){var r=ZP[e.type](e,t);if(n&&t.size!==n.size){r=Y(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new I(`Got group of unknown type: '`+e.type+`'`)};function pF(e,t){var n=Y([`katex-base`],e,t),r=Y([`katex-strut`]);return r.style.height=R(n.height+n.depth),n.depth&&(r.style.verticalAlign=R(-n.depth)),n.children.unshift(r),n}function mF(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=oF(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(pF(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(pF(o,t));var l;n?(l=pF(oF(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=Y([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=R(u.height+u.depth),u.depth&&(d.style.verticalAlign=R(-u.depth))}return u}function hF(e){return new uN(e)}var Z=class{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e.setAttribute(n,r)}this.classes.length>0&&(e.className=hN(this.classes));for(var i=0;i0&&(e+=` class ="`+bM(hN(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},gF=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return bM(this.toText())}toText(){return this.text}},_F=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:e>=-.05556&&e<=-.05555?` ⁣`:e>=-.1667&&e<=-.1666?` ⁣`:e>=-.2223&&e<=-.2222?` ⁣`:e>=-.2778&&e<=-.2777?` ⁣`:null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mspace`);return e.setAttribute(`width`,R(this.width)),e}toMarkup(){return this.character?``+this.character+``:``}toText(){return this.character?this.character:` `}},vF=new Set([`\\imath`,`\\jmath`]),yF=new Set([`mrow`,`mtable`]),bF=function(e,t,n){var r,i;return zN[t][e]&&zN[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(qN,e)||(n==null||(r=n.fontFamily)==null?void 0:r.slice(4,6))!==`tt`&&(n==null||(i=n.font)==null?void 0:i.slice(4,6))!==`tt`)&&(e=zN[t][e].replace),new gF(e)},xF=function(e){return e.length===1?e[0]:new Z(`mrow`,e)},SF={mathit:`italic`,boldsymbol:e=>e.type===`textord`?`bold`:`bold-italic`,mathbf:`bold`,mathbb:`double-struck`,mathsfit:`sans-serif-italic`,mathfrak:`fraktur`,mathscr:`script`,mathcal:`script`,mathsf:`sans-serif`,mathtt:`monospace`},CF=(e,t)=>{if(e.mode===`text`){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`bold-sans-serif`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`}var n=t.font;if(!n||n===`mathnormal`)return null;var r=e.mode,i=SF[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(vF.has(a))return null;if(zN[r][a]){var o=zN[r][a].replace;o&&(a=o)}var s=HP[n].fontName;return IN(a,s,r)?HP[n].variant:null};function wF(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof gF&&t.text===`.`}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){var n=e.children[0];return n instanceof gF&&n.text===`,`}return!1}var TF=function(e,t,n){if(e.length===1){var r=DF(e[0],t);return n&&r instanceof Z&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o=1&&(a.type===`mn`||wF(a))){var c=s.children[0];c instanceof Z&&c.type===`mn`&&(c.children=[...a.children,...c.children],i.pop())}else if(a.type===`mi`&&a.children.length===1){var l=a.children[0];if(l instanceof gF&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof gF&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},EF=function(e,t,n){return xF(TF(e,t,n))},DF=function(e,t){if(!e)return new Z(`mrow`);if(QP[e.type])return QP[e.type](e,t);throw new I(`Got group of unknown type: '`+e.type+`'`)};function OF(e,t,n,r,i){var a=TF(e,n),o=a.length===1&&a[0]instanceof Z&&yF.has(a[0].type)?a[0]:new Z(`mrow`,a),s=new Z(`annotation`,[new gF(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new Z(`math`,[new Z(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),Y([i?`katex`:`katex-mathml`],[c])}var kF=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],AF=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],jF=function(e,t){return t.size<2?e:kF[e-1][t.size-1]},MF=class e{constructor(t){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=t.style,this.color=t.color,this.size=t.size||e.BASESIZE,this.textSize=t.textSize||this.size,this.phantom=!!t.phantom,this.font=t.font||``,this.fontFamily=t.fontFamily||``,this.fontWeight=t.fontWeight||``,this.fontShape=t.fontShape||``,this.sizeMultiplier=AF[this.size-1],this.maxSize=t.maxSize,this.minRuleThickness=t.minRuleThickness,this._fontMetrics=void 0}extend(t){var n={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(n,t),new e(n)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:jF(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:AF[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=jF(e.BASESIZE,t);return this.size===n&&this.textSize===e.BASESIZE&&this.style===t?this:this.extend({style:t,size:n})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}sizingClasses(e){return e.size===this.size?[]:[`katex-sizing`,`reset-size`+e.size,`size`+this.size]}baseSizingClasses(){return this.size===e.BASESIZE?[]:[`katex-sizing`,`reset-size`+this.size,`size`+e.BASESIZE]}fontMetrics(){return this._fontMetrics||=RN(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};MF.BASESIZE=6;var NF=function(e){return new MF({style:e.displayMode?L.DISPLAY:L.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},PF=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=Y(n,[e])}return e},FF=function(e,t,n){var r=NF(n),i;return n.output===`mathml`?OF(e,t,r,n.displayMode,!0):(i=n.output===`html`?Y([`katex`],[mF(e,r)]):Y([`katex`],[OF(e,t,r,n.displayMode,!1),mF(e,r)]),PF(i,n))},IF=function(e,t,n){return PF(Y([`katex`],[mF(e,NF(n))]),n)},LF={widehat:`^`,widecheck:`ˇ`,widetilde:`~`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,underbracket:`⎵`,overbracket:`⎴`,overgroup:`⏠`,undergroup:`⏡`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xrightleftharpoons:`⇌`,xleftrightharpoons:`⇋`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xtofrom:`⇄`,xrightleftarrows:`⇄`,xrightequilibrium:`⇌`,xleftequilibrium:`⇋`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`},RF=function(e){var t=new Z(`mo`,[new gF(LF[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},zF={overrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],overleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],underrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],underleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],xrightarrow:[[`rightarrow`],1.469,522,`xMaxYMin`],"\\cdrightarrow":[[`rightarrow`],3,522,`xMaxYMin`],xleftarrow:[[`leftarrow`],1.469,522,`xMinYMin`],"\\cdleftarrow":[[`leftarrow`],3,522,`xMinYMin`],Overrightarrow:[[`doublerightarrow`],.888,560,`xMaxYMin`],xRightarrow:[[`doublerightarrow`],1.526,560,`xMaxYMin`],xLeftarrow:[[`doubleleftarrow`],1.526,560,`xMinYMin`],overleftharpoon:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoonup:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoondown:[[`leftharpoondown`],.888,522,`xMinYMin`],overrightharpoon:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoonup:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoondown:[[`rightharpoondown`],.888,522,`xMaxYMin`],xlongequal:[[`longequal`],.888,334,`xMinYMin`],"\\cdlongequal":[[`longequal`],3,334,`xMinYMin`],xtwoheadleftarrow:[[`twoheadleftarrow`],.888,334,`xMinYMin`],xtwoheadrightarrow:[[`twoheadrightarrow`],.888,334,`xMaxYMin`],overleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],overbrace:[[`leftbrace`,`midbrace`,`rightbrace`],1.6,548],underbrace:[[`leftbraceunder`,`midbraceunder`,`rightbraceunder`],1.6,548],underleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],xleftrightarrow:[[`leftarrow`,`rightarrow`],1.75,522],xLeftrightarrow:[[`doubleleftarrow`,`doublerightarrow`],1.75,560],xrightleftharpoons:[[`leftharpoondownplus`,`rightharpoonplus`],1.75,716],xleftrightharpoons:[[`leftharpoonplus`,`rightharpoondownplus`],1.75,716],xhookleftarrow:[[`leftarrow`,`righthook`],1.08,522],xhookrightarrow:[[`lefthook`,`rightarrow`],1.08,522],overlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],underlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],overbracket:[[`leftbracketover`,`rightbracketover`],1.6,440],underbracket:[[`leftbracketunder`,`rightbracketunder`],1.6,410],overgroup:[[`leftgroup`,`rightgroup`],.888,342],undergroup:[[`leftgroupunder`,`rightgroupunder`],.888,342],xmapsto:[[`leftmapsto`,`rightarrow`],1.5,522],xtofrom:[[`leftToFrom`,`rightToFrom`],1.75,528],xrightleftarrows:[[`baraboveleftarrow`,`rightarrowabovebar`],1.75,901],xrightequilibrium:[[`baraboveshortleftharpoon`,`rightharpoonaboveshortbar`],1.75,716],xleftequilibrium:[[`shortbaraboveleftharpoon`,`shortrightharpoonabovebar`],1.75,716]},BF=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),VF=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(BF.has(r)&&`base`in e){var i=e.base.type===`ordgroup`?e.base.body.length:1,a,o,s;if(i>5)r===`widehat`||r===`widecheck`?(a=420,n=2364,s=.42,o=r+`4`):(a=312,n=2340,s=.34,o=`tilde4`);else{var c=[1,1,2,2,3,3][i];r===`widehat`||r===`widecheck`?(n=[0,1062,2364,2364,2364][c],a=[0,239,300,360,420][c],s=[0,.24,.3,.3,.36,.42][c],o=r+c):(n=[0,600,1033,2339,2340][c],a=[0,260,286,306,312][c],s=[0,.26,.286,.3,.306,.34][c],o=`tilde`+c)}return{span:NP([],[new EN([new DN(o)],{width:`100%`,height:R(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=zF[r];if(!u)throw Error(`No SVG data for "`+r+`".`);var d=u[0],f=u[1],p=u[2],m=p/1e3,h=d.length,g,_;if(h===1){if(u.length!==4)throw Error(`Expected 4-tuple for single-path SVG data "`+r+`".`);g=[`hide-tail`],_=[u[3]]}else if(h===2)g=[`halfarrow-left`,`halfarrow-right`],_=[`xMinYMin`,`xMaxYMin`];else if(h===3)g=[`brace-left`,`brace-center`,`brace-right`],_=[`xMinYMin`,`xMidYMin`,`xMaxYMin`];else throw Error(`Correct katexImagesData or update code here to support + `+h+` children.`);for(var v=0;v0&&(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`,`\\xleftrightarrow`,`\\xLeftrightarrow`,`\\xhookleftarrow`,`\\xhookrightarrow`,`\\xmapsto`,`\\xrightharpoondown`,`\\xrightharpoonup`,`\\xleftharpoondown`,`\\xleftharpoonup`,`\\xrightleftharpoons`,`\\xleftrightharpoons`,`\\xlongequal`,`\\xtwoheadrightarrow`,`\\xtwoheadleftarrow`,`\\xtofrom`,`\\xrightleftarrows`,`\\xrightequilibrium`,`\\xleftequilibrium`,`\\\\cdrightarrow`,`\\\\cdleftarrow`,`\\\\cdlongequal`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=e.funcName;return{type:`xArrow`,mode:r.mode,label:i,body:t[0],below:n[0]}},htmlBuilder(e,t){var n=t.style,r=t.havingStyle(n.sup()),i=LP(fF(e.body,r,t),t),a=e.label.slice(0,2)===`\\x`?`x`:`cd`;i.classes.push(a+`-arrow-pad`);var o;e.below&&(r=t.havingStyle(n.sub()),o=LP(fF(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=VF(e,t),c=-t.fontMetrics().axisHeight+.5*s.height,l=-t.fontMetrics().axisHeight-.5*s.height-.111;(i.depth>.25||e.label===`\\xleftequilibrium`)&&(l-=i.depth);var u;if(o){var d=-t.fontMetrics().axisHeight+o.height+.5*s.height+.111;u=zP({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]},{type:`elem`,elem:o,shift:d}]})}else u=zP({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return Y([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=RF(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=tI(DF(e.body,t));r=e.below?new Z(`munderover`,[n,tI(DF(e.below,t)),i]):new Z(`mover`,[n,i])}else e.below?r=new Z(`munder`,[n,tI(DF(e.below,t))]):(r=tI(),r=new Z(`mover`,[n,r]));return r}});function nI(e,t){var n=oF(e.body,t,!0);return Y([e.mclass],n,t)}function rI(e,t){var n,r=TF(e.body,t);return e.mclass===`minner`?n=new Z(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new Z(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new Z(`mo`,r),e.mclass===`mbin`?(n.attributes.lspace=`0.22em`,n.attributes.rspace=`0.22em`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0.17em`):(e.mclass===`mopen`||e.mclass===`mclose`)&&(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`)),n}X({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],numArgs:1,primitive:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`mclass`,mode:n.mode,mclass:`m`+r.slice(5),body:tF(i),isCharacterBox:CM(i)}},htmlBuilder:nI,mathmlBuilder:rI});var iI=e=>{var t=e.type===`ordgroup`&&e.body.length?e.body[0]:e;return t.type===`atom`&&(t.family===`bin`||t.family===`rel`)?`m`+t.family:`mord`};X({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:iI(t[0]),body:tF(t[1]),isCharacterBox:CM(t[1])}}}),X({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],numArgs:2,handler(e,t){var n=e.parser,r=e.funcName,i=t[1],a=t[0],o=r===`\\stackrel`?`mrel`:iI(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:tF(i)},c=r===`\\underset`?{type:`supsub`,mode:a.mode,base:s,sub:a}:{type:`supsub`,mode:a.mode,base:s,sup:a};return{type:`mclass`,mode:n.mode,mclass:o,body:[c],isCharacterBox:CM(c)}}}),X({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:iI(t[0]),body:tF(t[0])}},htmlBuilder(e,t){var n=oF(e.body,t,!0),r=Y([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new Z(`mstyle`,TF(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var aI={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},oI=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),sI=e=>e.type===`textord`&&e.text===`@`,cI=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function lI(e,t,n){var r=aI[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:var i=n.callFunction(`\\\\cdleft`,[t[0]],[]),a={type:`atom`,text:r,mode:`math`,family:`rel`},o={type:`ordgroup`,mode:`math`,body:[i,n.callFunction(`\\Big`,[a],[]),n.callFunction(`\\\\cdright`,[t[1]],[])]};return n.callFunction(`\\\\cdparent`,[o],[]);case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function uI(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();var n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new I(`Expected \\\\ or \\cr or \\end`,e.nextToken)}for(var r=[],i=[r],a=0;aAV`.includes(l))for(var d=0;d<2;d++){for(var f=!0,p=c+1;pAV=|." after @`,o[c])}var m={type:`styling`,body:[lI(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=oI()}a%2==0?r.push(s):r.shift(),r=[],i.push(r)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:Array(i[0].length).fill({type:`align`,align:`c`,pregap:.25,postgap:.25}),colSeparationType:`CD`,hLinesBeforeRow:Array(i.length+1).fill([])}}X({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`cdlabel`,mode:n.mode,side:r.slice(4),label:t[0]}},htmlBuilder(e,t){var n=t.havingStyle(t.style.sup()),r=LP(fF(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=R(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new Z(`mrow`,[DF(e.label,t)]);return n=new Z(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new Z(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),X({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=LP(fF(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Z(`mrow`,[DF(e.fragment,t)])}}),X({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=XF(Q(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new I(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new I(`\\@char with invalid code point `+r);return i<=65535?a=String.fromCharCode(i):(i-=65536,a=String.fromCharCode((i>>10)+55296,(i&1023)+56320)),{type:`textord`,mode:n.mode,text:a}}}),X({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=Q(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:tF(i)}},htmlBuilder:(e,t)=>IP(oF(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Z(`mstyle`,TF(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),X({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=Q(t[0],`color-token`).color;n.gullet.macros.set(`\\current@color`,i);var a=n.parseExpression(!0,r);return{type:`color`,mode:n.mode,color:i,body:a}}}),X({type:`cr`,names:[`\\\\`],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,n){var r=e.parser,i=r.gullet.future().text===`[`?r.parseSizeGroup(!0):null,a=!r.settings.displayMode||!r.settings.useStrictBehavior(`newLineInDisplayMode`,`In LaTeX, \\\\ or \\newline does nothing in display mode`);return{type:`cr`,mode:r.mode,newLine:a,size:i&&Q(i,`size`).value}},htmlBuilder(e,t){var n=Y([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=R(mN(e.size,t)))),n},mathmlBuilder(e,t){var n=new Z(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,R(mN(e.size,t)))),n}});var dI={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},fI=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new I(`Expected a control sequence`,e);return t},pI=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},mI=(e,t,n,r)=>{var i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};X({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=e.funcName;t.consumeSpaces();var r=t.fetch();if(dI[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=dI[r.text]),Q(t.parseFunction(),`internal`);throw new I(`Invalid token after macro prefix`,r)}}),X({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=t.gullet.popToken(),i=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new I(`Expected a control sequence`,r);for(var a=0,o,s=[[]];t.gullet.future().text!==`{`;)if(r=t.gullet.popToken(),r.text===`#`){if(t.gullet.future().text===`{`){o=t.gullet.future(),s[a].push(`{`);break}if(r=t.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new I(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new I(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new I(`Expected a macro definition`);else s[a].push(r.text);var c=t.gullet.consumeArg().tokens;return o&&c.unshift(o),(n===`\\edef`||n===`\\xdef`)&&(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(i,{tokens:c,numArgs:a,delimiters:s},n===dI[n]),{type:`internal`,mode:t.mode}}}),X({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=fI(t.gullet.popToken());return t.gullet.consumeSpaces(),mI(t,r,pI(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),X({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=fI(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return mI(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var hI=function(e,t,n){var r=IN(zN.math[e]&&zN.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},gI=function(e,t,n,r){var i=n.havingBaseStyle(t),a=Y(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},_I=function(e,t,n){var r=t.havingBaseStyle(n),i=(1-t.sizeMultiplier/r.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push(`delimcenter`),e.style.top=R(i),e.height-=i,e.depth+=i},vI=function(e,t,n,r,i,a){var o=gI(EP(e,`Main-Regular`,i,r),t,r,a);return n&&_I(o,r,t),o},yI=function(e,t,n,r){return EP(e,`Size`+t+`-Regular`,n,r)},bI=function(e,t,n,r,i,a){var o=yI(e,t,i,r),s=gI(Y([`delimsizing`,`size`+t],[o],r),L.TEXT,r,a);return n&&_I(s,r,L.TEXT),s},xI=function(e,t,n){return{type:`elem`,elem:Y([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[Y([],[EP(e,t,n)])])}},SI=function(e,t,n){var r=MN[`Size4-Regular`][e.charCodeAt(0)]?MN[`Size4-Regular`][e.charCodeAt(0)][4]:MN[`Size1-Regular`][e.charCodeAt(0)][4],i=NP([],[new EN([new DN(`inner`,oN(e,Math.round(1e3*t)))],{width:R(r),height:R(t),style:`width:`+R(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=R(t),i.style.width=R(r),{type:`elem`,elem:i}},CI=.008,wI={type:`kern`,size:-1*CI},TI=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),EI=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),DI=function(e,t,n,r,i,a){var o,s,c,l,u=``,d=0;o=c=l=e,s=null;var f=`Size1-Regular`;e===`\\uparrow`?c=l=`⏐`:e===`\\Uparrow`?c=l=`‖`:e===`\\downarrow`?o=c=`⏐`:e===`\\Downarrow`?o=c=`‖`:e===`\\updownarrow`?(o=`\\uparrow`,c=`⏐`,l=`\\downarrow`):e===`\\Updownarrow`?(o=`\\Uparrow`,c=`‖`,l=`\\Downarrow`):TI.has(e)?(c=`∣`,u=`vert`,d=333):EI.has(e)?(c=`∥`,u=`doublevert`,d=556):e===`[`||e===`\\lbrack`?(o=`⎡`,c=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lbrack`,d=667):e===`]`||e===`\\rbrack`?(o=`⎤`,c=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rbrack`,d=667):e===`\\lfloor`||e===`⌊`?(c=o=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lfloor`,d=667):e===`\\lceil`||e===`⌈`?(o=`⎡`,c=l=`⎢`,f=`Size4-Regular`,u=`lceil`,d=667):e===`\\rfloor`||e===`⌋`?(c=o=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rfloor`,d=667):e===`\\rceil`||e===`⌉`?(o=`⎤`,c=l=`⎥`,f=`Size4-Regular`,u=`rceil`,d=667):e===`(`||e===`\\lparen`?(o=`⎛`,c=`⎜`,l=`⎝`,f=`Size4-Regular`,u=`lparen`,d=875):e===`)`||e===`\\rparen`?(o=`⎞`,c=`⎟`,l=`⎠`,f=`Size4-Regular`,u=`rparen`,d=875):e===`\\{`||e===`\\lbrace`?(o=`⎧`,s=`⎨`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\}`||e===`\\rbrace`?(o=`⎫`,s=`⎬`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lgroup`||e===`⟮`?(o=`⎧`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\rgroup`||e===`⟯`?(o=`⎫`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lmoustache`||e===`⎰`?(o=`⎧`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):(e===`\\rmoustache`||e===`⎱`)&&(o=`⎫`,l=`⎩`,c=`⎪`,f=`Size4-Regular`);var p=hI(o,f,i),m=p.height+p.depth,h=hI(c,f,i),g=h.height+h.depth,_=hI(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=hI(s,f,i);y=x.height+x.depth,b=2}var S=m+v+y,ee=S+Math.max(0,Math.ceil((t-S)/(b*g)))*b*g,te=r.fontMetrics().axisHeight;n&&(te*=r.sizeMultiplier);var ne=ee/2-te,re=[];if(u.length>0){var ie=ee-m-v,ae=Math.round(ee*1e3),oe=cN(u,Math.round(ie*1e3)),se=new DN(u,oe),ce=R(d/1e3),le=R(ae/1e3),ue=NP([],[new EN([se],{width:ce,height:le,viewBox:`0 0 `+d+` `+ae})],r);ue.height=ae/1e3,ue.style.width=ce,ue.style.height=le,re.push({type:`elem`,elem:ue})}else{if(re.push(xI(l,f,i)),re.push(wI),s===null){var de=ee-m-v+2*CI;re.push(SI(c,de,r))}else{var fe=(ee-m-v-y)/2+2*CI;re.push(SI(c,fe,r)),re.push(wI),re.push(xI(s,f,i)),re.push(wI),re.push(SI(c,fe,r))}re.push(wI),re.push(xI(o,f,i))}var pe=r.havingBaseStyle(L.TEXT);return gI(Y([`delimsizing`,`mult`],[zP({positionType:`bottom`,positionData:ne,children:re})],pe),L.TEXT,r,a)},OI=80,kI=.08,AI=function(e,t,n,r,i){return NP([`hide-tail`],[new EN([new DN(e,aN(e,r,n))],{width:`400em`,height:R(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},jI=function(e,t){var n=t.havingBaseSizing(),r=VI(`\\surd`,e*n.sizeMultiplier,zI,n),i=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,s,c,l,u;return r.type===`small`?(l=1e3+1e3*a+OI,e<1?i=1:e<1.4&&(i=.7),s=(1+a+kI)/i,c=(1+a)/i,o=AI(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+OI)*FI[r.size],c=(FI[r.size]+a)/i,s=(FI[r.size]+a+kI)/i,o=AI(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+kI,c=e+a,l=Math.floor(1e3*e+a)+OI,o=AI(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=R(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},MI=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),NI=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),PI=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),FI=[0,1.2,1.8,2.4,3],II=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),MI.has(e)||PI.has(e))return bI(e,t,!1,n,r,i);if(NI.has(e))return DI(e,FI[t],!1,n,r,i);throw new I(`Illegal delimiter: '`+e+`'`)},LI=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],RI=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`stack`}],zI=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],BI=function(e){if(e.type===`small`)return`Main-Regular`;if(e.type===`large`)return`Size`+e.size+`-Regular`;if(e.type===`stack`)return`Size4-Regular`;var t=e.type;throw Error(`Add support for delim type '`+t+`' here.`)},VI=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},HI=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=PI.has(e)?LI:MI.has(e)?zI:RI,s=VI(e,t,o,r);return s.type===`small`?vI(e,s.style,n,r,i,a):s.type===`large`?bI(e,s.size,n,r,i,a):DI(e,t,n,r,i,a)},UI=function(e,t,n,r,i,a){var o=r.fontMetrics().axisHeight*r.sizeMultiplier,s=901,c=5/r.fontMetrics().ptPerEm,l=Math.max(t-o,n+o);return HI(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},WI={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},GI=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,/,\\backslash,|,\\vert,\\|,\\Vert,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`));function KI(e){return`isMiddle`in e}function qI(e,t){var n=YF(e);if(n&&GI.has(n.text))return n;throw n?new I(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new I(`Invalid delimiter type '`+e.type+`'`,e)}X({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],numArgs:1,argTypes:[`primitive`],handler:(e,t)=>{var n=qI(eF(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:WI[e.funcName].size,mclass:WI[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?Y([e.mclass]):II(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(bF(e.delim,e.mode));var n=new Z(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=R(FI[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function JI(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}X({type:`leftright-right`,names:[`\\right`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser.gullet.macros.get(`\\current@color`);if(n&&typeof n!=`string`)throw new I(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:qI(t[0],e).text,color:n}}}),X({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=qI(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=Q(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{JI(e);for(var n=oF(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{JI(e);var n=TF(e.body,t);if(e.left!==`.`){var r=new Z(`mo`,[bF(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Z(`mo`,[bF(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return xF(n)}}),X({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=qI(t[0],e);if(!e.parser.leftrightDepth)throw new I(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=dF(t,[]):(n=II(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new Z(`mo`,[e.delim===`\\vert`||e.delim===`|`?bF(`|`,`text`):bF(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),X({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Q(t[0],`color-token`).color,o=t[1];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:a,body:o}},htmlBuilder:(e,t)=>{var n=LP(fF(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=CM(e.body);if(r===`sout`)a=Y([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=mN({number:.6,unit:`pt`},t),l=mN({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=R(d/2+c);var f=Math.floor(1e3*d*i);a=NP([`hide-tail`],[new EN([new DN(`phase`,rN(f))],{width:`400em`,height:R(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=R(d),o=n.depth+c+l}else{/cancel/.test(r)?s||n.classes.push(`cancel-pad`):r===`angl`?n.classes.push(`anglpad`):n.classes.push(`boxpad`);var p,m,h=0;/box/.test(r)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),p=t.fontMetrics().fboxsep+(r===`colorbox`?0:h),m=p):r===`angl`?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),p=4*h,m=Math.max(0,.25-n.depth)):(p=s?.2:0,m=p),a=HF(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=R(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=R(h),a.style.borderRightWidth=R(h)),o=n.depth+m,e.backgroundColor&&(a.style.backgroundColor=e.backgroundColor,e.borderColor&&(a.style.borderColor=e.borderColor))}var g;if(e.backgroundColor)g=zP({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=zP({positionType:`individualShift`,children:[{type:`elem`,elem:n,shift:0},{type:`elem`,elem:a,shift:o,wrapperClasses:_}]})}return/cancel/.test(r)&&(g.height=n.height,g.depth=n.depth),/cancel/.test(r)&&!s?Y([`mord`,`cancel-lap`],[g],t):Y([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new Z(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[DF(e.body,t)]);switch(e.label){case`\\cancel`:r.setAttribute(`notation`,`updiagonalstrike`);break;case`\\bcancel`:r.setAttribute(`notation`,`downdiagonalstrike`);break;case`\\phase`:r.setAttribute(`notation`,`phasorangle`);break;case`\\sout`:r.setAttribute(`notation`,`horizontalstrike`);break;case`\\fbox`:r.setAttribute(`notation`,`box`);break;case`\\angl`:r.setAttribute(`notation`,`actuarial`);break;case`\\fcolorbox`:case`\\colorbox`:if(n=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,r.setAttribute(`width`,`+`+2*n+`pt`),r.setAttribute(`height`,`+`+2*n+`pt`),r.setAttribute(`lspace`,n+`pt`),r.setAttribute(`voffset`,n+`pt`),e.label===`\\fcolorbox`){var i=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);r.setAttribute(`style`,`border: `+R(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),X({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=Q(t[0],`color-token`).color,o=Q(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),X({type:`enclose`,names:[`\\fbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\fbox`,body:t[0]}}}),X({type:`enclose`,names:[`\\cancel`,`\\bcancel`,`\\xcancel`,`\\phase`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),X({type:`enclose`,names:[`\\sout`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName;n.mode===`math`&&n.settings.reportNonstrict(`mathVsSout`,`LaTeX's \\sout works only in text mode`);var i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),X({type:`enclose`,names:[`\\angl`],numArgs:1,argTypes:[`hbox`],allowedInText:!1,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\angl`,body:t[0]}}});var YI={};function XI(e){for(var t=e.type,n=e.names,r=e.props,i=e.handler,a=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},c=0;c{if(!e.parser.settings.displayMode)throw new I(`{`+e.envName+`} can be used only in display mode.`)},nL=new Set([`gather`,`gather*`]);function rL(e){if(!e.includes(`ed`))return!e.includes(`*`)}function iL(e,t,n){var r=t.hskipBeforeAndAfter,i=t.addJot,a=t.cols,o=t.arraystretch,s=t.colSeparationType,c=t.autoTag,l=t.singleRow,u=t.emptySingleRow,d=t.maxNumCols,f=t.leqno;if(e.gullet.beginGroup(),l||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),!o){var p=e.gullet.expandMacroAsText(`\\arraystretch`);if(p==null)o=1;else if(o=parseFloat(p),!o||o<0)throw new I(`Invalid \\arraystretch: `+p)}e.gullet.beginGroup();var m=[],h=[m],g=[],_=[],v=c==null?void 0:[];function y(){c&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function b(){v&&(e.gullet.macros.get(`\\df@tag`)?(v.push(e.subparse([new $I(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(eL(e));;){var x=e.parseExpression(!1,l?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup();var S={type:`ordgroup`,mode:e.mode,body:x};n&&(S={type:`styling`,mode:e.mode,style:n,resetFont:!0,body:[S]}),m.push(S);var ee=e.fetch().text;if(ee===`&`){if(d&&m.length===d){if(l||s)throw new I(`Too many tab characters: &`,e.nextToken);e.settings.reportNonstrict(`textEnv`,`Too few columns specified in the {array} column argument.`)}e.consume()}else if(ee===`\\end`){b(),m.length===1&&S.type===`styling`&&S.body.length===1&&S.body[0].type===`ordgroup`&&S.body[0].body.length===0&&(h.length>1||!u)&&!Array.isArray(v?.[v.length-1])&&!(c&&v?.[v.length-1]===!0)&&h.pop(),_.length0&&(_+=.25),c.push({pos:_,isDashed:e[t]})}for(v(a[0]),n=0;n0&&(ne+=g,xe))for(n=0;n=o)){var ye=void 0;(r>0||e.hskipBeforeAndAfter)&&(ye=pe?.pregap??d,ye!==0&&(oe=Y([`arraycolsep`],[]),oe.style.width=R(ye),ae.push(oe)));var be=[];for(n=0;n0){for(var De=PP(`katex-hline`,t,l),Oe=PP(`katex-hdashline`,t,l),ke=[{type:`elem`,elem:Ee,shift:0}];c.length>0;){var Ae=c.pop(),je=Ae.pos-re;Ae.isDashed?ke.push({type:`elem`,elem:Oe,shift:je}):ke.push({type:`elem`,elem:De,shift:je})}Ee=zP({positionType:`individualShift`,children:ke})}if(ce.length===0)return Y([`mord`],[Ee],t);var Me=Y([`katex-tag`],[zP({positionType:`individualShift`,children:ce})],t);return IP([Ee,Me])},sL={c:`center `,l:`left `,r:`right `},cL=function(e,t){for(var n=[],r=new Z(`mtd`,[],[`mtr-glue`]),i=new Z(`mtd`,[],[`mml-eqn-num`]),a=0;a0){var p=e.cols,m=``,h=!1,g=0,_=p.length;p[0].type===`separator`&&(d+=`top `,g=1),p[p.length-1].type===`separator`&&(d+=`bottom `,--_);for(var v=g;v<_;v++){var y=p[v];y.type===`align`?(f+=sL[y.align],h&&(m+=`none `),h=!0):y.type===`separator`&&(h&&=(m+=y.separator===`|`?`solid `:`dashed `,!1))}l.setAttribute(`columnalign`,f.trim()),/[sd]/.test(m)&&l.setAttribute(`columnlines`,m.trim())}if(e.colSeparationType===`align`){for(var b=e.cols||[],x=``,S=1;S0?`left `:``,d+=te[te.length-1].length>0?`right `:``;for(var ne=1;ne0&&u&&(p=1),n[d]={type:`align`,align:f,pregap:p,postgap:0}}return i.colSeparationType=u?`align`:`alignat`,i};XI({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(YF(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=JF(e).text;if(`lcr`.includes(t))return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new I(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return iL(e.parser,r,aL(e.envName))},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={hskipBeforeAndAfter:!1,cols:[{type:`align`,align:n}]};if(e.envName.charAt(e.envName.length-1)===`*`){var i=e.parser;if(i.consumeSpaces(),i.fetch().text===`[`){if(i.consume(),i.consumeSpaces(),n=i.fetch().text,!`lcr`.includes(n))throw new I(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=iL(e.parser,r,aL(e.envName)),o=Math.max(0,...a.body.map(e=>e.length));return a.cols=Array(o).fill({type:`align`,align:n}),t?{type:`leftright`,mode:e.mode,body:[a],left:t[0],right:t[1],rightColor:void 0}:a},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=iL(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(YF(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=JF(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new I(`Unknown column alignment: `+t,e)});if(n.length>1)throw new I(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=iL(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new I(`{subarray} can contain only one column`);return i},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=iL(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},aL(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:lL,htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){nL.has(e.envName)&&tL(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:rL(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return iL(e.parser,t,`display`)},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:lL,htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){tL(e);var t={autoTag:rL(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return iL(e.parser,t,`display`)},htmlBuilder:oL,mathmlBuilder:cL}),XI({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return tL(e),uI(e.parser)},htmlBuilder:oL,mathmlBuilder:cL}),$(`\\nonumber`,`\\gdef\\@eqnsw{0}`),$(`\\notag`,`\\nonumber`),X({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new I(e.funcName+` valid only within array environment`)}});var uL=YI;X({type:`environment`,names:[`\\begin`,`\\end`],numArgs:1,argTypes:[`text`],handler(e,t){var n=e.parser,r=e.funcName,i=t[0];if(i.type!==`ordgroup`)throw new I(`Invalid environment name`,i);var a=XF(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(uL,a))throw new I(`No such environment: `+a,i);var o=uL[a],s=n.parseArguments(`\\begin{`+a+`}`,o),c=s.args,l=s.optArgs,u={mode:n.mode,envName:a,parser:n},d=o.handler(u,c,l);n.expect(`\\end`,!1);var f=n.nextToken,p=Q(n.parseFunction(),`environment`);if(p.name!==a)throw new I(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var dL=(e,t)=>{var n=e.font,r=t.withFont(n);return fF(e.body,r)},fL=(e,t)=>{var n=e.font,r=t.withFont(n);return DF(e.body,r)},pL={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};X({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\mathsfit`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathtt`,`\\Bbb`,`\\bold`,`\\frak`],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=eF(t[0]),a=r in pL?pL[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:dL,mathmlBuilder:fL}),X({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:iI(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:CM(r)}}}),X({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=e.breakOnTokenText,a=n.mode,o=n.parseExpression(!0,i);return{type:`font`,mode:a,font:`math`+r.slice(1),body:{type:`ordgroup`,mode:n.mode,body:o}}}});var mL=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=fF(e.numer,a,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,c=3.5/t.fontMetrics().ptPerEm;o.height=o.height0?3*f:7*f,h=t.fontMetrics().denom1):(d>0?(p=t.fontMetrics().num2,m=f):(p=t.fontMetrics().num3,m=3*f),h=t.fontMetrics().denom2);var g;if(u){var _=t.fontMetrics().axisHeight;p-o.depth-(_+.5*d){var n=new Z(`mfrac`,[DF(e.numer,t),DF(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=mN(e.barSize,t);n.setAttribute(`linethickness`,R(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new Z(`mo`,[new gF(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Z(`mo`,[new gF(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return xF(i)}return n},gL=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;X({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0],a=t[1],o,s=null,c=null;switch(r){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:o=!0;break;case`\\\\atopfrac`:o=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=!1,s=`(`,c=`)`;break;case`\\\\bracefrac`:o=!1,s=`\\{`,c=`\\}`;break;case`\\\\brackfrac`:o=!1,s=`[`,c=`]`;break;default:throw Error(`Unrecognized genfrac command`)}var l=r===`\\cfrac`,u=null;return l||r.startsWith(`\\d`)?u=`display`:r.startsWith(`\\t`)&&(u=`text`),gL({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:mL,mathmlBuilder:hL}),X({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],numArgs:0,infix:!0,handler(e){var t=e.parser,n=e.funcName,r=e.token,i;switch(n){case`\\over`:i=`\\frac`;break;case`\\choose`:i=`\\binom`;break;case`\\atop`:i=`\\\\atopfrac`;break;case`\\brace`:i=`\\\\bracefrac`;break;case`\\brack`:i=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:t.mode,replaceWith:i,token:r}}});var _L=[`display`,`text`,`script`,`scriptscript`],vL=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};X({type:`genfrac`,names:[`\\genfrac`],numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`],handler(e,t){var n=e.parser,r=t[4],i=t[5],a=eF(t[0]),o=a.type===`atom`&&a.family===`open`?vL(a.text):null,s=eF(t[1]),c=s.type===`atom`&&s.family===`close`?vL(s.text):null,l=Q(t[2],`size`),u,d=null;l.isBlank?u=!0:(d=l.value,u=d.number>0);var f=null,p=t[3];if(p.type===`ordgroup`){if(p.body.length>0){var m=Q(p.body[0],`textord`);f=_L[Number(m.text)]}}else p=Q(p,`textord`),f=_L[Number(p.text)];return gL({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),X({type:`infix`,names:[`\\above`],numArgs:1,argTypes:[`size`],infix:!0,handler(e,t){var n=e.parser;e.funcName;var r=e.token;return{type:`infix`,mode:n.mode,replaceWith:`\\\\abovefrac`,size:Q(t[0],`size`).value,token:r}}}),X({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=Q(t[1],`infix`).size;if(!i)throw Error(`\\\\abovefrac expected size, but got `+String(i));var a=t[2],o=i.number>0;return{type:`genfrac`,mode:n.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null}}});var yL=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?fF(e.sup,t.havingStyle(n.sup()),t):fF(e.sub,t.havingStyle(n.sub()),t),i=Q(e.base,`horizBrace`)):i=Q(e,`horizBrace`);var a=fF(i.base,t.havingBaseStyle(L.DISPLAY)),o=VF(i,t),s=i.isOver?zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):zP({positionType:`bottom`,positionData:a.depth+.1+o.height,children:[{type:`elem`,elem:o,wrapperClasses:[`svg-align`]},{type:`kern`,size:.1},{type:`elem`,elem:a}]});if(r){var c=Y([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):zP({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return Y([`minner`,i.isOver?`mover`:`munder`],[s],t)};X({type:`horizBrace`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`horizBrace`,mode:n.mode,label:r,isOver:r.includes(`\\over`),base:t[0]}},htmlBuilder:yL,mathmlBuilder:(e,t)=>{var n=RF(e.label);return new Z(e.isOver?`mover`:`munder`,[DF(e.base,t),n])}}),X({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=Q(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:tF(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=oF(e.body,t,!1);return FP(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=EF(e.body,t);return n instanceof Z||(n=new Z(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),X({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=Q(t[0],`url`).url;if(!n.settings.isTrusted({command:`\\url`,url:r}))return n.formatUnsupportedCmd(`\\url`);for(var i=[],a=0;a{var n=e.parser,r=e.funcName;e.token;var i=Q(t[0],`raw`).string,a=t[1];n.settings.strict&&n.settings.reportNonstrict(`htmlExtension`,`HTML extension is disabled on strict mode`);var o,s={};switch(r){case`\\htmlClass`:s.class=i,o={command:`\\htmlClass`,class:i};break;case`\\htmlId`:s.id=i,o={command:`\\htmlId`,id:i};break;case`\\htmlStyle`:s.style=i,o={command:`\\htmlStyle`,style:i};break;case`\\htmlData`:for(var c=`{,}`,l=[],u=``,d=0;d{var n=oF(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=Y(r,n,t);for(var a of Object.entries(e.attributes)){var o=a[0],s=a[1];o!==`class`&&i.setAttribute(o,s)}return i},mathmlBuilder:(e,t)=>EF(e.body,t)}),X({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:tF(t[0]),mathml:tF(t[1])}),htmlBuilder:(e,t)=>IP(oF(e.html,t,!1)),mathmlBuilder:(e,t)=>EF(e.mathml,t)});var bL=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new I(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!pN(n))throw new I(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};X({type:`includegraphics`,names:[`\\includegraphics`],numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1,handler:(e,t,n)=>{var r=e.parser,i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(n[0])for(var c=Q(n[0],`raw`).string.split(`,`),l=0;l{var n=mN(e.height,t),r=0;e.totalheight.number>0&&(r=mN(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=mN(e.width,t));var a={height:R(n+r)};i>0&&(a.width=R(i)),r>0&&(a.verticalAlign=R(-r));var o=new CN(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new Z(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=mN(e.height,t),i=0;if(e.totalheight.number>0&&(i=mN(e.totalheight,t)-r,n.setAttribute(`valign`,R(-i))),n.setAttribute(`height`,R(r+i)),e.width.number>0){var a=mN(e.width,t);n.setAttribute(`width`,R(a))}return n.setAttribute(`src`,e.src),n}}),X({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=Q(t[0],`size`);if(n.settings.strict){var a=r[1]===`m`,o=i.value.unit===`mu`;a?(o||n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` supports only mu units, `+(`not `+i.value.unit+` units`)),n.mode!==`math`&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` works only in math mode`)):o&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` doesn't support mu units`)}return{type:`kern`,mode:n.mode,dimension:i.value}},htmlBuilder(e,t){return BP(e.dimension,t)},mathmlBuilder(e,t){return new _F(mN(e.dimension,t))}}),X({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`lap`,mode:n.mode,alignment:r.slice(5),body:i}},htmlBuilder:(e,t)=>{var n;e.alignment===`clap`?(n=Y([],[fF(e.body,t)]),n=Y([`katex-inner`],[n],t)):n=Y([`katex-inner`],[fF(e.body,t)]);var r=Y([`katex-fix`],[]),i=Y([e.alignment],[n,r],t),a=Y([`katex-strut`]);return a.style.height=R(i.height+i.depth),i.depth&&(a.style.verticalAlign=R(-i.depth)),i.children.unshift(a),i=Y([`katex-thinbox`],[i],t),Y([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new Z(`mpadded`,[DF(e.body,t)]);if(e.alignment!==`rlap`){var r=e.alignment===`llap`?`-1`:`-0.5`;n.setAttribute(`lspace`,r+`width`)}return n.setAttribute(`width`,`0px`),n}}),X({type:`styling`,names:[`\\(`,`$`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var n=e.funcName,r=e.parser,i=r.mode;r.switchMode(`math`);var a=n===`\\(`?`\\)`:`$`,o=r.parseExpression(!1,a);return r.expect(a),r.switchMode(i),{type:`styling`,mode:r.mode,style:`text`,resetFont:!0,body:o}}}),X({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new I(`Mismatched `+e.funcName)}});var xL=(e,t)=>{switch(t.style.size){case L.DISPLAY.size:return e.display;case L.TEXT.size:return e.text;case L.SCRIPT.size:return e.script;case L.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};X({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:tF(t[0]),text:tF(t[1]),script:tF(t[2]),scriptscript:tF(t[3])}),htmlBuilder:(e,t)=>IP(oF(xL(e,t),t,!1)),mathmlBuilder:(e,t)=>EF(xL(e,t),t)});var SL=(e,t,n,r,i,a,o)=>{e=Y([],[e]);var s=n&&CM(n),c,l;if(t){var u=fF(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=fF(n,r.havingStyle(i.sub()),r);c={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-d.height)}}var f;if(l&&c)f=zP({positionType:`bottom`,positionData:r.fontMetrics().bigOpSpacing5+c.elem.height+c.elem.depth+c.kern+e.depth+o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:R(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:R(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=zP({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:R(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=zP({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:R(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=Y([`mspace`],[],r);m.style.marginRight=R(a),p.unshift(m)}return Y([`mop`,`op-limits`],p,r)},CL=new Set([`\\smallint`]),wL=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Q(e.base,`op`),i=!0):a=Q(e,`op`);var o=t.style,s=!1;o.size===L.DISPLAY.size&&a.symbol&&!CL.has(a.name)&&(s=!0);var c,l;if(a.symbol){var u=s?`Size2-Regular`:`Size1-Regular`,d=``;if((a.name===`\\oiint`||a.name===`\\oiiint`)&&(d=a.name.slice(1),a.name=d===`oiint`?`\\iint`:`\\iiint`),c=EP(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=WP(d+`Size`+(s?`2`:`1`),t);c=zP({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:0},{type:`elem`,elem:f,shift:s?.08:0}]}),a.name=`\\`+d,c.classes.unshift(`mop`),c.italic=l}}else if(a.body){var p=oF(a.body,t,!0);p.length===1&&p[0]instanceof TN?(c=p[0],c.classes[0]=`mop`):c=Y([`mop`],p,t)}else{for(var m=[],h=1;h{var n;if(e.symbol)n=new Z(`mo`,[bF(e.name,e.mode)]),CL.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Z(`mo`,TF(e.body,t));else{n=new Z(`mi`,[new gF(e.name.slice(1))]);var r=new Z(`mo`,[bF(`⁡`,`text`)]);n=e.parentIsSupSub?new Z(`mrow`,[n,r]):hF([n,r])}return n},EL={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};X({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcap.\\bigcup.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcup.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨄.⨆`.split(`.`),numArgs:0,handler:(e,t)=>{var n=e.parser,r=e.funcName;return r.length===1&&(r=EL[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:wL,mathmlBuilder:TL}),X({type:`op`,names:[`\\mathop`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`op`,mode:n.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:tF(r)}}});var DL={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};X({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\tan.\\tanh.\\tg.\\th`.split(`.`),numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:n}}}),X({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:n}}}),X({type:`op`,names:[`\\int`,`\\iint`,`\\iiint`,`\\oint`,`\\oiint`,`\\oiiint`,`∫`,`∬`,`∭`,`∮`,`∯`,`∰`],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,n=e.funcName;return n.length===1&&(n=DL[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var OL=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=Q(e.base,`operatorname`),i=!0):a=Q(e,`operatorname`);var o;if(a.body.length>0){for(var s=oF(a.body.map(e=>{var t=`text`in e?e.text:void 0;return typeof t==`string`?{type:`textord`,mode:e.mode,text:t}:e}),t.withFont(`mathrm`),!0),c=0;c{var n=e.parser,r=e.funcName,i=t[0];return{type:`operatorname`,mode:n.mode,body:tF(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:OL,mathmlBuilder:(e,t)=>{for(var n=TF(e.body,t.withFont(`mathrm`)),r=!0,i=0;ie.toText()).join(``))]);var s=new Z(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new Z(`mo`,[bF(`⁡`,`text`)]);return e.parentIsSupSub?new Z(`mrow`,[s,c]):hF([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),$P({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?IP(oF(e.body,t,!1)):Y([`mord`],oF(e.body,t,!0),t)},mathmlBuilder(e,t){return EF(e.body,t,!0)}}),X({type:`overline`,names:[`\\overline`],numArgs:1,handler(e,t){var n=e.parser,r=t[0];return{type:`overline`,mode:n.mode,body:r}},htmlBuilder(e,t){var n=fF(e.body,t.havingCrampedStyle()),r=PP(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-overline`],[zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:n},{type:`kern`,size:3*i},{type:`elem`,elem:r},{type:`kern`,size:i}]})],t)},mathmlBuilder(e,t){var n=new Z(`mo`,[new gF(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`mover`,[DF(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),X({type:`phantom`,names:[`\\phantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`phantom`,mode:n.mode,body:tF(r)}},htmlBuilder:(e,t)=>IP(oF(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Z(`mphantom`,TF(e.body,t))}),$(`\\hphantom`,`\\smash{\\phantom{#1}}`),X({type:`vphantom`,names:[`\\vphantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`vphantom`,mode:n.mode,body:r}},htmlBuilder:(e,t)=>Y([`mord`,`rlap`],[Y([`katex-inner`],[fF(e.body,t.withPhantom())]),Y([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Z(`mpadded`,[new Z(`mphantom`,TF(tF(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),X({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=Q(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=fF(e.body,t);return zP({positionType:`shift`,positionData:-mN(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Z(`mpadded`,[DF(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var kL=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});X({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:kL,htmlBuilder(e,t){return Y([`mord`,`reflectbox`],[fF(e.body,t)],t)},mathmlBuilder(e,t){return DF(e.body,t)}}),X({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:kL}),X({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),X({type:`rule`,names:[`\\rule`],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`],handler(e,t,n){var r=e.parser,i=n[0],a=Q(t[0],`size`),o=Q(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&Q(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=Y([`mord`,`katex-rule`],[],t),r=mN(e.width,t),i=mN(e.height,t),a=e.shift?mN(e.shift,t):0;return n.style.borderRightWidth=R(r),n.style.borderTopWidth=R(i),n.style.bottom=R(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=mN(e.width,t),r=mN(e.height,t),i=e.shift?mN(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new Z(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,R(n)),o.setAttribute(`height`,R(r));var s=new Z(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,R(i)):(s.setAttribute(`height`,R(i)),s.setAttribute(`depth`,R(-i))),s.setAttribute(`voffset`,R(i)),s}});function AL(e,t,n){for(var r=oF(e,t,!1),i=t.sizeMultiplier/n.sizeMultiplier,a=0;a{var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!1,n);return{type:`sizing`,mode:i.mode,size:jL.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return AL(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Z(`mstyle`,TF(e.body,n));return r.setAttribute(`mathsize`,R(n.sizeMultiplier)),r}}),X({type:`smash`,names:[`\\smash`],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,n)=>{var r=e.parser,i=!1,a=!1,o=n[0]&&Q(n[0],`ordgroup`);if(o)for(var s,c=0;c{var n=Y([],[fF(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return n;if(e.smashHeight&&(n.height=0),e.smashDepth&&(n.depth=0),e.smashHeight&&e.smashDepth)return Y([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r{var n=new Z(`mpadded`,[DF(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),X({type:`sqrt`,names:[`\\sqrt`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=n[0],a=t[0];return{type:`sqrt`,mode:r.mode,body:a,index:i}},htmlBuilder(e,t){var n=fF(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=LP(n,t);var r=t.fontMetrics().defaultRuleThickness,i=r;t.style.idn.height+n.depth+a&&(a=(a+u-n.height-n.depth)/2);var d=s.height-n.height-a-c;n.style.paddingLeft=R(l);var f=zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:n,wrapperClasses:[`svg-align`]},{type:`kern`,size:-(n.height+d)},{type:`elem`,elem:s},{type:`kern`,size:c}]});if(e.index){var p=t.havingStyle(L.SCRIPTSCRIPT),m=fF(e.index,p,t);return Y([`mord`,`sqrt`],[Y([`katex-root`],[zP({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return Y([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new Z(`mroot`,[DF(n,t),DF(r,t)]):new Z(`msqrt`,[DF(n,t)])}});var ML={display:L.DISPLAY,text:L.TEXT,script:L.SCRIPT,scriptscript:L.SCRIPTSCRIPT};function NL(e){return e in ML}X({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!0,n),o=r.slice(1,r.length-5);if(!NL(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=ML[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),AL(e.body,r,t)},mathmlBuilder(e,t){var n=ML[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Z(`mstyle`,TF(e.body,r)),a={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]}[e.style];return i.setAttribute(`scriptlevel`,a[0]),i.setAttribute(`displaystyle`,a[1]),i}});var PL=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===L.DISPLAY.size||n.alwaysHandleSupSub)?wL:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===L.DISPLAY.size||n.limits)?OL:null:n.type===`accent`?CM(n.base)?QF:null:n.type===`horizBrace`&&!e.sub===n.isOver?yL:null:null};$P({type:`supsub`,htmlBuilder(e,t){var n=PL(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=fF(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&CM(r);if(i){var p=t.havingStyle(t.style.sup());s=fF(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=fF(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===L.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=R(.5/l.ptPerEm/g),v=null;if(c){var y=e.base&&e.base.type===`op`&&e.base.name&&(e.base.name===`\\oiint`||e.base.name===`\\oiiint`);(o instanceof TN||y)&&(v=R(-(o.italic??0)))}var b;if(s&&c){u=Math.max(u,h,s.depth+.25*l.xHeight),d=Math.max(d,l.sub2);var x=4*l.defaultRuleThickness;if(u-s.depth-(c.height-d)0&&(u+=S,d-=S)}b=zP({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:d,marginRight:_,marginLeft:v},{type:`elem`,elem:s,shift:-u,marginRight:_}]})}else if(c)d=Math.max(d,l.sub1,c.height-.8*l.xHeight),b=zP({positionType:`shift`,positionData:d,children:[{type:`elem`,elem:c,marginLeft:v,marginRight:_}]});else if(s)u=Math.max(u,h,s.depth+.25*l.xHeight),b=zP({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return Y([uF(o,`right`)||`mord`],[o,Y([`msupsub`],[b])],t)},mathmlBuilder(e,t){var n=!1,r,i;e.base&&e.base.type===`horizBrace`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0);var a=[DF(e.base,t)];e.sub&&a.push(DF(e.sub,t)),e.sup&&a.push(DF(e.sup,t));var o;if(n)o=r?`mover`:`munder`;else if(!e.sub){var s=e.base;o=s&&s.type===`op`&&s.limits&&(t.style===L.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===L.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===L.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===L.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===L.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===L.DISPLAY)?`munder`:`msub`}return new Z(o,a)}}),$P({type:`atom`,htmlBuilder(e,t){return DP(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Z(`mo`,[bF(e.text,e.mode)]);if(e.family===`bin`){var r=CF(e,t);r===`bold-italic`&&n.setAttribute(`mathvariant`,r)}else e.family===`punct`?n.setAttribute(`separator`,`true`):(e.family===`open`||e.family===`close`)&&n.setAttribute(`stretchy`,`false`);return n}});var FL={mi:`italic`,mn:`normal`,mtext:`normal`};$P({type:`mathord`,htmlBuilder(e,t){return kP(e,t)},mathmlBuilder(e,t){var n=new Z(`mi`,[bF(e.text,e.mode,t)]),r=CF(e,t)||`italic`;return r!==FL[n.type]&&n.setAttribute(`mathvariant`,r),n}}),$P({type:`textord`,htmlBuilder(e,t){return kP(e,t)},mathmlBuilder(e,t){var n=bF(e.text,e.mode,t),r=CF(e,t)||`normal`,i=e.mode===`text`?new Z(`mtext`,[n]):/[0-9]/.test(e.text)?new Z(`mn`,[n]):e.text===`\\prime`?new Z(`mo`,[n]):new Z(`mi`,[n]);return r!==FL[i.type]&&i.setAttribute(`mathvariant`,r),i}});var IL=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),LL=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);$P({type:`spacing`,htmlBuilder(e,t){var n=LL.get(e.text),r=IL.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=kP(e,t);return a.classes.push(i),a}return Y([`mspace`,i],[DP(e.text,e.mode,t)],t)}if(r)return Y([`mspace`,r],[],t);throw new I(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(LL.has(e.text))n=new Z(`mtext`,[new gF(`\xA0`)]);else if(IL.has(e.text))return new Z(`mspace`);else throw new I(`Unknown type of space "`+e.text+`"`);return n}});var RL=()=>{var e=new Z(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};$P({type:`tag`,mathmlBuilder(e,t){var n=new Z(`mtable`,[new Z(`mtr`,[RL(),new Z(`mtd`,[EF(e.body,t)]),RL(),new Z(`mtd`,[EF(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var zL={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},BL={"\\textbf":`textbf`,"\\textmd":`textmd`},VL={"\\textit":`textit`,"\\textup":`textup`},HL=(e,t)=>{var n=e.font;return n?zL[n]?t.withTextFontFamily(zL[n]):BL[n]?t.withTextFontWeight(BL[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(VL[n]):t};X({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`text`,mode:n.mode,body:tF(i),font:r}},htmlBuilder(e,t){var n=HL(e,t);return Y([`mord`,`text`],oF(e.body,n,!0),n)},mathmlBuilder(e,t){var n=HL(e,t);return EF(e.body,n)}}),X({type:`underline`,names:[`\\underline`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`underline`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=fF(e.body,t),r=PP(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-underline`],[zP({positionType:`top`,positionData:n.height,children:[{type:`kern`,size:i},{type:`elem`,elem:r},{type:`kern`,size:3*i},{type:`elem`,elem:n}]})],t)},mathmlBuilder(e,t){var n=new Z(`mo`,[new gF(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`munder`,[DF(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),X({type:`vcenter`,names:[`\\vcenter`],numArgs:1,argTypes:[`original`],allowedInText:!1,handler(e,t){return{type:`vcenter`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=fF(e.body,t),r=t.fontMetrics().axisHeight;return zP({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new Z(`mrow`,[new Z(`mpadded`,[DF(e.body,t)],[`vcenter`])])}}),X({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new I(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=UL(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),WL=XP,GL=`[ \r + ]`,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;r0&&(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{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{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var YF={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},XF=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in YF?t=YF[n]:(n.slice(0,4)===`\\not`||n in Aj.math&&XF.has(Aj.math[n].group))&&(t=`\\dotsb`),t});var ZF={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in ZF?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in ZF&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in ZF?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new I(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var QF=R(Cj[`Main-Regular`][84][1]-.7*Cj[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+QF+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+QF+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`↤`,`\\mapsfrom`),$(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var $F=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,$F(!1)),$(`\\bra@set`,$F(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var eI={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},tI=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new GF(KF,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new WF(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new WP(`EOF`,n.loc)),this.pushTokens(r),new WP(``,UP.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new I(`Extra }`,i)}else if(i.text===`EOF`)throw new I(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new I(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;rthis.settings.maxExpand)throw new I(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new I(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new I(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new I(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new WP(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new WF(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(FF,e)||Object.prototype.hasOwnProperty.call(Aj.math,e)||Object.prototype.hasOwnProperty.call(Aj.text,e)||Object.prototype.hasOwnProperty.call(eI,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(FF,e)&&!FF[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},nI=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,rI=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),iI={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},aI={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},oI=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new tI(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new I(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new WP(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&FF[i.text]&&FF[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r=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;ce.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?FI:II;case`left`:case`right`:return t?LI:RI;default:return[]}}function BI(e,t,n,r){let i=DI(e),a=zI(EI(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(PI)))),a}function VI(e){let t=EI(e);return CI[t]+e.slice(t.length)}function HI(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function UI(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:HI(e)}function WI(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function GI(e,t,n){let{reference:r,floating:i}=e,a=AI(t),o=jI(t),s=kI(o),c=EI(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=DI(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function KI(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=TI(t,e),p=UI(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=WI(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=WI(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var qI=50,JI=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:KI},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=GI(l,r,c),f=r,p=0,m={};for(let n=0;ne<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===AI(t)||ne.every(e=>AI(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:ne},reset:{placement:t}};let n=ne.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=ne.filter(e=>{if(x){let t=AI(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},XI=new Set([`left`,`top`]);async function ZI(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=EI(n),s=DI(n),c=AI(n)===`y`,l=XI.has(o)?-1:1,u=a&&c?-1:1,d=TI(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var QI=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ZI(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},$I=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=TI(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=AI(i),p=OI(f),m=u[p],h=u[f],g=(e,t)=>wI(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}};function eL(){return typeof window<`u`}function tL(e){return iL(e)?(e.nodeName||``).toLowerCase():`#document`}function nL(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function rL(e){return((iL(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function iL(e){return eL()?e instanceof Node||e instanceof nL(e).Node:!1}function aL(e){return eL()?e instanceof Element||e instanceof nL(e).Element:!1}function oL(e){return eL()?e instanceof HTMLElement||e instanceof nL(e).HTMLElement:!1}function sL(e){return!eL()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof nL(e).ShadowRoot}function cL(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=yL(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function lL(e){return/^(table|td|th)$/.test(tL(e))}function uL(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var dL=/transform|translate|scale|rotate|perspective|filter/,fL=/paint|layout|strict|content/,pL=e=>!!e&&e!==`none`,mL;function hL(e){let t=aL(e)?yL(e):e;return pL(t.transform)||pL(t.translate)||pL(t.scale)||pL(t.rotate)||pL(t.perspective)||!_L()&&(pL(t.backdropFilter)||pL(t.filter))||dL.test(t.willChange||``)||fL.test(t.contain||``)}function gL(e){let t=xL(e);for(;oL(t)&&!vL(t);){if(hL(t))return t;if(uL(t))return null;t=xL(t)}return null}function _L(){return mL??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mL}function vL(e){return/^(html|body|#document)$/.test(tL(e))}function yL(e){return nL(e).getComputedStyle(e)}function bL(e){return aL(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xL(e){if(tL(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||sL(e)&&e.host||rL(e);return sL(t)?t.host:t}function SL(e){let t=xL(e);return vL(t)?(e.ownerDocument||e).body:oL(t)&&cL(t)?t:SL(t)}function CL(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=SL(e),i=r===e.ownerDocument?.body,a=nL(r);if(i){let e=wL(a);return t.concat(a,a.visualViewport||[],cL(r)?r:[],e&&n?CL(e):[])}return t.concat(r,CL(r,[],n))}function wL(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function TL(e){let t=yL(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=oL(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=bI(n)!==a||bI(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function EL(e){return aL(e)?e:e.contextElement}function DL(e){let t=EL(e);if(!oL(t))return SI(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=TL(t),o=(a?bI(n.width):n.width)/r,s=(a?bI(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var OL=SI(0);function kL(e){let t=nL(e);return!_L()||!t.visualViewport?OL:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function AL(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===nL(e)}function jL(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=EL(e),o=SI(1);t&&(r?aL(r)&&(o=DL(r)):o=DL(e));let s=AL(a,n,r)?kL(a):SI(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=nL(a),t=aL(r)?nL(r):r,n=e,i=wL(n);for(;i&&t!==n;){let e=DL(i),t=i.getBoundingClientRect(),r=yL(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=nL(i),i=wL(n)}}return WI({width:u,height:d,x:c,y:l})}function ML(e,t){let n=bL(e).scrollLeft;return t?t.left+n:jL(rL(e)).left+n}function NL(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ML(e,n),y:n.top+t.scrollTop}}function PL(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=rL(r),s=t?uL(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=SI(1),u=SI(0),d=oL(r);if((d||!a)&&((tL(r)!==`body`||cL(o))&&(c=bL(r)),d)){let e=jL(r);l=DL(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?NL(o,c):SI(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function FL(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function IL(e){let t=bL(e),n=e.ownerDocument.body,r=yI(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=yI(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ML(e),o=-t.scrollTop;return yL(n).direction===`rtl`&&(a+=yI(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var LL=25;function RL(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=nL(e),a=rL(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!_L()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(ML(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=LL&&(s-=o)}return{width:s,height:c,x:l,y:u}}function zL(e,t){let n=jL(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=DL(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function BL(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=RL(e,n,t);else if(t===`document`)r=IL(rL(e));else if(aL(t))r=zL(t,n);else{let n=kL(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return WI(r)}function VL(e,t){let n=t.get(e);if(n)return n;let r=CL(e,[],!1).filter(e=>aL(e)&&tL(e)!==`body`),i=null,a=yL(e).position===`fixed`,o=a?xL(e):e;for(;aL(o)&&!vL(o);){let e=yL(o),t=hL(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=xL(o)}return t.set(e,r),r}function HL(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?uL(t)?[]:VL(t,this._c):[].concat(n),r],o=BL(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=nL(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function $L(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=EL(e),u=i||a?[...l?CL(l):[],...t?CL(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?QL(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?jL(e):null;c&&g();function g(){let t=jL(e);h&&!ZL(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var eR=QI,tR=$I,nR=YI,rR=(e,t,n)=>{let r=new Map,i=n??{},a={...XL,...i.platform,_c:r};return JI(e,t,{...i,platform:a})},iR=null;function aR(e){iR?.();let t=document.createElement(`div`);t.className=`dw-source`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,e.label);let n=document.createElement(e.multiline?`textarea`:`input`);n.className=`dw-source__field`+(e.monospace?` dw-source__field--mono`:``),n.value=e.value,n.setAttribute(`aria-label`,e.label),n.spellcheck=!1,n instanceof HTMLTextAreaElement&&(n.rows=Math.min(16,Math.max(4,e.value.split(` -`).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?{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)){(yf.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({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,ee=b.query!==x.query,te=b.text!==x.text,ne=b.range.from!==x.range.from||b.range.to!==x.range.to,re=ee||te||ne;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&re)S=`updated`;else return;let ie=S===`stopped`?b:x,ae=n.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`),oe=m(n,ae),se=i===0||(ie.query?ie.query.length>=i:!1),ce=(S===`started`||S===`updated`)&&se;if(g={editor:e,range:ie.range,query:ie.query||``,text:ie.text||``,items:o??[],command:t=>p({editor:e,range:ie.range,props:t}),decorationNode:ae,clientRect:oe,loading:ce,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:vR({getReferenceRect:oe,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var le;r==null||(le=r.onBeforeStart)==null||le.call(r,g)}if(S===`updated`){var ue;r==null||(ue=r.onBeforeUpdate)==null||ue.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!ce)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(ie.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var bR=new D(`suggestion`);function xR({pluginKey:e=bR,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:ee=()=>!0,findSuggestionMatch:te=sR,shouldShow:ne,shouldResetDismissed:re}){let ie=S?.(),ae=r&&!i,oe=(n,r)=>uR(t,n,r,e);function se(e){return dR({...e,editor:t,shouldResetDismissed:re,effectiveAllowSpaces:ae})}let ce=t=>fR({view:t,pluginKeyRef:e});return new E({key:e,view:()=>yR({editor:t,pluginKey:e,items:f,renderer:ie,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:oe,dispatchExit:ce}),state:mR({editor:t,char:n,effectiveAllowSpaces:ae,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:te,allow:ee,shouldShow:ne,shouldKeepDismissed:se,pluginKey:e}),props:pR({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:ie,dispatchExit:ce})})}var SR=xR;function CR({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new D,command:({editor:e,range:t,props:i})=>{var a,o;let s=e.view.state.selection.$to.nodeAfter;s!=null&&(a=s.text)!=null&&a.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(o=e.view.dom.ownerDocument.defaultView)==null||(o=o.getSelection())==null||o.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function wR(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>CR({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function TR(e,t){let n=wR(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var ER=Hp.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,Fu(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=TR(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,Fu({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=Fu({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,Fu({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},...qf({nodeName:`mention`,name:`@`,selfClosing:!0,allowedAttributes:[`id`,`label`,{name:`mentionSuggestionChar`,skipIfDefault:`@`}],parseAttributes:e=>{let t={},n=/(?:^|\s)(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i===`char`?`mentionSuggestionChar`:i]=a??o,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e===`mentionSuggestionChar`?`char`:e}="${t}"`).join(` `)}),renderText({node:e}){let t={options:this.options,node:e,suggestion:TR(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;let o=new le,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return wR(this).map(xR)}}),DR={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-down":[`M6 10l6 6 6-6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8 20H4v-4z`],sigma:[`M18 6V4H6l6 8l-6 8h12v-2`],diagram:[`M4 4h6v5H4z`,`M14 15h6v5h-6z`,`M7 9v4a2 2 0 0 0 2 2h5`],users:[`M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 1 0 0 7z`,`M3 20a6 6 0 0 1 12 0`,`M16 4.5a3.5 3.5 0 0 1 0 6.5`,`M18 14a6 6 0 0 1 3 6`]},OR=`http://www.w3.org/2000/svg`;function kR(e){let t=document.createElementNS(OR,`svg`);for(let[e,n]of Object.entries({width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))t.setAttribute(e,n);for(let n of DR[e]){let e=document.createElementNS(OR,`path`);e.setAttribute(`d`,n),t.append(e)}return t}function AR(e){return()=>{let t=null,n=null,r=null,i=0,a=t=>{let n=r?.items[t];r&&n!==void 0&&e.pick(r,n)},o=()=>{if(!t||!r)return;let n=r;if(t.replaceChildren(),e.showQuery){let e=document.createElement(`div`);e.className=`dw-suggest__query`,e.textContent=`/${n.query}`,t.append(e)}if(n.items.length)n.items.forEach((n,r)=>{let o=e.toItem(n),s=document.createElement(`div`);s.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,s.setAttribute(`role`,`option`),s.setAttribute(`aria-selected`,String(r===i)),s.addEventListener(`mousedown`,e=>{e.preventDefault(),a(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(kR(o.icon??`text`));let l=document.createElement(`span`);l.className=`dw-suggest__text`;let u=document.createElement(`span`);if(u.className=`dw-suggest__label`,u.textContent=o.label,l.append(u),o.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=o.description,l.append(e)}s.append(c,l),t.append(s)}),t.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`});else{let n=document.createElement(`div`);n.className=`dw-suggest__empty`,n.setAttribute(`role`,`status`),n.textContent=e.empty,t.append(n)}},s=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=$L(i,t,()=>{t&&rR(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[eR(6),nR(),tR({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},c=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),o(),s()},onUpdate(e){e.items!==r?.items&&(i=0),r=e,o(),s()},onKeyDown({event:e}){let t=r?.items.length??0;return e.key===`Escape`?(c(),!0):t?e.key===`ArrowDown`||e.key===`ArrowUp`?(i=(i+(e.key===`ArrowDown`?1:-1)+t)%t,o(),!0):e.key===`Enter`||e.key===`Tab`?(a(i),!0):!1:!1},onExit(){r=null,c()}}}}function jR(e,t){return ER.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,items:async({query:e})=>t?(await t.search(e).catch(()=>[])).slice(0,8):[],render:AR({label:e.mentions,empty:e.noPeople,toItem:e=>({label:e.label,description:e.hint,icon:`at`}),pick:(e,t)=>e.command({id:t.id,label:t.label})})}})}var MR=`flowchart LR - 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().focus().deleteRange(t).insertInlineMath({latex:`x^2`}).run()),a(`mermaid`,`diagram`,[`diagram`,`flowchart`,`chart`,`sequence`,`graph`],(e,t)=>e.chain().focus().deleteRange(t).insertMermaid().run())];if(r&&o.push(a(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),UR(e).then(e=>eA(r,t,e).catch(n))};o.push(a(`image`,`image`,[`picture`,`photo`,`img`],e(`image/*`)),a(`file`,`paperclip`,[`attachment`,`upload`,`pdf`],e(``)),a(`drawio`,`diagram`,[`diagram`,`diagrams.net`,`draw`,`chart`,`uml`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`drawio`).run())),i&&o.push(a(`excalidraw`,`pencil`,[`drawing`,`sketch`,`whiteboard`,`draw`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`excalidraw`).run()))}return o}function GR(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n))):e}var KR=yp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[SR({editor:this.editor,pluginKey:new D(`slashMenu`),char:`/`,allowSpaces:!1,startOfLine:!1,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:({query:e})=>GR(this.options.commands,e),render:AR({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),pick:(e,t)=>t.run(e.editor,e.range)})})]}});function qR(e){let t=[];return e.descendants((e,n)=>e.type.name!==`heading`||(t.push({level:Number(e.attrs.level)||1,text:e.textContent.trim(),pos:n}),!1)),t}function JR(e,t){let n=e.view.nodeDOM(t);n instanceof HTMLElement&&n.scrollIntoView({behavior:`smooth`,block:`start`}),e.isEditable&&e.commands.setTextSelection(t+1)}var YR=Hp.create({name:`tableOfContents`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},parseHTML(){return[{tag:`nav[data-type='toc']`}]},renderHTML(){return[`nav`,{"data-type":`toc`}]},addCommands(){return{insertTableOfContents:()=>({commands:e})=>e.insertContent({type:this.name})}},addNodeView(){return({editor:e})=>{let t=this.options.labels.blocks,n=document.createElement(`nav`);n.className=`dw-toc`,n.setAttribute(`data-type`,`toc`),n.setAttribute(`aria-label`,t.toc),n.contentEditable=`false`;let r=document.createElement(`p`);r.className=`dw-toc__title`,r.textContent=t.toc;let i=document.createElement(`ol`);i.className=`dw-toc__list`,n.append(r,i);let a=``,o=()=>{let n=qR(e.state.doc),r=JSON.stringify(n.map(e=>[e.level,e.text]));if(r===a){i.querySelectorAll(`a`).forEach((e,t)=>e.dataset.pos=String(n[t]?.pos??0));return}if(a=r,i.replaceChildren(),!n.length){let e=document.createElement(`li`);e.className=`dw-toc__empty`,e.textContent=t.tocEmpty,i.append(e);return}let o=Math.min(...n.map(e=>e.level));for(let t of n){let n=document.createElement(`li`);n.style.paddingLeft=`${(t.level-o)*1}rem`;let r=document.createElement(`a`);r.href=`#`,r.textContent=t.text||`…`,r.dataset.pos=String(t.pos),r.addEventListener(`click`,t=>{t.preventDefault(),JR(e,Number(r.dataset.pos))}),n.append(r),i.append(n)}};return o(),e.on(`update`,o),{dom:n,update:e=>e.type.name===`tableOfContents`,ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`),destroy:()=>e.off(`update`,o)}}}});function XR(e={}){let t=e.labels??oA,n=null,r=yp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Fk.configure({heading:{levels:[1,2,3]},link:{openOnClick:!1,autolink:!0},undoRedo:!e.collab&&void 0}),rT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),tA.configure({host:e.files}),rA.configure({host:e.files}),iA.configure({host:e.files,onError:e.onError}),jR(t,e.mentions),KR.configure({commands:WR(t,e.files,e.onError,e.pages,!!e.loadExcalidraw),labels:t}),Bk.configure({onSelect:e.onCommentSelect}),oR(t,()=>n),LR.configure({labels:t,load:e.loadMermaid}),YR.configure({labels:t}),Xk.configure(i),Zk.configure(i),HR.configure({host:e.pages,labels:t,onNavigate:e.onNavigate})];return e.collab&&a.push(yw.configure({document:e.collab.provider.doc}),ww.configure({provider:e.collab.provider,user:e.collab.user,render:ZR})),a}function ZR(e){let t=typeof e.color==`string`&&/^#[0-9a-f]{3,8}$/i.test(e.color)?e.color:`#888`,n=document.createElement(`span`);n.classList.add(`collaboration-carets__caret`),n.style.borderColor=t;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.setAttribute(`aria-hidden`,`true`),r.style.backgroundColor=t,r.textContent=typeof e.name==`string`?e.name:``,n.append(r),n}var QR=3e4,$R=class extends im{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Eh();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&ez(this,t,`timeout`)},am(QR/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Eh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Kh(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},ez=(e,t,n)=>{let r=[];for(let n=0;n0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},tz=(e,t,n=e.states)=>{let r=t.length,i=Em();j(i,r);for(let a=0;a{let r=oh(t),i=Eh(),a=[],o=[],s=[],c=[],l=M(r);for(let t=0;t0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},rz=(e,t)=>{j(e,0),Rm(e,zv(t))},iz=(e,t,n)=>{j(e,1),Rm(e,Nv(t,n))},az=(e,t,n)=>iz(t,n,lh(e)),oz=(e,t,n,r)=>{try{Av(t,lh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},sz=(e,t)=>{j(e,2),Rm(e,t)},cz=oz,lz=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:az(e,t,n);break;case 1:oz(e,n,r,i);break;case 2:cz(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},uz=0,dz=1,fz=4401,pz=4404,mz=4409,hz=class{opts;doc=new mv;awareness=new $R(this.doc);status=`connecting`;synced=!1;ws=null;retries=0;retryTimer;destroyed=!1;listeners=new Set;constructor(e){this.opts=e,this.doc.on(`update`,this.onDocUpdate),this.awareness.on(`update`,this.onAwarenessUpdate),window.addEventListener(`beforeunload`,this.onUnload),this.connect()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.listeners.clear(),clearTimeout(this.retryTimer),window.removeEventListener(`beforeunload`,this.onUnload),ez(this.awareness,[this.doc.clientID],`local`),this.doc.off(`update`,this.onDocUpdate),this.awareness.off(`update`,this.onAwarenessUpdate),this.ws?.close(),this.awareness.destroy(),this.doc.destroy(),this.listeners.clear())}set(e,t=this.synced){(e!==this.status||t!==this.synced)&&(this.status=e,this.synced=t,this.listeners.forEach(e=>e()))}connect(){let e=new WebSocket(`${this.opts.url}?page=${encodeURIComponent(this.opts.page)}`);e.binaryType=`arraybuffer`,this.ws=e,e.onopen=()=>{e.send(this.opts.token()??``);let t=Em();j(t,uz),rz(t,this.doc),e.send(km(t)),this.awareness.getLocalState()!==null&&this.sendAwareness([this.doc.clientID])},e.onmessage=e=>this.onMessage(new Uint8Array(e.data)),e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=[...this.awareness.getStates().keys()].filter(e=>e!==this.doc.clientID);ez(this.awareness,n,this),this.destroyed||(t.code===fz||t.code===pz?this.set(`denied`,!1):t.code===mz?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=oh(e),n=M(t);if(n===uz){let e=Em();j(e,uz);let n=lz(t,e,this.doc,this);Om(e)>1&&this.ws?.send(km(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===dz&&nz(this.awareness,lh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.ws?.readyState!==WebSocket.OPEN)return;let n=Em();j(n,uz),sz(n,e),this.ws.send(km(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r!==this&&this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=Em();j(t,dz),Rm(t,tz(this.awareness,e)),this.ws.send(km(t))}onUnload=()=>ez(this.awareness,[this.doc.clientID],`unload`)},gz={bold:e=>e.chain().focus().toggleBold().run(),italic:e=>e.chain().focus().toggleItalic().run(),strike:e=>e.chain().focus().toggleStrike().run(),code:e=>e.chain().focus().toggleCode().run(),heading1:e=>e.chain().focus().toggleHeading({level:1}).run(),heading2:e=>e.chain().focus().toggleHeading({level:2}).run(),heading3:e=>e.chain().focus().toggleHeading({level:3}).run(),bulletList:e=>e.chain().focus().toggleBulletList().run(),orderedList:e=>e.chain().focus().toggleOrderedList().run(),blockquote:e=>e.chain().focus().toggleBlockquote().run(),codeBlock:e=>e.chain().focus().toggleCodeBlock().run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},_z=[[`bold`,e=>e.isActive(`bold`)],[`italic`,e=>e.isActive(`italic`)],[`strike`,e=>e.isActive(`strike`)],[`code`,e=>e.isActive(`code`)],[`heading1`,e=>e.isActive(`heading`,{level:1})],[`heading2`,e=>e.isActive(`heading`,{level:2})],[`heading3`,e=>e.isActive(`heading`,{level:3})],[`bulletList`,e=>e.isActive(`bulletList`)],[`orderedList`,e=>e.isActive(`orderedList`)],[`blockquote`,e=>e.isActive(`blockquote`)],[`codeBlock`,e=>e.isActive(`codeBlock`)]],vz=class{el;send;editor;provider=null;lastState=``;editable=!0;constructor(e,t){this.el=e,this.send=t,this.editor=this.create({}),t({type:`ready`,version:1})}receive(e){try{let t=typeof e==`string`?JSON.parse(e):e;this.handle(t)}catch(e){this.send({type:`error`,message:e instanceof Error?e.message:String(e)})}}get content(){return this.editor.getJSON()}destroy(){this.editor.destroy(),this.provider?.destroy()}handle(e){switch(e.type){case`hello`:this.send({type:`ready`,version:1}),this.lastState=``,this.reportState(this.editor);return;case`setContent`:this.editor.commands.setContent(e.content??``,{emitUpdate:!1}),this.reportState(this.editor);return;case`setEditable`:this.editable=e.editable,this.editor.setEditable(e.editable);return;case`setTheme`:document.documentElement.classList.toggle(`dark`,e.dark);return;case`command`:{let t=gz[e.command];if(!t)throw Error(`unknown command ${e.command}`);t(this.editor);return}case`focus`:this.editor.commands.focus();return;case`blur`:this.editor.commands.blur();return;case`connect`:this.connect(e);return;default:throw Error(`unknown message ${e.type}`)}}connect(e){this.provider?.destroy();let t=new hz({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}})}create(e){return this.el.replaceChildren(),new Fp({element:this.el,editable:this.editable,extensions:XR(e),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:({editor:e})=>this.reportState(e),onTransaction:({editor:e})=>this.reportState(e),onFocus:({editor:e})=>this.reportState(e),onBlur:({editor:e})=>this.reportState(e)})}reportState(e){let t={active:_z.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function yz(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var bz=new vz(document.getElementById(`editor`),yz);window.docwell={receive:e=>bz.receive(e)}; +?)[ \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;r0&&(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{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{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var iR={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},aR=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in iR?t=iR[n]:(n.slice(0,4)===`\\not`||n in zN.math&&aR.has(zN.math[n].group))&&(t=`\\dotsb`),t});var oR={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in oR?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in oR&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in oR?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new I(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var sR=R(MN[`Main-Regular`][84][1]-.7*MN[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+sR+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+sR+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`↤`,`\\mapsfrom`),$(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var cR=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,cR(!1)),$(`\\bra@set`,cR(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var lR={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},uR=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new eR(tR,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new $L(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new $I(`EOF`,n.loc)),this.pushTokens(r),new $I(``,QI.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new I(`Extra }`,i)}else if(i.text===`EOF`)throw new I(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new I(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;rthis.settings.maxExpand)throw new I(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new I(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new I(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new I(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new $I(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new $L(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(WL,e)||Object.prototype.hasOwnProperty.call(zN.math,e)||Object.prototype.hasOwnProperty.call(zN.text,e)||Object.prototype.hasOwnProperty.call(lR,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(WL,e)&&!WL[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},dR=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,fR=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),pR={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},mR={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},hR=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new uR(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new I(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new $I(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&WL[i.text]&&WL[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r=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;ce.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=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(kf).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?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function kR(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 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)){(yf.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({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,ee=b.query!==x.query,te=b.text!==x.text,ne=b.range.from!==x.range.from||b.range.to!==x.range.to,re=ee||te||ne;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&re)S=`updated`;else return;let ie=S===`stopped`?b:x,ae=n.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`),oe=m(n,ae),se=i===0||(ie.query?ie.query.length>=i:!1),ce=(S===`started`||S===`updated`)&&se;if(g={editor:e,range:ie.range,query:ie.query||``,text:ie.text||``,items:o??[],command:t=>p({editor:e,range:ie.range,props:t}),decorationNode:ae,clientRect:oe,loading:ce,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:zR({getReferenceRect:oe,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var le;r==null||(le=r.onBeforeStart)==null||le.call(r,g)}if(S===`updated`){var ue;r==null||(ue=r.onBeforeUpdate)==null||ue.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!ce)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(ie.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var VR=new D(`suggestion`);function HR({pluginKey:e=VR,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:ee=()=>!0,findSuggestionMatch:te=OR,shouldShow:ne,shouldResetDismissed:re}){let ie=S?.(),ae=r&&!i,oe=(n,r)=>jR(t,n,r,e);function se(e){return MR({...e,editor:t,shouldResetDismissed:re,effectiveAllowSpaces:ae})}let ce=t=>NR({view:t,pluginKeyRef:e});return new E({key:e,view:()=>BR({editor:t,pluginKey:e,items:f,renderer:ie,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:oe,dispatchExit:ce}),state:FR({editor:t,char:n,effectiveAllowSpaces:ae,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:te,allow:ee,shouldShow:ne,shouldKeepDismissed:se,pluginKey:e}),props:PR({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:ie,dispatchExit:ce})})}var UR=HR;function WR({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new D,command:({editor:e,range:t,props:i})=>{var a,o;let s=e.view.state.selection.$to.nodeAfter;s!=null&&(a=s.text)!=null&&a.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(o=e.view.dom.ownerDocument.defaultView)==null||(o=o.getSelection())==null||o.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function GR(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>WR({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function KR(e,t){let n=GR(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var qR=qp.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,A(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=KR(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=A({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},...Qf({nodeName:`mention`,name:`@`,selfClosing:!0,allowedAttributes:[`id`,`label`,{name:`mentionSuggestionChar`,skipIfDefault:`@`}],parseAttributes:e=>{let t={},n=/(?:^|\s)(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i===`char`?`mentionSuggestionChar`:i]=a??o,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e===`mentionSuggestionChar`?`char`:e}="${t}"`).join(` `)}),renderText({node:e}){let t={options:this.options,node:e,suggestion:KR(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;let o=new le,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return GR(this).map(HR)}}),JR={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-down":[`M6 10l6 6 6-6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8 20H4v-4z`],sigma:[`M18 6V4H6l6 8l-6 8h12v-2`],diagram:[`M4 4h6v5H4z`,`M14 15h6v5h-6z`,`M7 9v4a2 2 0 0 0 2 2h5`],video:[`M4 6h11v12H4z`,`M15 10l5-3v10l-5-3`],archive:[`M4 5h16v4H4z`,`M5 9v10h14V9`,`M10 13h4`],server:[`M4 4h16v6H4z`,`M4 14h16v6H4z`,`M8 7h.01`,`M8 17h.01`],users:[`M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 1 0 0 7z`,`M3 20a6 6 0 0 1 12 0`,`M16 4.5a3.5 3.5 0 0 1 0 6.5`,`M18 14a6 6 0 0 1 3 6`]},YR=`http://www.w3.org/2000/svg`;function XR(e){let t=document.createElementNS(YR,`svg`);for(let[e,n]of Object.entries({width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))t.setAttribute(e,n);for(let n of JR[e]){let e=document.createElementNS(YR,`path`);e.setAttribute(`d`,n),t.append(e)}return t}function ZR(e){return()=>{let t=null,n=null,r=null,i=0,a=t=>{let n=r?.items[t];r&&n!==void 0&&e.pick(r,n)},o=()=>{if(!t||!r)return;let n=r;if(t.replaceChildren(),e.showQuery){let e=document.createElement(`div`);e.className=`dw-suggest__query`,e.textContent=`/${n.query}`,t.append(e)}if(n.items.length)n.items.forEach((n,r)=>{let o=e.toItem(n),s=document.createElement(`div`);s.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,s.setAttribute(`role`,`option`),s.setAttribute(`aria-selected`,String(r===i)),s.addEventListener(`mousedown`,e=>{e.preventDefault(),a(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(XR(o.icon??`text`));let l=document.createElement(`span`);l.className=`dw-suggest__text`;let u=document.createElement(`span`);if(u.className=`dw-suggest__label`,u.textContent=o.label,l.append(u),o.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=o.description,l.append(e)}s.append(c,l),t.append(s)}),t.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`});else{let n=document.createElement(`div`);n.className=`dw-suggest__empty`,n.setAttribute(`role`,`status`),n.textContent=e.empty,t.append(n)}},s=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=Wj(i,t,()=>{t&&Jj(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[Gj(6),qj(),Kj({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},c=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),o(),s()},onUpdate(e){e.items!==r?.items&&(i=0),r=e,o(),s()},onKeyDown({event:e}){let t=r?.items.length??0;return e.key===`Escape`?(c(),!0):t?e.key===`ArrowDown`||e.key===`ArrowUp`?(i=(i+(e.key===`ArrowDown`?1:-1)+t)%t,o(),!0):e.key===`Enter`||e.key===`Tab`?(a(i),!0):!1:!1},onExit(){r=null,c()}}}}function QR(e,t){return qR.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,items:async({query:e})=>t?(await t.search(e).catch(()=>[])).slice(0,8):[],render:ZR({label:e.mentions,empty:e.noPeople,toItem:e=>({label:e.label,description:e.hint,icon:`at`}),pick:(e,t)=>e.command({id:t.id,label:t.label})})}})}var $R=`flowchart LR + 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().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),o(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focus().deleteRange(t).insertInlineMath({latex:`x^2`}).run()),o(`mermaid`,`diagram`,[`diagram`,`flowchart`,`chart`,`sequence`,`graph`],(e,t)=>e.chain().focus().deleteRange(t).insertMermaid().run()),o(`embed`,`video`,[`video`,`youtube`,`vimeo`,`figma`,`loom`,`iframe`,`map`],(t,r)=>{t.chain().focus().deleteRange(r).run(),nM(t,e,a,n)}),o(`linkCard`,`link`,[`bookmark`,`preview`,`card`,`url`,`web`],(t,r)=>{t.chain().focus().deleteRange(r).run(),rM(t,e,a,n)})];if(r&&s.push(o(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),uz(e).then(e=>lM(r,t,e).catch(n))};s.push(o(`image`,`image`,[`picture`,`photo`,`img`],e(`image/*`)),o(`file`,`paperclip`,[`attachment`,`upload`,`pdf`],e(``)),o(`drawio`,`diagram`,[`diagram`,`diagrams.net`,`draw`,`chart`,`uml`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`drawio`).run())),i&&s.push(o(`excalidraw`,`pencil`,[`drawing`,`sketch`,`whiteboard`,`draw`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`excalidraw`).run()))}return s}function fz(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n))):e}var pz=wp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[UR({editor:this.editor,pluginKey:new D(`slashMenu`),char:`/`,allowSpaces:!1,startOfLine:!1,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:({query:e})=>fz(this.options.commands,e),render:ZR({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),pick:(e,t)=>t.run(e.editor,e.range)})})]}});function mz(e){let t=[];return e.descendants((e,n)=>e.type.name!==`heading`||(t.push({level:Number(e.attrs.level)||1,text:e.textContent.trim(),pos:n}),!1)),t}function hz(e,t){let n=e.view.nodeDOM(t);n instanceof HTMLElement&&n.scrollIntoView({behavior:`smooth`,block:`start`}),e.isEditable&&e.commands.setTextSelection(t+1)}var gz=qp.create({name:`tableOfContents`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},parseHTML(){return[{tag:`nav[data-type='toc']`}]},renderHTML(){return[`nav`,{"data-type":`toc`}]},addCommands(){return{insertTableOfContents:()=>({commands:e})=>e.insertContent({type:this.name})}},addNodeView(){return({editor:e})=>{let t=this.options.labels.blocks,n=document.createElement(`nav`);n.className=`dw-toc`,n.setAttribute(`data-type`,`toc`),n.setAttribute(`aria-label`,t.toc),n.contentEditable=`false`;let r=document.createElement(`p`);r.className=`dw-toc__title`,r.textContent=t.toc;let i=document.createElement(`ol`);i.className=`dw-toc__list`,n.append(r,i);let a=``,o=()=>{let n=mz(e.state.doc),r=JSON.stringify(n.map(e=>[e.level,e.text]));if(r===a){i.querySelectorAll(`a`).forEach((e,t)=>e.dataset.pos=String(n[t]?.pos??0));return}if(a=r,i.replaceChildren(),!n.length){let e=document.createElement(`li`);e.className=`dw-toc__empty`,e.textContent=t.tocEmpty,i.append(e);return}let o=Math.min(...n.map(e=>e.level));for(let t of n){let n=document.createElement(`li`);n.style.paddingLeft=`${(t.level-o)*1}rem`;let r=document.createElement(`a`);r.href=`#`,r.textContent=t.text||`…`,r.dataset.pos=String(t.pos),r.addEventListener(`click`,t=>{t.preventDefault(),hz(e,Number(r.dataset.pos))}),n.append(r),i.append(n)}};return o(),e.on(`update`,o),{dom:n,update:e=>e.type.name===`tableOfContents`,ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`),destroy:()=>e.off(`update`,o)}}}}),_z=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},vz=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=_z(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},yz=(e,t)=>{let{state:n,view:r,extensionManager:i}=e,{schema:a,selection:o}=n,{empty:s,$anchor:c}=o,l=!!i.extensions.find(e=>e.name===`gapCursor`);if(!s||c.parent.type!==a.nodes.detailsSummary||!l||t===`right`&&c.parentOffset!==c.parent.nodeSize-2)return!1;let u=yu(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=gu(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||_z(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=Mw.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new Mw(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},bz=qp.create({name:`details`,content:`detailsSummary detailsContent`,group:`block`,defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:`is-open`,HTMLAttributes:{},renderToggleButton:({element:e,isOpen:t})=>{e.setAttribute(`aria-label`,t?`Collapse details content`:`Expand details content`)}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:e=>e.hasAttribute(`open`),renderHTML:({open:e})=>e?{open:``}:{}}}:[]},parseHTML(){return[{tag:`details`}]},renderHTML({HTMLAttributes:e}){return[`details`,A(this.options.HTMLAttributes,e),0]},...Yf({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=A(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(a).forEach(([e,t])=>i.setAttribute(e,t));let o=document.createElement(`button`);o.type=`button`;let s=e=>{this.options.renderToggleButton({element:o,...e})};i.append(o);let c=document.createElement(`div`);i.append(c);let l=e=>{let{setToValue:t,node:r=n}=e||{};if(t!==void 0){if(t){if(i.classList.contains(this.options.openClassName))return;i.classList.add(this.options.openClassName)}else{if(!i.classList.contains(this.options.openClassName))return;i.classList.remove(this.options.openClassName)}}else i.classList.toggle(this.options.openClassName);let a=i.classList.contains(this.options.openClassName);s({isOpen:a,node:r});let o=new Event(`toggleDetailsContent`);c.querySelector(`:scope > div[data-type="detailsContent"]`)?.dispatchEvent(o)};return s({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>l()),o.addEventListener(`click`,()=>{if(l(),!this.options.persist)e.commands.focus(void 0,{scrollIntoView:!1});else if(e.isEditable&&typeof t==`function`){let{from:n,to:r}=e.state.selection;e.chain().command(({tr:e})=>{let n=t();if(typeof n!=`number`)return!1;let r=e.doc.nodeAt(n);return r?.type===this.type&&(e.setNodeMarkup(n,void 0,{open:!r.attrs.open}),!0)}).setTextSelection({from:n,to:r}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:i,contentDOM:c,ignoreMutation(e){if(e.type===`selection`)return!1;let t=e.target,n=i.contains(t);return o.contains(t)||!n||i===t},update:e=>e.type===this.type&&(e.attrs.open===void 0?s({isOpen:i.classList.contains(this.options.openClassName),node:e}):l({setToValue:e.attrs.open,node:e}),!0)}}},addCommands(){return{setDetails:()=>({state:e,chain:t})=>{let{schema:n,selection:r}=e,{$from:i,$to:a}=r,o=i.blockRange(a);if(!o)return!1;let s=e.doc.slice(o.start,o.end);if(!n.nodes.detailsContent.contentMatch.matchFragment(s.content))return!1;let c=s.toJSON()?.content||[];return t().insertContentAt({from:o.start,to:o.end},{type:this.name,content:[{type:`detailsSummary`},{type:`detailsContent`,content:c}]}).setTextSelection(o.start+2).run()},unsetDetails:()=>({state:e,chain:t})=>{let{selection:n,schema:r}=e,i=yu(e=>e.type===this.type)(n);if(!i)return!1;let a=gu(i.node,e=>e.type===r.nodes.detailsSummary),o=gu(i.node,e=>e.type===r.nodes.detailsContent);if(!a.length||!o.length)return!1;let s=a[0],c=o[0],l=i.pos,u=e.doc.resolve(l),d={from:l,to:l+i.node.nodeSize},f=c.node.content.toJSON()||[],p=[u.parent.type.contentMatch.defaultType?.create(null,s.node.content).toJSON(),...f];return t().insertContentAt(d,p).setTextSelection(l+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:e,selection:t}=this.editor.state,{empty:n,$anchor:r}=t;return!n||r.parent.type!==e.nodes.detailsSummary?!1:r.parentOffset===0?this.editor.commands.unsetDetails():this.editor.commands.command(({tr:e})=>{let t=r.pos-1,n=r.pos;return e.delete(t,n),!0})},Enter:({editor:e})=>{let{state:t,view:n}=e,{schema:r,selection:i}=t,{$head:a}=i;if(a.parent.type!==r.nodes.detailsSummary)return!1;let o=_z(a.after()+1,e),s=o?t.doc.nodeAt(a.after()):a.node(-2);if(!s)return!1;let c=o?0:a.indexAfter(-1),l=Ll(s.contentMatchAt(c));if(!l||!s.canReplaceWith(c,c,l))return!1;let u=l.createAndFill();if(!u)return!1;let d=o?a.after()+1:a.after(-1),f=t.tr.replaceWith(d,d,u),p=f.doc.resolve(d),m=C.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>yz(e,`right`),ArrowDown:({editor:e})=>yz(e,`down`)}},addProseMirrorPlugins(){return[new E({key:new D(`detailsSelection`),appendTransaction:(e,t,n)=>{let{editor:r,type:i}=this;if(r.view.composing||!e.some(e=>e.selectionSet)||!t.selection.empty||!n.selection.empty||!sd(n,i.name))return;let{$from:a}=n.selection;if(_z(a.pos,r))return;let o=vz(a,e=>e.type===i,r);if(!o)return;let s=gu(o.node,e=>e.type===n.schema.nodes.detailsSummary);if(!s.length)return;let c=s[0],l=(t.selection.from{let t=document.createElement(`div`),n=A(this.options.HTMLAttributes,e,{"data-type":this.name,hidden:`hidden`});return Object.entries(n).forEach(([e,n])=>t.setAttribute(e,n)),t.addEventListener(`toggleDetailsContent`,()=>{t.toggleAttribute(`hidden`)}),{dom:t,contentDOM:t,ignoreMutation(e){return e.type===`selection`?!1:!t.contains(e.target)||t===e.target},update:e=>e.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{state:t,view:n}=e,{selection:r}=t,{$from:i,empty:a}=r,o=yu(e=>e.type===this.type)(r);if(!a||!o||!o.node.childCount)return!1;let s=i.index(o.depth),{childCount:c}=o.node;if(c!==s+1)return!1;let l=o.node.type.contentMatch.defaultType?.createAndFill();if(!l)return!1;let u=t.doc.resolve(o.pos+1),d=c-1,f=o.node.child(d),p=u.posAtIndex(d,o.depth);if(!f.eq(l))return!1;let m=i.node(-3);if(!m)return!1;let h=i.indexAfter(-3),g=Ll(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:v}=t,y=i.after(-2);v.replaceWith(y,y,_);let b=v.doc.resolve(y),x=C.near(b,1);v.setSelection(x);let S=p,ee=p+f.nodeSize;return v.delete(S,ee),v.scrollIntoView(),n.dispatch(v),!0}}},...Yf({nodeName:`detailsContent`})}),Sz=qp.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,A(this.options.HTMLAttributes,e),0]},...Yf({nodeName:`detailsSummary`,content:`inline`})});function Cz(e){return[bz.configure({persist:!1,HTMLAttributes:{class:`dw-toggle`},renderToggleButton:({element:t,isOpen:n})=>{t.setAttribute(`aria-label`,n?e.blocks.collapse:e.blocks.expand),t.setAttribute(`aria-expanded`,String(n))}}),Sz,xz]}function wz(e={}){let t=e.labels??hM,n=null,r=wp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Bk.configure({heading:{levels:[1,2,3]},link:{openOnClick:!1,autolink:!0},undoRedo:!e.collab&&void 0}),cT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),uM.configure({host:e.files}),fM.configure({host:e.files}),pM.configure({host:e.files,onError:e.onError}),QR(t,e.mentions),pz.configure({commands:dz(t,e.files,e.onError,e.pages,!!e.loadExcalidraw,e.links),labels:t}),Zk.configure({onSelect:e.onCommentSelect}),DR(t,()=>n),iz.configure({labels:t,load:e.loadMermaid}),gz.configure({labels:t}),sA.configure(i),cA.configure(i),lz.configure({host:e.pages,labels:t,onNavigate:e.onNavigate}),...Cz(t),aM.configure({labels:t}),oM.configure({labels:t}),Gk.configure({labels:t,link:e.blockLink,onCopied:e.onBlockLinkCopied})];return e.collab&&a.push(ww.configure({document:e.collab.provider.doc}),kw.configure({provider:e.collab.provider,user:e.collab.user,render:Tz})),a}function Tz(e){let t=typeof e.color==`string`&&/^#[0-9a-f]{3,8}$/i.test(e.color)?e.color:`#888`,n=document.createElement(`span`);n.classList.add(`collaboration-carets__caret`),n.style.borderColor=t;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.setAttribute(`aria-hidden`,`true`),r.style.backgroundColor=t,r.textContent=typeof e.name==`string`?e.name:``,n.append(r),n}var Ez=3e4,Dz=class extends lm{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=jh();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Oz(this,t,`timeout`)},um(Ez/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:jh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Zh(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},Oz=(e,t,n)=>{let r=[];for(let n=0;n0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},kz=(e,t,n=e.states)=>{let r=t.length,i=jm();j(i,r);for(let a=0;a{let r=dh(t),i=jh(),a=[],o=[],s=[],c=[],l=M(r);for(let t=0;t0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},jz=(e,t)=>{j(e,0),Um(e,Wv(t))},Mz=(e,t,n)=>{j(e,1),Um(e,Rv(t,n))},Nz=(e,t,n)=>Mz(t,n,mh(e)),Pz=(e,t,n,r)=>{try{Fv(t,mh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Fz=(e,t)=>{j(e,2),Um(e,t)},Iz=Pz,Lz=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:Nz(e,t,n);break;case 1:Pz(e,n,r,i);break;case 2:Iz(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Rz=0,zz=1,Bz=4401,Vz=4404,Hz=4409,Uz=class{opts;doc=new yv;awareness=new Dz(this.doc);status=`connecting`;synced=!1;ws=null;retries=0;retryTimer;destroyed=!1;listeners=new Set;constructor(e){this.opts=e,this.doc.on(`update`,this.onDocUpdate),this.awareness.on(`update`,this.onAwarenessUpdate),window.addEventListener(`beforeunload`,this.onUnload),this.connect()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.listeners.clear(),clearTimeout(this.retryTimer),window.removeEventListener(`beforeunload`,this.onUnload),Oz(this.awareness,[this.doc.clientID],`local`),this.doc.off(`update`,this.onDocUpdate),this.awareness.off(`update`,this.onAwarenessUpdate),this.ws?.close(),this.awareness.destroy(),this.doc.destroy(),this.listeners.clear())}set(e,t=this.synced){(e!==this.status||t!==this.synced)&&(this.status=e,this.synced=t,this.listeners.forEach(e=>e()))}connect(){let e=new WebSocket(`${this.opts.url}?page=${encodeURIComponent(this.opts.page)}`);e.binaryType=`arraybuffer`,this.ws=e,e.onopen=()=>{e.send(this.opts.token()??``);let t=jm();j(t,Rz),jz(t,this.doc),e.send(Pm(t)),this.awareness.getLocalState()!==null&&this.sendAwareness([this.doc.clientID])},e.onmessage=e=>this.onMessage(new Uint8Array(e.data)),e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=[...this.awareness.getStates().keys()].filter(e=>e!==this.doc.clientID);Oz(this.awareness,n,this),this.destroyed||(t.code===Bz||t.code===Vz?this.set(`denied`,!1):t.code===Hz?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=dh(e),n=M(t);if(n===Rz){let e=jm();j(e,Rz);let n=Lz(t,e,this.doc,this);Nm(e)>1&&this.ws?.send(Pm(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===zz&&Az(this.awareness,mh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.ws?.readyState!==WebSocket.OPEN)return;let n=jm();j(n,Rz),Fz(n,e),this.ws.send(Pm(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r!==this&&this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=jm();j(t,zz),Um(t,kz(this.awareness,e)),this.ws.send(Pm(t))}onUnload=()=>Oz(this.awareness,[this.doc.clientID],`unload`)},Wz={bold:e=>e.chain().focus().toggleBold().run(),italic:e=>e.chain().focus().toggleItalic().run(),strike:e=>e.chain().focus().toggleStrike().run(),code:e=>e.chain().focus().toggleCode().run(),heading1:e=>e.chain().focus().toggleHeading({level:1}).run(),heading2:e=>e.chain().focus().toggleHeading({level:2}).run(),heading3:e=>e.chain().focus().toggleHeading({level:3}).run(),bulletList:e=>e.chain().focus().toggleBulletList().run(),orderedList:e=>e.chain().focus().toggleOrderedList().run(),blockquote:e=>e.chain().focus().toggleBlockquote().run(),codeBlock:e=>e.chain().focus().toggleCodeBlock().run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},Gz=[[`bold`,e=>e.isActive(`bold`)],[`italic`,e=>e.isActive(`italic`)],[`strike`,e=>e.isActive(`strike`)],[`code`,e=>e.isActive(`code`)],[`heading1`,e=>e.isActive(`heading`,{level:1})],[`heading2`,e=>e.isActive(`heading`,{level:2})],[`heading3`,e=>e.isActive(`heading`,{level:3})],[`bulletList`,e=>e.isActive(`bulletList`)],[`orderedList`,e=>e.isActive(`orderedList`)],[`blockquote`,e=>e.isActive(`blockquote`)],[`codeBlock`,e=>e.isActive(`codeBlock`)]],Kz=class{el;send;editor;provider=null;lastState=``;editable=!0;constructor(e,t){this.el=e,this.send=t,this.editor=this.create({}),t({type:`ready`,version:1})}receive(e){try{let t=typeof e==`string`?JSON.parse(e):e;this.handle(t)}catch(e){this.send({type:`error`,message:e instanceof Error?e.message:String(e)})}}get content(){return this.editor.getJSON()}destroy(){this.editor.destroy(),this.provider?.destroy()}handle(e){switch(e.type){case`hello`:this.send({type:`ready`,version:1}),this.lastState=``,this.reportState(this.editor);return;case`setContent`:this.editor.commands.setContent(e.content??``,{emitUpdate:!1}),this.reportState(this.editor);return;case`setEditable`:this.editable=e.editable,this.editor.setEditable(e.editable);return;case`setTheme`:document.documentElement.classList.toggle(`dark`,e.dark);return;case`command`:{let t=Wz[e.command];if(!t)throw Error(`unknown command ${e.command}`);t(this.editor);return}case`focus`:this.editor.commands.focus();return;case`blur`:this.editor.commands.blur();return;case`connect`:this.connect(e);return;default:throw Error(`unknown message ${e.type}`)}}connect(e){this.provider?.destroy();let t=new Uz({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}})}create(e){return this.el.replaceChildren(),new Bp({element:this.el,editable:this.editable,extensions:wz({...e,onNavigate:e=>this.send({type:`navigate`,path:e})}),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:({editor:e})=>this.reportState(e),onTransaction:({editor:e})=>this.reportState(e),onFocus:({editor:e})=>this.reportState(e),onBlur:({editor:e})=>this.reportState(e)})}reportState(e){let t={active:Gz.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function qz(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var Jz=new Kz(document.getElementById(`editor`),qz);window.docwell={receive:e=>Jz.receive(e)}; diff --git a/Packages/editor-bridge/src/bridge.ts b/Packages/editor-bridge/src/bridge.ts index db9edae..818b335 100644 --- a/Packages/editor-bridge/src/bridge.ts +++ b/Packages/editor-bridge/src/bridge.ts @@ -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), diff --git a/Packages/editor-bridge/src/protocol.ts b/Packages/editor-bridge/src/protocol.ts index 17e87d7..a42cf29 100644 --- a/Packages/editor-bridge/src/protocol.ts +++ b/Packages/editor-bridge/src/protocol.ts @@ -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/". */ + | { type: "navigate"; path: string } | { type: "error"; message: string }; /** Bumped when a message changes shape, so the app can refuse a stale bundle. */ diff --git a/Packages/editor/src/blocklinks.ts b/Packages/editor/src/blocklinks.ts index f6f6232..acc64f3 100644 --- a/Packages/editor/src/blocklinks.ts +++ b/Packages/editor/src/blocklinks.ts @@ -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; } diff --git a/Phone-App/android/app/build.gradle.kts b/Phone-App/android/app/build.gradle.kts index f2a3096..9191635 100644 --- a/Phone-App/android/app/build.gradle.kts +++ b/Phone-App/android/app/build.gradle.kts @@ -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") +} diff --git a/Phone-App/android/app/src/main/AndroidManifest.xml b/Phone-App/android/app/src/main/AndroidManifest.xml index 5dc1479..c017f80 100644 --- a/Phone-App/android/app/src/main/AndroidManifest.xml +++ b/Phone-App/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ + + + + + + + diff --git a/Phone-App/android/app/src/main/kotlin/app/docwell/docwell_mobile/MainActivity.kt b/Phone-App/android/app/src/main/kotlin/app/docwell/docwell_mobile/MainActivity.kt index 9063d49..302dd48 100644 --- a/Phone-App/android/app/src/main/kotlin/app/docwell/docwell_mobile/MainActivity.kt +++ b/Phone-App/android/app/src/main/kotlin/app/docwell/docwell_mobile/MainActivity.kt @@ -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? = 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? { + 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)) + } +} diff --git a/Phone-App/lib/api/docwell_api.dart b/Phone-App/lib/api/docwell_api.dart index fb16e52..30eacd4 100644 --- a/Phone-App/lib/api/docwell_api.dart +++ b/Phone-App/lib/api/docwell_api.dart @@ -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 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 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 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 refresh() async => + _session(await _send('POST', '/api/v1/auth/refresh')); + + User _session(Map 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); } - Future me() async => - User.fromJson(await _send('GET', '/api/v1/auth/me')); + /// The signed-in user (cached, so the app can start offline). + Future me() async => User.fromJson(await _get('/api/v1/auth/me')); void logout() => token = null; + // ---- Browsing (cached for offline reading) ------------------------------- + + Future> workspaces() async => (await _getList( + '/api/v1/workspaces', + )).map((e) => Workspace.fromJson(e as Map)).toList(); + + Future> spaces(String workspace) async => (await _getList( + '/api/v1/workspaces/${_id(workspace)}/spaces', + )).map((e) => Space.fromJson(e as Map)).toList(); + + /// The space's page tree as a flat list in depth-first order. + Future> pages(String space) async => (await _getList( + '/api/v1/spaces/${_id(space)}/pages', + )).map((e) => PageNode.fromJson(e as Map)).toList(); + + Future page(String id) async => + Page.fromJson(await _get('/api/v1/pages/${_id(id)}')); + + Future content(String id) async => + PageContent.fromJson(await _get('/api/v1/pages/${_id(id)}/content')); + + Future> recent(String workspace) async => (await _getList( + '/api/v1/workspaces/${_id(workspace)}/recent', + )).map((e) => PageItem.fromJson(e as Map)).toList(); + + Future 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 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 saveContent(String page, Map doc) => + _send('PUT', '/api/v1/pages/${_id(page)}/content', {'content': doc}); + + /// Records that the user opened the page, for their recent list. + Future visit(String page) => + _send('POST', '/api/v1/pages/${_id(page)}/visit'); + + // ---- Comments ------------------------------------------------------------ + + Future> comments(String page) async => (await _getList( + '/api/v1/pages/${_id(page)}/comments', + )).map((e) => Comment.fromJson(e as Map)).toList(); + + Future 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 resolveComment(String id, bool resolved) => _send( + 'POST', + '/api/v1/comments/${_id(id)}/resolve', + {'resolved': resolved}, + ); + + // ---- Notifications ------------------------------------------------------- + + Future notifications() async => NotificationList.fromJson( + await _send('GET', '/api/v1/notifications?limit=50'), + ); + + Future markRead({List 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 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 removeDevice(String id) => + _send('DELETE', '/api/v1/me/devices/${_id(id)}'); + + // ---- Transport ----------------------------------------------------------- + + static String _id(String id) => Uri.encodeComponent(id); + + Future> _get(String path) async => + (await _cached(path)) as Map; + + Future> _getList(String path) async => + (await _cached(path)) as List; + + /// A GET that falls back to the cached copy when the server is unreachable. + Future _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> _send( String method, String path, [ Object? body, ]) async { + final raw = await _raw(method, path, body); + if (raw.isEmpty) return {}; + final data = jsonDecode(raw); + return data is Map ? data : {'items': data}; + } + + Future _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 - ? {} - : jsonDecode(res.body) as Map; + final text = utf8.decode(res.bodyBytes); if (res.statusCode >= 300) { + Map data = {}; + try { + data = jsonDecode(text) as Map; + } 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)'; } diff --git a/Phone-App/lib/api/generated/models.dart b/Phone-App/lib/api/generated/models.dart index 57f34bd..59155fa 100644 --- a/Phone-App/lib/api/generated/models.dart +++ b/Phone-App/lib/api/generated/models.dart @@ -1048,6 +1048,58 @@ class TrashedPage { }; } +class PushDevice { + const PushDevice({ + required this.id, + required this.name, + required this.created, + }); + + factory PushDevice.fromJson(Map 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 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 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/``?comment=`` + final String route; + + Map toJson() => { + 'title': title, + 'body': body, + 'route': route, + }; +} + class ArchivedPage { const ArchivedPage({ required this.id, diff --git a/Phone-App/lib/api/response_cache.dart b/Phone-App/lib/api/response_cache.dart new file mode 100644 index 0000000..7703b04 --- /dev/null +++ b/Phone-App/lib/api/response_cache.dart @@ -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 read(String key); + Future write(String key, String body); + + /// Forgets everything (signing out, switching servers). + Future clear(); +} + +/// Kept in memory only: tests, and before the disk cache is ready. +class MemoryCache implements ResponseCache { + final _items = {}; + + @override + Future read(String key) async => _items[key]; + + @override + Future write(String key, String body) async => _items[key] = body; + + @override + Future 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 read(String key) async { + try { + return await _file(key).readAsString(); + } on FileSystemException { + return null; + } + } + + @override + Future 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 clear() async { + if (await dir.exists()) await dir.delete(recursive: true); + } +} diff --git a/Phone-App/lib/app.dart b/Phone-App/lib/app.dart new file mode 100644 index 0000000..06604a5 --- /dev/null +++ b/Phone-App/lib/app.dart @@ -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 createState() => _DocwellAppState(); +} + +class _DocwellAppState extends State { + final _navigator = GlobalKey(); + 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 _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 _onLogin(DocwellApi api, User user) async { + await widget.sessions.save(api.baseUrl, api.token!); + _server = api.baseUrl; + _signedIn(api, user); + } + + Future _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/` (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( + 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( + 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), + ); + } +} diff --git a/Phone-App/lib/editor/bridge.dart b/Phone-App/lib/editor/bridge.dart index f565fe1..032af38 100644 --- a/Phone-App/lib/editor/bridge.dart +++ b/Phone-App/lib/editor/bridge.dart @@ -68,6 +68,7 @@ class EditorBridge extends ChangeNotifier { String? _error; final _readyCompleter = Completer(); final _changes = StreamController>.broadcast(); + final _navigations = StreamController.broadcast(); /// The latest document (Tiptap JSON), null until there is one. Map? get content => _content; @@ -88,6 +89,9 @@ class EditorBridge extends ChangeNotifier { /// Every edit the user makes. Stream> get changes => _changes.stream; + /// App routes of page links the user followed, e.g. `/p/`. + Stream get navigations => _navigations.stream; + /// Call once the page has loaded. Future 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(); } } diff --git a/Phone-App/lib/editor/editor_screen.dart b/Phone-App/lib/editor/editor_screen.dart index 21e1573..6b1ef17 100644 --- a/Phone-App/lib/editor/editor_screen.dart +++ b/Phone-App/lib/editor/editor_screen.dart @@ -95,7 +95,7 @@ class _EditorScreenState extends State { ], ), ), - _Toolbar(bridge: _bridge), + EditorToolbar(bridge: _bridge), ], ), ); @@ -103,8 +103,8 @@ class _EditorScreenState extends State { } /// 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; diff --git a/Phone-App/lib/main.dart b/Phone-App/lib/main.dart index 9de3c98..7da0bfc 100644 --- a/Phone-App/lib/main.dart +++ b/Phone-App/lib/main.dart @@ -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 createState() => _DocwellAppState(); -} - -class _DocwellAppState extends State { - 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 onSignedIn; - - @override - State createState() => _LoginScreenState(); -} - -class _LoginScreenState extends State { - 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 _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 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 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 { - late Future _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( - 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( - builder: (_) => const EditorScreen( - title: 'Scratch page', - content: _scratchPage, - ), - ), - ), - ), - ], - ), - ), - ); - } + push: PushService(), + shares: ShareReceiver(), + defaultServer: defaultServerUrl, + ), + ); } diff --git a/Phone-App/lib/push.dart b/Phone-App/lib/push.dart new file mode 100644 index 0000000..1094ad1 --- /dev/null +++ b/Phone-App/lib/push.dart @@ -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 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 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 _register() => + UnifiedPushPlatform.instance.register(_instance, const [], null, null); + + /// Turns push off on this phone and tells the server to stop. + Future 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 _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 _forget() async { + _deviceId = null; + await _storage.delete(key: 'push_device'); + notifyListeners(); + } + + Future _show(PushMessage m) async { + if (!m.decrypted) return; + final Map msg; + try { + msg = jsonDecode(utf8.decode(m.content)) as Map; + } 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?, + ); + } +} diff --git a/Phone-App/lib/screens/comments_screen.dart b/Phone-App/lib/screens/comments_screen.dart new file mode 100644 index 0000000..3d47e51 --- /dev/null +++ b/Phone-App/lib/screens/comments_screen.dart @@ -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 createState() => _CommentsScreenState(); +} + +class _CommentsScreenState extends State { + DocwellApi get _api => widget.session.api; + List? _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 _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 _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 _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, + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/Phone-App/lib/screens/home_screen.dart b/Phone-App/lib/screens/home_screen.dart new file mode 100644 index 0000000..8dddd85 --- /dev/null +++ b/Phone-App/lib/screens/home_screen.dart @@ -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 createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + DocwellApi get _api => widget.session.api; + List? _workspaces; + Workspace? _workspace; + List _spaces = []; + List _recent = []; + int _unread = 0; + String? _error; + bool _offline = false; + + @override + void initState() { + super.initState(); + _load(); + } + + Future _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 spaces = []; + List recent = []; + if (ws != null) { + spaces = await _api.spaces(ws.id); + offline |= _api.offline; + recent = await _api.recent(ws.id).catchError((_) => []); + } + 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(builder: (_) => screen)).then((_) => _load()); + + Future _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( + 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( + 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)), + ), + ], + ], + ), + ), + ); + } +} diff --git a/Phone-App/lib/screens/login_screen.dart b/Phone-App/lib/screens/login_screen.dart new file mode 100644 index 0000000..93b0221 --- /dev/null +++ b/Phone-App/lib/screens/login_screen.dart @@ -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 Function(DocwellApi api, User user) onSignedIn; + + @override + State createState() => _LoginScreenState(); +} + +class _LoginScreenState extends State { + 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 _run(Future 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'), + ), + ], + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/Phone-App/lib/screens/notifications_screen.dart b/Phone-App/lib/screens/notifications_screen.dart new file mode 100644 index 0000000..bf1a5a8 --- /dev/null +++ b/Phone-App/lib/screens/notifications_screen.dart @@ -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 createState() => _NotificationsScreenState(); +} + +class _NotificationsScreenState extends State { + DocwellApi get _api => widget.session.api; + NotificationList? _list; + String? _error; + + @override + void initState() { + super.initState(); + _load(); + } + + Future _load() async { + try { + final list = await _api.notifications(); + if (mounted) { + setState(() { + _list = list; + _error = null; + }); + } + } catch (e) { + if (mounted) setState(() => _error = describeError(e)); + } + } + + Future _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( + builder: (_) => PageScreen( + session: widget.session, + pageId: page.id, + openComment: n.comment.isEmpty ? null : n.comment, + ), + ), + ); + _load(); + } + + Future _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 ?? []) + 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), + ), + ], + ), + ), + ); + } +} diff --git a/Phone-App/lib/screens/page_screen.dart b/Phone-App/lib/screens/page_screen.dart new file mode 100644 index 0000000..3dae95b --- /dev/null +++ b/Phone-App/lib/screens/page_screen.dart @@ -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 createState() => _PageScreenState(); +} + +class _PageScreenState extends State { + DocwellApi get _api => widget.session.api; + final _web = WebViewController(); + late final EditorBridge _bridge = EditorBridge(evaluate: _web.runJavaScript); + StreamSubscription? _links; + + Page? _page; + Map? _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 _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 _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 _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( + builder: (_) => PageScreen(session: widget.session, pageId: m[1]!), + ), + ); + } + + void _comments() { + final page = _page; + if (page == null) return; + Navigator.of(context).push( + MaterialPageRoute( + 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), + ], + ), + ); + } +} diff --git a/Phone-App/lib/screens/search_screen.dart b/Phone-App/lib/screens/search_screen.dart new file mode 100644 index 0000000..b50a6ee --- /dev/null +++ b/Phone-App/lib/screens/search_screen.dart @@ -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 createState() => _SearchScreenState(); +} + +class _SearchScreenState extends State { + final _query = TextEditingController(); + Timer? _debounce; + List _hits = []; + String? _error; + bool _searching = false; + int _seq = 0; + + void _changed(String q) { + _debounce?.cancel(); + _debounce = Timer(const Duration(milliseconds: 250), () => _search(q)); + } + + Future _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( + builder: (_) => + PageScreen(session: widget.session, pageId: h.id), + ), + ), + ), + ], + ), + ); + } +} diff --git a/Phone-App/lib/screens/share_screen.dart b/Phone-App/lib/screens/share_screen.dart new file mode 100644 index 0000000..456423f --- /dev/null +++ b/Phone-App/lib/screens/share_screen.dart @@ -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 sharedDoc(String text) { + List> inline(String line) { + final out = >[]; + 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 createState() => _ShareScreenState(); +} + +class _ShareScreenState extends State { + 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 _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 _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( + 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'), + ), + ], + ), + ); + } +} diff --git a/Phone-App/lib/screens/space_screen.dart b/Phone-App/lib/screens/space_screen.dart new file mode 100644 index 0000000..086f967 --- /dev/null +++ b/Phone-App/lib/screens/space_screen.dart @@ -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 treeRows(List pages) { + final depth = {}; + 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 createState() => _SpaceScreenState(); +} + +class _SpaceScreenState extends State { + List? _pages; + final _open = {}; + 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 _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 _openPage(String id, {bool edit = false}) async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => + PageScreen(session: widget.session, pageId: id, startEditing: edit), + ), + ); + _load(); + } + + Future _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 ? [] : treeRows(pages); + final hasChildren = {for (final p in pages ?? []) p.parent}; + // A row shows when every ancestor is open. + final visible = []; + final shown = {''}; + 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), + ), + ], + ), + ), + ); + } +} diff --git a/Phone-App/lib/screens/widgets.dart b/Phone-App/lib/screens/widgets.dart new file mode 100644 index 0000000..8288c44 --- /dev/null +++ b/Phone-App/lib/screens/widgets.dart @@ -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]; +} diff --git a/Phone-App/lib/session.dart b/Phone-App/lib/session.dart new file mode 100644 index 0000000..1237cd0 --- /dev/null +++ b/Phone-App/lib/session.dart @@ -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 save(String server, String token); + + /// Signs out on this phone; the server address is kept for next time. + Future clearToken(); + Future 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 save(String server, String token) async { + await _storage.write(key: 'server', value: server); + await _storage.write(key: 'token', value: token); + } + + @override + Future clearToken() => _storage.delete(key: 'token'); + + @override + Future 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 save(String server, String token) async { + this.server = server; + this.token = token; + } + + @override + Future clearToken() async => token = null; + + @override + Future lastServer() async => server; +} diff --git a/Phone-App/lib/share.dart b/Phone-App/lib/share.dart new file mode 100644 index 0000000..8cd2005 --- /dev/null +++ b/Phone-App/lib/share.dart @@ -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 listen(void Function(SharedText) onShare) async { + _channel.setMethodCallHandler((call) async { + if (call.method == 'shared') onShare(_read(call.arguments)); + }); + try { + final first = await _channel.invokeMethod('takeShared'); + if (first != null) onShare(_read(first)); + } on MissingPluginException { + // Not on Android. + } + } + + static SharedText _read(Object? raw) { + final m = (raw as Map).cast(); + return SharedText( + m['text'] as String? ?? '', + m['subject'] as String? ?? '', + ); + } +} diff --git a/Phone-App/pubspec.lock b/Phone-App/pubspec.lock index 6483628..39da054 100644 --- a/Phone-App/pubspec.lock +++ b/Phone-App/pubspec.lock @@ -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: diff --git a/Phone-App/pubspec.yaml b/Phone-App/pubspec.yaml index 3b635a8..6c6b4f3 100644 --- a/Phone-App/pubspec.yaml +++ b/Phone-App/pubspec.yaml @@ -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 diff --git a/Phone-App/test/widget_test.dart b/Phone-App/test/widget_test.dart index bb3c90e..d4277fe 100644 --- a/Phone-App/test/widget_test.dart +++ b/Phone-App/test/widget_test.dart @@ -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 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 = >[]; + + 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; 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; + 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; + 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 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 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())); + server.down = false; + // A refusal is never hidden behind the cache. + api.token = 'other'; + await expectLater(api.workspaces(), throwsA(isA())); + }, + ); } diff --git a/Server/cmd/docwell-server/main.go b/Server/cmd/docwell-server/main.go index c66ac41..a9de1a2 100644 --- a/Server/cmd/docwell-server/main.go +++ b/Server/cmd/docwell-server/main.go @@ -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, }), diff --git a/Server/internal/api/api.gen.go b/Server/internal/api/api.gen.go index 6f5d318..98ff7ee 100644 --- a/Server/internal/api/api.gen.go +++ b/Server/internal/api/api.gen.go @@ -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 diff --git a/Server/internal/directory/directory.go b/Server/internal/directory/directory.go index 71b8e21..aad7057 100644 --- a/Server/internal/directory/directory.go +++ b/Server/internal/directory/directory.go @@ -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 { diff --git a/Server/internal/directory/notify.go b/Server/internal/directory/notify.go index 3b2dcc6..5446780 100644 --- a/Server/internal/directory/notify.go +++ b/Server/internal/directory/notify.go @@ -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)) } } } diff --git a/Server/internal/httpapi/auth.go b/Server/internal/httpapi/auth.go index d18f45d..ef0fe0c 100644 --- a/Server/internal/httpapi/auth.go +++ b/Server/internal/httpapi/auth.go @@ -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) diff --git a/Server/internal/httpapi/collab.go b/Server/internal/httpapi/collab.go index e808416..ab1cbc0 100644 --- a/Server/internal/httpapi/collab.go +++ b/Server/internal/httpapi/collab.go @@ -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") +} diff --git a/Server/internal/httpapi/push.go b/Server/internal/httpapi/push.go new file mode 100644 index 0000000..6311216 --- /dev/null +++ b/Server/internal/httpapi/push.go @@ -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"))) + })) +} diff --git a/Server/internal/httpapi/router.go b/Server/internal/httpapi/router.go index a9fc858..283ef9b 100644 --- a/Server/internal/httpapi/router.go +++ b/Server/internal/httpapi/router.go @@ -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) diff --git a/Server/internal/httpapi/router_test.go b/Server/internal/httpapi/router_test.go index 5cbc7c2..a92e94d 100644 --- a/Server/internal/httpapi/router_test.go +++ b/Server/internal/httpapi/router_test.go @@ -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) + } + } +} diff --git a/Server/internal/push/push.go b/Server/internal/push/push.go new file mode 100644 index 0000000..51f830a --- /dev/null +++ b/Server/internal/push/push.go @@ -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/?comment=". + 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) +} diff --git a/Server/internal/push/push_test.go b/Server/internal/push/push_test.go new file mode 100644 index 0000000..27bbc3d --- /dev/null +++ b/Server/internal/push/push_test.go @@ -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") + } +} diff --git a/Server/internal/push/webpush.go b/Server/internal/push/webpush.go new file mode 100644 index 0000000..ea92b52 --- /dev/null +++ b/Server/internal/push/webpush.go @@ -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 +} diff --git a/Server/internal/webhooks/webhooks.go b/Server/internal/webhooks/webhooks.go index dd9906a..6d3def3 100644 --- a/Server/internal/webhooks/webhooks.go +++ b/Server/internal/webhooks/webhooks.go @@ -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 { diff --git a/api/openapi.yaml b/api/openapi.yaml index 9aa09ed..0b237b2 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -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/?comment=' } ArchivedPage: type: object required: [id, title, icon, archivedAt] diff --git a/go.work.sum b/go.work.sum index 0933723..868aeaa 100644 --- a/go.work.sum +++ b/go.work.sum @@ -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=