diff --git a/Docs-Site/guide/using-docwell.md b/Docs-Site/guide/using-docwell.md index a30cbed..312a6f6 100644 --- a/Docs-Site/guide/using-docwell.md +++ b/Docs-Site/guide/using-docwell.md @@ -36,6 +36,31 @@ A synced page is read-only where it is shown: open it to edit it. People who can title. **Account → Editor** sets, for this device, the text size, whether new pages start full width or titled with today's date, whether properties and the pages that link here show, and line numbers in code blocks. +## Databases + +A database is a block that holds records: type `/database` to add one, or select a list and press **Ctrl+G** (or +choose **Group as database** in the list's ⠿ menu) to turn each item into a record. Everyone with the page open edits +it together, and Ctrl+Z undoes database changes like any other. + +- **Properties** are the columns: title, text, number, checkbox, select, multi-select, date, progress, link, + attachment, member, created time and created by. Click a column's name to rename it, change its type (values are + converted), sort or filter by it, hide it, move it, or insert another next to it. Drag its edge to resize it, or its + name to move it. +- **Cells:** click a cell and type, or press Enter to edit it; arrow keys and Tab move between cells, Delete clears + them and Shift+arrows select several. Copy and paste work with spreadsheets: paste a block of cells and new records + are added as needed. +- **Views** sit in tabs above the records, each with its own filters, sorts, grouping and visible properties: a + **table**, a **kanban** board grouped by a select, checkbox or member property (drag cards between columns), and a + **calendar** that places records on a date property (drag them to another day). Click the active tab to rename, + duplicate, change or delete the view; which view you look at is yours alone. +- **Records as pages:** **Open** on a record, or a click on a card, opens it beside the page, with its properties on + top and room to write below. +- **CSV:** the ⋯ menu exports the current view as a CSV file, or adds records from one; an empty database takes the + file's columns and guesses their types. + +Exports (Markdown, HTML, PDF, Word) show a database as a table of its first view's columns, and search finds the text +in its records. On a public link or in **History**, databases are read-only. + ## Comments Select text and choose **Comment** to start a discussion; the text stays highlighted and the comment appears in @@ -89,8 +114,9 @@ account. Turning it off makes the link stop working at once. Pages in the trash tables, alignment, colours, links and images are kept. Up to 20 files at once. - **From Notion:** in Notion, choose **Settings → Export**, pick **Markdown & CSV** or **HTML** and include subpages and files. Import the `.zip` you get (up to 100 MB, 2000 pages) as it is. Docwell rebuilds the page tree, keeps links - between the pages, and stores images and files as attachments. Each database becomes a page that lists its rows, - with the row pages under it. Tables in pages, and databases, come in as tables; callouts and to-do lists are kept. + between the pages, and stores images and files as attachments. Each database becomes a page with a database block of + its rows, with guessed property types, and the row pages under it. Tables in pages come in as tables; callouts and + to-do lists are kept. - **To Notion:** export the page as Word or Markdown, then import that file with **Import** in Notion's sidebar. ## Trash diff --git a/Packages/editor-bridge/dist/index.html b/Packages/editor-bridge/dist/index.html index b5a8fcb..4cd8d68 100644 --- a/Packages/editor-bridge/dist/index.html +++ b/Packages/editor-bridge/dist/index.html @@ -105,16 +105,16 @@ img.ProseMirror-separator { `,textSerializers:n={}}=e||{};return qu(this.state.doc,{blockSeparator:t,textSerializers:{...Ju(this.schema),...n}})}get isEmpty(){return fd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new zp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Hp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(ed(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;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 Up(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Wp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=Nu(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Gp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=Nu(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&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 Kp=e=>`touches`in e,qp=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.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,Kp(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}}},Jp=class e extends gp{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 Yp(e){return new vp({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 Xp=()=>new Map,Zp=e=>{let t=Xp();return e.forEach((e,n)=>{t.set(n,e)}),t},Qp=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},$p=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},em=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},tm=()=>new Set,nm=e=>e[e.length-1],rm=(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 im((this._observers.get(e)||Xp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Xp()}},um=class{constructor(){this._observers=Xp()}on(e,t){Qp(this._observers,e,tm).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 im((this._observers.get(e)||Xp()).values()).forEach(e=>e(...t))}destroy(){this._observers=Xp()}},dm=Math.floor,fm=Math.abs,pm=(e,t)=>ee>t?e:t;Number.isNaN;var hm=e=>e===0?1/e<0:e<0,gm=1<<29,_m=2**53-1,vm=-(2**53-1),ym=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&dm(e)===e);Number.isNaN,Number.parseInt;var bm=String.fromCharCode;String.fromCodePoint,bm(65535);var xm=e=>e.toLowerCase(),Sm=/^\s*/g,Cm=e=>e.replace(Sm,``),wm=/([A-Z])/g,Tm=(e,t)=>Cm(e.replace(wm,e=>`${t}${xm(e)}`)),Em=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;eDm.encode(e):Em,km=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});km&&km.decode(new Uint8Array).length===1&&(km=null);var Am=(e,t)=>sm(t,()=>e).join(``),jm=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Mm=()=>new jm,Nm=e=>{let t=Mm();return e(t),Fm(t)},Pm=e=>{let t=e.cpos;for(let n=0;n{let t=new Uint8Array(Pm(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},Rm=Lm,j=(e,t)=>{for(;t>127;)Lm(e,128|127&t),t=dm(t/128);Lm(e,127&t)},zm=(e,t)=>{let n=hm(t);for(n&&(t=-t),Lm(e,(t>63?128:0)|(n?64:0)|63&t),t=dm(t/64);t>0;)Lm(e,(t>127?128:0)|127&t),t=dm(t/128)},Bm=new Uint8Array(3e4),Vm=Bm.length/3,Hm=Dm&&Dm.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=pm(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(mm(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Wm=(e,t)=>{j(e,t.byteLength),Um(e,t)},Gm=(e,t)=>{Im(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Km=(e,t)=>Gm(e,4).setFloat32(0,t,!1),qm=(e,t)=>Gm(e,8).setFloat64(0,t,!1),Jm=(e,t)=>Gm(e,8).setBigInt64(0,t,!1),Ym=new DataView(new ArrayBuffer(4)),Xm=e=>(Ym.setFloat32(0,e),Ym.getFloat32(0)===e),Zm=(e,t)=>{switch(typeof t){case`string`:Lm(e,119),Hm(e,t);break;case`number`:ym(t)&&fm(t)<=2147483647?(Lm(e,125),zm(e,t)):Xm(t)?(Lm(e,124),Km(e,t)):(Lm(e,123),qm(e,t));break;case`bigint`:Lm(e,122),Jm(e,t);break;case`object`:if(t===null)Lm(e,126);else if(cm(t)){Lm(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)}},$m=e=>{e.count>0&&(zm(e.encoder,e.count===1?e.s:-e.s),e.count>1&&j(e.encoder,e.count-2))},eh=class{constructor(){this.encoder=new jm,this.s=0,this.count=0}write(e){this.s===e?this.count++:($m(this),this.count=1,this.s=e)}toUint8Array(){return $m(this),Fm(this.encoder)}},th=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);zm(e.encoder,t),e.count>1&&j(e.encoder,e.count-2)}},nh=class{constructor(){this.encoder=new jm,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(th(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return th(this),Fm(this.encoder)}},rh=class{constructor(){this.sarr=[],this.s=``,this.lensE=new eh}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 jm;return this.sarr.push(this.s),this.s=``,Hm(e,this.sarr.join(``)),Um(e,this.lensE.toUint8Array()),Fm(e)}},ih=e=>Error(e),ah=()=>{throw ih(`Method unimplemented`)},oh=()=>{throw ih(`Unexpected case`)},sh=ih(`Unexpected end of array`),ch=ih(`Integer out of Range`),lh=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw sh;return new Uint8Array(e.buffer,e.byteOffset+t,n)},uh=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw sh;return new DataView(e.buffer,e.byteOffset+t,n)},dh=class{constructor(e){this.arr=e,this.pos=0}},fh=e=>new dh(e),ph=e=>e.pos!==e.arr.length,mh=(e,t)=>{let n=lh(e.arr,e.pos,t);return e.pos+=t,n},hh=e=>mh(e,M(e)),gh=e=>e.arr[e.pos++],M=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos_m)throw ch}throw sh},_h=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.pos_m)throw ch}throw sh},vh=km?e=>km.decode(hh(e)):e=>{let t=M(e);if(t===0)return``;{let n=String.fromCodePoint(gh(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(gh(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))}},yh=(e,t)=>{let n=uh(e.arr,e.pos,t);return e.pos+=t,n},bh=[e=>void 0,e=>null,_h,e=>yh(e,4).getFloat32(0,!1),e=>yh(e,8).getFloat64(0,!1),e=>yh(e,8).getBigInt64(0,!1),e=>!1,e=>!0,vh,e=>{let t=M(e),n={};for(let r=0;r{let t=M(e),n=[];for(let r=0;rbh[127-gh(e)](e),Sh=class extends dh{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=ph(this)?M(this)+1:-1),this.count--,this.s}},Ch=class extends dh{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=_h(this);let e=hm(this.s);this.count=1,e&&(this.s=-this.s,this.count=M(this)+2)}return this.count--,this.s}},wh=class extends dh{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=_h(this),t=e&1;this.diff=dm(e/2),this.count=1,t&&(this.count=M(this)+2)}return this.s+=this.diff,this.count--,this.s}},Th=class{constructor(e){this.decoder=new Ch(e),this.str=vh(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 Eh=crypto.getRandomValues.bind(crypto),Dh=Math.random,Oh=()=>Eh(new Uint32Array(1))[0],kh=e=>e[dm(Dh()*e.length)],Ah=`10000000-1000-4000-8000-100000000000`,jh=()=>Ah.replace(/[018]/g,e=>(e^Oh()&15>>e/4).toString(16)),Mh=Date.now,Nh=e=>new Promise(e);Promise.all.bind(Promise);var Ph=e=>e===void 0?null:e,Fh=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&&(Fh=localStorage)}catch{}var Ih=Fh,Lh=Symbol(`Equality`),Rh=(e,t)=>e===t||!!e?.[Lh]?.(t)||!1,zh=e=>typeof e==`object`,Bh=Object.assign,Vh=Object.keys,Hh=(e,t)=>{for(let n in e)t(e[n],n)},Uh=e=>Vh(e).length,Wh=e=>{for(let t in e)return!1;return!0},Gh=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Kh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),qh=(e,t)=>e===t||Uh(e)===Uh(t)&&Gh(e,(e,n)=>(e!==void 0||Kh(t,n))&&Rh(t[n],e)),Jh=Object.freeze,Yh=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Yh(e[t])}return Jh(e)},Xh=(e,t,n=0)=>{try{for(;ne,Qh=(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[Lh]!=null)return e[Lh](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),eg=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,tg=typeof window<`u`&&typeof document<`u`&&!eg;typeof navigator<`u`&&/Mac/.test(navigator.platform);var ng,rg=[],ig=()=>{if(ng===void 0){if(eg){ng=Xp();let e=process.argv,t=null;for(let n=0;n{if(e.length!==0){let[t,n]=e.split(`=`);ng.set(`--${Tm(t,`-`)}`,n),ng.set(`-${Tm(t,`-`)}`,n)}})):ng=Xp()}return ng},ag=e=>ig().has(e),og=e=>Ph(eg?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Ih.getItem(e)),sg=e=>ag(`--`+e)||og(e)!==null,cg=sg(`production`),lg=eg&&$h({}.FORCE_COLOR,[`true`,`1`,`2`])||!ag(`--no-colors`)&&!sg(`no-color`)&&(!eg||process.stdout.isTTY)&&(!eg||ag(`--color`)||og(`COLORTERM`)!==null||(og(`TERM`)||``).includes(`color`)),ug=e=>new Uint8Array(e),dg=e=>{let t=``;for(let n=0;nBuffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),pg=e=>{let t=atob(e),n=ug(t.length);for(let e=0;enew Uint8Array(Buffer.from(e,`base64`)),hg=tg?dg:fg,gg=tg?pg:mg,_g=e=>{let t=ug(e.byteLength);return t.set(e),t},vg=e=>Nm(t=>Zm(t,e)),yg=class{constructor(e,t){this.left=e,this.right=t}},bg=(e,t)=>new yg(e,t),xg=e=>e.next()>=.5,Sg=(e,t,n)=>dm(e.next()*(n+1-t)+t),Cg=(e,t,n)=>dm(e.next()*(n+1-t)+t),wg=(e,t,n)=>Cg(e,t,n),Tg=e=>bm(wg(e,97,122)),Eg=(e,t=0,n=20)=>{let r=wg(e,t,n),i=``;for(let t=0;tt[wg(e,0,t.length-1)],Og=Symbol(`0schema`),kg=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(Am(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(` `)}},Ag=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Lh]?Rh(e,t):cm(e)?am(e,e=>om(t,t=>Ag(e,t))):zh(e)?Gh(e,(e,n)=>Ag(e,t[n])):!1,jg=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Ag(t,n)}equals(e){return this.constructor===e.constructor&&Qh(this.shape,e.shape)}[Og](){return!0}[Lh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ah()}get nullable(){return u_(this,T_)}get optional(){return new Hg(this)}cast(e){return k_(e,this),e}expect(e){return k_(e,this),e}},Mg=class extends jg{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}},Ng=(e,t=null)=>new Mg(e,t);Ng(Mg);var Pg=class extends jg{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}},Fg=e=>new Pg(e);Ng(Pg);var Ig=class extends jg{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}},Lg=(...e)=>new Ig(e),Rg=Ng(Ig),zg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Bg=e=>{if(b_.check(e))return[zg(e)];if(Rg.check(e))return e.shape.map(e=>e+``);if(y_.check(e))return[`[+-]?\\d+.?\\d*`];if(x_.check(e))return[`.*`];if(d_.check(e))return e.shape.map(Bg).flat(1);oh()};Ng(class extends jg{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Bg).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 Vg=Symbol(`optional`),Hg=class extends jg{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[Vg](){return!0}},Ug=Ng(Hg),Wg=class extends jg{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Wg,Ng(Wg);var Gg=class e extends jg{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):Gh(this.shape,(n,r)=>{let i=this._isPartial&&!Kh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Kg=e=>new Gg(e),qg=Ng(Gg),Jg=Fg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Yg=class extends jg{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Gh(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)})}},Xg=(e,t)=>new Yg(e,t),Zg=Ng(Yg),Qg=class extends jg{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Gh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},$g=(...e)=>new Qg(e);Ng(Qg);var e_=class extends jg{constructor(e){super(),this.shape=e.length===1?e[0]:new l_(e)}check(e,t){let n=cm(e)&&am(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},t_=(...e)=>new e_(e),n_=Ng(e_),r_=Fg(e=>cm(e)),i_=class extends jg{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}},a_=(e,t=null)=>new i_(e,t);Ng(i_);var o_=a_(jg),s_=Ng(class extends jg{constructor(e){super(),this.len=e.length-1,this.args=$g(...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}}),c_=Fg(e=>typeof e==`function`);Ng(class extends jg{constructor(e){super(),this.shape=e}check(e,t){let n=am(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var l_=class extends jg{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=om(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},u_=(...e)=>e.findIndex(e=>d_.check(e))>=0?u_(...e.map(e=>O_(e)).map(e=>d_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new l_(e),d_=Ng(l_),f_=()=>!0,p_=Fg(f_),m_=Ng(Pg,e=>e.shape===f_),h_=Fg(e=>typeof e==`bigint`),g_=Fg(e=>e===h_),__=Fg(e=>typeof e==`symbol`);Fg(e=>e===__);var v_=Fg(e=>typeof e==`number`),y_=Fg(e=>e===v_),b_=Fg(e=>typeof e==`string`),x_=Fg(e=>e===b_),S_=Fg(e=>typeof e==`boolean`),C_=Fg(e=>e===S_),w_=Lg(void 0);Ng(Ig,e=>e.shape.length===1&&e.shape[0]===void 0),Lg(void 0);var T_=Lg(null),E_=Ng(Ig,e=>e.shape.length===1&&e.shape[0]===null);Ng(Uint8Array),Ng(Mg,e=>e.shape===Uint8Array);var D_=u_(v_,b_,T_,w_,h_,S_,__);(()=>{let e=t_(p_),t=Xg(b_,p_),n=u_(v_,b_,T_,S_,e,t);return e.shape=n,t.shape.values=n,n})();var O_=e=>{if(o_.check(e))return e;if(Jg.check(e)){let t={};for(let n in e)t[n]=O_(e[n]);return Kg(t)}if(r_.check(e))return u_(...e.map(O_));if(D_.check(e))return Lg(e);if(c_.check(e))return Ng(e);oh()},k_=cg?()=>{}:(e,t)=>{let n=new kg;if(!t.check(e,n))throw ih(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},A_=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:O_(e),h:t}),this}else(e){return this.if(p_,e)}done(){return(e,t)=>{for(let n=0;nnew A_(e))(p_).if(y_,(e,t)=>Sg(t,vm,_m)).if(x_,(e,t)=>Eg(t)).if(C_,(e,t)=>xg(t)).if(g_,(e,t)=>BigInt(Sg(t,vm,_m))).if(d_,(e,t)=>M_(t,Dg(t,e.shape))).if(qg,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Ug.check(i)){if(xg(t))continue;i=i.shape}n[r]=j_(i,t)}return n}).if(n_,(e,t)=>{let n=[],r=Cg(t,0,42);for(let i=0;iDg(t,e.shape)).if(E_,(e,t)=>null).if(s_,(e,t)=>{let n=M_(t,e.res);return()=>n}).if(m_,(e,t)=>M_(t,Dg(t,[v_,b_,T_,w_,h_,S_,t_(v_),Xg(u_(`a`,`b`,`c`),v_)]))).if(Zg,(e,t)=>{let n={},r=Sg(t,0,3);for(let i=0;ij_(O_(t),e),N_=typeof document<`u`?document:{};Fg(e=>e.nodeType===R_),typeof DOMParser<`u`&&new DOMParser,Fg(e=>e.nodeType===F_),Fg(e=>e.nodeType===I_);var P_=e=>$p(e,(e,t)=>`${t}:${e};`).join(``),F_=N_.ELEMENT_NODE,I_=N_.TEXT_NODE;N_.CDATA_SECTION_NODE,N_.COMMENT_NODE;var L_=N_.DOCUMENT_NODE;N_.DOCUMENT_TYPE_NODE;var R_=N_.DOCUMENT_FRAGMENT_NODE;Fg(e=>e.nodeType===L_);var z_=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),B_=(e,t)=>new z_(setTimeout(t,e)),V_=Symbol,H_=V_(),U_=V_(),W_=V_(),G_=V_(),K_=V_(),q_=V_(),J_=V_(),Y_=V_(),X_=V_(),Z_=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=Xp(),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(...$_(e)),nv.forEach(t=>t.print(e))},tv=(...e)=>{console.warn(...$_(e)),e.unshift(Y_),nv.forEach(t=>t.print(e))},nv=tm(),rv=e=>({[Symbol.iterator](){return this},next:e}),iv=(e,t)=>rv(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),av=(e,t)=>rv(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),ov=class{constructor(e,t){this.clock=e,this.len=t}},sv=class{constructor(){this.clients=new Map}},cv=(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=dm((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&&lv(n,t.clock)!==null},dv=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 ov(r.clock,mm(r.len,i.clock+i.len-r.clock)):(n{let t=new sv;for(let n=0;n{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t{Qp(e.clients,t,()=>[]).push(new ov(n,r))},mv=()=>new sv,hv=e=>{let t=mv();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t0&&t.clients.set(n,r)}),t},gv=(e,t)=>{j(e.restEncoder,t.clients.size),im(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 sv,n=M(e.restDecoder);for(let r=0;r0){let i=Qp(t.clients,n,()=>[]);for(let t=0;t{let r=new sv,i=M(e.restDecoder);for(let a=0;a0){let e=new Ov;return j(e.restEncoder,0),gv(e,r),e.toUint8Array()}return null},yv=Oh,bv=class e extends lm{constructor({guid:e=jh(),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=yv(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new yy,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=Nh(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Nh(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&&Ly(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(im(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Ly(this,e,t)}get(e,t=pb){let n=Qp(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==pb&&r!==t){if(r===pb){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,Pb)}getText(e=``){return this.get(e,tx)}getMap(e=``){return this.get(e,Lb)}getXmlElement(e=``){return this.get(e,ox)}getXmlFragment(e=``){return this.get(e,ix)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,im(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,Ly(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()}},xv=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return M(this.restDecoder)}readDsLen(){return M(this.restDecoder)}},Sv=class extends xv{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 gh(this.restDecoder)}readString(){return vh(this.restDecoder)}readParentInfo(){return M(this.restDecoder)===1}readTypeRef(){return M(this.restDecoder)}readLen(){return M(this.restDecoder)}readAny(){return xh(this.restDecoder)}readBuf(){return _g(hh(this.restDecoder))}readJSON(){return JSON.parse(vh(this.restDecoder))}readKey(){return vh(this.restDecoder)}},Cv=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}},wv=class extends Cv{constructor(e){super(e),this.keys=[],M(e),this.keyClockDecoder=new wh(hh(e)),this.clientDecoder=new Ch(hh(e)),this.leftClockDecoder=new wh(hh(e)),this.rightClockDecoder=new wh(hh(e)),this.infoDecoder=new Sh(hh(e),gh),this.stringDecoder=new Th(hh(e)),this.parentInfoDecoder=new Sh(hh(e),gh),this.typeRefDecoder=new Ch(hh(e)),this.lenDecoder=new Ch(hh(e))}readLeftID(){return new Zv(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Zv(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 xh(this.restDecoder)}readBuf(){return hh(this.restDecoder)}readJSON(){return xh(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e{r=mm(r,t[0].id.clock);let i=Cy(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)=>{xy(t,n)>e&&r.set(n,e)}),by(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),j(e.restEncoder,r.size),im(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{kv(e,t.clients.get(n),n,r)})},jv=(e,t)=>{let n=Xp(),r=M(e.restDecoder);for(let i=0;i{let r=[],i=im(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 yy,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!==$x){let i=Qp(d,u.id.client,()=>xy(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,xy(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 Ov;return Av(e,s,new Map),j(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Nv=(e,t)=>Av(e,t.doc.store,t.beforeState),Pv=(e,t,n,r=new wv(e))=>Ly(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Mv(e,i,jv(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(nt)&&o.missing.set(e,t)}o.update=qy([o.update,a.update])}}else i.pendingStructs=a;let s=vv(r,e,i);if(i.pendingDs){let t=new wv(fh(i.pendingDs));M(t.restDecoder);let n=vv(t,e,i);i.pendingDs=s&&n?qy([s,n]):s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Fv(e.doc,t)}},n,!1),Fv=(e,t,n,r=wv)=>{let i=fh(t);Pv(i,e,n,new r(i))},Iv=(e,t,n)=>Fv(e,t,n,Sv),Lv=(e,t,n=new Map)=>{Av(e,t.store,n),gv(e,hv(t.store))},Rv=(e,t=new Uint8Array([0]),n=new Ov)=>{Lv(n,e,Vv(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Jy(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Ev)return Gy(r.map((e,t)=>t===0?e:$y(e)));if(n.constructor===Ov)return qy(r)}return r[0]},zv=(e,t)=>Rv(e,t,new Ev),Bv=e=>{let t=new Map,n=M(e.restDecoder);for(let r=0;rBv(new xv(fh(e))),Hv=(e,t)=>(j(e.restEncoder,t.size),im(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{j(e.restEncoder,t),j(e.restEncoder,n)}),e),Uv=(e,t)=>Hv(e,by(t.store)),Wv=(e,t=new Dv)=>(e instanceof Map?Hv(t,e):Uv(t,e),t.toUint8Array()),Gv=e=>Wv(e,new Tv),Kv=class{constructor(){this.l=[]}},qv=()=>new Kv,Jv=(e,t)=>e.l.push(t),Yv=(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.`)},Xv=(e,t,n)=>Xh(e.l,[t,n]),Zv=class{constructor(e,t){this.client=e,this.clock=t}},Qv=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,N=(e,t)=>new Zv(e,t),$v=e=>N(M(e),M(e)),ey=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw oh()},ty=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ny=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ry=e=>new ny(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),iy=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ay=(e,t,n=0)=>new iy(e,t,n),oy=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ey(e):r=N(e._item.id.client,e._item.id.clock),new ny(r,i,t,n)},sy=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return oy(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return oy(e,N(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return oy(e,r.lastId,n);r=r.right}return oy(e,null,n)},cy=e=>{let t=null,n=null,r=null;switch(M(e)){case 0:r=$v(e);break;case 1:n=vh(e);break;case 2:t=$v(e)}let i=ph(e)?_h(e):0;return new ny(t,n,r,i)},ly=e=>cy(fh(e)),uy=(e,t)=>{let n=wy(e,t);return{item:n,diff:t.clock-n.id.clock}},dy=(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(xy(r,i.client)<=i.clock)return null;let e=n?Wx(r,i):uy(r,i),t=e.item;if(!(t instanceof Yx))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(xy(r,a.client)<=a.clock)return null;let{item:e}=n?Wx(r,a):{item:wy(r,a)};if(e instanceof Yx&&e.content instanceof Hx)c=e.content.type;else return null}else throw oh();l=s>=0?c._length:0}return ay(c,l,e.assoc)},fy=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Qv(e.item,t.item)&&Qv(e.type,t.type)&&e.assoc===t.assoc,py=class{constructor(e,t){this.ds=e,this.sv=t}},my=(e,t)=>new py(e,t),hy=my(mv(),new Map),gy=e=>my(hv(e.store),by(e.store)),_y=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!uv(t.ds,e.id),vy=(e,t)=>{let n=Qp(e.meta,vy,tm),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t{}),n.add(t))},yy=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},by=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},xy=(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},Sy=(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 oh()}n.push(t)},Cy=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=dm(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[Cy(n,t.clock)]},Ty=(e,t,n)=>{let r=Cy(t,n),i=t[r];return i.id.clock{let n=e.doc.store.clients.get(t.client);return n[Ty(e,n,t.clock)]},Dy=(e,t,n)=>{let r=t.clients.get(n.client),i=Cy(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==hx&&r.splice(i+1,0,Kx(e,a,n.clock-a.id.clock+1)),a},Oy=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Cy(r,t.id.clock)]=n},ky=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Ty(e,t,n),s;do s=t[o++],at.deleteSet.clients.size===0&&!em(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(dv(t.deleteSet),Nv(e,t),gv(e,t.deleteSet),!0),My=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Qp(e.changed,t,tm).add(n)},Ny=(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 Yx&&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},Py=(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=Cy(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=pm(r.length-1,1+Cy(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+Ny(r,e)}})},Iy=(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),Xv(r._dEH,t,n)})}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Qb(n)})}),Xh(e,[])}finally{r.gc&&Py(a,i,r.gcFilter),Fy(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=mm(Cy(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ny(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=Cy(r,n);a+11||a>0&&Ny(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(ev(Y_,H_,`[yjs] `,U_,q_,`Changed the client-id because another client seems to be using it.`),r.clientID=yv()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Ev;jy(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Ov;jy(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])):Iy(e,t+1)}}},Ly=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ay(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&&Iy(i,0)}}return o},Ry=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},zy=(e,t,n)=>{cv(e,n.deletions,n=>{n instanceof Yx&&t.scope.some(t=>t===e.doc||ty(t,n))&&Gx(n,!1)})},By=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Ly(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;cv(n,o.insertions,e=>{if(e instanceof Yx){if(e.redone!==null){let{item:t,diff:i}=Wx(r,e.id);i>0&&(t=Ey(n,N(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ty(t,e))&&c.push(e)}}),cv(n,o.deletions,e=>{e instanceof Yx&&a.some(t=>t===n.doc||ty(t,e))&&!uv(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Jx(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},Vy=class extends lm{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=cm(e)?e[0].doc:e instanceof bv?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 sv;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&pv(i,n,r,a)});let a=Mh(),o=!1;if(this.lastChange>0&&a-this.lastChange0&&!t&&!n){let t=r[r.length-1];t.deletions=fv([t.deletions,e.deleteSet]),t.insertions=fv([t.insertions,i])}else r.push(new Ry(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),cv(e,e.deleteSet,t=>{t instanceof Yx&&this.scope.some(n=>n===e.doc||ty(n,t))&&Gx(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=cm(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof pb?e.doc!==this.doc:e!==this.doc)&&tv(`[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=>zy(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>zy(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=By(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=By(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*Hy(e){let t=M(e.restDecoder);for(let n=0;nqy(e,Sv,Ev),Ky=(e,t)=>{if(e.constructor===hx){let{client:n,clock:r}=e.id;return new hx(N(n,r+t),e.length-t)}if(e.constructor===$x){let{client:n,clock:r}=e.id;return new $x(N(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Yx(N(r,i+t),null,N(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},qy=(e,t=wv,n=Ov)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(fh(e))),i=r.map(e=>new Uy(e,!0)),a=null,o=new n,s=new Wy(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===$x?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)Xy(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length0&&(a.struct.constructor===$x?a.struct.length-=t:n=Ky(n,t)),a.struct.mergeWith(n)||(Xy(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!==$x;n=e.next())Xy(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Xy(s,a.struct,a.offset),a=null),Zy(s),gv(o,fv(r.map(e=>_v(e)))),o.toUint8Array()},Jy=(e,t,n=wv,r=Ov)=>{let i=Vv(t),a=new r,o=new Wy(a),s=new n(fh(e)),c=new Uy(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===$x)c.next();else if(e.id.clock+e.length>n)for(Xy(o,e,mm(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Xy(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 Zy(o),gv(a,_v(s)),a.toUint8Array()},Yy=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Fm(e.encoder.restEncoder)}),e.encoder.restEncoder=Mm(),e.written=0)},Xy=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Yy(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++},Zy=e=>{Yy(e);let t=e.encoder.restEncoder;j(t,e.clientStructs.length);for(let n=0;n{let i=new n(fh(e)),a=new Uy(i,!1),o=new r,s=new Wy(o);for(let e=a.curr;e!==null;e=a.next())Xy(s,t(e),0);return Zy(s),gv(o,_v(i)),o.toUint8Array()},$y=e=>Qy(e,Zh,wv,Ev),eb=`You must not compute changes after the event-handler fired.`,tb=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||=nb(this.currentTarget,this.target)}deletes(e){return uv(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ih(eb);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=nm(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=nm(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=nm(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 ih(eb);let t=this.target,n=tm(),r=tm(),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}},nb=(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},rb=()=>{tv(`Invalid access: Add Yjs type to a document before reading data.`)},ib=80,ab=0,ob=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ab++}},sb=e=>{e.timestamp=ab++},cb=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ab++},lb=(e,t,n)=>{if(e.length>=ib){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)=>fm(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&&fm(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=mm(t,i.index+n))}},fb=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Qp(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Xv(r._eH,n,t)},pb=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=qv(),this._dEH=qv(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw ah()}clone(){throw ah()}_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){Jv(this._eH,e)}observeDeep(e){Jv(this._dEH,e)}unobserve(e){Yv(this._eH,e)}unobserveDeep(e){Yv(this._dEH,e)}toJSON(){}},mb=(e,t,n)=>{e.doc??rb(),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},hb=e=>{e.doc??rb();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&&_y(r,t)){let e=r.content.getContent();for(let t=0;t{let n=0,r=e._start;for(e.doc??rb();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r{let n=[];return _b(e,(r,i)=>{n.push(t(r,i,e))}),n},yb=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}}}},bb=(e,t)=>{e.doc??rb();let n=ub(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 Yx(N(o,xy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ax(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 Yx(N(o,xy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new gx(new Uint8Array(n))),i.integrate(e,0);break;case bv:i=new Yx(N(o,xy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new xx(n)),i.integrate(e,0);break;default:if(n instanceof pb)i=new Yx(N(o,xy(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Hx(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Sb=()=>ih(`Length exceeded!`),Cb=(e,t,n,r)=>{if(n>t._length)throw Sb();if(n===0)return t._searchMarker&&db(t._searchMarker,n,r.length),xb(e,t,null,r);let i=n,a=ub(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 xb(e,t,r,n)},Tb=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=ub(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 Sb();t._searchMarker&&db(t._searchMarker,i,-a+r)},Eb=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Db=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Ax([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Ax([r]);break;case Uint8Array:s=new gx(r);break;case bv:s=new xx(r);break;default:if(r instanceof pb)s=new Hx(r);else throw Error(`Unexpected content type`)}new Yx(N(o,xy(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Ob=(e,t)=>{e.doc??rb();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},kb=e=>{let t={};return e.doc??rb(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Ab=(e,t)=>{e.doc??rb();let n=e._map.get(t);return n!==void 0&&!n.deleted},jb=(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&&_y(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Mb=e=>(e.doc??rb(),iv(e._map.entries(),e=>!e[1].deleted)),Nb=class extends tb{},Pb=class e extends pb{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 pb?e.clone():e)),t}get length(){return this.doc??rb(),this._length}_callObserver(e,t){super._callObserver(e,t),fb(this,e,new Nb(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ly(this.doc,n=>{Cb(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Ly(this.doc,t=>{wb(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ly(this.doc,n=>{Tb(n,this,e,t)})}get(e){return bb(this,e)}toArray(){return hb(this)}slice(e=0,t=this.length){return mb(this,e,t)}toJSON(){return this.map(e=>e instanceof pb?e.toJSON():e)}map(e){return vb(this,e)}forEach(e){_b(this,e)}[Symbol.iterator](){return yb(this)}_write(e){e.writeTypeRef(Fx)}},Fb=e=>new Pb,Ib=class extends tb{constructor(e,t,n){super(e,t),this.keysChanged=n}},Lb=class e extends pb{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 pb?e.clone():e)}),t}_callObserver(e,t){fb(this,e,new Ib(this,e,t))}toJSON(){this.doc??rb();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof pb?r.toJSON():r}}),e}get size(){return[...Mb(this)].length}keys(){return av(Mb(this),e=>e[0])}values(){return av(Mb(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return av(Mb(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??rb(),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):Ly(this.doc,t=>{Eb(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Ly(this.doc,n=>{Db(n,this,e,t)}),t}get(e){return Ob(this,e)}has(e){return Ab(this,e)}clear(){this.doc===null?this._prelimContent.clear():Ly(this.doc,e=>{this.forEach(function(t,n,r){Eb(e,r,n)})})}_write(e){e.writeTypeRef(Ix)}},Rb=e=>new Lb,zb=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&qh(e,t),Bb=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&oh(),this.right.content.constructor){case Tx:this.right.deleted||Wb(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}},Vb=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Tx:t.right.deleted||Wb(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n{let i=new Map,a=r?ub(t,n):null;return a?Vb(e,new Bb(a.p.left,a.p,a.index,i),n-a.index):Vb(e,new Bb(null,t._start,0,i),n)},Ub=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Tx&&zb(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 Yx(N(a,xy(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Tx(o,r));l.integrate(e,0),n.right=l,n.forward()})},Wb=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Gb=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Tx&&zb(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Kb=(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(!zb(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Yx(N(a,xy(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Tx(s,c)),n.right.integrate(e,0),n.forward()}}return o},qb=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Gb(n,i);let s=Kb(e,t,n,i),c=r.constructor===String?new Mx(r):r instanceof pb?new Hx(r):new Cx(r),{left:l,right:u,index:d}=n;t._searchMarker&&db(t._searchMarker,n.index,c.getLength()),u=new Yx(N(o,xy(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(),Ub(e,t,n,s)},Jb=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Gb(n,i);let s=Kb(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Tx));){if(!n.right.deleted)switch(n.right.content.constructor){case Tx:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(zb(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 Yx(N(o,xy(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Mx(i)),n.right.integrate(e,0),n.forward()}Ub(e,t,n,s)},Yb=(e,t,n,r,i)=>{let a=t,o=Xp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Tx){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 Tx:{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&&Wb(i,n);break}}}t=t.right}return s},Xb=(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===Tx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Zb=e=>{let t=0;return Ly(e.doc,n=>{let r=e._start,i=e._start,a=Xp(),o=Zp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Tx:Wb(o,i.content);break;default:t+=Yb(n,r,i,a,o),a=Zp(o),r=i}i=i.right}}),t},Qb=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&&ky(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Tx&&e.constructor!==hx&&t.add(e.parent)})}Ly(n,n=>{cv(e,e.deleteSet,e=>{if(e instanceof hx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Tx?t.add(r):Xb(n,e)});for(let e of t)Zb(e)})},$b=(e,t,n)=>{let r=n,i=Zp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Hx:case Cx:case Mx: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=[];Ly(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},Wh(o)||(e.attributes=Bh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Hx:case Cx: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 Mx: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 Tx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(zb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),zb(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;zb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(zb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Wb(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}},tx=class e extends pb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??rb(),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 ex(this,e,t);fb(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??rb();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Mx&&(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)):Ly(this.doc,n=>{let r=new Bb(null,this._start,0,new Map);for(let i=0;i0)&&qb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&$b(n,r,a.delete):Jb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??rb();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(_y(s,e)||t!==void 0&&_y(s,t))switch(s.content.constructor){case Mx:{let r=i.get(`ychange`);e!==void 0&&!_y(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&&!_y(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 Hx:case Cx:{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 Tx:_y(s,e)&&(c(),Wb(i,s.content))}s=s.right}c()};return e||t?Ly(a,n=>{e&&vy(n,e),t&&vy(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)):Ly(r,r=>{let i=Hb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),qb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Ly(r,r=>{let i=Hb(r,this,e,!n);qb(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)):Ly(n,n=>{$b(n,Hb(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)):Ly(r,r=>{let i=Hb(r,this,e,!1);i.right!==null&&Jb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Ly(this.doc,t=>{Eb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Ly(this.doc,n=>{Db(n,this,e,t)})}getAttribute(e){return Ob(this,e)}getAttributes(){return kb(this)}_write(e){e.writeTypeRef(Lx)}},nx=e=>new tx,rx=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??rb()}[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===ox||t.constructor===ix)&&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})}},ix=class e extends pb{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 pb?e.clone():e)),t}get length(){return this.doc??rb(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rx(this,e)}querySelector(e){e=e.toUpperCase();let t=new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),im(new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){fb(this,e,new cx(this,t,e))}toString(){return vb(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),_b(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ly(this.doc,n=>{Cb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Ly(this.doc,n=>{let r=e&&e instanceof pb?e._item:e;xb(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 ih(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ly(this.doc,n=>{Tb(n,this,e,t)})}toArray(){return hb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return bb(this,e)}slice(e=0,t=this.length){return mb(this,e,t)}forEach(e){_b(this,e)}_write(e){e.writeTypeRef(zx)}},ax=e=>new ix,ox=class e extends ix{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 Hh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof pb?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):Ly(this.doc,t=>{Eb(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Ly(this.doc,n=>{Db(n,this,e,t)})}getAttribute(e){return Ob(this,e)}hasAttribute(e){return Ab(this,e)}getAttributes(e){return e?jb(this,e):kb(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 _b(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Rx),e.writeKey(this.nodeName)}},sx=e=>new ox(e.readKey()),cx=class extends tb{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)})}},lx=class e extends Lb{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(Bx),e.writeKey(this.hookName)}},ux=e=>new lx(e.readKey()),dx=class e extends tx{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(Vx)}},fx=e=>new dx,px=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ah()}mergeWith(e){return!1}write(e,t,n){throw ah()}integrate(e,t){throw ah()}},mx=0,hx=class extends px{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),Sy(e.doc.store,this)}write(e,t){e.writeInfo(mx),e.writeLen(this.length-t)}getMissing(e,t){return null}},gx=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 ah()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},_x=e=>new gx(e.readBuf()),vx=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){pv(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}},yx=e=>new vx(e.readLen()),bx=(e,t)=>new bv({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),xx=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(bx(this.doc.guid,this.opts))}splice(e){throw ah()}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}},Sx=e=>new xx(bx(e.readString(),e.readAny())),Cx=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 ah()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},wx=e=>new Cx(e.readJSON()),Tx=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 ah()}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}},Ex=e=>new Tx(e.readKey(),e.readJSON()),Dx=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}},Nx=e=>new Mx(e.readString()),Px=[Fb,Rb,nx,sx,ax,ux,fx],Fx=0,Ix=1,Lx=2,Rx=3,zx=4,Bx=5,Vx=6,Hx=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 ah()}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}},Ux=e=>new Hx(Px[e.readTypeRef()](e)),Wx=(e,t)=>{let n=t,r=0,i;do r>0&&(n=N(n.client,n.clock+r)),i=wy(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Yx);return{item:i,diff:r}},Gx=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Kx=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Yx(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},qx=(e,t)=>om(e,e=>uv(e.deletions,t)),Jx=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Ey(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Jx(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Ey(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:Ey(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:Ey(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||uv(r,d.right.id)||qx(a.undoStack,d.right.id)||qx(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ey(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,xy(s,c)),h=new Yx(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Gx(h,!0),h.integrate(e,0),h},Yx=class e extends px{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>=xy(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=xy(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Zv&&this.id.client!==this.parent.client&&this.parent.clock>=xy(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Dy(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Ey(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===hx||this.right&&this.right.constructor===hx)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===Zv){let e=wy(n,this.parent);this.parent=e.constructor===hx?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Dy(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),Qv(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(),pv(e.deleteSet,this.id.client,this.id.clock,this.length),My(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw oh();this.content.gc(e),t?Oy(e,this,new hx(this.id,this.length)):this.content=new vx(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=ey(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===Zv?(e.writeParentInfo(!1),e.writeLeftID(t)):oh();i!==null&&e.writeString(i)}this.content.write(e,t)}},Xx=(e,t)=>Zx[t&31](e),Zx=[()=>{oh()},yx,Ox,_x,Nx,wx,Ex,Ux,jx,Sx,()=>{oh()}],Qx=10,$x=class extends px{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){oh()}write(e,t){e.writeInfo(Qx),j(e.restEncoder,this.length-t)}getMissing(e,t){return null}},eS=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},tS=`__ $YJS$ __`;eS[tS]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),eS[tS]=!0;var nS=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},rS=(e,t)=>e>>>t|e<<32-t,iS=e=>rS(e,2)^rS(e,13)^rS(e,22),aS=e=>rS(e,6)^rS(e,11)^rS(e,25),oS=e=>rS(e,7)^rS(e,18)^e>>>3,sS=e=>rS(e,17)^rS(e,19)^e>>>10,cS=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]),lS=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),uS=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lS),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=sS(t[e-2])+t[e-7]+oS(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+aS(o)+(o&s^~o&c)+cS[e]+t[e]>>>0,d=iS(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}},dS=e=>new uS().digest(e),fS=/[\uD800-\uDBFF]/,pS=/[\uDC00-\uDFFF]/,mS=(e,t)=>{let n=0,r=0;for(;n0&&fS.test(e[n-1])&&n--;r+n0&&pS.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}};function hS(e){if(!e||!(e.content instanceof Hx))return null;let t=e.content.type;if(!(t instanceof ix||t instanceof tx||t instanceof lx))throw Error(`Expected a Yjs XML type`);return t}function gS(e){if(e===null)return null;if(!(e.parent instanceof pb))throw Error(`Expected an integrated Yjs parent`);let t=e.parent;if(!(t instanceof ix||t instanceof tx||t instanceof lx))throw Error(`Expected a Yjs XML type`);return t}var _S=(e,t)=>{let n=null,r=null;return e._item===null?r=ey(e):n=N(e._item.id.client,e._item.id.clock),new ny(n,r,t.id)},vS=(e,t,n)=>{if(e===0)return sy(t,0,-1);let r=hS(t._first);for(;r!==null&&t!==r;){if(r instanceof dx){if(r._length>=e)return sy(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=hS(r._item.next);else{do r=gS(r._item),e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:hS(r._item.next))}}else{let i=n.get(r),a=i instanceof le?i.nodeSize:0;if(r._first!==null&&e1)return new ny(r._item===null?null:r._item.id,r._item===null?ey(r):null,null);if(e-=a,r._item!==null&&r._item.next!==null)r=hS(r._item.next);else{if(e===0){if(r=r._item===null?r:gS(r._item),r===null)throw oh();return new ny(r._item===null?null:r._item.id,r._item===null?ey(r):null,null)}do{if(r=gS(r._item),r===null)throw oh();e--}while(r!==t&&r._item?.next===null);r!==t&&(r=hS(r._item?.next))}}}if(r===null)throw oh();if(e===0&&r.constructor!==dx&&r!==t){let e=r._item,t=gS(e);if(e===null||t===null)throw oh();return _S(t,e)}}return sy(t,t._length,-1)},yS=(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 bS(e,t){if(e instanceof dx)return e._length;let n=t.get(e);return n instanceof le?n.nodeSize:null}function xS(e,t,n){let r=0,i=e._first;for(;i!==null;){let e=hS(i);if(e===t)break;let a=i.deleted;if(i=i.right,a)continue;if(e===null)return null;let o=bS(e,n);if(o===null)return null;r+=o}return r}function SS(e,t,n){let r=0,i=0,a=e._first;for(;i{if(n===null)return!1;let r=dy(t,e);return r!==null&&r.type instanceof dx&&t.item!==null&&r.type._item?.deleted===!0},wS=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:${ey(e)}`;return e.doc.getMap(`__tiptap_position_migrations:${t}`)},TS=new WeakMap,ES=(e,t)=>{let n=t.item??t.type;if(!n)return[];let r;t.item||(r=t.assoc<0?`start`:`end`);let i=TS.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},TS.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)))},DS=(e,t,n)=>{let{source:r,target:i}=e.transfer;return i?new ny(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},OS=(e,t,n)=>{let r=DS(e[0],t,n);return!r||e.some(e=>{let i=DS(e,t,n);return!i||!fy(r,i)})?null:r},kS=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}`},AS=(e,t)=>{let n=wS(e),r=new Set,i=t,a=i.item??i.type;for(;a;){let e=kS(i);if(r.has(e))return null;r.add(e);let t=ES(n,i);if(t.length===0)return i;let o=OS(t,a,i.assoc);if(!o)return null;if(kS(o)===e)return o;i=o,a=o.item??o.type}return i},jS=(e,t,n,r)=>{let i=AS(t,n);if(!i)return null;n=i;let a=dy(n,e);if(a===null||a.type!==t&&!ty(t,a.type._item))return null;let o=a.type,s=0;if(o.constructor===dx)s=a.index;else if(!o._item?.deleted){let e=SS(o,a.index,r);if(e===null)return null;s=e+1}for(;o!==t&&o._item!==null;){let e=gS(o._item);if(e===null)return null;if(e._item?.deleted){o=e;continue}let t=xS(e,o,r);if(t===null)return null;s+=t+1,o=e}let c=s-1;return CS(e,n,c)?null:c},MS=new D(`y-sync`),NS=new D(`y-undo`),PS=new D(`yjs-cursor`),FS=null;function IS(){let e=FS;FS=null;let t=[];return e?.forEach((e,n)=>{e.forEach((e,r)=>t.push({view:n,key:r,value:e}))}),t}function LS(e=IS(),t=!1){let n=!0;for(;e.length>0;){let{view:r,key:i,value:a}=e[0];try{let e=MS.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&&B_(0,()=>LS(e,!0));return}n=!1,e.shift()}}function RS(e,t,n){FS===null&&(FS=new Map,B_(0,LS));let r=FS.get(e);r||(r=new Map,FS.set(e,r)),r.set(t,n)}var zS=(e,t,n)=>e!==t,BS=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},VS=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),HS=/^#[0-9a-fA-F]{6}$/,US=e=>typeof e.name==`string`&&typeof e.color==`string`,WS=(e,t,n,r,i)=>{let a=MS.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`:HS.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`,!US(n))return;let l=jS(o,a.type,ry(t.cursor.anchor),a.binding.mapping),u=jS(o,a.type,ry(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=mm(e.doc.content.size-1,0);l=pm(l,t),u=pm(u,t),s.push(vs.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=pm(l,u),o=mm(l,u);s.push(vs.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),xs.create(e.doc,s))},GS=(e,{awarenessStateFilter:t=zS,cursorBuilder:n=BS,selectionBuilder:r=VS,getSelection:i=e=>e.selection}={},a=`cursor`)=>new E({key:PS,state:{init(i,a){return WS(a,e,t,n,r)},apply(i,a,o,s){let c=MS.getState(s),l=i.getMeta(PS),u=c&&c.isChangeOrigin;return i.docChanged&&!u&&yS(i,o.doc)?xs.empty:u||l&&l.awarenessUpdated?WS(s,e,t,n,r):i.docChanged?a.map(i.mapping,i.doc):a}},props:{decorations:e=>PS.getState(e)??xs.empty},view:t=>{let n=()=>{t.isDestroyed||RS(t,PS,{awarenessUpdated:!0})},r=t=>{let n=MS.getState(t.state);if(!n||!n.binding)return;let r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=vS(o.anchor,n.type,n.binding.mapping),c=vS(o.head,n.type,n.binding.mapping);r.cursor!=null&&fy(ry(r.cursor.anchor),s)&&fy(ry(r.cursor.head),c)||e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&jS(n.doc,n.type,ry(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 KS(e){let t=MS.getState(e);if(!t)throw Error(`The editor requires ySyncPlugin`);return t}var qS=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)??0)>e.id.clock&&!uv(t.ds,e.id),JS=(e,t,n)=>{if(!e.has(n)){if(e.sizen.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,kh(t))}let r=e.get(n);if(!r)throw Error(`At least one snapshot color is required`);return r},YS=(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])},XS=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]})},ZS=(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=ZS(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&&YS(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||XS(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)},QS=(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||!YS(i.parent.attrs,a.parent.attrs);if(o||s){let i=ZS(e,t,n);return i!==null&&i!==r}return!1},$S=(e,t,n,r)=>{if(n==null||n<0||n>t.content.size||!(r===null||n>1&&r<=1||QS(t,e,n,r)))return r;let i=ZS(t,e,n);return i===null?r:i},eC=(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=jS(n.doc,n.type,t.anchor,n.mapping);r!==null&&e.setSelection(tC(e,r))}else if(t.type===`nodeRange`){let r=nC(e,jS(n.doc,n.type,t.anchor,n.mapping),jS(n.doc,n.type,t.head,n.mapping),t.depth);r!==null&&e.setSelection(r)}else{let i=jS(n.doc,n.type,t.anchor,n.mapping),a=jS(n.doc,n.type,t.head,n.mapping);r!=null&&(AS(n.type,t.anchor)===t.anchor&&(i=$S(e.doc,r,t.absAnchor,i)),AS(n.type,t.head)===t.head&&(a=$S(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)))}}},tC=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?T.create(e.doc,t):w.near(n)},nC=(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))}},rC=(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:vS(t.selection.anchor,e.type,e.mapping),head:vS(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},iC=new WeakMap,aC=(e,t)=>{var n;(t instanceof ix||t instanceof tx||t instanceof lx)&&(e.delete(t),(n=iC.get(e))==null||n.delete(t))},oC=/(.*)(--[a-zA-Z0-9+/=]{8})$/,sC=e=>oC.exec(e)?.[1]??e,cC=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(sC(r),e[r]));return n},lC=e=>{let t=e.doc,n=e._item;if(!t||!n)throw oh();t.transact(e=>{n.delete(e)},MS)},uC=(e,t,n,r,i,a)=>{let o=e.toDelta(r,i,a);try{return o.map(e=>t.text(e.insert,cC(e.attributes,t)))}catch{return lC(e),null}},dC=e=>{var t;let n=(t=e._item)==null||(t=t.right)==null?void 0:t.content,r=n instanceof Hx?n.type:null;if(!(r instanceof tx))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)}))},fC=(e,t,n,r)=>{if(e._item){if(!qS(e._item,t))return r?r(`removed`,e._item.id):{type:`removed`};if(!qS(e._item,n))return r?r(`added`,e._item.id):{type:`added`}}},pC=(e,t,n)=>{e.mapping.set(t,n);let r=iC.get(e.mapping);r===void 0&&(r=new WeakMap,iC.set(e.mapping,r)),r.set(t,n)},mC=(e,t,n,r,i,a)=>{let o=n.mapping.get(e),s=Array.isArray(o)?void 0:o;if(s!==void 0&&iC.get(n.mapping)?.get(e)===s)return s;let c=[],l=e=>{if(e instanceof ox){let o=mC(e,t,n,r,i,a);o!==null&&c.push(o)}else e instanceof dx&&(dC(e),uC(e,t,n,r,i,a)?.forEach(e=>c.push(e)))};r===void 0||i===void 0?e.toArray().forEach(l):gb(e,new py(i.ds,r.sv)).forEach(l);try{let o=e.getAttributes(r),l=r?fC(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),pC(n,e,u),u}catch{return lC(e),aC(n.mapping,e),null}},hC=e=>{for(let t=6;thg(hC(dS(vg(e)))),_C=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Qp(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${gC(e.toJSON())}`:e.type.name]=e.attrs}}),n},vC=(e,t)=>{let n=new dx,r=e.map(e=>({insert:e.text??``,attributes:_C(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},yC=e=>{let t=e.content.content,n=[];for(let e=0;ee instanceof Array?vC(e,t):xC(e,t),xC=(e,t)=>{let n=new ox(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,yC(e).map(e=>bC(e,t))),t.mapping.set(n,e),n},SC=e=>typeof e==`object`&&!!e,CC=(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&&Vh(e.attributes||{}).length===t[n].marks.length&&Object.entries(e.attributes??{}).every(([e,r])=>{let i=sC(e),a=t[n].marks.find(e=>e.type.name===i);return a?CC(r,a.attrs):!1}))},TC=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,EC=(e,t)=>{if(e instanceof ox&&!(t instanceof Array)&&TC(e,t)){let n=yC(t);return e._length===n.length&&CC(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>EC(e,n[t]))}return e instanceof dx&&t instanceof Array&&wC(e,t)},DC=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),OC=(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&&DC(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()},kC=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Mx?t+=n.content.str:n.content instanceof Tx&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},AC=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=kC(e),a=t.map(e=>({insert:e.text??``,attributes:Object.assign({},r,_C(e.marks,n))})),{insert:o,remove:s,index:c}=mS(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})))},jC=(e,t,n,r,i)=>t instanceof dx&&n instanceof Array?(wC(t,n)?r.mapping.set(t,n):AC(t,n,r),!0):t instanceof ox&&!(n instanceof Array)&&TC(t,n)?(EC(t,n)?r.mapping.set(t,n):i(e,t,n,r),!0):!1,MC=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>aC(r.mapping,e)),e.delete(t,n))},NC=(e,t,n,r,i,a)=>{if(r{let u=pm(a-i,s-o);for(let a=0;a{let o=OC(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 dx&&t instanceof Array||e.yChild instanceof ox&&!(t instanceof Array))}))return!1;let s=0,c=0;for(let l of o){PC(e,t,n,r,s,l.yIndex,c,l.pIndex,i,a);let o=n[l.pIndex];jC(e,l.yChild,o,i,a),s=l.yIndex+1,c=l.pIndex+1}return PC(e,t,n,r,s,r.length,c,n.length,i,a),!0},IC=(e,t,n)=>{let r=e.toArray(),i=yC(t),a=i.length,o=r.length,s=pm(o,a),c=0,l=0,u=!1;for(;c{if(t instanceof ox&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ox){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=yC(n),a=i.length,o=t.toArray(),s=o.length,c=pm(a,s),l=!1;if(e.transact(()=>{l=FC(e,t,i,o,r,LC)},MS),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 dx&&c instanceof Array){wC(n,c)||AC(n,c,r),u+=1;continue}let p=n instanceof ox&&TC(n,c),m=l instanceof ox&&TC(l,f);if(p&&m&&n instanceof ox&&l instanceof ox&&!Array.isArray(c)&&!Array.isArray(f)){let e=IC(n,c,r),t=IC(l,f,r);e.foundMappedChild&&!t.foundMappedChild?m=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor0&&(t.slice(u,u+n).forEach(e=>aC(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 Mx))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},BC=(e,t,n,r,i)=>{let a=RC(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 RC(e,n)},VC=(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&&Qv(e.target.type,t.target.type),HC=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&&VC(n,e)?n.source.length+=e.source.length:t.push({...e,source:{...e.source}})}),t},UC=(e,t)=>{let n=e.doc;if(!n||t.length===0)return;let r=xy(n.store,n.clientID);e.set(`${n.clientID}:${r}`,{version:1,client:n.clientID,clock:r,seen:[...Vv(Gv(n))],transfers:HC(t)})},WC=(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&&Qv(n.type,a.type)||r.push({source:{...n.type,length:1,boundary:`start`},target:a?{...a,assoc:0}:null}),o&&Qv(i.type,o.type)||r.push({source:{...n.type,length:1,boundary:`end`},target:o?{...o,assoc:-1}:null})}),r},GC=(e,t,n,r)=>{let i=[];e.forEach(e=>{let n=e.position===null?null:t.get(e.position)??null;n&&Qv(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&&Qv(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},KC=(e,t,n,r,i,a)=>{let o=e.get(t);if(!(o instanceof ox)||!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&&(aC(a.mapping,o),e.delete(t,1),o=bC(n,a),e.insert(t,[o])),!(o instanceof ox)||!o._item)throw Error(`Position migration requires integrated elements`);return o},qC=(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;yC(t).forEach((t,r)=>{let p=d[r];if(Array.isArray(t)){if(!(p instanceof dx)||!p._item)throw Error(`Position migration requires integrated text`);let e=t.map(e=>e.text??``).join(``),r=BC(p,e,f,i,a),s=p._item.id;r.forEach(e=>o.set(e.position,{client:e.client,clock:e.clock,type:s})),AC(p,t,n),f+=e.length;return}let m=KC(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:ey(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&&Qv(e,t)&&Qv(e.type,t.type)||d.push({source:{client:e.client,clock:e.clock,length:1},target:t})}),d.push(...WC(t.characters,o)),d.push(...GC(t.nodes,c,l,t.emptyTexts)),UC(r,d)},JC=(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))},YC=class{constructor(e,t=new Map){if(this.prosemirrorView=null,this.mux=nS(),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=rC(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()?(tg&&this._domSelectionInView===null&&(B_(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=N_.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||=my(mv(),new Map),this.view.dispatch(this._tr.setMeta(MS,{snapshot:e,prevSnapshot:t}))}createDocumentTransaction(){let e=this.type.toArray().map(e=>{if(!(e instanceof ox))throw ah();return mC(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(),iC.delete(this.mapping),this.mux(()=>{let e=this.createDocumentTransaction();e.setMeta(MS,{snapshot:null,prevSnapshot:null}),this.view.dispatch(e)})}_forceRerender(){this.mapping.clear(),iC.delete(this.mapping),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.view.state.selection:null,t=this.createDocumentTransaction();if(e){let n=pm(mm(e.anchor,0),t.doc.content.size),r=pm(mm(e.head,0),t.doc.content.size);t.setSelection(w.create(t.doc,n,r))}this.view.dispatch(t.setMeta(MS,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=gy(this.doc),e instanceof Uint8Array||t instanceof Uint8Array){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw oh();if(r=new bv({gc:!1}),Fv(r,t),t=gy(r),Fv(r,e),e=gy(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[Cy(e,i._item.id.clock)];if(!(t instanceof Yx&&t.content instanceof Hx&&t.content.type instanceof ix))throw oh();i=t.content.type}}let a=e,o=t??hy;this.mapping.clear(),iC.delete(this.mapping),this.mux(()=>{r.transact(e=>{let t=n.permanentUserData;t&&t.dss.forEach(t=>{cv(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:JS(n.colorMapping,n.colors,i)}},c=gb(i,new py(o.ds,a.sv)).map(e=>!(e instanceof ox)||!e._item?null:!e._item.deleted||qS(e._item,a)||qS(e._item,o)?mC(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(MS,{isChangeOrigin:!0}))},MS)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=KS(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 Vy,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)=>aC(this.mapping,t);cv(t,t.deleteSet,e=>{e instanceof Yx&&e.content instanceof Hx&&aC(this.mapping,e.content.type)}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>{if(!(e instanceof ox))throw ah();return mC(e,this.view.state.schema,this)}).filter(e=>e!==null),i=JC(this._tr,s.from(n));eC(i,a,this,o),i=i.setMeta(MS,{isChangeOrigin:!0,isUndoRedoOperation:r}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.view.dispatch(i)})}_prosemirrorChanged(e,t=null){let n=KS(this.view.state);n.snapshot==null&&n.prevSnapshot==null&&this.doc.transact(()=>{LC(this.doc,this.type,e,this),t?.doc===e&&qC(this.type,t,this,wS(this.type)),this.syncedDoc=e,this.beforeTransactionSelection=rC(this,this.view.state)},MS)}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))}},XC=(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=yC(t),l=o;t.content.size===0&&s.forEach(e=>{e instanceof dx&&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 ox)||!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 dx))throw Error(`Position tracking requires synchronized editor text`);let o=RC(i,l);n.push(...o),l+=o.length})};return a(e,t,0),{characters:n,nodes:r,emptyTexts:i}},ZC=(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:QC(a,o)},QC=(e,t)=>e.type===t.type&&e.content.eq(t.content)&&!e.sameMarkup(t),$C=(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)},ew=e=>{let t=new Map;return e.descendants((e,n)=>{let r=t.get(e)??[];r.push(n),t.set(e,r)}),t},tw=(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=tw(e.node,e.offset,t,r);if(n)return n}return null},rw=(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)=>$C(t,e.docs[n])))return r;let i=r??XC(t.type,e.before),a=[...e.docs,e.doc],o=a.map(ew),s=i.characters.map(t=>({...t,position:t.position===null?null:rw(t.position,e,a,o)})),c=t=>({...t,position:t.position===null?null:rw(t.position,e,a,o),end:t.end===null?null:rw(t.end,e,a,o)});return{doc:e.doc,characters:s,nodes:i.nodes.map(c),emptyTexts:i.emptyTexts.map(c)}},aw=[{light:`#ecd44433`,dark:`#ecd444`}],ow=(e,{colors:t=aw,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new YC(e,a);return new E({props:{editable:e=>{let t=KS(e);return t.snapshot==null&&t.prevSnapshot==null}},key:MS,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(MS);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:iw(e,s,t.positionMigration??null)},s.prosemirrorView===null||n===void 0||n.snapshot==null&&n.prevSnapshot==null||B_(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(MS,{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=KS(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=NS.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)},MS)})}}},destroy:()=>{s.destroy()}})})};function sw(e){let t=NS.getState(e);if(!t)throw Error(`The editor requires yUndoPlugin`);return t}var cw=e=>{let t=new Map,n=e=>{e.toArray().forEach(r=>{if(r instanceof ox){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:ey(e)}}),n(r);return}if(!(r instanceof dx)||!r._item)return;let i=r._item.id;RC(r).forEach(e=>{t.set(`${e.client}:${e.clock}`,{client:e.client,clock:e.clock,type:i})})})};return n(e),t},lw=(e,t)=>{let n=e.doc;if(!n)return;let r=cw(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 Yx&&e.redone&&(e.content instanceof Mx||e.content instanceof Hx))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=wy(n.store,t);if(a.content instanceof Hx&&a.content.type instanceof ox)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}})})}),UC(t,s)},uw=(e,t,n)=>{let r=wS(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&&lw(e,r)},t)}finally{t.off(`stack-item-popped`,o),t[i]=!1,t.currStackItem=null}return a},dw=(e,t)=>{let n=KS(e);if(n.snapshot!=null||n.prevSnapshot!=null)return!1;let r=sw(e).undoManager;if(r!=null)return uw(n.type,r,t),!0},fw=e=>dw(e,`undo`),pw=e=>dw(e,`redo`),mw=new Set([`paragraph`]),hw=(e,t)=>!(e instanceof Yx)||!(e.content instanceof Hx)||!(e.content.type instanceof tx||e.content.type instanceof ox&&t.has(e.content.type.nodeName))||e.content.type._length===0,gw=({protectedNodes:e=mw,trackedOrigins:t=[],undoManager:n=null}={})=>new E({key:NS,state:{init:(r,i)=>{let a=KS(i),o=new Set,s=n;if(!s){let n=new Set(a.doc._observers.get(`destroy`));s=new Vy(a.type,{trackedOrigins:new Set([MS,...t]),deleteFilter:t=>hw(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=KS(r).binding;return{...t,prevSel:i?rC(i,n):t.prevSel,hasUndoOps:t.undoManager.undoStack.length>0,hasRedoOps:t.undoManager.redoStack.length>0}}},view:e=>{let t=KS(e.state),{undoManager:n,destroyListeners:r}=sw(e.state);return n.on(`stack-item-added`,({stackItem:r})=>{let i=t.binding;if(i){let t=n.undoing||n.redoing?i.beforeTransactionSelection:sw(e.state).prevSel;r.meta.set(i,t)}}),{destroy:()=>{n.destroy(),r.forEach(e=>n.doc.off(`destroy`,e)),r.clear()}}}});function _w(e){return!!e.getMeta(MS)}function vw(e,t){if(t===null)return 0;let n=bw(e);return jS(n.doc,n.type,t,n.binding.mapping)||0}function yw(e,t){let n=bw(e);return vS(t,n.type,n.binding.mapping)}function bw(e){let t=MS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs sync plugin`);return t}var xw=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 Sw(e,t){return new xw(e,yw(t,e))}function Cw(e,t,n){let r=e instanceof xw?e.yRelativePosition:null;if(_w(t)&&r)return{position:new xw(vw(n,r),r),mapResult:null};let i=_d(e,t),a=i.position.position;return{position:new xw(a,r??yw(n,a)),mapResult:i.mapResult}}function ww(e){let t=NS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs undo plugin`);return t.undoManager}var Tw=Tp.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)=>Cw(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>Sw(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),ww(t).undoStack.length===0?!1:n?fw(t)??!1:!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),ww(t).redoStack.length===0?!1:n?pw(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=gw(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let t=ww(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()}}},[ow(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,new E({filterTransaction:(e,t)=>(e.getMeta(`inputRule`)&&ww(t).stopCapturing(),!0)}),this.editor.options.enableContentCheck&&new E({key:new D(`filterInvalidContent`),filterTransaction:t=>{if(!_w(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)}}),Ew=e=>Array.from(e.entries()).map(([e,t])=>t&&t.user?{clientId:e,...t.user}:{clientId:e}),Dw=()=>null,Ow=e=>Pf(e)&&/^#[0-9a-fA-F]{6}$/.test(e),kw=e=>({...e,color:Ow(e.color)?e.color:`transparent`}),Aw=Tp.create({name:`collaborationCaret`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`),{color:n}=kw(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=>Ow(e.color)?VS({name:e.name,color:e.color}):{},onUpdate:Dw}},onCreate(){if(this.options.onUpdate!==Dw&&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=Ew(e.awareness.states)};return e.awareness.setLocalStateField(`user`,n),t.users=Ew(e.awareness.states),e.awareness.on(`update`,r),{destroy:()=>{e.awareness.off(`update`,r),t.users=[]}}}}),GS(e.awareness,{cursorBuilder:e=>this.options.render(kw(e)),selectionBuilder:e=>this.options.selectionRender(kw(e))})]}});function jw(e={}){return new E({view(t){return new Mw(t,e)}})}var Mw=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)}},Nw=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 Pw(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Iw(e)||!Lw(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}}};Nw.prototype.visible=!1,Nw.findFrom=Nw.findGapCursorFrom,C.jsonID(`gapcursor`,Nw);var Pw=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 Nw.valid(t)?new Nw(t):C.near(t)}};function Fw(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Iw(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||Fw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Lw(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||Fw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Rw(){return new E({props:{decorations:Uw,createSelectionBetween(e,t,n){return t.pos==n.pos&&Nw.valid(n)?new Nw(n):null},handleClick:Vw,handleKeyDown:zw,handleDOMEvents:{beforeinput:Hw}}})}var zw=Sc({ArrowLeft:Bw(`horiz`,-1),ArrowRight:Bw(`horiz`,1),ArrowUp:Bw(`vert`,-1),ArrowDown:Bw(`vert`,1)});function Bw(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=Nw.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Nw(c))),!0):!1}}function Vw(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Nw.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 Nw(r))),!0)}function Hw(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Nw))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 Uw(e){if(!(e.selection instanceof Nw))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,xs.create(e.doc,[vs.widget(e.selection.head,t,{key:`gapcursor`})])}Tp.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 Ww=Tp.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[jw(this.options)]}});Tp.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 Gw=Tp.create({name:`gapCursor`,addProseMirrorPlugins(){return[Rw()]},extendNodeSchema(e){return{allowGapCursor:Nu(k(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Kw=`placeholder`,qw=new D(`tiptap__placeholder`);function Jw(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 Yw(e,t){return typeof e==`function`?e(t):e}function Xw({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(Jw({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Yw(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Zw({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(Jw({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Yw(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Xw({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return xs.create(r,o)}function Qw(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 $w(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function eT(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 tT(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($w(e,Qw(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=Xw({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function oT({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Zw({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:aT({decorations:i.map(r.mapping,r.doc),ranges:rT(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function sT(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function cT({editor:e,options:t}){let n=t.dataAttribute?`data-${sT(t.dataAttribute)}`:`data-${Kw}`,r=t.showOnlyCurrent&&!t.includeChildren;return new E({key:qw,...r?{}:{state:oT({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Zw({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?xs.empty:qw.getState(n)??xs.empty}})}var lT=Tp.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Kw,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[cT({editor:this.editor,options:this.options})]}});function uT(e,t){return!e.selection.empty&&!pd(e.selection)&&t.isEditable}function dT(e,t){return uT(e,t)&&!t.isFocused&&!t.view.dragging}function fT(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function pT(e){e.focus()}Tp.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 dT(n,e)?xs.create(n.doc,[vs.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return uT(t.state,e)&&fT(),!1},focus(t){return uT(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&pT(t)}),!1}}}})]}});function mT({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var hT=Tp.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!mT({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!mT({node:r,types:n})}}})]}}),gT=Tp.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()}}}),_T=new WeakSet,vT=new WeakSet;function yT(e){let t=e;return _T.add(t),t}function bT(e){return Array.isArray(e)&&_T.has(e)}function xT(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&vT.has(e)&&!bT(e)?xT(e):[e])}function ST(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!bT(n)&&!vT.has(n)?yT(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(bT(n))return yT([e,r,n]);if(n.length===0)return yT([e,r]);let t=xT(n);return t.length===0?yT([e,r]):yT([e,r,...t])}return yT(n==null?[e,r]:[e,r,n])}var CT=(e,t)=>ST(e,t),wT=(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})},TT=/^\s*>\s$/,ET=Jp.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return CT(`blockquote`,{...A(this.options.HTMLAttributes,e),children:CT(`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(` +`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&qb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&$b(n,r,a.delete):Jb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??rb();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(_y(s,e)||t!==void 0&&_y(s,t))switch(s.content.constructor){case Mx:{let r=i.get(`ychange`);e!==void 0&&!_y(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&&!_y(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 Hx:case Cx:{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 Tx:_y(s,e)&&(c(),Wb(i,s.content))}s=s.right}c()};return e||t?Ly(a,n=>{e&&vy(n,e),t&&vy(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)):Ly(r,r=>{let i=Hb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),qb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Ly(r,r=>{let i=Hb(r,this,e,!n);qb(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)):Ly(n,n=>{$b(n,Hb(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)):Ly(r,r=>{let i=Hb(r,this,e,!1);i.right!==null&&Jb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Ly(this.doc,t=>{Eb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Ly(this.doc,n=>{Db(n,this,e,t)})}getAttribute(e){return Ob(this,e)}getAttributes(){return kb(this)}_write(e){e.writeTypeRef(Lx)}},nx=e=>new tx,rx=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??rb()}[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===ox||t.constructor===ix)&&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})}},ix=class e extends pb{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 pb?e.clone():e)),t}get length(){return this.doc??rb(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rx(this,e)}querySelector(e){e=e.toUpperCase();let t=new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),im(new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){fb(this,e,new cx(this,t,e))}toString(){return vb(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),_b(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ly(this.doc,n=>{Cb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Ly(this.doc,n=>{let r=e&&e instanceof pb?e._item:e;xb(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 ih(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ly(this.doc,n=>{Tb(n,this,e,t)})}toArray(){return hb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return bb(this,e)}slice(e=0,t=this.length){return mb(this,e,t)}forEach(e){_b(this,e)}_write(e){e.writeTypeRef(zx)}},ax=e=>new ix,ox=class e extends ix{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 Hh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof pb?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):Ly(this.doc,t=>{Eb(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Ly(this.doc,n=>{Db(n,this,e,t)})}getAttribute(e){return Ob(this,e)}hasAttribute(e){return Ab(this,e)}getAttributes(e){return e?jb(this,e):kb(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 _b(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Rx),e.writeKey(this.nodeName)}},sx=e=>new ox(e.readKey()),cx=class extends tb{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)})}},lx=class e extends Lb{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(Bx),e.writeKey(this.hookName)}},ux=e=>new lx(e.readKey()),dx=class e extends tx{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(Vx)}},fx=e=>new dx,px=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ah()}mergeWith(e){return!1}write(e,t,n){throw ah()}integrate(e,t){throw ah()}},mx=0,hx=class extends px{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),Sy(e.doc.store,this)}write(e,t){e.writeInfo(mx),e.writeLen(this.length-t)}getMissing(e,t){return null}},gx=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 ah()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},_x=e=>new gx(e.readBuf()),vx=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){pv(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}},yx=e=>new vx(e.readLen()),bx=(e,t)=>new bv({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),xx=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(bx(this.doc.guid,this.opts))}splice(e){throw ah()}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}},Sx=e=>new xx(bx(e.readString(),e.readAny())),Cx=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 ah()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},wx=e=>new Cx(e.readJSON()),Tx=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 ah()}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}},Ex=e=>new Tx(e.readKey(),e.readJSON()),Dx=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}},Nx=e=>new Mx(e.readString()),Px=[Fb,Rb,nx,sx,ax,ux,fx],Fx=0,Ix=1,Lx=2,Rx=3,zx=4,Bx=5,Vx=6,Hx=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 ah()}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}},Ux=e=>new Hx(Px[e.readTypeRef()](e)),Wx=(e,t)=>{let n=t,r=0,i;do r>0&&(n=N(n.client,n.clock+r)),i=wy(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Yx);return{item:i,diff:r}},Gx=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Kx=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Yx(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},qx=(e,t)=>om(e,e=>uv(e.deletions,t)),Jx=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Ey(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Jx(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Ey(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:Ey(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:Ey(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||uv(r,d.right.id)||qx(a.undoStack,d.right.id)||qx(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ey(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,xy(s,c)),h=new Yx(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Gx(h,!0),h.integrate(e,0),h},Yx=class e extends px{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>=xy(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=xy(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Zv&&this.id.client!==this.parent.client&&this.parent.clock>=xy(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Dy(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Ey(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===hx||this.right&&this.right.constructor===hx)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===Zv){let e=wy(n,this.parent);this.parent=e.constructor===hx?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Dy(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),Qv(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(),pv(e.deleteSet,this.id.client,this.id.clock,this.length),My(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw oh();this.content.gc(e),t?Oy(e,this,new hx(this.id,this.length)):this.content=new vx(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=ey(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===Zv?(e.writeParentInfo(!1),e.writeLeftID(t)):oh();i!==null&&e.writeString(i)}this.content.write(e,t)}},Xx=(e,t)=>Zx[t&31](e),Zx=[()=>{oh()},yx,Ox,_x,Nx,wx,Ex,Ux,jx,Sx,()=>{oh()}],Qx=10,$x=class extends px{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){oh()}write(e,t){e.writeInfo(Qx),j(e.restEncoder,this.length-t)}getMissing(e,t){return null}},eS=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},tS=`__ $YJS$ __`;eS[tS]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),eS[tS]=!0;var nS=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},rS=(e,t)=>e>>>t|e<<32-t,iS=e=>rS(e,2)^rS(e,13)^rS(e,22),aS=e=>rS(e,6)^rS(e,11)^rS(e,25),oS=e=>rS(e,7)^rS(e,18)^e>>>3,sS=e=>rS(e,17)^rS(e,19)^e>>>10,cS=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]),lS=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),uS=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lS),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=sS(t[e-2])+t[e-7]+oS(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+aS(o)+(o&s^~o&c)+cS[e]+t[e]>>>0,d=iS(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}},dS=e=>new uS().digest(e),fS=/[\uD800-\uDBFF]/,pS=/[\uDC00-\uDFFF]/,mS=(e,t)=>{let n=0,r=0;for(;n0&&fS.test(e[n-1])&&n--;r+n0&&pS.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}};function hS(e){if(!e||!(e.content instanceof Hx))return null;let t=e.content.type;if(!(t instanceof ix||t instanceof tx||t instanceof lx))throw Error(`Expected a Yjs XML type`);return t}function gS(e){if(e===null)return null;if(!(e.parent instanceof pb))throw Error(`Expected an integrated Yjs parent`);let t=e.parent;if(!(t instanceof ix||t instanceof tx||t instanceof lx))throw Error(`Expected a Yjs XML type`);return t}var _S=(e,t)=>{let n=null,r=null;return e._item===null?r=ey(e):n=N(e._item.id.client,e._item.id.clock),new ny(n,r,t.id)},vS=(e,t,n)=>{if(e===0)return sy(t,0,-1);let r=hS(t._first);for(;r!==null&&t!==r;){if(r instanceof dx){if(r._length>=e)return sy(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=hS(r._item.next);else{do r=gS(r._item),e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:hS(r._item.next))}}else{let i=n.get(r),a=i instanceof le?i.nodeSize:0;if(r._first!==null&&e1)return new ny(r._item===null?null:r._item.id,r._item===null?ey(r):null,null);if(e-=a,r._item!==null&&r._item.next!==null)r=hS(r._item.next);else{if(e===0){if(r=r._item===null?r:gS(r._item),r===null)throw oh();return new ny(r._item===null?null:r._item.id,r._item===null?ey(r):null,null)}do{if(r=gS(r._item),r===null)throw oh();e--}while(r!==t&&r._item?.next===null);r!==t&&(r=hS(r._item?.next))}}}if(r===null)throw oh();if(e===0&&r.constructor!==dx&&r!==t){let e=r._item,t=gS(e);if(e===null||t===null)throw oh();return _S(t,e)}}return sy(t,t._length,-1)},yS=(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 bS(e,t){if(e instanceof dx)return e._length;let n=t.get(e);return n instanceof le?n.nodeSize:null}function xS(e,t,n){let r=0,i=e._first;for(;i!==null;){let e=hS(i);if(e===t)break;let a=i.deleted;if(i=i.right,a)continue;if(e===null)return null;let o=bS(e,n);if(o===null)return null;r+=o}return r}function SS(e,t,n){let r=0,i=0,a=e._first;for(;i{if(n===null)return!1;let r=dy(t,e);return r!==null&&r.type instanceof dx&&t.item!==null&&r.type._item?.deleted===!0},wS=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:${ey(e)}`;return e.doc.getMap(`__tiptap_position_migrations:${t}`)},TS=new WeakMap,ES=(e,t)=>{let n=t.item??t.type;if(!n)return[];let r;t.item||(r=t.assoc<0?`start`:`end`);let i=TS.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},TS.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)))},DS=(e,t,n)=>{let{source:r,target:i}=e.transfer;return i?new ny(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},OS=(e,t,n)=>{let r=DS(e[0],t,n);return!r||e.some(e=>{let i=DS(e,t,n);return!i||!fy(r,i)})?null:r},kS=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}`},AS=(e,t)=>{let n=wS(e),r=new Set,i=t,a=i.item??i.type;for(;a;){let e=kS(i);if(r.has(e))return null;r.add(e);let t=ES(n,i);if(t.length===0)return i;let o=OS(t,a,i.assoc);if(!o)return null;if(kS(o)===e)return o;i=o,a=o.item??o.type}return i},jS=(e,t,n,r)=>{let i=AS(t,n);if(!i)return null;n=i;let a=dy(n,e);if(a===null||a.type!==t&&!ty(t,a.type._item))return null;let o=a.type,s=0;if(o.constructor===dx)s=a.index;else if(!o._item?.deleted){let e=SS(o,a.index,r);if(e===null)return null;s=e+1}for(;o!==t&&o._item!==null;){let e=gS(o._item);if(e===null)return null;if(e._item?.deleted){o=e;continue}let t=xS(e,o,r);if(t===null)return null;s+=t+1,o=e}let c=s-1;return CS(e,n,c)?null:c},MS=new D(`y-sync`),NS=new D(`y-undo`),PS=new D(`yjs-cursor`),FS=null;function IS(){let e=FS;FS=null;let t=[];return e?.forEach((e,n)=>{e.forEach((e,r)=>t.push({view:n,key:r,value:e}))}),t}function LS(e=IS(),t=!1){let n=!0;for(;e.length>0;){let{view:r,key:i,value:a}=e[0];try{let e=MS.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&&B_(0,()=>LS(e,!0));return}n=!1,e.shift()}}function RS(e,t,n){FS===null&&(FS=new Map,B_(0,LS));let r=FS.get(e);r||(r=new Map,FS.set(e,r)),r.set(t,n)}var zS=(e,t,n)=>e!==t,BS=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},VS=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),HS=/^#[0-9a-fA-F]{6}$/,US=e=>typeof e.name==`string`&&typeof e.color==`string`,WS=(e,t,n,r,i)=>{let a=MS.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`:HS.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`,!US(n))return;let l=jS(o,a.type,ry(t.cursor.anchor),a.binding.mapping),u=jS(o,a.type,ry(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=mm(e.doc.content.size-1,0);l=pm(l,t),u=pm(u,t),s.push(vs.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=pm(l,u),o=mm(l,u);s.push(vs.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),xs.create(e.doc,s))},GS=(e,{awarenessStateFilter:t=zS,cursorBuilder:n=BS,selectionBuilder:r=VS,getSelection:i=e=>e.selection}={},a=`cursor`)=>new E({key:PS,state:{init(i,a){return WS(a,e,t,n,r)},apply(i,a,o,s){let c=MS.getState(s),l=i.getMeta(PS),u=c&&c.isChangeOrigin;return i.docChanged&&!u&&yS(i,o.doc)?xs.empty:u||l&&l.awarenessUpdated?WS(s,e,t,n,r):i.docChanged?a.map(i.mapping,i.doc):a}},props:{decorations:e=>PS.getState(e)??xs.empty},view:t=>{let n=()=>{t.isDestroyed||RS(t,PS,{awarenessUpdated:!0})},r=t=>{let n=MS.getState(t.state);if(!n||!n.binding)return;let r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=vS(o.anchor,n.type,n.binding.mapping),c=vS(o.head,n.type,n.binding.mapping);r.cursor!=null&&fy(ry(r.cursor.anchor),s)&&fy(ry(r.cursor.head),c)||e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&jS(n.doc,n.type,ry(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 KS(e){let t=MS.getState(e);if(!t)throw Error(`The editor requires ySyncPlugin`);return t}var qS=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)??0)>e.id.clock&&!uv(t.ds,e.id),JS=(e,t,n)=>{if(!e.has(n)){if(e.sizen.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,kh(t))}let r=e.get(n);if(!r)throw Error(`At least one snapshot color is required`);return r},YS=(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])},XS=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]})},ZS=(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=ZS(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&&YS(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||XS(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)},QS=(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||!YS(i.parent.attrs,a.parent.attrs);if(o||s){let i=ZS(e,t,n);return i!==null&&i!==r}return!1},$S=(e,t,n,r)=>{if(n==null||n<0||n>t.content.size||!(r===null||n>1&&r<=1||QS(t,e,n,r)))return r;let i=ZS(t,e,n);return i===null?r:i},eC=(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=jS(n.doc,n.type,t.anchor,n.mapping);r!==null&&e.setSelection(tC(e,r))}else if(t.type===`nodeRange`){let r=nC(e,jS(n.doc,n.type,t.anchor,n.mapping),jS(n.doc,n.type,t.head,n.mapping),t.depth);r!==null&&e.setSelection(r)}else{let i=jS(n.doc,n.type,t.anchor,n.mapping),a=jS(n.doc,n.type,t.head,n.mapping);r!=null&&(AS(n.type,t.anchor)===t.anchor&&(i=$S(e.doc,r,t.absAnchor,i)),AS(n.type,t.head)===t.head&&(a=$S(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)))}}},tC=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?T.create(e.doc,t):w.near(n)},nC=(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))}},rC=(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:vS(t.selection.anchor,e.type,e.mapping),head:vS(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},iC=new WeakMap,aC=(e,t)=>{var n;(t instanceof ix||t instanceof tx||t instanceof lx)&&(e.delete(t),(n=iC.get(e))==null||n.delete(t))},oC=/(.*)(--[a-zA-Z0-9+/=]{8})$/,sC=e=>oC.exec(e)?.[1]??e,cC=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(sC(r),e[r]));return n},lC=e=>{let t=e.doc,n=e._item;if(!t||!n)throw oh();t.transact(e=>{n.delete(e)},MS)},uC=(e,t,n,r,i,a)=>{let o=e.toDelta(r,i,a);try{return o.map(e=>t.text(e.insert,cC(e.attributes,t)))}catch{return lC(e),null}},dC=e=>{var t;let n=(t=e._item)==null||(t=t.right)==null?void 0:t.content,r=n instanceof Hx?n.type:null;if(!(r instanceof tx))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)}))},fC=(e,t,n,r)=>{if(e._item){if(!qS(e._item,t))return r?r(`removed`,e._item.id):{type:`removed`};if(!qS(e._item,n))return r?r(`added`,e._item.id):{type:`added`}}},pC=(e,t,n)=>{e.mapping.set(t,n);let r=iC.get(e.mapping);r===void 0&&(r=new WeakMap,iC.set(e.mapping,r)),r.set(t,n)},mC=(e,t,n,r,i,a)=>{let o=n.mapping.get(e),s=Array.isArray(o)?void 0:o;if(s!==void 0&&iC.get(n.mapping)?.get(e)===s)return s;let c=[],l=e=>{if(e instanceof ox){let o=mC(e,t,n,r,i,a);o!==null&&c.push(o)}else e instanceof dx&&(dC(e),uC(e,t,n,r,i,a)?.forEach(e=>c.push(e)))};r===void 0||i===void 0?e.toArray().forEach(l):gb(e,new py(i.ds,r.sv)).forEach(l);try{let o=e.getAttributes(r),l=r?fC(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),pC(n,e,u),u}catch{return lC(e),aC(n.mapping,e),null}},hC=e=>{for(let t=6;thg(hC(dS(vg(e)))),_C=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Qp(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${gC(e.toJSON())}`:e.type.name]=e.attrs}}),n},vC=(e,t)=>{let n=new dx,r=e.map(e=>({insert:e.text??``,attributes:_C(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},yC=e=>{let t=e.content.content,n=[];for(let e=0;ee instanceof Array?vC(e,t):xC(e,t),xC=(e,t)=>{let n=new ox(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,yC(e).map(e=>bC(e,t))),t.mapping.set(n,e),n},SC=e=>typeof e==`object`&&!!e,CC=(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&&Vh(e.attributes||{}).length===t[n].marks.length&&Object.entries(e.attributes??{}).every(([e,r])=>{let i=sC(e),a=t[n].marks.find(e=>e.type.name===i);return a?CC(r,a.attrs):!1}))},TC=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,EC=(e,t)=>{if(e instanceof ox&&!(t instanceof Array)&&TC(e,t)){let n=yC(t);return e._length===n.length&&CC(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>EC(e,n[t]))}return e instanceof dx&&t instanceof Array&&wC(e,t)},DC=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),OC=(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&&DC(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()},kC=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Mx?t+=n.content.str:n.content instanceof Tx&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},AC=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=kC(e),a=t.map(e=>({insert:e.text??``,attributes:Object.assign({},r,_C(e.marks,n))})),{insert:o,remove:s,index:c}=mS(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})))},jC=(e,t,n,r,i)=>t instanceof dx&&n instanceof Array?(wC(t,n)?r.mapping.set(t,n):AC(t,n,r),!0):t instanceof ox&&!(n instanceof Array)&&TC(t,n)?(EC(t,n)?r.mapping.set(t,n):i(e,t,n,r),!0):!1,MC=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>aC(r.mapping,e)),e.delete(t,n))},NC=(e,t,n,r,i,a)=>{if(r{let u=pm(a-i,s-o);for(let a=0;a{let o=OC(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 dx&&t instanceof Array||e.yChild instanceof ox&&!(t instanceof Array))}))return!1;let s=0,c=0;for(let l of o){PC(e,t,n,r,s,l.yIndex,c,l.pIndex,i,a);let o=n[l.pIndex];jC(e,l.yChild,o,i,a),s=l.yIndex+1,c=l.pIndex+1}return PC(e,t,n,r,s,r.length,c,n.length,i,a),!0},IC=(e,t,n)=>{let r=e.toArray(),i=yC(t),a=i.length,o=r.length,s=pm(o,a),c=0,l=0,u=!1;for(;c{if(t instanceof ox&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ox){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=yC(n),a=i.length,o=t.toArray(),s=o.length,c=pm(a,s),l=!1;if(e.transact(()=>{l=FC(e,t,i,o,r,LC)},MS),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 dx&&c instanceof Array){wC(n,c)||AC(n,c,r),u+=1;continue}let p=n instanceof ox&&TC(n,c),m=l instanceof ox&&TC(l,f);if(p&&m&&n instanceof ox&&l instanceof ox&&!Array.isArray(c)&&!Array.isArray(f)){let e=IC(n,c,r),t=IC(l,f,r);e.foundMappedChild&&!t.foundMappedChild?m=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor0&&(t.slice(u,u+n).forEach(e=>aC(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 Mx))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},BC=(e,t,n,r,i)=>{let a=RC(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 RC(e,n)},VC=(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&&Qv(e.target.type,t.target.type),HC=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&&VC(n,e)?n.source.length+=e.source.length:t.push({...e,source:{...e.source}})}),t},UC=(e,t)=>{let n=e.doc;if(!n||t.length===0)return;let r=xy(n.store,n.clientID);e.set(`${n.clientID}:${r}`,{version:1,client:n.clientID,clock:r,seen:[...Vv(Gv(n))],transfers:HC(t)})},WC=(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&&Qv(n.type,a.type)||r.push({source:{...n.type,length:1,boundary:`start`},target:a?{...a,assoc:0}:null}),o&&Qv(i.type,o.type)||r.push({source:{...n.type,length:1,boundary:`end`},target:o?{...o,assoc:-1}:null})}),r},GC=(e,t,n,r)=>{let i=[];e.forEach(e=>{let n=e.position===null?null:t.get(e.position)??null;n&&Qv(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&&Qv(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},KC=(e,t,n,r,i,a)=>{let o=e.get(t);if(!(o instanceof ox)||!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&&(aC(a.mapping,o),e.delete(t,1),o=bC(n,a),e.insert(t,[o])),!(o instanceof ox)||!o._item)throw Error(`Position migration requires integrated elements`);return o},qC=(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;yC(t).forEach((t,r)=>{let p=d[r];if(Array.isArray(t)){if(!(p instanceof dx)||!p._item)throw Error(`Position migration requires integrated text`);let e=t.map(e=>e.text??``).join(``),r=BC(p,e,f,i,a),s=p._item.id;r.forEach(e=>o.set(e.position,{client:e.client,clock:e.clock,type:s})),AC(p,t,n),f+=e.length;return}let m=KC(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:ey(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&&Qv(e,t)&&Qv(e.type,t.type)||d.push({source:{client:e.client,clock:e.clock,length:1},target:t})}),d.push(...WC(t.characters,o)),d.push(...GC(t.nodes,c,l,t.emptyTexts)),UC(r,d)},JC=(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))},YC=class{constructor(e,t=new Map){if(this.prosemirrorView=null,this.mux=nS(),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=rC(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()?(tg&&this._domSelectionInView===null&&(B_(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=N_.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||=my(mv(),new Map),this.view.dispatch(this._tr.setMeta(MS,{snapshot:e,prevSnapshot:t}))}createDocumentTransaction(){let e=this.type.toArray().map(e=>{if(!(e instanceof ox))throw ah();return mC(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(),iC.delete(this.mapping),this.mux(()=>{let e=this.createDocumentTransaction();e.setMeta(MS,{snapshot:null,prevSnapshot:null}),this.view.dispatch(e)})}_forceRerender(){this.mapping.clear(),iC.delete(this.mapping),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.view.state.selection:null,t=this.createDocumentTransaction();if(e){let n=pm(mm(e.anchor,0),t.doc.content.size),r=pm(mm(e.head,0),t.doc.content.size);t.setSelection(w.create(t.doc,n,r))}this.view.dispatch(t.setMeta(MS,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=gy(this.doc),e instanceof Uint8Array||t instanceof Uint8Array){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw oh();if(r=new bv({gc:!1}),Fv(r,t),t=gy(r),Fv(r,e),e=gy(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[Cy(e,i._item.id.clock)];if(!(t instanceof Yx&&t.content instanceof Hx&&t.content.type instanceof ix))throw oh();i=t.content.type}}let a=e,o=t??hy;this.mapping.clear(),iC.delete(this.mapping),this.mux(()=>{r.transact(e=>{let t=n.permanentUserData;t&&t.dss.forEach(t=>{cv(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:JS(n.colorMapping,n.colors,i)}},c=gb(i,new py(o.ds,a.sv)).map(e=>!(e instanceof ox)||!e._item?null:!e._item.deleted||qS(e._item,a)||qS(e._item,o)?mC(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(MS,{isChangeOrigin:!0}))},MS)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=KS(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 Vy,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)=>aC(this.mapping,t);cv(t,t.deleteSet,e=>{e instanceof Yx&&e.content instanceof Hx&&aC(this.mapping,e.content.type)}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>{if(!(e instanceof ox))throw ah();return mC(e,this.view.state.schema,this)}).filter(e=>e!==null),i=JC(this._tr,s.from(n));eC(i,a,this,o),i=i.setMeta(MS,{isChangeOrigin:!0,isUndoRedoOperation:r}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.view.dispatch(i)})}_prosemirrorChanged(e,t=null){let n=KS(this.view.state);n.snapshot==null&&n.prevSnapshot==null&&this.doc.transact(()=>{LC(this.doc,this.type,e,this),t?.doc===e&&qC(this.type,t,this,wS(this.type)),this.syncedDoc=e,this.beforeTransactionSelection=rC(this,this.view.state)},MS)}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))}},XC=(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=yC(t),l=o;t.content.size===0&&s.forEach(e=>{e instanceof dx&&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 ox)||!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 dx))throw Error(`Position tracking requires synchronized editor text`);let o=RC(i,l);n.push(...o),l+=o.length})};return a(e,t,0),{characters:n,nodes:r,emptyTexts:i}},ZC=(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:QC(a,o)},QC=(e,t)=>e.type===t.type&&e.content.eq(t.content)&&!e.sameMarkup(t),$C=(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)},ew=e=>{let t=new Map;return e.descendants((e,n)=>{let r=t.get(e)??[];r.push(n),t.set(e,r)}),t},tw=(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=tw(e.node,e.offset,t,r);if(n)return n}return null},rw=(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)=>$C(t,e.docs[n])))return r;let i=r??XC(t.type,e.before),a=[...e.docs,e.doc],o=a.map(ew),s=i.characters.map(t=>({...t,position:t.position===null?null:rw(t.position,e,a,o)})),c=t=>({...t,position:t.position===null?null:rw(t.position,e,a,o),end:t.end===null?null:rw(t.end,e,a,o)});return{doc:e.doc,characters:s,nodes:i.nodes.map(c),emptyTexts:i.emptyTexts.map(c)}},aw=[{light:`#ecd44433`,dark:`#ecd444`}],ow=(e,{colors:t=aw,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new YC(e,a);return new E({props:{editable:e=>{let t=KS(e);return t.snapshot==null&&t.prevSnapshot==null}},key:MS,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(MS);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:iw(e,s,t.positionMigration??null)},s.prosemirrorView===null||n===void 0||n.snapshot==null&&n.prevSnapshot==null||B_(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(MS,{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=KS(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=NS.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)},MS)})}}},destroy:()=>{s.destroy()}})})};function sw(e){let t=NS.getState(e);if(!t)throw Error(`The editor requires yUndoPlugin`);return t}var cw=e=>{let t=new Map,n=e=>{e.toArray().forEach(r=>{if(r instanceof ox){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:ey(e)}}),n(r);return}if(!(r instanceof dx)||!r._item)return;let i=r._item.id;RC(r).forEach(e=>{t.set(`${e.client}:${e.clock}`,{client:e.client,clock:e.clock,type:i})})})};return n(e),t},lw=(e,t)=>{let n=e.doc;if(!n)return;let r=cw(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 Yx&&e.redone&&(e.content instanceof Mx||e.content instanceof Hx))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=wy(n.store,t);if(a.content instanceof Hx&&a.content.type instanceof ox)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}})})}),UC(t,s)},uw=(e,t,n)=>{let r=wS(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&&lw(e,r)},t)}finally{t.off(`stack-item-popped`,o),t[i]=!1,t.currStackItem=null}return a},dw=(e,t)=>{let n=KS(e);if(n.snapshot!=null||n.prevSnapshot!=null)return!1;let r=sw(e).undoManager;if(r!=null)return uw(n.type,r,t),!0},fw=e=>dw(e,`undo`),pw=e=>dw(e,`redo`),mw=new Set([`paragraph`]),hw=(e,t)=>!(e instanceof Yx)||!(e.content instanceof Hx)||!(e.content.type instanceof tx||e.content.type instanceof ox&&t.has(e.content.type.nodeName))||e.content.type._length===0,gw=({protectedNodes:e=mw,trackedOrigins:t=[],undoManager:n=null}={})=>new E({key:NS,state:{init:(r,i)=>{let a=KS(i),o=new Set,s=n;if(!s){let n=new Set(a.doc._observers.get(`destroy`));s=new Vy(a.type,{trackedOrigins:new Set([MS,...t]),deleteFilter:t=>hw(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=KS(r).binding;return{...t,prevSel:i?rC(i,n):t.prevSel,hasUndoOps:t.undoManager.undoStack.length>0,hasRedoOps:t.undoManager.redoStack.length>0}}},view:e=>{let t=KS(e.state),{undoManager:n,destroyListeners:r}=sw(e.state);return n.on(`stack-item-added`,({stackItem:r})=>{let i=t.binding;if(i){let t=n.undoing||n.redoing?i.beforeTransactionSelection:sw(e.state).prevSel;r.meta.set(i,t)}}),{destroy:()=>{n.destroy(),r.forEach(e=>n.doc.off(`destroy`,e)),r.clear()}}}});function _w(e,t){let n=t||new ix;return LC(n.doc??{transact:e=>e()},n,e,{mapping:new Map,isOMark:new Map}),n}function vw(e){let t=e.toArray(),n=e=>{let t;if(e instanceof dx)t=e.toDelta().map(e=>{let t={type:`text`,text:e.insert},n=e.attributes;return n&&(t.marks=Object.keys(n).map(e=>{let t=n[e],r={type:sC(e)};return Object.keys(t).length&&(r.attrs=t),r})),t});else if(e instanceof ox){t={type:e.nodeName};let r=e.getAttributes();Object.keys(r).length&&(t.attrs=r);let i=e.toArray();i.length&&(t.content=i.map(n).flat())}else oh();return t};return{type:`doc`,content:t.map(n)}}function yw(e,t,n){return _w(le.fromJSON(e,t),n)}function bw(e){return!!e.getMeta(MS)}function xw(e,t){if(t===null)return 0;let n=Cw(e);return jS(n.doc,n.type,t,n.binding.mapping)||0}function Sw(e,t){let n=Cw(e);return vS(t,n.type,n.binding.mapping)}function Cw(e){let t=MS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs sync plugin`);return t}var ww=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 Tw(e,t){return new ww(e,Sw(t,e))}function Ew(e,t,n){let r=e instanceof ww?e.yRelativePosition:null;if(bw(t)&&r)return{position:new ww(xw(n,r),r),mapResult:null};let i=_d(e,t),a=i.position.position;return{position:new ww(a,r??Sw(n,a)),mapResult:i.mapResult}}function Dw(e){let t=NS.getState(e);if(!t)throw Error(`Collaboration requires the Yjs undo plugin`);return t.undoManager}var Ow=Tp.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)=>Ew(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>Tw(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Dw(t).undoStack.length===0?!1:n?fw(t)??!1:!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Dw(t).redoStack.length===0?!1:n?pw(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=gw(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let t=Dw(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()}}},[ow(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,new E({filterTransaction:(e,t)=>(e.getMeta(`inputRule`)&&Dw(t).stopCapturing(),!0)}),this.editor.options.enableContentCheck&&new E({key:new D(`filterInvalidContent`),filterTransaction:t=>{if(!bw(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)}}),kw=e=>Array.from(e.entries()).map(([e,t])=>t&&t.user?{clientId:e,...t.user}:{clientId:e}),Aw=()=>null,jw=e=>Pf(e)&&/^#[0-9a-fA-F]{6}$/.test(e),Mw=e=>({...e,color:jw(e.color)?e.color:`transparent`}),Nw=Tp.create({name:`collaborationCaret`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`),{color:n}=Mw(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=>jw(e.color)?VS({name:e.name,color:e.color}):{},onUpdate:Aw}},onCreate(){if(this.options.onUpdate!==Aw&&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=kw(e.awareness.states)};return e.awareness.setLocalStateField(`user`,n),t.users=kw(e.awareness.states),e.awareness.on(`update`,r),{destroy:()=>{e.awareness.off(`update`,r),t.users=[]}}}}),GS(e.awareness,{cursorBuilder:e=>this.options.render(Mw(e)),selectionBuilder:e=>this.options.selectionRender(Mw(e))})]}});function Pw(e={}){return new E({view(t){return new Fw(t,e)}})}var Fw=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)}},Iw=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 Lw(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!zw(e)||!Bw(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}}};Iw.prototype.visible=!1,Iw.findFrom=Iw.findGapCursorFrom,C.jsonID(`gapcursor`,Iw);var Lw=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 Iw.valid(t)?new Iw(t):C.near(t)}};function Rw(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function zw(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||Rw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Bw(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||Rw(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Vw(){return new E({props:{decorations:Kw,createSelectionBetween(e,t,n){return t.pos==n.pos&&Iw.valid(n)?new Iw(n):null},handleClick:Ww,handleKeyDown:Hw,handleDOMEvents:{beforeinput:Gw}}})}var Hw=Sc({ArrowLeft:Uw(`horiz`,-1),ArrowRight:Uw(`horiz`,1),ArrowUp:Uw(`vert`,-1),ArrowDown:Uw(`vert`,1)});function Uw(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=Iw.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Iw(c))),!0):!1}}function Ww(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Iw.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 Iw(r))),!0)}function Gw(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Iw))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 Kw(e){if(!(e.selection instanceof Iw))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,xs.create(e.doc,[vs.widget(e.selection.head,t,{key:`gapcursor`})])}Tp.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 qw=Tp.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Pw(this.options)]}});Tp.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 Jw=Tp.create({name:`gapCursor`,addProseMirrorPlugins(){return[Vw()]},extendNodeSchema(e){return{allowGapCursor:Nu(k(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Yw=`placeholder`,Xw=new D(`tiptap__placeholder`);function Zw(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 Qw(e,t){return typeof e==`function`?e(t):e}function $w({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(Zw({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Qw(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function eT({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(Zw({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Qw(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...$w({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return xs.create(r,o)}function tT(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 nT(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function rT(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 iT(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(nT(e,tT(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=$w({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function lT({editor:e,options:t,dataAttribute:n}){return{init(r,i){return eT({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:cT({decorations:i.map(r.mapping,r.doc),ranges:oT(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function uT(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function dT({editor:e,options:t}){let n=t.dataAttribute?`data-${uT(t.dataAttribute)}`:`data-${Yw}`,r=t.showOnlyCurrent&&!t.includeChildren;return new E({key:Xw,...r?{}:{state:lT({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>eT({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?xs.empty:Xw.getState(n)??xs.empty}})}var fT=Tp.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Yw,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[dT({editor:this.editor,options:this.options})]}});function pT(e,t){return!e.selection.empty&&!pd(e.selection)&&t.isEditable}function mT(e,t){return pT(e,t)&&!t.isFocused&&!t.view.dragging}function hT(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function gT(e){e.focus()}Tp.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 mT(n,e)?xs.create(n.doc,[vs.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return pT(t.state,e)&&hT(),!1},focus(t){return pT(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&gT(t)}),!1}}}})]}});function _T({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var vT=Tp.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!_T({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!_T({node:r,types:n})}}})]}}),yT=Tp.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()}}}),bT=new WeakSet,xT=new WeakSet;function ST(e){let t=e;return bT.add(t),t}function CT(e){return Array.isArray(e)&&bT.has(e)}function wT(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&xT.has(e)&&!CT(e)?wT(e):[e])}function TT(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!CT(n)&&!xT.has(n)?ST(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(CT(n))return ST([e,r,n]);if(n.length===0)return ST([e,r]);let t=wT(n);return t.length===0?ST([e,r]):ST([e,r,...t])}return ST(n==null?[e,r]:[e,r,n])}var ET=(e,t)=>TT(e,t),DT=(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})},OT=/^\s*>\s$/,kT=Jp.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return ET(`blockquote`,{...A(this.options.HTMLAttributes,e),children:ET(`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:()=>wT(this.editor,this.type)}},addInputRules(){return[Gp({find:TT,type:this.type})]}}),DT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,OT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,kT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,AT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jT=_p.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return CT(`strong`,{...A(this.options.HTMLAttributes,e),children:CT(`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[Hp({find:DT,type:this.type}),Hp({find:kT,type:this.type})]},addPasteRules(){return[Yp({find:OT,type:this.type}),Yp({find:AT,type:this.type})]}}),MT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},NT=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 PT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var FT=_p.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(PT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hp({find:MT,type:this.type})]},addPasteRules(){return[Yp({find:NT,type:this.type})]}}),IT=4,LT=/^```([a-z]+)?[\s\n]$/,RT=/^~~~([a-z]+)?[\s\n]$/,zT=Jp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:IT,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??IT,{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:()=>DT(this.editor,this.type)}},addInputRules(){return[Gp({find:OT,type:this.type})]}}),AT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,jT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,MT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,NT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,PT=_p.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return ET(`strong`,{...A(this.options.HTMLAttributes,e),children:ET(`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[Hp({find:AT,type:this.type}),Hp({find:MT,type:this.type})]},addPasteRules(){return[Yp({find:jT,type:this.type}),Yp({find:NT,type:this.type})]}}),FT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},IT=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 LT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var RT=_p.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(LT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hp({find:FT,type:this.type})]},addPasteRules(){return[Yp({find:IT,type:this.type})]}}),zT=4,BT=/^```([a-z]+)?[\s\n]$/,VT=/^~~~([a-z]+)?[\s\n]$/,HT=Jp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:zT,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??zT,{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??IT,{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??zT,{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,` @@ -123,44 +123,48 @@ 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[Wp({find:LT,type:this.type,getAttributes:e=>({language:e[1]})}),Wp({find:RT,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}}})]}}),BT=zT,VT=Jp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(C.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Wp({find:BT,type:this.type,getAttributes:e=>({language:e[1]})}),Wp({find:VT,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}}})]}}),UT=HT,WT=Jp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``}),HT=Jp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,A(this.options.HTMLAttributes,e)]},renderText(){return` +`):``}),GT=Jp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,A(this.options.HTMLAttributes,e)]},renderText(){return` `},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()}}}),UT=Jp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Wp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),WT=Jp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,A(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Df(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(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[Up({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,KT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,JT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,YT=_p.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hp({find:GT,type:this.type}),Hp({find:qT,type:this.type})]},addPasteRules(){return[Yp({find:KT,type:this.type}),Yp({find:JT,type:this.type})]}}),XT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,ZT=`ελ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`,QT=`numeric`,$T=`ascii`,eE=`alpha`,tE=`asciinumeric`,nE=`alphanumeric`,rE=`domain`,iE=`emoji`,aE=`scheme`,oE=`slashscheme`,sE=`whitespace`;function cE(e,t){return e in t||(t[e]=[]),t[e]}function lE(e,t,n){t[QT]&&(t[tE]=!0,t[nE]=!0),t[$T]&&(t[tE]=!0,t[eE]=!0),t[tE]&&(t[nE]=!0),t[eE]&&(t[nE]=!0),t[nE]&&(t[rE]=!0),t[iE]&&(t[rE]=!0);for(let r in t){let t=cE(r,n);t.indexOf(e)<0&&t.push(e)}}function uE(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function dE(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}dE.groups={},dE.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),fE=(e,t,n,r,i)=>e.tr(t,n,r,i),pE=(e,t,n,r,i)=>e.ts(t,n,r,i),F=(e,t,n,r,i)=>e.tt(t,n,r,i),mE=`WORD`,hE=`UWORD`,gE=`ASCIINUMERICAL`,_E=`ALPHANUMERICAL`,vE=`LOCALHOST`,yE=`TLD`,bE=`UTLD`,xE=`SCHEME`,SE=`SLASH_SCHEME`,CE=`NUM`,wE=`WS`,TE=`NL`,EE=`OPENBRACE`,DE=`CLOSEBRACE`,OE=`OPENBRACKET`,kE=`CLOSEBRACKET`,AE=`OPENPAREN`,jE=`CLOSEPAREN`,ME=`OPENANGLEBRACKET`,NE=`CLOSEANGLEBRACKET`,PE=`FULLWIDTHLEFTPAREN`,FE=`FULLWIDTHRIGHTPAREN`,IE=`LEFTCORNERBRACKET`,LE=`RIGHTCORNERBRACKET`,RE=`LEFTWHITECORNERBRACKET`,zE=`RIGHTWHITECORNERBRACKET`,BE=`FULLWIDTHLESSTHAN`,VE=`FULLWIDTHGREATERTHAN`,HE=`AMPERSAND`,UE=`APOSTROPHE`,WE=`ASTERISK`,GE=`AT`,KE=`BACKSLASH`,qE=`BACKTICK`,JE=`CARET`,YE=`COLON`,XE=`COMMA`,ZE=`DOLLAR`,QE=`DOT`,$E=`EQUALS`,eD=`EXCLAMATION`,tD=`HYPHEN`,nD=`PERCENT`,rD=`PIPE`,iD=`PLUS`,aD=`POUND`,oD=`QUERY`,sD=`QUOTE`,cD=`FULLWIDTHMIDDLEDOT`,lD=`SEMI`,uD=`SLASH`,dD=`TILDE`,fD=`UNDERSCORE`,pD=`EMOJI`,mD=`SYM`,hD=Object.freeze({__proto__:null,ALPHANUMERICAL:_E,AMPERSAND:HE,APOSTROPHE:UE,ASCIINUMERICAL:gE,ASTERISK:WE,AT:GE,BACKSLASH:KE,BACKTICK:qE,CARET:JE,CLOSEANGLEBRACKET:NE,CLOSEBRACE:DE,CLOSEBRACKET:kE,CLOSEPAREN:jE,COLON:YE,COMMA:XE,DOLLAR:ZE,DOT:QE,EMOJI:pD,EQUALS:$E,EXCLAMATION:eD,FULLWIDTHGREATERTHAN:VE,FULLWIDTHLEFTPAREN:PE,FULLWIDTHLESSTHAN:BE,FULLWIDTHMIDDLEDOT:cD,FULLWIDTHRIGHTPAREN:FE,HYPHEN:tD,LEFTCORNERBRACKET:IE,LEFTWHITECORNERBRACKET:RE,LOCALHOST:vE,NL:TE,NUM:CE,OPENANGLEBRACKET:ME,OPENBRACE:EE,OPENBRACKET:OE,OPENPAREN:AE,PERCENT:nD,PIPE:rD,PLUS:iD,POUND:aD,QUERY:oD,QUOTE:sD,RIGHTCORNERBRACKET:LE,RIGHTWHITECORNERBRACKET:zE,SCHEME:xE,SEMI:lD,SLASH:uD,SLASH_SCHEME:SE,SYM:mD,TILDE:dD,TLD:yE,UNDERSCORE:fD,UTLD:bE,UWORD:hE,WORD:mE,WS:wE}),gD=/[a-z]/,_D=/[a-z]/i,vD=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{_D=RegExp(`\\p{L}`,`u`),vD=RegExp(`\\p{Emoji}`,`u`)}catch{}var yD=/\d/,bD=/\s/,xD=`\r`,SD=` -`,CD=`️`,wD=`‍`,TD=``,ED=null,DD=null;function OD(e=[]){let t={};dE.groups=t;let n=new dE;ED??=MD(XT),DD??=MD(ZT),F(n,`'`,UE),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,`>`,VE),F(n,`&`,HE),F(n,`*`,WE),F(n,`@`,GE),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,`?`,oD),F(n,`"`,sD),F(n,`/`,uD),F(n,`;`,lD),F(n,`~`,dD),F(n,`_`,fD),F(n,`\\`,KE),F(n,`・`,cD);let r=fE(n,yD,CE,{[QT]:!0});fE(r,yD,r);let i=fE(r,gD,gE,{[tE]:!0}),a=fE(r,_D,_E,{[nE]:!0}),o=fE(n,gD,mE,{[$T]:!0});fE(o,yD,i),fE(o,gD,o),fE(i,yD,i),fE(i,gD,i);let s=fE(n,_D,hE,{[eE]:!0});fE(s,gD),fE(s,yD,a),fE(s,_D,s),fE(a,yD,a),fE(a,gD),fE(a,_D,a);let c=F(n,SD,TE,{[sE]:!0}),l=F(n,xD,wE,{[sE]:!0}),u=fE(n,bD,wE,{[sE]:!0});F(n,TD,u),F(l,SD,c),F(l,TD,u),fE(l,bD,u),F(u,xD),F(u,SD),fE(u,bD,u),F(u,TD,u);let d=fE(n,vD,pD,{[iE]:!0});F(d,`#`),fE(d,vD,d),F(d,CD,d);let f=F(d,wD);F(f,`#`),fE(f,vD,d);let p=[[gD,o],[yD,i]],m=[[gD,null],[_D,s],[yD,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[rE]=!0:gD.test(r)?yD.test(r)?i[tE]=!0:i[$T]=!0:i[QT]=!0,pE(n,r,r,i)}return pE(n,`localhost`,vE,{ascii:!0}),n.jd=new dE(mD),{start:n,tokens:Object.assign({groups:t},hD)}}function kD(e,t){let n=AD(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 AD(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 jD(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 ND={defaultProtocol:`http`,events:null,format:FD,formatHref:FD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function PD(e,t=null){let n=Object.assign({},ND);e&&(n=Object.assign(n,e instanceof PD?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]:ND[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 FD(e){return e}function ID(e,t){this.t=`token`,this.v=e,this.tk=t}ID.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=ND.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 LD(e,t){class n extends ID{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 RD=LD(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),zD=LD(`text`),BD=LD(`nl`),VD=LD(`url`,{isLink:!0,toHref(e=ND.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==vE&&e[1].t===YE}}),HD=e=>new dE(e);function UD({groups:e}){let t=e.domain.concat([HE,WE,GE,KE,qE,JE,ZE,$E,tD,CE,nD,rD,iD,aD,uD,mD,dD,fD]),n=[UE,YE,XE,QE,eD,nD,oD,sD,lD,ME,NE,EE,DE,kE,OE,AE,jE,PE,FE,IE,LE,RE,zE,BE,VE],r=[HE,UE,WE,KE,qE,JE,ZE,$E,tD,EE,DE,nD,rD,iD,aD,oD,uD,mD,dD,fD],i=HD(),a=F(i,dD);P(a,r,a),P(a,e.domain,a);let o=HD(),s=HD(),c=HD();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,GE);F(a,GE,l),F(s,GE,l),F(c,GE,l);let u=F(a,QE);P(u,r,a),P(u,e.domain,a);let d=HD();P(l,e.domain,d),P(d,e.domain,d);let f=F(d,QE);P(f,e.domain,d);let p=HD(RD);P(f,e.tld,p),P(f,e.utld,p),F(l,vE,p);let m=F(d,tD);F(m,tD,m),P(m,e.domain,d),P(p,e.domain,d),F(p,QE,f),F(p,tD,m);let h=F(o,tD),g=F(o,QE);F(h,tD,h),P(h,e.domain,o),P(g,r,a),P(g,e.domain,o);let _=HD(VD);P(g,e.tld,_),P(g,e.utld,_),P(_,e.domain,o),P(_,r,a),F(_,QE,g),F(_,tD,h),F(_,GE,l);let v=F(_,YE),y=HD(VD);P(v,e.numeric,y);let b=HD(VD),x=HD();P(b,t,b),P(b,n,x),P(x,t,b),P(x,n,x),F(_,uD,b),F(y,uD,b),F(_,oD,x),F(_,aD,b),F(y,oD,x),F(y,aD,b);let S=F(s,YE),ee=F(F(F(c,YE),uD),uD);P(s,e.domain,o),F(s,QE,g),F(s,tD,h),P(c,e.domain,o),F(c,QE,g),F(c,tD,h),P(S,e.domain,b),F(S,uD,b),F(S,oD,b),P(ee,e.domain,b),P(ee,t,b),F(ee,uD,b);let te=[[EE,DE],[OE,kE],[AE,jE],[ME,NE],[PE,FE],[IE,LE],[RE,zE],[BE,VE]];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(GD(zD,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(GD(e,t,r))}}return o.length>0&&a.push(GD(zD,t,o)),a}function GD(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var KD=typeof console<`u`&&console&&console.warn||(()=>{}),qD=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,JD={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function YD(){return dE.groups={},JD.scanner=null,JD.parser=null,JD.tokenQueue=[],JD.pluginQueue=[],JD.customSchemes=[],JD.initialized=!1,JD}function XD(e,t=!1){if(JD.initialized&&KD(`linkifyjs: already initialized - will not register custom scheme "${e}" ${qD}`),!/^[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()}}}),KT=Jp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Wp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),qT=Jp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,A(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Df(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(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[Up({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),JT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,YT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,XT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ZT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,QT=_p.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hp({find:JT,type:this.type}),Hp({find:XT,type:this.type})]},addPasteRules(){return[Yp({find:YT,type:this.type}),Yp({find:ZT,type:this.type})]}}),$T=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,eE=`ελ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`,tE=`numeric`,nE=`ascii`,rE=`alpha`,iE=`asciinumeric`,aE=`alphanumeric`,oE=`domain`,sE=`emoji`,cE=`scheme`,lE=`slashscheme`,uE=`whitespace`;function dE(e,t){return e in t||(t[e]=[]),t[e]}function fE(e,t,n){t[tE]&&(t[iE]=!0,t[aE]=!0),t[nE]&&(t[iE]=!0,t[rE]=!0),t[iE]&&(t[aE]=!0),t[rE]&&(t[aE]=!0),t[aE]&&(t[oE]=!0),t[sE]&&(t[oE]=!0);for(let r in t){let t=dE(r,n);t.indexOf(e)<0&&t.push(e)}}function pE(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function mE(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}mE.groups={},mE.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),hE=(e,t,n,r,i)=>e.tr(t,n,r,i),gE=(e,t,n,r,i)=>e.ts(t,n,r,i),F=(e,t,n,r,i)=>e.tt(t,n,r,i),_E=`WORD`,vE=`UWORD`,yE=`ASCIINUMERICAL`,bE=`ALPHANUMERICAL`,xE=`LOCALHOST`,SE=`TLD`,CE=`UTLD`,wE=`SCHEME`,TE=`SLASH_SCHEME`,EE=`NUM`,DE=`WS`,OE=`NL`,kE=`OPENBRACE`,AE=`CLOSEBRACE`,jE=`OPENBRACKET`,ME=`CLOSEBRACKET`,NE=`OPENPAREN`,PE=`CLOSEPAREN`,FE=`OPENANGLEBRACKET`,IE=`CLOSEANGLEBRACKET`,LE=`FULLWIDTHLEFTPAREN`,RE=`FULLWIDTHRIGHTPAREN`,zE=`LEFTCORNERBRACKET`,BE=`RIGHTCORNERBRACKET`,VE=`LEFTWHITECORNERBRACKET`,HE=`RIGHTWHITECORNERBRACKET`,UE=`FULLWIDTHLESSTHAN`,WE=`FULLWIDTHGREATERTHAN`,GE=`AMPERSAND`,KE=`APOSTROPHE`,qE=`ASTERISK`,JE=`AT`,YE=`BACKSLASH`,XE=`BACKTICK`,ZE=`CARET`,QE=`COLON`,$E=`COMMA`,eD=`DOLLAR`,tD=`DOT`,nD=`EQUALS`,rD=`EXCLAMATION`,iD=`HYPHEN`,aD=`PERCENT`,oD=`PIPE`,sD=`PLUS`,cD=`POUND`,lD=`QUERY`,uD=`QUOTE`,dD=`FULLWIDTHMIDDLEDOT`,fD=`SEMI`,pD=`SLASH`,mD=`TILDE`,hD=`UNDERSCORE`,gD=`EMOJI`,_D=`SYM`,vD=Object.freeze({__proto__:null,ALPHANUMERICAL:bE,AMPERSAND:GE,APOSTROPHE:KE,ASCIINUMERICAL:yE,ASTERISK:qE,AT:JE,BACKSLASH:YE,BACKTICK:XE,CARET:ZE,CLOSEANGLEBRACKET:IE,CLOSEBRACE:AE,CLOSEBRACKET:ME,CLOSEPAREN:PE,COLON:QE,COMMA:$E,DOLLAR:eD,DOT:tD,EMOJI:gD,EQUALS:nD,EXCLAMATION:rD,FULLWIDTHGREATERTHAN:WE,FULLWIDTHLEFTPAREN:LE,FULLWIDTHLESSTHAN:UE,FULLWIDTHMIDDLEDOT:dD,FULLWIDTHRIGHTPAREN:RE,HYPHEN:iD,LEFTCORNERBRACKET:zE,LEFTWHITECORNERBRACKET:VE,LOCALHOST:xE,NL:OE,NUM:EE,OPENANGLEBRACKET:FE,OPENBRACE:kE,OPENBRACKET:jE,OPENPAREN:NE,PERCENT:aD,PIPE:oD,PLUS:sD,POUND:cD,QUERY:lD,QUOTE:uD,RIGHTCORNERBRACKET:BE,RIGHTWHITECORNERBRACKET:HE,SCHEME:wE,SEMI:fD,SLASH:pD,SLASH_SCHEME:TE,SYM:_D,TILDE:mD,TLD:SE,UNDERSCORE:hD,UTLD:CE,UWORD:vE,WORD:_E,WS:DE}),yD=/[a-z]/,bD=/[a-z]/i,xD=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{bD=RegExp(`\\p{L}`,`u`),xD=RegExp(`\\p{Emoji}`,`u`)}catch{}var SD=/\d/,CD=/\s/,wD=`\r`,TD=` +`,ED=`️`,DD=`‍`,OD=``,kD=null,AD=null;function jD(e=[]){let t={};mE.groups=t;let n=new mE;kD??=FD($T),AD??=FD(eE),F(n,`'`,KE),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,`『`,VE),F(n,`』`,HE),F(n,`<`,UE),F(n,`>`,WE),F(n,`&`,GE),F(n,`*`,qE),F(n,`@`,JE),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,`|`,oD),F(n,`+`,sD),F(n,`#`,cD),F(n,`?`,lD),F(n,`"`,uD),F(n,`/`,pD),F(n,`;`,fD),F(n,`~`,mD),F(n,`_`,hD),F(n,`\\`,YE),F(n,`・`,dD);let r=hE(n,SD,EE,{[tE]:!0});hE(r,SD,r);let i=hE(r,yD,yE,{[iE]:!0}),a=hE(r,bD,bE,{[aE]:!0}),o=hE(n,yD,_E,{[nE]:!0});hE(o,SD,i),hE(o,yD,o),hE(i,SD,i),hE(i,yD,i);let s=hE(n,bD,vE,{[rE]:!0});hE(s,yD),hE(s,SD,a),hE(s,bD,s),hE(a,SD,a),hE(a,yD),hE(a,bD,a);let c=F(n,TD,OE,{[uE]:!0}),l=F(n,wD,DE,{[uE]:!0}),u=hE(n,CD,DE,{[uE]:!0});F(n,OD,u),F(l,TD,c),F(l,OD,u),hE(l,CD,u),F(u,wD),F(u,TD),hE(u,CD,u),F(u,OD,u);let d=hE(n,xD,gD,{[sE]:!0});F(d,`#`),hE(d,xD,d),F(d,ED,d);let f=F(d,DD);F(f,`#`),hE(f,xD,d);let p=[[yD,o],[SD,i]],m=[[yD,null],[bD,s],[SD,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[oE]=!0:yD.test(r)?SD.test(r)?i[iE]=!0:i[nE]=!0:i[tE]=!0,gE(n,r,r,i)}return gE(n,`localhost`,xE,{ascii:!0}),n.jd=new mE(_D),{start:n,tokens:Object.assign({groups:t},vD)}}function MD(e,t){let n=ND(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 ND(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 PD(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 ID={defaultProtocol:`http`,events:null,format:RD,formatHref:RD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function LD(e,t=null){let n=Object.assign({},ID);e&&(n=Object.assign(n,e instanceof LD?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]:ID[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 RD(e){return e}function zD(e,t){this.t=`token`,this.v=e,this.tk=t}zD.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=ID.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 BD(e,t){class n extends zD{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 VD=BD(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),HD=BD(`text`),UD=BD(`nl`),WD=BD(`url`,{isLink:!0,toHref(e=ID.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==xE&&e[1].t===QE}}),GD=e=>new mE(e);function KD({groups:e}){let t=e.domain.concat([GE,qE,JE,YE,XE,ZE,eD,nD,iD,EE,aD,oD,sD,cD,pD,_D,mD,hD]),n=[KE,QE,$E,tD,rD,aD,lD,uD,fD,FE,IE,kE,AE,ME,jE,NE,PE,LE,RE,zE,BE,VE,HE,UE,WE],r=[GE,KE,qE,YE,XE,ZE,eD,nD,iD,kE,AE,aD,oD,sD,cD,lD,pD,_D,mD,hD],i=GD(),a=F(i,mD);P(a,r,a),P(a,e.domain,a);let o=GD(),s=GD(),c=GD();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,JE);F(a,JE,l),F(s,JE,l),F(c,JE,l);let u=F(a,tD);P(u,r,a),P(u,e.domain,a);let d=GD();P(l,e.domain,d),P(d,e.domain,d);let f=F(d,tD);P(f,e.domain,d);let p=GD(VD);P(f,e.tld,p),P(f,e.utld,p),F(l,xE,p);let m=F(d,iD);F(m,iD,m),P(m,e.domain,d),P(p,e.domain,d),F(p,tD,f),F(p,iD,m);let h=F(o,iD),g=F(o,tD);F(h,iD,h),P(h,e.domain,o),P(g,r,a),P(g,e.domain,o);let _=GD(WD);P(g,e.tld,_),P(g,e.utld,_),P(_,e.domain,o),P(_,r,a),F(_,tD,g),F(_,iD,h),F(_,JE,l);let v=F(_,QE),y=GD(WD);P(v,e.numeric,y);let b=GD(WD),x=GD();P(b,t,b),P(b,n,x),P(x,t,b),P(x,n,x),F(_,pD,b),F(y,pD,b),F(_,lD,x),F(_,cD,b),F(y,lD,x),F(y,cD,b);let S=F(s,QE),ee=F(F(F(c,QE),pD),pD);P(s,e.domain,o),F(s,tD,g),F(s,iD,h),P(c,e.domain,o),F(c,tD,g),F(c,iD,h),P(S,e.domain,b),F(S,pD,b),F(S,lD,b),P(ee,e.domain,b),P(ee,t,b),F(ee,pD,b);let te=[[kE,AE],[jE,ME],[NE,PE],[FE,IE],[LE,RE],[zE,BE],[VE,HE],[UE,WE]];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(JD(HD,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(JD(e,t,r))}}return o.length>0&&a.push(JD(HD,t,o)),a}function JD(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var YD=typeof console<`u`&&console&&console.warn||(()=>{}),XD=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,ZD={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function QD(){return mE.groups={},ZD.scanner=null,ZD.parser=null,ZD.tokenQueue=[],ZD.pluginQueue=[],ZD.customSchemes=[],ZD.initialized=!1,ZD}function $D(e,t=!1){if(ZD.initialized&&YD(`linkifyjs: already initialized - will not register custom scheme "${e}" ${XD}`),!/^[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`);JD.customSchemes.push([e,t])}function ZD(){JD.scanner=OD(JD.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 oO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function sO(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=>aO(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(!nO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(tO).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=QD(n).map(t=>t.toObject(e.defaultProtocol));if(!oO(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 cO(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 lO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,uO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function dO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function fO(e,t){let n=0,r=0;for(;r0}function pO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||dO(e,t.index??0)||fO(e,t.index??0)?!1:!!r.trim()&&n(i)}function mO(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 hO(e,t){return e.index{let n=lO.exec(t);return!n||!pO(t,n,e.isAllowedHref)?null:mO(n)},type:e.type,getAttributes:gO});return new lp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function vO(e){let t=Yp({find:t=>{let n=[];for(let r of t.matchAll(uO))pO(t,r,e.isAllowedHref)&&n.push(mO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>hO(t,e)));return[...n,...r]},type:e.type,getAttributes:gO});return new vp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function yO(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=$D(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 bO(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(iO,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var xO=_p.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`?XD(e):XD(e.scheme,e.optionalSlashes)})},onDestroy(){YD()},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)=>!!bO(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=>!!bO(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=>!!bO(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=>!!bO(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=>!!bO(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?[_O({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!bO(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;$D(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!bO(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?[vO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!bO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Yp({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(sO({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!bO(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(cO({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(yO({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),SO=`listItem`,CO=`textStyle`,wO=/^\s*([-+*])\s$/,TO=Jp.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(SO,this.editor.getAttributes(CO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Gp({find:wO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Gp({find:wO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(CO),editor:this.editor})),[e]}}),EO=(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}},DO=(e,t,n,r)=>{let i=EO(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},OO=(e,t,n)=>DO(e.state,e.view.dispatch,t,n),kO=(e,t)=>Tp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>OO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),AO=[[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`]],jO=`abcdefghijklmnopqrstuvwxyz`,MO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function NO(e){let t=e,n=``;for(let[e,r]of AO)for(;t>=e;)n+=r,t-=e;return n}function PO(e){return NO(e).toUpperCase()}function FO(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 VO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return RO(t);case`A`:return RO(t).toUpperCase();case`i`:return NO(t);case`I`:return PO(t);default:return String(t)}}function HO(e){if(e.length===0)return!1;let t=zO(e[0])??`numeric`,n=BO(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??YO)>YO;function ZO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function QO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var $O=Jp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(ZO(e))return{type:`listItem`,content:[{type:`paragraph`,content:QO(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:KO(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 GO((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=op(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!qO(e)||!XO(n))return i;let a=r(n);return`${a}${JO}${i.slice(a.length)}`},addExtensions(){return[kO(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)}}}),ek=(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}},tk=(e,t)=>{let n=ek(e,t);if(!n)return!1;let[,r]=td(t,e,n.$pos.pos+4);return r},nk=(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))},rk=(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)&&nk(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()},ik=(e,t)=>{let n=tk(e,t),r=ek(e,t);return!r||!n?!1:n>r.depth},ak=(e,t)=>{let n=tk(e,t),r=ek(e,t);return!r||!n?!1:n!Zl(e.state,t)||!cd(e.state,t)||!e.state.selection.empty?!1:ik(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():ak(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Jn(e,t)):e.commands.joinItemForward(),sk=(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))},ck=Tp.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&&ok(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&&ok(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&&rk(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&&rk(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&&sk(e,t,n))return!0;return!1}}}}),lk=RegExp(`^(\\s*)(${MO})([.)])\\s+(.*)$`),uk=/^\s/,dk={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function fk(e){return lk.test(e.trimStart())}function pk(e){let t=e.trimStart();return dk.bulletItem.test(t)||fk(t)||dk.heading.test(t)||dk.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||dk.codeFence.test(t)||dk.blockMath.test(t)}function mk(e){return Object.values(dk).some(t=>t.test(e))}function hk(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&pk(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function gk(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 lO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function uO(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=>cO(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(!aO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(iO).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=tO(n).map(t=>t.toObject(e.defaultProtocol));if(!lO(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 dO(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 fO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,pO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function mO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function hO(e,t){let n=0,r=0;for(;r0}function gO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||mO(e,t.index??0)||hO(e,t.index??0)?!1:!!r.trim()&&n(i)}function _O(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 vO(e,t){return e.index{let n=fO.exec(t);return!n||!gO(t,n,e.isAllowedHref)?null:_O(n)},type:e.type,getAttributes:yO});return new lp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function xO(e){let t=Yp({find:t=>{let n=[];for(let r of t.matchAll(pO))gO(t,r,e.isAllowedHref)&&n.push(_O(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>vO(t,e)));return[...n,...r]},type:e.type,getAttributes:yO});return new vp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function SO(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=nO(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 CO(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(sO,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var wO=_p.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`?$D(e):$D(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)=>!!CO(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=>!!CO(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=>!!CO(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=>!!CO(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=>!!CO(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?[bO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!CO(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;nO(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!CO(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?[xO({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!CO(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Yp({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(uO({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!CO(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(dO({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(SO({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),TO=`listItem`,EO=`textStyle`,DO=/^\s*([-+*])\s$/,OO=Jp.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(TO,this.editor.getAttributes(EO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Gp({find:DO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Gp({find:DO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(EO),editor:this.editor})),[e]}}),kO=(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}},AO=(e,t,n,r)=>{let i=kO(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},jO=(e,t,n)=>AO(e.state,e.view.dispatch,t,n),MO=(e,t)=>Tp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>jO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),NO=[[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`]],PO=`abcdefghijklmnopqrstuvwxyz`,FO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function IO(e){let t=e,n=``;for(let[e,r]of NO)for(;t>=e;)n+=r,t-=e;return n}function LO(e){return IO(e).toUpperCase()}function RO(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 WO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return VO(t);case`A`:return VO(t).toUpperCase();case`i`:return IO(t);case`I`:return LO(t);default:return String(t)}}function GO(e){if(e.length===0)return!1;let t=HO(e[0])??`numeric`,n=UO(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??QO)>QO;function ek(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function tk(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var nk=Jp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(ek(e))return{type:`listItem`,content:[{type:`paragraph`,content:tk(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:YO(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 JO((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=op(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!XO(e)||!$O(n))return i;let a=r(n);return`${a}${ZO}${i.slice(a.length)}`},addExtensions(){return[MO(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)}}}),rk=(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}},ik=(e,t)=>{let n=rk(e,t);if(!n)return!1;let[,r]=td(t,e,n.$pos.pos+4);return r},ak=(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))},ok=(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)&&ak(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()},sk=(e,t)=>{let n=ik(e,t),r=rk(e,t);return!r||!n?!1:n>r.depth},ck=(e,t)=>{let n=ik(e,t),r=rk(e,t);return!r||!n?!1:n!Zl(e.state,t)||!cd(e.state,t)||!e.state.selection.empty?!1:sk(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():ck(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Jn(e,t)):e.commands.joinItemForward(),uk=(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))},dk=Tp.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&&lk(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&&lk(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&&ok(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&&ok(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&&uk(e,t,n))return!0;return!1}}}}),fk=RegExp(`^(\\s*)(${FO})([.)])\\s+(.*)$`),pk=/^\s/,mk={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function hk(e){return fk.test(e.trimStart())}function gk(e){let t=e.trimStart();return mk.bulletItem.test(t)||hk(t)||mk.heading.test(t)||mk.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||mk.codeFence.test(t)||mk.blockMath.test(t)}function _k(e){return Object.values(mk).some(t=>t.test(e))}function vk(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&gk(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function yk(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(_k);if(!t)return null;n.push({marker:t[1],content:t[3]})}return HO(n.map(e=>e.marker))?{type:`orderedList`,attrs:WO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function yk(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(bk);if(!t)return null;n.push({marker:t[1],content:t[3]})}return GO(n.map(e=>e.marker))?{type:`orderedList`,attrs:qO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Sk(e,t,n){let r=[],i=0;for(;it;)f.push(e[d]),d+=1;if(f.length>0){let e=yk(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 bk(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 xk=64;function Sk(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=Dk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Dk(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?bk(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]=Ck(e);if(r.length===0)return;let o=yk(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(wk,this.editor.getAttributes(Tk)).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=vk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Gp({find:Ek,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:Ek,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Tk)}),joinPredicate:e,editor:this.editor})),[t]}}),kk=/^\s*(\[([( |x])?\])\s$/,Ak=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,jk=(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`}`},Mk=Jp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>op(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[kO(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=Ak;let l=e=>{let t=jk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Gp({find:kk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Nk=Jp.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=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(TO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push($O.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ck.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ok.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Mk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Nk.configure(this.options.taskList)),e}});var Pk=` `,Fk=`\xA0`,Ik=Jp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Pk||n[0].text===Pk||n[0].raw===Fk||n[0].text===Fk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Pk||r[0].text===Fk)?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?Pk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Lk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Rk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,zk=_p.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hp({find:Lk,type:this.type})]},addPasteRules(){return[Yp({find:Rk,type:this.type})]}}),Bk=Jp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Vk=_p.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${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()}}}),Hk=Tp.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(jT.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(ET.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(TO.configure(this.options.bulletList)),this.options.code!==!1&&e.push(FT.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(zT.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(VT.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Ww.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Gw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(HT.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(UT.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(gT.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(WT.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(YT.configure(this.options.italic)),this.options.listItem!==!1&&e.push($O.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ck.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(xO.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Ok.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Ik.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(zk.configure(this.options.strike)),this.options.text!==!1&&e.push(Bk.configure(this.options.text)),this.options.underline!==!1&&e.push(Vk.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(hT.configure(this.options?.trailingNode)),e}}),Uk=Math.min,Wk=Math.max,Gk=Math.round,Kk=Math.floor,qk=e=>({x:e,y:e}),Jk={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Yk(e,t,n){return Wk(e,Uk(t,n))}function Xk(e,t){return typeof e==`function`?e(t):e}function Zk(e){return e.split(`-`)[0]}function Qk(e){return e.split(`-`)[1]}function $k(e){return e===`x`?`y`:`x`}function eA(e){return e===`y`?`height`:`width`}function tA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function nA(e){return $k(tA(e))}function rA(e,t,n){n===void 0&&(n=!1);let r=Qk(e),i=nA(e),a=eA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=fA(o)),[o,fA(o)]}function iA(e){let t=fA(e);return[aA(e),t,aA(t)]}function aA(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var oA=[`left`,`right`],sA=[`right`,`left`],cA=[`top`,`bottom`],lA=[`bottom`,`top`];function uA(e,t,n){switch(e){case`top`:case`bottom`:return n?t?sA:oA:t?oA:sA;case`left`:case`right`:return t?cA:lA;default:return[]}}function dA(e,t,n,r){let i=Qk(e),a=uA(Zk(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(aA)))),a}function fA(e){let t=Zk(e);return Jk[t]+e.slice(t.length)}function pA(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function mA(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:pA(e)}function hA(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 gA(e,t,n){let{reference:r,floating:i}=e,a=tA(t),o=nA(t),s=eA(o),c=Zk(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=Qk(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function _A(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}=Xk(t,e),p=mA(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=hA(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=hA(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 vA=50,yA=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_A},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gA(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`||_===tA(t)||ne.every(e=>tA(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=tA(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{}}}},xA=new Set([`left`,`top`]);async function SA(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Zk(n),s=Qk(n),c=tA(n)===`y`,l=xA.has(o)?-1:1,u=a&&c?-1:1,d=Xk(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 CA=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 SA(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}=Xk(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=tA(i),p=$k(f),m=u[p],h=u[f],g=(e,t)=>Yk(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 TA(){return typeof window<`u`}function EA(e){return kA(e)?(e.nodeName||``).toLowerCase():`#document`}function DA(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function OA(e){return((kA(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function kA(e){return TA()?e instanceof Node||e instanceof DA(e).Node:!1}function AA(e){return TA()?e instanceof Element||e instanceof DA(e).Element:!1}function jA(e){return TA()?e instanceof HTMLElement||e instanceof DA(e).HTMLElement:!1}function MA(e){return!TA()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof DA(e).ShadowRoot}function NA(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=WA(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function PA(e){return/^(table|td|th)$/.test(EA(e))}function FA(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var IA=/transform|translate|scale|rotate|perspective|filter/,LA=/paint|layout|strict|content/,RA=e=>!!e&&e!==`none`,zA;function BA(e){let t=AA(e)?WA(e):e;return RA(t.transform)||RA(t.translate)||RA(t.scale)||RA(t.rotate)||RA(t.perspective)||!HA()&&(RA(t.backdropFilter)||RA(t.filter))||IA.test(t.willChange||``)||LA.test(t.contain||``)}function VA(e){let t=KA(e);for(;jA(t)&&!UA(t);){if(BA(t))return t;if(FA(t))return null;t=KA(t)}return null}function HA(){return zA??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),zA}function UA(e){return/^(html|body|#document)$/.test(EA(e))}function WA(e){return DA(e).getComputedStyle(e)}function GA(e){return AA(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function KA(e){if(EA(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||MA(e)&&e.host||OA(e);return MA(t)?t.host:t}function qA(e){let t=KA(e);return UA(t)?(e.ownerDocument||e).body:jA(t)&&NA(t)?t:qA(t)}function JA(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=qA(e),i=r===e.ownerDocument?.body,a=DA(r);if(i){let e=YA(a);return t.concat(a,a.visualViewport||[],NA(r)?r:[],e&&n?JA(e):[])}return t.concat(r,JA(r,[],n))}function YA(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function XA(e){let t=WA(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=jA(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Gk(n)!==a||Gk(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ZA(e){return AA(e)?e:e.contextElement}function QA(e){let t=ZA(e);if(!jA(t))return qk(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=XA(t),o=(a?Gk(n.width):n.width)/r,s=(a?Gk(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var $A=qk(0);function ej(e){let t=DA(e);return!HA()||!t.visualViewport?$A:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function tj(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===DA(e)}function nj(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ZA(e),o=qk(1);t&&(r?AA(r)&&(o=QA(r)):o=QA(e));let s=tj(a,n,r)?ej(a):qk(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=DA(a),t=AA(r)?DA(r):r,n=e,i=YA(n);for(;i&&t!==n;){let e=QA(i),t=i.getBoundingClientRect(),r=WA(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=DA(i),i=YA(n)}}return hA({width:u,height:d,x:c,y:l})}function rj(e,t){let n=GA(e).scrollLeft;return t?t.left+n:nj(OA(e)).left+n}function ij(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-rj(e,n),y:n.top+t.scrollTop}}function aj(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=OA(r),s=t?FA(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qk(1),u=qk(0),d=jA(r);if((d||!a)&&((EA(r)!==`body`||NA(o))&&(c=GA(r)),d)){let e=nj(r);l=QA(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ij(o,c):qk(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 oj(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function sj(e){let t=GA(e),n=e.ownerDocument.body,r=Wk(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Wk(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+rj(e),o=-t.scrollTop;return WA(n).direction===`rtl`&&(a+=Wk(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var cj=25;function lj(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=DA(e),a=OA(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!HA()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(rj(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<=cj&&(s-=o)}return{width:s,height:c,x:l,y:u}}function uj(e,t){let n=nj(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=QA(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function dj(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=lj(e,n,t);else if(t===`document`)r=sj(OA(e));else if(AA(t))r=uj(t,n);else{let n=ej(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return hA(r)}function fj(e,t){let n=t.get(e);if(n)return n;let r=JA(e,[],!1).filter(e=>AA(e)&&EA(e)!==`body`),i=null,a=WA(e).position===`fixed`,o=a?KA(e):e;for(;AA(o)&&!UA(o);){let e=WA(o),t=BA(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=KA(o)}return t.set(e,r),r}function pj(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?FA(t)?[]:fj(t,this._c):[].concat(n),r],o=dj(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=DA(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=ZA(e),u=i||a?[...l?JA(l):[],...t?JA(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Cj(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?nj(e):null;c&&g();function g(){let t=nj(e);h&&!Sj(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 Tj=CA,Ej=wA,Dj=bA,Oj=(e,t,n)=>{let r=new Map,i=n??{},a={...xj,...i.platform,_c:r};return yA(e,t,{...i,platform:a})};function kj(e,t){return typeof e==`boolean`?e:t}var Aj=BT.extend({addOptions(){return{...this.parent(),lineNumbers:!1}},addAttributes(){return{...this.parent?.(),lineNumbers:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-line-numbers`);return t===`true`||t!==`false`&&null},renderHTML:e=>typeof e.lineNumbers==`boolean`?{"data-line-numbers":String(e.lineNumbers)}:{}}}},addCommands(){return{...this.parent?.(),toggleCodeLineNumbers:()=>({editor:e,commands:t})=>{if(!e.isActive(this.name))return!1;let n=kj(e.getAttributes(this.name).lineNumbers,this.options.lineNumbers);return t.updateAttributes(this.name,{lineNumbers:!n})}}},addNodeView(){let e=this.options.lineNumbers,t=this.options.languageClassPrefix??`language-`;return({node:n})=>{let r=document.createElement(`pre`);r.className=`dw-code`;let i=document.createElement(`div`);i.className=`dw-code__gutter`,i.contentEditable=`false`,i.setAttribute(`aria-hidden`,`true`);let a=document.createElement(`code`);r.append(i,a);let o=-1,s=n=>{let s=kj(n.attrs.lineNumbers,e);r.classList.toggle(`dw-code--numbered`,s),a.className=n.attrs.language?`${t}${String(n.attrs.language)}`:``;let c=s?n.textContent.split(` +`).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=Sk(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 Ck(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 wk=64;function Tk(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=Ak(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Ak(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?Ck(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]=Ek(e);if(r.length===0)return;let o=Sk(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(Dk,this.editor.getAttributes(Ok)).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=xk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Gp({find:kk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:kk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ok)}),joinPredicate:e,editor:this.editor})),[t]}}),Mk=/^\s*(\[([( |x])?\])\s$/,Nk=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Pk=(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`}`},Fk=Jp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>op(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[MO(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=Nk;let l=e=>{let t=Pk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Gp({find:Mk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Ik=Jp.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=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(OO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(nk.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(dk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(jk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Fk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Ik.configure(this.options.taskList)),e}});var Lk=` `,Rk=`\xA0`,zk=Jp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Lk||n[0].text===Lk||n[0].raw===Rk||n[0].text===Rk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Lk||r[0].text===Rk)?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?Lk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Bk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Vk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hk=_p.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hp({find:Bk,type:this.type})]},addPasteRules(){return[Yp({find:Vk,type:this.type})]}}),Uk=Jp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Wk=_p.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${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()}}}),Gk=Tp.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(PT.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(kT.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(OO.configure(this.options.bulletList)),this.options.code!==!1&&e.push(RT.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(HT.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(WT.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(qw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Jw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(GT.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(KT.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(yT.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(qT.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(QT.configure(this.options.italic)),this.options.listItem!==!1&&e.push(nk.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(dk.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(wO.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(jk.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(zk.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Hk.configure(this.options.strike)),this.options.text!==!1&&e.push(Uk.configure(this.options.text)),this.options.underline!==!1&&e.push(Wk.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(vT.configure(this.options?.trailingNode)),e}}),Kk=Math.min,qk=Math.max,Jk=Math.round,Yk=Math.floor,Xk=e=>({x:e,y:e}),Zk={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Qk(e,t,n){return qk(e,Kk(t,n))}function $k(e,t){return typeof e==`function`?e(t):e}function eA(e){return e.split(`-`)[0]}function tA(e){return e.split(`-`)[1]}function nA(e){return e===`x`?`y`:`x`}function rA(e){return e===`y`?`height`:`width`}function iA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function aA(e){return nA(iA(e))}function oA(e,t,n){n===void 0&&(n=!1);let r=tA(e),i=aA(e),a=rA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=hA(o)),[o,hA(o)]}function sA(e){let t=hA(e);return[cA(e),t,cA(t)]}function cA(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var lA=[`left`,`right`],uA=[`right`,`left`],dA=[`top`,`bottom`],fA=[`bottom`,`top`];function pA(e,t,n){switch(e){case`top`:case`bottom`:return n?t?uA:lA:t?lA:uA;case`left`:case`right`:return t?dA:fA;default:return[]}}function mA(e,t,n,r){let i=tA(e),a=pA(eA(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(cA)))),a}function hA(e){let t=eA(e);return Zk[t]+e.slice(t.length)}function gA(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function _A(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:gA(e)}function vA(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 yA(e,t,n){let{reference:r,floating:i}=e,a=iA(t),o=aA(t),s=rA(o),c=eA(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=tA(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function bA(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}=$k(t,e),p=_A(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=vA(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=vA(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 xA=50,SA=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:bA},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=yA(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`||_===iA(t)||ne.every(e=>iA(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=iA(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{}}}},wA=new Set([`left`,`top`]);async function TA(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=eA(n),s=tA(n),c=iA(n)===`y`,l=wA.has(o)?-1:1,u=a&&c?-1:1,d=$k(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 EA=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 TA(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}}}}},DA=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}=$k(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=iA(i),p=nA(f),m=u[p],h=u[f],g=(e,t)=>Qk(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 OA(){return typeof window<`u`}function kA(e){return MA(e)?(e.nodeName||``).toLowerCase():`#document`}function AA(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jA(e){return((MA(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function MA(e){return OA()?e instanceof Node||e instanceof AA(e).Node:!1}function NA(e){return OA()?e instanceof Element||e instanceof AA(e).Element:!1}function PA(e){return OA()?e instanceof HTMLElement||e instanceof AA(e).HTMLElement:!1}function FA(e){return!OA()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof AA(e).ShadowRoot}function IA(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=qA(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function LA(e){return/^(table|td|th)$/.test(kA(e))}function RA(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var zA=/transform|translate|scale|rotate|perspective|filter/,BA=/paint|layout|strict|content/,VA=e=>!!e&&e!==`none`,HA;function UA(e){let t=NA(e)?qA(e):e;return VA(t.transform)||VA(t.translate)||VA(t.scale)||VA(t.rotate)||VA(t.perspective)||!GA()&&(VA(t.backdropFilter)||VA(t.filter))||zA.test(t.willChange||``)||BA.test(t.contain||``)}function WA(e){let t=YA(e);for(;PA(t)&&!KA(t);){if(UA(t))return t;if(RA(t))return null;t=YA(t)}return null}function GA(){return HA??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),HA}function KA(e){return/^(html|body|#document)$/.test(kA(e))}function qA(e){return AA(e).getComputedStyle(e)}function JA(e){return NA(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function YA(e){if(kA(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||FA(e)&&e.host||jA(e);return FA(t)?t.host:t}function XA(e){let t=YA(e);return KA(t)?(e.ownerDocument||e).body:PA(t)&&IA(t)?t:XA(t)}function ZA(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=XA(e),i=r===e.ownerDocument?.body,a=AA(r);if(i){let e=QA(a);return t.concat(a,a.visualViewport||[],IA(r)?r:[],e&&n?ZA(e):[])}return t.concat(r,ZA(r,[],n))}function QA(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $A(e){let t=qA(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=PA(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Jk(n)!==a||Jk(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ej(e){return NA(e)?e:e.contextElement}function tj(e){let t=ej(e);if(!PA(t))return Xk(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=$A(t),o=(a?Jk(n.width):n.width)/r,s=(a?Jk(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var nj=Xk(0);function rj(e){let t=AA(e);return!GA()||!t.visualViewport?nj:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ij(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===AA(e)}function aj(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ej(e),o=Xk(1);t&&(r?NA(r)&&(o=tj(r)):o=tj(e));let s=ij(a,n,r)?rj(a):Xk(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=AA(a),t=NA(r)?AA(r):r,n=e,i=QA(n);for(;i&&t!==n;){let e=tj(i),t=i.getBoundingClientRect(),r=qA(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=AA(i),i=QA(n)}}return vA({width:u,height:d,x:c,y:l})}function oj(e,t){let n=JA(e).scrollLeft;return t?t.left+n:aj(jA(e)).left+n}function sj(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-oj(e,n),y:n.top+t.scrollTop}}function cj(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jA(r),s=t?RA(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Xk(1),u=Xk(0),d=PA(r);if((d||!a)&&((kA(r)!==`body`||IA(o))&&(c=JA(r)),d)){let e=aj(r);l=tj(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?sj(o,c):Xk(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 lj(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function uj(e){let t=JA(e),n=e.ownerDocument.body,r=qk(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=qk(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+oj(e),o=-t.scrollTop;return qA(n).direction===`rtl`&&(a+=qk(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var dj=25;function fj(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=AA(e),a=jA(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!GA()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(oj(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<=dj&&(s-=o)}return{width:s,height:c,x:l,y:u}}function pj(e,t){let n=aj(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=tj(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function mj(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=fj(e,n,t);else if(t===`document`)r=uj(jA(e));else if(NA(t))r=pj(t,n);else{let n=rj(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return vA(r)}function hj(e,t){let n=t.get(e);if(n)return n;let r=ZA(e,[],!1).filter(e=>NA(e)&&kA(e)!==`body`),i=null,a=qA(e).position===`fixed`,o=a?YA(e):e;for(;NA(o)&&!KA(o);){let e=qA(o),t=UA(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=YA(o)}return t.set(e,r),r}function gj(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?RA(t)?[]:hj(t,this._c):[].concat(n),r],o=mj(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=AA(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Dj(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=ej(e),u=i||a?[...l?ZA(l):[],...t?ZA(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ej(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?aj(e):null;c&&g();function g(){let t=aj(e);h&&!Tj(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 Oj=EA,kj=DA,Aj=CA,jj=(e,t,n)=>{let r=new Map,i=n??{},a={...wj,...i.platform,_c:r};return SA(e,t,{...i,platform:a})};function Mj(e,t){return typeof e==`boolean`?e:t}var Nj=UT.extend({addOptions(){return{...this.parent(),lineNumbers:!1}},addAttributes(){return{...this.parent?.(),lineNumbers:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-line-numbers`);return t===`true`||t!==`false`&&null},renderHTML:e=>typeof e.lineNumbers==`boolean`?{"data-line-numbers":String(e.lineNumbers)}:{}}}},addCommands(){return{...this.parent?.(),toggleCodeLineNumbers:()=>({editor:e,commands:t})=>{if(!e.isActive(this.name))return!1;let n=Mj(e.getAttributes(this.name).lineNumbers,this.options.lineNumbers);return t.updateAttributes(this.name,{lineNumbers:!n})}}},addNodeView(){let e=this.options.lineNumbers,t=this.options.languageClassPrefix??`language-`;return({node:n})=>{let r=document.createElement(`pre`);r.className=`dw-code`;let i=document.createElement(`div`);i.className=`dw-code__gutter`,i.contentEditable=`false`,i.setAttribute(`aria-hidden`,`true`);let a=document.createElement(`code`);r.append(i,a);let o=-1,s=n=>{let s=Mj(n.attrs.lineNumbers,e);r.classList.toggle(`dw-code--numbered`,s),a.className=n.attrs.language?`${t}${String(n.attrs.language)}`:``;let c=s?n.textContent.split(` `).length:0;c!==o&&(o=c,i.textContent=Array.from({length:c},(e,t)=>t+1).join(` -`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),jj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function Mj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Nj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 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`],pin:[`M9 4h6`,`M10 4v6l-3 4h10l-3-4V4`,`M12 14v6`],width:[`M3 12h18`,`M7 8l-4 4 4 4`,`M17 8l4 4-4 4`],type:[`M5 7V5h14v2`,`M12 5v14`,`M9 19h6`],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`],"align-left":[`M4 6h16`,`M4 10h10`,`M4 14h16`,`M4 18h10`],"align-center":[`M4 6h16`,`M7 10h10`,`M4 14h16`,`M7 18h10`],"align-right":[`M4 6h16`,`M10 10h10`,`M4 14h16`,`M10 18h10`],grip:[`M9 6h.01`,`M15 6h.01`,`M9 12h.01`,`M15 12h.01`,`M9 18h.01`,`M15 18h.01`],copy:[`M9 9h11v11H9z`,`M5 15H4V4h11v1`],"arrow-up":[`M12 19V5`,`M6 11l6-6 6 6`],"arrow-down":[`M12 5v14`,`M6 13l6 6 6-6`],callout:[`M4 5h16v14H4z`,`M8 10h.01`,`M11 10h5`,`M8 14h8`],palette:[`M12 3a9 9 0 1 0 0 18c1 0 1.5-.7 1.5-1.5 0-1.2-1-1.5-1-2.5s.8-1.5 2-1.5H17a4 4 0 0 0 4-4c0-4.7-4-8.5-9-8.5z`,`M7.5 11h.01`,`M10 7.5h.01`,`M14.5 7.5h.01`],"page-plus":[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M12 11v6`,`M9 14h6`],tag:[`M4 4h7l9 9-7 7-9-9z`,`M8 8h.01`],grid:[`M4 4h7v7H4z`,`M13 4h7v7h-7z`,`M4 13h7v7H4z`,`M13 13h7v7h-7z`],cards:[`M4 5h16v6H4z`,`M4 15h16v4H4z`],filter:[`M4 5h16l-6 8v6l-4-2v-4z`],layers:[`M12 4l8 4-8 4-8-4z`,`M4 12l8 4 8-4`,`M4 16l8 4 8-4`],journal:[`M6 3h11a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6z`,`M9 3v18`,`M12 8h3`,`M12 12h3`],sliders:[`M5 6h14`,`M5 12h14`,`M5 18h14`,`M9 4v4`,`M15 10v4`,`M11 16v4`]},Pj=`http://www.w3.org/2000/svg`;function Fj(e,t=18){let n=document.createElementNS(Pj,`svg`);for(let[e,r]of Object.entries({width:String(t),height:String(t),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))n.setAttribute(e,r);for(let t of Nj[e]){let e=document.createElementNS(Pj,`path`);e.setAttribute(`d`,t),n.append(e)}return n}function Ij(e){return()=>{let t=null,n=null,r=null,i=0,a=null,o=()=>a?.items??r?.items??[],s=t=>{let n=o()[t];if(!r||n===void 0)return;let s=e.children?.(n);s?.length?(a={parent:n,items:s},i=0,c()):e.pick(r,n)},c=()=>{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(a){let n=document.createElement(`div`);n.className=`dw-suggest__query`,n.textContent=`‹ ${e.toItem(a.parent).label}`,t.append(n)}let c=o();if(c.length)c.forEach((n,r)=>{let a=e.toItem(n),o=document.createElement(`div`);o.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,o.setAttribute(`role`,`option`),o.setAttribute(`aria-selected`,String(r===i)),o.addEventListener(`mousedown`,e=>{e.preventDefault(),s(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(Fj(a.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=a.label,l.append(u),a.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=a.description,l.append(e)}if(o.append(c,l),e.children?.(n)?.length){o.setAttribute(`aria-haspopup`,`listbox`);let e=Fj(`chevron-right`,14);e.classList.add(`dw-suggest__more`),o.append(e)}t.append(o)}),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)}},l=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=wj(i,t,()=>{t&&Oj(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[Tj(6),Dj(),Ej({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},u=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,a=null,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),c(),l()},onUpdate(e){e.items!==r?.items&&(i=0,a=null),r=e,c(),l()},onKeyDown({event:t}){let n=o().length;if(a&&(t.key===`Escape`||t.key===`ArrowLeft`))return a=null,i=0,c(),!0;let r=o()[i];return t.key===`ArrowRight`&&r!==void 0&&e.children?.(r)?.length?(s(i),!0):t.key===`Escape`?(u(),!0):n?t.key===`ArrowDown`||t.key===`ArrowUp`?(i=(i+(t.key===`ArrowDown`?1:-1)+n)%n,c(),!0):t.key===`Enter`||t.key===`Tab`?(s(i),!0):!1:!1},onExit(){r=null,u()}}}}var Lj=[[`text`,`text`,e=>e],[`h1`,`heading`,e=>e.setNode(`heading`,{level:1})],[`h2`,`heading`,e=>e.setNode(`heading`,{level:2})],[`h3`,`heading`,e=>e.setNode(`heading`,{level:3})],[`bullet`,`list`,e=>e.toggleBulletList()],[`ordered`,`list-ordered`,e=>e.toggleOrderedList()],[`todo`,`todo`,e=>e.toggleTaskList()],[`quote`,`quote`,e=>e.setBlockquote()],[`code`,`code`,e=>e.setCodeBlock()],[`callout`,`callout`,e=>e.setCallout()]],Rj=[`paragraph`,`heading`,`codeBlock`,`blockquote`,`bulletList`,`orderedList`,`taskList`,`callout`];function zj(e){let t={...e};return t.attrs&&`blockId`in t.attrs&&(t.attrs={...t.attrs,blockId:null}),t.content&&=t.content.map(zj),t}function Bj(e,t,n,r){let i=e.state.doc.nodeAt(t);if(!i)return[];let a=n.blockMenu,o=t+i.nodeSize,c=e.state.doc.resolve(t).index(0),l=[];if(Rj.includes(i.type.name)&&l.push({id:`turnInto`,label:a.turnInto,icon:`text`,children:Lj.map(([r,a,c])=>({id:r,icon:a,label:n.slash[r]?.label??r,run:()=>{if(r===`callout`){if(i.type.name===`callout`)return;let n=i.type.name===`blockquote`?i.content:s.from(i),r=e.schema.nodes.callout.create(null,n),a=e.state.tr.replaceWith(t,o,r);e.view.dispatch(a.setSelection(C.near(a.doc.resolve(t+1))).scrollIntoView()),e.commands.focus();return}let n=e.state.doc,a=C.findFrom(n.resolve(t),1,!0)?.from??t+1,l=C.findFrom(n.resolve(o),-1,!0)?.to??o-1;c(e.chain().focus().setTextSelection({from:a,to:l}).clearNodes()).run()}}))}),i.type.name===`codeBlock`){let n=!!e.extensionManager.extensions.find(e=>e.name===`codeBlock`)?.options.lineNumbers,r=kj(i.attrs.lineNumbers,n);l.push({id:`lineNumbers`,label:r?a.hideLineNumbers:a.showLineNumbers,icon:`list-ordered`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`lineNumbers`,!r))})}if(i.type.name===`fileAttachment`&&jj(i.attrs.mime,i.attrs.name)){let n=i.attrs.view===`preview`;l.push({id:`pdfView`,label:n?a.showAsFile:a.showPages,icon:n?`paperclip`:`file`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`view`,n?`card`:`preview`))})}return c>0&&l.push({id:`moveUp`,label:a.moveUp,icon:`arrow-up`,run:()=>{let n=e.state.doc.child(c-1),r=e.state.tr.delete(t,o).insert(t-n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),c{let n=e.state.doc.child(c+1),r=e.state.tr.delete(t,o).insert(t+n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),l.push({id:`duplicate`,label:a.duplicate,icon:`plus`,run:()=>{let t=e.schema.nodeFromJSON(zj(i.toJSON()));e.view.dispatch(e.state.tr.insert(o,t).scrollIntoView())}},{id:`copy`,label:a.copy,icon:`copy`,run:()=>{e.chain().focus().setNodeSelection(t).run(),document.execCommand(`copy`)}}),r&&l.push({id:`copyLink`,label:n.blocks.copyBlockLink,icon:`link`,run:r}),l.push({id:`delete`,label:a.delete,icon:`trash`,danger:!0,run:()=>{e.view.dispatch(e.state.tr.delete(t,o)),e.commands.focus()}}),l}function Vj(e,t,n,r){let i=document.createElement(`div`);i.className=`dw-suggest dw-block-menu`,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,n);let a=t,o=0,s=[],c=()=>{i.replaceChildren(),a.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`dw-suggest__item${t===o?` is-active`:``}${e.danger?` is-danger`:``}`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,e.children&&n.setAttribute(`aria-haspopup`,`menu`);let r=document.createElement(`span`);r.className=`dw-suggest__icon`,r.append(Fj(e.icon));let a=document.createElement(`span`);if(a.className=`dw-suggest__label`,a.textContent=e.label,n.append(r,a),e.children){let e=Fj(`chevron-right`,14);e.classList.add(`dw-block-menu__more`),n.append(e)}n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>l(t)),n.addEventListener(`mouseenter`,()=>{o=t;for(let[e,n]of[...i.children].entries())n.classList.toggle(`is-active`,e===t)}),i.append(n)}),i.children[o]?.focus()},l=e=>{let t=a[e];t&&(t.children?(s.push(a),a=t.children,o=0,c()):(m(),t.run?.()))},u=e=>{e.key===`Escape`||e.key===`ArrowLeft`&&s.length?(e.preventDefault(),e.stopPropagation(),s.length?(a=s.pop(),o=0,c()):m()):e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),o=(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length,c()):(e.key===`Enter`||e.key===` `||e.key===`ArrowRight`)&&(e.preventDefault(),(e.key!==`ArrowRight`||a[o]?.children)&&l(o))},d=t=>{!i.contains(t.target)&&!e.contains(t.target)&&m()};document.body.append(i);let f=wj(e,i,()=>{Oj(e,i,{placement:`bottom-start`,strategy:`fixed`,middleware:[Tj(4),Dj(),Ej({padding:8})]}).then(({x:e,y:t})=>Object.assign(i.style,{left:`${e}px`,top:`${t}px`}))});i.addEventListener(`keydown`,u),document.addEventListener(`mousedown`,d,!0);let p=!1;function m(){p||(p=!0,f(),i.remove(),document.removeEventListener(`mousedown`,d,!0),s=[],r?.())}return c(),m}var Hj=[`paragraph`,`heading`,`blockquote`,`codeBlock`,`bulletList`,`orderedList`,`taskList`,`callout`,`table`,`details`,`image`,`embed`,`linkCard`,`mermaid`,`blockMath`,`drawio`,`excalidraw`,`fileAttachment`],Uj=/^[a-z0-9]{6,16}$/,Wj=e=>`#b-${e}`;function Gj(){return[...crypto.getRandomValues(new Uint8Array(8))].map(e=>(e%36).toString(36)).join(``)}function Kj(e,t){let n=e.state.doc.nodeAt(t);if(!n)return null;let r=n.attrs.blockId;if(r)return r;if(!e.editable||!Hj.includes(n.type.name))return null;let i=Gj();return e.dispatch(e.state.tr.setNodeAttribute(t,`blockId`,i)),i}async function qj(e,t,n,r){let i=Kj(e,t);if(!i)return!1;let a=n(Wj(i));try{await navigator.clipboard.writeText(a),r?.(a)}catch{window.prompt(``,a)}return!0}var Jj=Tp.create({name:`blockLinks`,addOptions(){return{labels:null,link:void 0,onCopied:void 0}},addGlobalAttributes(){return[{types:Hj,attributes:{blockId:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-block-id`);return t&&Uj.test(t)?t:null},renderHTML:e=>e.blockId?{"data-block-id":e.blockId}:{}}}}]},addKeyboardShortcuts(){let{link:e,onCopied:t}=this.options;return{"Mod-Shift-c":({editor:n})=>{if(!e)return!1;let r=n.state.selection.$from;if(r.depth<1)return!1;let i=r.before(1),a=n.state.doc.nodeAt(i);return!a||!Hj.includes(a.type.name)||!a.attrs.blockId&&!n.isEditable?!1:(qj(n.view,i,e,t),!0)}}},addProseMirrorPlugins(){let{link:e,onCopied:t}=this.options,n=this.options.labels,r=this.editor;return[new E({key:new D(`blockLinks`),view:i=>new Zj(i,r,n,e,t)})]}}),Yj=``,Xj=``,Zj=class{view;editor;labels;link;onCopied;gutter=document.createElement(`div`);linkButton=document.createElement(`button`);grip=document.createElement(`button`);pos=-1;closeMenu=null;constructor(e,t,n,r,i){this.view=e,this.editor=t,this.labels=n,this.link=r,this.onCopied=i;let a=this.gutter;a.className=`dw-block-gutter`,a.contentEditable=`false`,a.hidden=!0,a.addEventListener(`mouseleave`,this.leave);let o=this.linkButton;o.type=`button`,o.className=`dw-block-handle`,o.setAttribute(`aria-label`,n.blocks.copyBlockLink),o.title=n.blocks.copyBlockLink,o.innerHTML=Yj,o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>void this.copy());let s=this.grip;s.type=`button`,s.className=`dw-block-handle dw-block-grip`,s.setAttribute(`aria-label`,n.blockMenu.open),s.setAttribute(`aria-haspopup`,`menu`),s.setAttribute(`aria-expanded`,`false`),s.title=n.blockMenu.open,s.innerHTML=Xj,s.draggable=!0,s.addEventListener(`click`,this.openMenu),s.addEventListener(`dragstart`,this.dragStart),s.addEventListener(`dragend`,()=>this.hide()),r&&a.append(o),a.append(s),e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.gutter.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.gutter)),e}hide=()=>{this.closeMenu||(this.gutter.hidden=!0,this.pos=-1)};leave=e=>{let t=e.relatedTarget;t&&(this.gutter.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.closeMenu)return;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)return this.hide();let s=!!this.link&&Hj.includes(o.type.name)&&(!!o.attrs.blockId||this.view.editable),c=this.view.editable;if(!s&&!c)return this.hide();this.linkButton.hidden=!s,this.grip.hidden=!c,this.pos=a;let l=t.getBoundingClientRect(),u=n.getBoundingClientRect();this.gutter.style.top=`${l.top-u.top+Math.min(l.height/2,14)-11}px`,this.gutter.hidden=!1};openMenu=()=>{if(this.closeMenu){this.closeMenu();return}let e=this.pos;if(e<0||!this.view.editable)return;let t=this.view.state.doc.nodeAt(e),n=!!this.link&&!!t&&Hj.includes(t.type.name),r=Bj(this.editor,e,this.labels,n?()=>void this.copy(e):void 0);this.grip.setAttribute(`aria-expanded`,`true`),this.closeMenu=Vj(this.grip,r,this.labels.blockMenu.open,()=>{this.closeMenu=null,this.grip.setAttribute(`aria-expanded`,`false`),this.hide()})};dragStart=e=>{let t=this.pos;if(t<0||!e.dataTransfer)return;this.closeMenu?.();let n=T.create(this.view.state.doc,t);this.view.dispatch(this.view.state.tr.setSelection(n)),e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setData(`text/plain`,n.node.textContent);let r=this.view.nodeDOM(t);r instanceof HTMLElement&&e.dataTransfer.setDragImage(r,0,0),this.view.dragging={slice:n.content(),move:!0}};async copy(e=this.pos){e>=0&&this.link&&await qj(this.view,e,this.link,this.onCopied)}update(){this.pos>=this.view.state.doc.content.size&&this.hide()}destroy(){this.closeMenu?.(),this.gutter.parentElement?.classList.remove(`dw-block-host`),this.gutter.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}},Qj,$j;if(typeof WeakMap<`u`){let e=new WeakMap;Qj=t=>e.get(t),$j=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;Qj=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var eM=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function rM(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function cM(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function lM(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function uM(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=sM(t.$head)||dM(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function dM(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function fM(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function pM(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function mM(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function hM(e,t,n){let r=e.node(-1),i=eM.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function gM(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function _M(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Cn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(fM(r)&&fM(i)&&mM(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return w.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=eM.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=gM(e,0,l)),u>0&&(e=gM(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=eM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=eM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(vs.node(n,n+e.nodeSize,{class:`selectedCell`}))}),xs.create(e.doc,t)}function SM({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function CM({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function wM(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof T&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=yM.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=yM.rowSelection(e,e)}else if(!n){let e=eM.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=yM.create(i,t+1,n)}}else r instanceof w&&SM(r)?a=w.create(i,r.from):r instanceof w&&CM(r)&&(a=w.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var TM=new D(`fix-tables`);function EM(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=OM(e,t,r,n))};return t?t.doc!=e.doc&&EM(t.doc,e.doc,0,r):e.doc.descendants(r),n}function OM(e,t,n,r){let i=eM.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;vM(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;FM(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=c+1+l.content.size,t=VM(l)?c+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new yM(n.doc.resolve(c+r.tableStart))),t(n)}return!0}function WM(e,t){let n=aM(e.schema);return GM(({node:e})=>n[e.type.spec.tableRole])(e,t)}function GM(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof yM){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=cM(r.$from),!i)return!1;a=sM(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=kM(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function qM(e){return function(t,n){if(!lM(t))return!1;if(n){let r=aM(t.schema),i=kM(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}YM(`row`,{useDeprecatedLogic:!0}),YM(`column`,{useDeprecatedLogic:!0});var XM=YM(`cell`,{useDeprecatedLogic:!0});function ZM(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function eN(e,t){let n=e.selection;if(!(n instanceof yM))return!1;if(t){let r=e.tr,i=aM(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new p(i,0,0))}),r.docChanged&&t(r)}return!0}function tN(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(s.empty),n[i]r&&(s=s.type.createChecked(gM(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(s.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function aN(e,t,n,r,i,a,o){let c=e.doc.type.schema,l=aM(c),u,d;if(i>t.width)for(let a=0,s=0;at.height){let c=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,s.from(c)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof yM)return uN(n,r,C.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=gN(i,e,t);if(o==null)return!1;if(e==`horiz`)return uN(n,r,C.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=hM(i,e,t),s;return s=a?C.near(a,1):t<0?C.near(n.doc.resolve(i.before(-1)),-1):C.near(n.doc.resolve(i.after(-1)),1),uN(n,r,s)}}}function fN(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof yM)o=a;else{let r=gN(i,e,t);if(r==null)return!1;o=new yM(n.doc.resolve(r))}let s=hM(o.$headCell,e,t);return s?uN(n,r,new yM(o.$anchorCell,s)):!1}}function pN(e,t){let n=e.state.doc,r=sM(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new yM(r))),!0):!1}function mN(e,t,n){if(!lM(e.state))return!1;let r=tN(n),i=e.state.selection;if(i instanceof yM){r||={width:1,height:1,rows:[s.from(rN(aM(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=eM.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=iN(r,o.right-o.left,o.bottom-o.top),cN(e.state,e.dispatch,a,o,r),!0}if(r){let t=uM(e.state),n=t.start(-1);return cN(e.state,e.dispatch,n,eM.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function hN(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=_N(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof yM)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=sM(e.state.selection.$anchor))!=null&&vN(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=vN(e,n),i=oM.getState(e.state)==null;if(!r||!mM(t,r)){if(i)r=t;else return}let a=new yM(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(oM,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),oM.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(oM,-1))}function o(r){let o=r,s=oM.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(_N(e,o.target)!=n&&(c=vN(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function gN(e,t,n){if(!(e.state.selection instanceof w))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function _N(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function vN(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&sM(e.state.doc.resolve(r))||sM(e.state.doc.resolve(i))}var yN=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),bN(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,bN(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function bN(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new CN(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=xN.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{wN(t,n,e,i)},mouseleave:e=>{TN(e)},mousedown:(e,r)=>{EN(e,r,t,n)}},decorations:e=>{let t=xN.getState(e);if(t&&t.activeHandle>-1)return FN(e,t.activeHandle)},nodeViews:{}}});return a}var CN=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(xN);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return fM(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function wN(e,t,n,r){if(!e.editable)return;let i=xN.getState(e.state);if(i&&!i.dragging){let a=ON(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=kN(e,t,`left`,n):i-t.clientX<=n&&(o=kN(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=eM.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}jN(e,o)}}}function TN(e){if(!e.editable)return;let t=xN.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&jN(e,-1)}function EN(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=xN.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=DN(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(xN,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=xN.getState(e.state);r?.dragging&&(MN(e,r.activeHandle,AN(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(xN,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=xN.getState(e.state);if(i&&i.dragging){let a=AN(i.dragging,t,n);NN(e,i.activeHandle,a,r)}}return NN(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function DN(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;eRN(e),renderHTML:e=>{let t=LN(e.align);return Pf(t)?{style:`text-align: ${t}`}:{}}}}function VN(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function HN(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):VN(e)}var UN=/[ \t\r\n\f]+/g;function WN(e){return e.children.length>0?!1:(e.textContent??``).replace(UN,``)===``}function GN(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function KN(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var qN=Jp.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:HN},align:BN()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>WN(e)?{}:!1,getContent:(e,t)=>GN(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return KN(t,e,`colspan`),KN(t,e,`rowspan`),[`td`,t,0]}}),JN=Jp.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:HN},align:BN()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>WN(e)?{}:!1,getContent:(e,t)=>GN(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return KN(t,e,`colspan`),KN(t,e,`rowspan`),[`th`,t,0]}}),YN=Jp.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,A(this.options.HTMLAttributes,e),0]}});function XN(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function ZN(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function nP(e,t,n,r,i){let a=tP(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!rP(t))return!1;let n=0;return vu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function aP(e,t){let n=e.mapping.map(t);if(vu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(w.near(e.doc.resolve(i),-1))}function oP(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function sP(e){return e.split(` -`).map(e=>!e.includes(`|`)||!e.includes("`")?e:oP(e)).join(` -`)}function cP(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function lP(e,t){return t?e.split(t).join(` -`):e}function uP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function dP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>lP(t.renderChildren(e),n.cellLineSeparator)).join(` -`):lP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=uP(cP(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=zN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var fP=new D(`preserveCellSelectionOnContextMenu`);function pP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function mP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=LN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=LN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>dP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` +`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),Pj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function Fj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Ij={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-left":[`M14 6l-6 6 6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 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`],pin:[`M9 4h6`,`M10 4v6l-3 4h10l-3-4V4`,`M12 14v6`],width:[`M3 12h18`,`M7 8l-4 4 4 4`,`M17 8l4 4-4 4`],type:[`M5 7V5h14v2`,`M12 5v14`,`M9 19h6`],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`],"align-left":[`M4 6h16`,`M4 10h10`,`M4 14h16`,`M4 18h10`],"align-center":[`M4 6h16`,`M7 10h10`,`M4 14h16`,`M7 18h10`],"align-right":[`M4 6h16`,`M10 10h10`,`M4 14h16`,`M10 18h10`],grip:[`M9 6h.01`,`M15 6h.01`,`M9 12h.01`,`M15 12h.01`,`M9 18h.01`,`M15 18h.01`],copy:[`M9 9h11v11H9z`,`M5 15H4V4h11v1`],"arrow-up":[`M12 19V5`,`M6 11l6-6 6 6`],"arrow-down":[`M12 5v14`,`M6 13l6 6 6-6`],callout:[`M4 5h16v14H4z`,`M8 10h.01`,`M11 10h5`,`M8 14h8`],palette:[`M12 3a9 9 0 1 0 0 18c1 0 1.5-.7 1.5-1.5 0-1.2-1-1.5-1-2.5s.8-1.5 2-1.5H17a4 4 0 0 0 4-4c0-4.7-4-8.5-9-8.5z`,`M7.5 11h.01`,`M10 7.5h.01`,`M14.5 7.5h.01`],"page-plus":[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M12 11v6`,`M9 14h6`],tag:[`M4 4h7l9 9-7 7-9-9z`,`M8 8h.01`],grid:[`M4 4h7v7H4z`,`M13 4h7v7h-7z`,`M4 13h7v7H4z`,`M13 13h7v7h-7z`],cards:[`M4 5h16v6H4z`,`M4 15h16v4H4z`],filter:[`M4 5h16l-6 8v6l-4-2v-4z`],layers:[`M12 4l8 4-8 4-8-4z`,`M4 12l8 4 8-4`,`M4 16l8 4 8-4`],journal:[`M6 3h11a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6z`,`M9 3v18`,`M12 8h3`,`M12 12h3`],sliders:[`M5 6h14`,`M5 12h14`,`M5 18h14`,`M9 4v4`,`M15 10v4`,`M11 16v4`],sort:[`M7 4v16`,`M4 7l3-3 3 3`,`M17 20V4`,`M14 17l3 3 3-3`],database:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 10v9`]},Lj=`http://www.w3.org/2000/svg`;function Rj(e,t=18){let n=document.createElementNS(Lj,`svg`);for(let[e,r]of Object.entries({width:String(t),height:String(t),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))n.setAttribute(e,r);for(let t of Ij[e]){let e=document.createElementNS(Lj,`path`);e.setAttribute(`d`,t),n.append(e)}return n}function zj(e){return()=>{let t=null,n=null,r=null,i=0,a=null,o=()=>a?.items??r?.items??[],s=t=>{let n=o()[t];if(!r||n===void 0)return;let s=e.children?.(n);s?.length?(a={parent:n,items:s},i=0,c()):e.pick(r,n)},c=()=>{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(a){let n=document.createElement(`div`);n.className=`dw-suggest__query`,n.textContent=`‹ ${e.toItem(a.parent).label}`,t.append(n)}let c=o();if(c.length)c.forEach((n,r)=>{let a=e.toItem(n),o=document.createElement(`div`);o.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,o.setAttribute(`role`,`option`),o.setAttribute(`aria-selected`,String(r===i)),o.addEventListener(`mousedown`,e=>{e.preventDefault(),s(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(Rj(a.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=a.label,l.append(u),a.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=a.description,l.append(e)}if(o.append(c,l),e.children?.(n)?.length){o.setAttribute(`aria-haspopup`,`listbox`);let e=Rj(`chevron-right`,14);e.classList.add(`dw-suggest__more`),o.append(e)}t.append(o)}),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)}},l=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=Dj(i,t,()=>{t&&jj(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[Oj(6),Aj(),kj({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},u=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,a=null,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),c(),l()},onUpdate(e){e.items!==r?.items&&(i=0,a=null),r=e,c(),l()},onKeyDown({event:t}){let n=o().length;if(a&&(t.key===`Escape`||t.key===`ArrowLeft`))return a=null,i=0,c(),!0;let r=o()[i];return t.key===`ArrowRight`&&r!==void 0&&e.children?.(r)?.length?(s(i),!0):t.key===`Escape`?(u(),!0):n?t.key===`ArrowDown`||t.key===`ArrowUp`?(i=(i+(t.key===`ArrowDown`?1:-1)+n)%n,c(),!0):t.key===`Enter`||t.key===`Tab`?(s(i),!0):!1:!1},onExit(){r=null,u()}}}}var Bj=[[`text`,`text`,e=>e],[`h1`,`heading`,e=>e.setNode(`heading`,{level:1})],[`h2`,`heading`,e=>e.setNode(`heading`,{level:2})],[`h3`,`heading`,e=>e.setNode(`heading`,{level:3})],[`bullet`,`list`,e=>e.toggleBulletList()],[`ordered`,`list-ordered`,e=>e.toggleOrderedList()],[`todo`,`todo`,e=>e.toggleTaskList()],[`quote`,`quote`,e=>e.setBlockquote()],[`code`,`code`,e=>e.setCodeBlock()],[`callout`,`callout`,e=>e.setCallout()]],Vj=[`paragraph`,`heading`,`codeBlock`,`blockquote`,`bulletList`,`orderedList`,`taskList`,`callout`];function Hj(e){let t={...e};return t.attrs&&`blockId`in t.attrs&&(t.attrs={...t.attrs,blockId:null}),t.content&&=t.content.map(Hj),t}function Uj(e,t,n,r){let i=e.state.doc.nodeAt(t);if(!i)return[];let a=n.blockMenu,o=t+i.nodeSize,c=e.state.doc.resolve(t).index(0),l=[];if(Vj.includes(i.type.name)&&l.push({id:`turnInto`,label:a.turnInto,icon:`text`,children:Bj.map(([r,a,c])=>({id:r,icon:a,label:n.slash[r]?.label??r,run:()=>{if(r===`callout`){if(i.type.name===`callout`)return;let n=i.type.name===`blockquote`?i.content:s.from(i),r=e.schema.nodes.callout.create(null,n),a=e.state.tr.replaceWith(t,o,r);e.view.dispatch(a.setSelection(C.near(a.doc.resolve(t+1))).scrollIntoView()),e.commands.focus();return}let n=e.state.doc,a=C.findFrom(n.resolve(t),1,!0)?.from??t+1,l=C.findFrom(n.resolve(o),-1,!0)?.to??o-1;c(e.chain().focus().setTextSelection({from:a,to:l}).clearNodes()).run()}}))}),[`bulletList`,`orderedList`,`taskList`].includes(i.type.name)&&l.push({id:`groupAsDatabase`,label:n.database.groupAsDatabase,icon:`database`,run:()=>{e.chain().focus().setTextSelection(t+2).groupAsDatabase().run()}}),i.type.name===`codeBlock`){let n=!!e.extensionManager.extensions.find(e=>e.name===`codeBlock`)?.options.lineNumbers,r=Mj(i.attrs.lineNumbers,n);l.push({id:`lineNumbers`,label:r?a.hideLineNumbers:a.showLineNumbers,icon:`list-ordered`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`lineNumbers`,!r))})}if(i.type.name===`fileAttachment`&&Pj(i.attrs.mime,i.attrs.name)){let n=i.attrs.view===`preview`;l.push({id:`pdfView`,label:n?a.showAsFile:a.showPages,icon:n?`paperclip`:`file`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`view`,n?`card`:`preview`))})}return c>0&&l.push({id:`moveUp`,label:a.moveUp,icon:`arrow-up`,run:()=>{let n=e.state.doc.child(c-1),r=e.state.tr.delete(t,o).insert(t-n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),c{let n=e.state.doc.child(c+1),r=e.state.tr.delete(t,o).insert(t+n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),l.push({id:`duplicate`,label:a.duplicate,icon:`plus`,run:()=>{let t=e.schema.nodeFromJSON(Hj(i.toJSON()));e.view.dispatch(e.state.tr.insert(o,t).scrollIntoView())}},{id:`copy`,label:a.copy,icon:`copy`,run:()=>{e.chain().focus().setNodeSelection(t).run(),document.execCommand(`copy`)}}),r&&l.push({id:`copyLink`,label:n.blocks.copyBlockLink,icon:`link`,run:r}),l.push({id:`delete`,label:a.delete,icon:`trash`,danger:!0,run:()=>{e.view.dispatch(e.state.tr.delete(t,o)),e.commands.focus()}}),l}function Wj(e,t,n,r){let i=document.createElement(`div`);i.className=`dw-suggest dw-block-menu`,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,n);let a=t,o=0,s=[],c=()=>{i.replaceChildren(),a.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`dw-suggest__item${t===o?` is-active`:``}${e.danger?` is-danger`:``}`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,e.children&&n.setAttribute(`aria-haspopup`,`menu`);let r=document.createElement(`span`);r.className=`dw-suggest__icon`,r.append(Rj(e.icon));let a=document.createElement(`span`);if(a.className=`dw-suggest__label`,a.textContent=e.label,n.append(r,a),e.children){let e=Rj(`chevron-right`,14);e.classList.add(`dw-block-menu__more`),n.append(e)}n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>l(t)),n.addEventListener(`mouseenter`,()=>{o=t;for(let[e,n]of[...i.children].entries())n.classList.toggle(`is-active`,e===t)}),i.append(n)}),i.children[o]?.focus()},l=e=>{let t=a[e];t&&(t.children?(s.push(a),a=t.children,o=0,c()):(m(),t.run?.()))},u=e=>{e.key===`Escape`||e.key===`ArrowLeft`&&s.length?(e.preventDefault(),e.stopPropagation(),s.length?(a=s.pop(),o=0,c()):m()):e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),o=(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length,c()):(e.key===`Enter`||e.key===` `||e.key===`ArrowRight`)&&(e.preventDefault(),(e.key!==`ArrowRight`||a[o]?.children)&&l(o))},d=t=>{!i.contains(t.target)&&!e.contains(t.target)&&m()};document.body.append(i);let f=Dj(e,i,()=>{jj(e,i,{placement:`bottom-start`,strategy:`fixed`,middleware:[Oj(4),Aj(),kj({padding:8})]}).then(({x:e,y:t})=>Object.assign(i.style,{left:`${e}px`,top:`${t}px`}))});i.addEventListener(`keydown`,u),document.addEventListener(`mousedown`,d,!0);let p=!1;function m(){p||(p=!0,f(),i.remove(),document.removeEventListener(`mousedown`,d,!0),s=[],r?.())}return c(),m}var Gj=[`paragraph`,`heading`,`blockquote`,`codeBlock`,`bulletList`,`orderedList`,`taskList`,`callout`,`table`,`details`,`image`,`embed`,`linkCard`,`mermaid`,`blockMath`,`drawio`,`excalidraw`,`fileAttachment`],Kj=/^[a-z0-9]{6,16}$/,qj=e=>`#b-${e}`;function Jj(){return[...crypto.getRandomValues(new Uint8Array(8))].map(e=>(e%36).toString(36)).join(``)}function Yj(e,t){let n=e.state.doc.nodeAt(t);if(!n)return null;let r=n.attrs.blockId;if(r)return r;if(!e.editable||!Gj.includes(n.type.name))return null;let i=Jj();return e.dispatch(e.state.tr.setNodeAttribute(t,`blockId`,i)),i}async function Xj(e,t,n,r){let i=Yj(e,t);if(!i)return!1;let a=n(qj(i));try{await navigator.clipboard.writeText(a),r?.(a)}catch{window.prompt(``,a)}return!0}var Zj=Tp.create({name:`blockLinks`,addOptions(){return{labels:null,link:void 0,onCopied:void 0}},addGlobalAttributes(){return[{types:Gj,attributes:{blockId:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-block-id`);return t&&Kj.test(t)?t:null},renderHTML:e=>e.blockId?{"data-block-id":e.blockId}:{}}}}]},addKeyboardShortcuts(){let{link:e,onCopied:t}=this.options;return{"Mod-Shift-c":({editor:n})=>{if(!e)return!1;let r=n.state.selection.$from;if(r.depth<1)return!1;let i=r.before(1),a=n.state.doc.nodeAt(i);return!a||!Gj.includes(a.type.name)||!a.attrs.blockId&&!n.isEditable?!1:(Xj(n.view,i,e,t),!0)}}},addProseMirrorPlugins(){let{link:e,onCopied:t}=this.options,n=this.options.labels,r=this.editor;return[new E({key:new D(`blockLinks`),view:i=>new eM(i,r,n,e,t)})]}}),Qj=``,$j=``,eM=class{view;editor;labels;link;onCopied;gutter=document.createElement(`div`);linkButton=document.createElement(`button`);grip=document.createElement(`button`);pos=-1;closeMenu=null;constructor(e,t,n,r,i){this.view=e,this.editor=t,this.labels=n,this.link=r,this.onCopied=i;let a=this.gutter;a.className=`dw-block-gutter`,a.contentEditable=`false`,a.hidden=!0,a.addEventListener(`mouseleave`,this.leave);let o=this.linkButton;o.type=`button`,o.className=`dw-block-handle`,o.setAttribute(`aria-label`,n.blocks.copyBlockLink),o.title=n.blocks.copyBlockLink,o.innerHTML=Qj,o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>void this.copy());let s=this.grip;s.type=`button`,s.className=`dw-block-handle dw-block-grip`,s.setAttribute(`aria-label`,n.blockMenu.open),s.setAttribute(`aria-haspopup`,`menu`),s.setAttribute(`aria-expanded`,`false`),s.title=n.blockMenu.open,s.innerHTML=$j,s.draggable=!0,s.addEventListener(`click`,this.openMenu),s.addEventListener(`dragstart`,this.dragStart),s.addEventListener(`dragend`,()=>this.hide()),r&&a.append(o),a.append(s),e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.gutter.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.gutter)),e}hide=()=>{this.closeMenu||(this.gutter.hidden=!0,this.pos=-1)};leave=e=>{let t=e.relatedTarget;t&&(this.gutter.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.closeMenu)return;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)return this.hide();let s=!!this.link&&Gj.includes(o.type.name)&&(!!o.attrs.blockId||this.view.editable),c=this.view.editable;if(!s&&!c)return this.hide();this.linkButton.hidden=!s,this.grip.hidden=!c,this.pos=a;let l=t.getBoundingClientRect(),u=n.getBoundingClientRect();this.gutter.style.top=`${l.top-u.top+Math.min(l.height/2,14)-11}px`,this.gutter.hidden=!1};openMenu=()=>{if(this.closeMenu){this.closeMenu();return}let e=this.pos;if(e<0||!this.view.editable)return;let t=this.view.state.doc.nodeAt(e),n=!!this.link&&!!t&&Gj.includes(t.type.name),r=Uj(this.editor,e,this.labels,n?()=>void this.copy(e):void 0);this.grip.setAttribute(`aria-expanded`,`true`),this.closeMenu=Wj(this.grip,r,this.labels.blockMenu.open,()=>{this.closeMenu=null,this.grip.setAttribute(`aria-expanded`,`false`),this.hide()})};dragStart=e=>{let t=this.pos;if(t<0||!e.dataTransfer)return;this.closeMenu?.();let n=T.create(this.view.state.doc,t);this.view.dispatch(this.view.state.tr.setSelection(n)),e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setData(`text/plain`,n.node.textContent);let r=this.view.nodeDOM(t);r instanceof HTMLElement&&e.dataTransfer.setDragImage(r,0,0),this.view.dragging={slice:n.content(),move:!0}};async copy(e=this.pos){e>=0&&this.link&&await Xj(this.view,e,this.link,this.onCopied)}update(){this.pos>=this.view.state.doc.content.size&&this.hide()}destroy(){this.closeMenu?.(),this.gutter.parentElement?.classList.remove(`dw-block-host`),this.gutter.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}},tM,nM;if(typeof WeakMap<`u`){let e=new WeakMap;tM=t=>e.get(t),nM=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;tM=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var rM=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function oM(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function dM(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function fM(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function pM(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=uM(t.$head)||mM(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function mM(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function hM(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function gM(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function _M(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function vM(e,t,n){let r=e.node(-1),i=rM.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function yM(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function bM(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Cn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(hM(r)&&hM(i)&&_M(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return w.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=rM.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=yM(e,0,l)),u>0&&(e=yM(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=rM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=rM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(vs.node(n,n+e.nodeSize,{class:`selectedCell`}))}),xs.create(e.doc,t)}function TM({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function EM({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function DM(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof T&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=SM.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=SM.rowSelection(e,e)}else if(!n){let e=rM.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=SM.create(i,t+1,n)}}else r instanceof w&&TM(r)?a=w.create(i,r.from):r instanceof w&&EM(r)&&(a=w.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var OM=new D(`fix-tables`);function kM(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=jM(e,t,r,n))};return t?t.doc!=e.doc&&kM(t.doc,e.doc,0,r):e.doc.descendants(r),n}function jM(e,t,n,r){let i=rM.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;xM(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;RM(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=c+1+l.content.size,t=WM(l)?c+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new SM(n.doc.resolve(c+r.tableStart))),t(n)}return!0}function qM(e,t){let n=cM(e.schema);return JM(({node:e})=>n[e.type.spec.tableRole])(e,t)}function JM(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof SM){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=dM(r.$from),!i)return!1;a=uM(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=MM(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function XM(e){return function(t,n){if(!fM(t))return!1;if(n){let r=cM(t.schema),i=MM(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}QM(`row`,{useDeprecatedLogic:!0}),QM(`column`,{useDeprecatedLogic:!0});var $M=QM(`cell`,{useDeprecatedLogic:!0});function eN(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function rN(e,t){let n=e.selection;if(!(n instanceof SM))return!1;if(t){let r=e.tr,i=cM(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new p(i,0,0))}),r.docChanged&&t(r)}return!0}function iN(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(s.empty),n[i]r&&(s=s.type.createChecked(yM(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(s.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function cN(e,t,n,r,i,a,o){let c=e.doc.type.schema,l=cM(c),u,d;if(i>t.width)for(let a=0,s=0;at.height){let c=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,s.from(c)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof SM)return pN(n,r,C.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=yN(i,e,t);if(o==null)return!1;if(e==`horiz`)return pN(n,r,C.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=vM(i,e,t),s;return s=a?C.near(a,1):t<0?C.near(n.doc.resolve(i.before(-1)),-1):C.near(n.doc.resolve(i.after(-1)),1),pN(n,r,s)}}}function hN(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof SM)o=a;else{let r=yN(i,e,t);if(r==null)return!1;o=new SM(n.doc.resolve(r))}let s=vM(o.$headCell,e,t);return s?pN(n,r,new SM(o.$anchorCell,s)):!1}}function gN(e,t){let n=e.state.doc,r=uM(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new SM(r))),!0):!1}function _N(e,t,n){if(!fM(e.state))return!1;let r=iN(n),i=e.state.selection;if(i instanceof SM){r||={width:1,height:1,rows:[s.from(oN(cM(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=rM.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=sN(r,o.right-o.left,o.bottom-o.top),dN(e.state,e.dispatch,a,o,r),!0}if(r){let t=pM(e.state),n=t.start(-1);return dN(e.state,e.dispatch,n,rM.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function vN(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=bN(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof SM)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=uM(e.state.selection.$anchor))!=null&&xN(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=xN(e,n),i=lM.getState(e.state)==null;if(!r||!_M(t,r)){if(i)r=t;else return}let a=new SM(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(lM,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),lM.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(lM,-1))}function o(r){let o=r,s=lM.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(bN(e,o.target)!=n&&(c=xN(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function yN(e,t,n){if(!(e.state.selection instanceof w))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function bN(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function xN(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&uM(e.state.doc.resolve(r))||uM(e.state.doc.resolve(i))}var SN=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),CN(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,CN(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function CN(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new EN(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=wN.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{DN(t,n,e,i)},mouseleave:e=>{ON(e)},mousedown:(e,r)=>{kN(e,r,t,n)}},decorations:e=>{let t=wN.getState(e);if(t&&t.activeHandle>-1)return RN(e,t.activeHandle)},nodeViews:{}}});return a}var EN=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(wN);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return hM(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function DN(e,t,n,r){if(!e.editable)return;let i=wN.getState(e.state);if(i&&!i.dragging){let a=jN(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=MN(e,t,`left`,n):i-t.clientX<=n&&(o=MN(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=rM.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}PN(e,o)}}}function ON(e){if(!e.editable)return;let t=wN.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&PN(e,-1)}function kN(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=wN.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=AN(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(wN,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=wN.getState(e.state);r?.dragging&&(FN(e,r.activeHandle,NN(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(wN,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=wN.getState(e.state);if(i&&i.dragging){let a=NN(i.dragging,t,n);IN(e,i.activeHandle,a,r)}}return IN(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function AN(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;eVN(e),renderHTML:e=>{let t=BN(e.align);return Pf(t)?{style:`text-align: ${t}`}:{}}}}function WN(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function GN(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):WN(e)}var KN=/[ \t\r\n\f]+/g;function qN(e){return e.children.length>0?!1:(e.textContent??``).replace(KN,``)===``}function JN(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function YN(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var XN=Jp.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:GN},align:UN()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>qN(e)?{}:!1,getContent:(e,t)=>JN(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return YN(t,e,`colspan`),YN(t,e,`rowspan`),[`td`,t,0]}}),ZN=Jp.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:GN},align:UN()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>qN(e)?{}:!1,getContent:(e,t)=>JN(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return YN(t,e,`colspan`),YN(t,e,`rowspan`),[`th`,t,0]}}),QN=Jp.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,A(this.options.HTMLAttributes,e),0]}});function $N(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function eP(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function aP(e,t,n,r,i){let a=iP(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!oP(t))return!1;let n=0;return vu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function cP(e,t){let n=e.mapping.map(t);if(vu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(w.near(e.doc.resolve(i),-1))}function lP(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function uP(e){return e.split(` +`).map(e=>!e.includes(`|`)||!e.includes("`")?e:lP(e)).join(` +`)}function dP(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function fP(e,t){return t?e.split(t).join(` +`):e}function pP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function mP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>fP(t.renderChildren(e),n.cellLineSeparator)).join(` +`):fP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=pP(dP(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=HN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var hP=new D(`preserveCellSelectionOnContextMenu`);function gP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function _P(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=BN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=BN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>mP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` `);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(` `),i=r>=0?e.slice(0,r):e,a=i.split(` -`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=sP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` +`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=uP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` `).length,u=e.split(` `).slice(0,l).join(` -`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=nP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>jM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>MM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return PM(e,t&&(e=>{n&&aP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>LM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>RM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return BM(e,t&&(e=>{n&&aP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>$M(e,t),mergeCells:()=>({state:e,dispatch:t})=>UM(e,t),splitCell:()=>({state:e,dispatch:t})=>WM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>YM(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>YM(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>XM(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>UM(e,t)?!0:WM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>KM(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>QM(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>QM(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&DM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=yM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:iP,"Mod-Backspace":iP,Delete:iP,"Mod-Delete":iP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[SN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],IN({allowTableNodeSelection:this.options.allowTableNodeSelection}),hP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),_P=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(gP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(qN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(JN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(YN.configure(this.options.tableRow)),e}}),vP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function yP(){return[Nk.configure({HTMLAttributes:{class:`dw-tasks`}}),Mk.configure({nested:!0})]}function bP(){return[_P.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var xP=vP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),SP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),CP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,wP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,TP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,A(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)(?!\s)([^=]*[^=\s])(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Hp({find:CP,type:this.type})]},addPasteRules(){return[Yp({find:wP,type:this.type})]}}),EP=[`gray`,`red`,`orange`,`yellow`,`green`,`teal`,`blue`,`purple`,`pink`],DP=e=>typeof e==`string`&&EP.includes(e),OP=_p.create({name:`textColor`,addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return DP(t)?t:null},renderHTML:e=>e.color?{"data-color":e.color}:{}}}},parseHTML(){return[{tag:`span[data-color]`,getAttrs:e=>DP(e.getAttribute(`data-color`))?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{class:`dw-text-color`}),0]},addCommands(){return{setTextColor:e=>({commands:t})=>t.setMark(this.name,{color:e}),unsetTextColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),kP=TP.extend({addOptions(){return{...this.parent(),multicolor:!0}},addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return DP(t)?t:null},renderHTML:e=>({"data-color":DP(e.color)?e.color:`yellow`})}}},renderHTML({HTMLAttributes:e}){return[`mark`,A(e,{class:`dw-highlight`}),0]}}),AP=`💡`;function jP(e){let t=e.trim();return t&&[...t].length<=4?t:``}var MP=Jp.create({name:`callout`,group:`block`,content:`block+`,defining:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{emoji:{default:AP,parseHTML:e=>jP(e.getAttribute(`data-emoji`)??``)||AP,renderHTML:e=>({"data-emoji":e.emoji})},color:{default:`blue`,parseHTML:e=>{let t=e.getAttribute(`data-color`);return DP(t)?t:`blue`},renderHTML:e=>({"data-color":e.color})}}},parseHTML(){return[{tag:`aside[data-type=callout]`,contentElement:e=>e.querySelector(`:scope > .callout-body`)??e}]},renderHTML({HTMLAttributes:e}){return[`aside`,A(e,{"data-type":`callout`,class:`dw-callout`}),0]},addCommands(){return{setCallout:e=>({commands:t})=>t.wrapIn(this.name,e),unsetCallout:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{$from:t,empty:n}=e.state.selection;if(!n||t.parentOffset>0)return!1;for(let n=t.depth-1;n>0;n--){if(t.node(n).type.name===this.name)return t.index(n)!==0||t.start(n+1)!==t.start()?!1:e.commands.lift(this.name);if(t.index(n)!==0)return!1}return!1}}},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=this.options.labels,i=document.createElement(`aside`);i.className=`dw-callout`,i.setAttribute(`data-type`,`callout`);let a=document.createElement(`div`);a.className=`dw-callout__side`,a.contentEditable=`false`;let o=document.createElement(`button`);o.type=`button`,o.className=`dw-callout__emoji`;let s=document.createElement(`button`);s.type=`button`,s.className=`dw-callout__color`,a.append(o,s);let c=document.createElement(`div`);c.className=`dw-callout__body`,i.append(a,c);let l=e,u=e=>{let r=t();typeof r==`number`&&n.isEditable&&n.view.dispatch(n.state.tr.setNodeMarkup(r,void 0,{...l.attrs,...e}))};o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>{if(!n.isEditable)return;let e=jP(window.prompt(r?.blocks.calloutEmoji??`Emoji`,l.attrs.emoji)??``);e&&u({emoji:e})}),s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`click`,()=>{let e=EP.indexOf(l.attrs.color);u({color:EP[(e+1)%EP.length]})});let d=()=>{i.setAttribute(`data-color`,String(l.attrs.color)),o.textContent=String(l.attrs.emoji);let e=r?.blocks.calloutEmoji??`Emoji`;o.setAttribute(`aria-label`,e),o.title=e;let t=r?.blocks.calloutColor??`Colour`;s.setAttribute(`aria-label`,t),s.title=t};return d(),{dom:i,contentDOM:c,update:t=>t.type===e.type&&(l=t,d(),!0),stopEvent:e=>a.contains(e.target),ignoreMutation:e=>a.contains(e.target)}}}});function NP(e){let t=MS.getState(e);return t?.type&&t.binding&&t.doc?t:null}function PP(e,t){let n=NP(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>jS(n.doc,n.type,ly(gg(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 FP=new D(`docwellComments`);function IP(e,t,n){let r=[];for(let i of t){let t=PP(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 LP=Tp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new E({key:FP,state:{init:()=>({marks:[],active:``,decos:xs.empty}),apply(e,t,n,r){let i=e.getMeta(FP);if(i)return{...i,decos:IP(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(MS)?.isChangeOrigin;return{...t,decos:a?IP(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>FP.getState(e)?.decos??xs.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}}),RP=/^(\d{4})-(\d{2})-(\d{2})$/;function zP(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function BP(e){let t=RP.exec(e);if(!t)return null;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return zP(n)===e?n:null}function VP(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function HP(e,t){return Math.round((t.getTime()-e.getTime())/864e5)}function UP(e,t,n=new Date){let r=BP(e);if(!r)return e;let i=t.dates,a=HP(VP(n,0),r);return a===0?i.today:a===1?i.tomorrow:a===-1?i.yesterday:new Intl.DateTimeFormat(t.locale,{month:`short`,day:`numeric`,year:r.getFullYear()===n.getFullYear()?void 0:`numeric`}).format(r)}function WP(e,t){let n=BP(e);return n?new Intl.DateTimeFormat(t.locale,{dateStyle:`full`}).format(n):e}function GP(e,t,n,r=new Date){let i=t.dates,a=e.trim().toLowerCase(),o=!1;for(let e of new Set([i.remindWord.toLowerCase(),`remind`])){if(a.startsWith(e)){o=!0,a=a.slice(e.length).trim();break}if(a.length>=3&&e.startsWith(a)){o=!0,a=``;break}}if(o&&!n)return[];let s=VP(r,0);if(!a)return o?[1,0,7].map(e=>({date:zP(VP(s,e)),remind:o})):[{date:zP(s),remind:!1},...n?[{date:zP(VP(s,1)),remind:!0}]:[]];let c=[{words:[i.today,`today`],date:s},{words:[i.tomorrow,`tomorrow`],date:VP(s,1)},{words:[i.nextWeek,`next week`],date:VP(s,7)}];o||c.push({words:[i.yesterday,`yesterday`],date:VP(s,-1)});let l=e=>new Intl.DateTimeFormat(e,{weekday:`long`});for(let e=1;e<=7;e++){let n=VP(s,e);c.push({words:[l(t.locale).format(n),l(`en`).format(n)],date:n})}let u=[];BP(a)&&u.push({date:a,remind:o});for(let e of c)e.words.some(e=>e.toLowerCase().startsWith(a))&&u.push({date:zP(e.date),remind:o});return u.filter((e,t)=>u.findIndex(t=>t.date===e.date)===t).slice(0,5)}function KP(e,t){let n=e.toLowerCase().split(` `),r=[t.dates.remindWord,`remind`,t.dates.nextWeek.split(` `)[0]??``,`next`];return n.length>1&&n.length<=3&&r.some(e=>e&&e.toLowerCase()===n[0])}var qP=Jp.create({name:`dateMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{labels:void 0,me:()=>void 0,onOpen:void 0}},addAttributes(){return{date:{default:``,parseHTML:e=>e.getAttribute(`data-date`)??``,renderHTML:e=>({"data-date":e.date})},remind:{default:``,parseHTML:e=>e.getAttribute(`data-remind`)??``,renderHTML:e=>e.remind?{"data-remind":e.remind}:{}},tz:{default:``,parseHTML:e=>e.getAttribute(`data-tz`)??``,renderHTML:e=>e.tz?{"data-tz":e.tz}:{}}}},parseHTML(){return[{tag:`span[data-type="date"]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,A({"data-type":`date`,class:`dw-date`},t),UP(e.attrs.date,this.options.labels)]},renderText({node:e}){return UP(e.attrs.date,this.options.labels)},addNodeView(){let{labels:e,me:t,onOpen:n}=this.options;return({node:r,editor:i,getPos:a})=>{let o=r,s=document.createElement(`span`);s.dataset.type=`date`,s.className=`dw-date`,s.contentEditable=`false`,s.classList.toggle(`is-link`,!!n);let c=null,l=()=>{let t=o.attrs.date,n=o.attrs.remind,r=!!BP(t)&&t{let t=typeof a==`function`?a():void 0;t!==void 0&&i.chain().command(({tr:n})=>(n.setNodeMarkup(t,void 0,{...o.attrs,...e}),!0)).run()};return s.addEventListener(`mousedown`,r=>{c||(i.isEditable?(r.preventDefault(),c=XP(s,i,o,e,t(),u,()=>c=null,n)):n&&BP(o.attrs.date)&&(r.preventDefault(),n(o.attrs.date)))}),{dom:s,update(e){return e.type===o.type&&(o=e,l(),!0)},ignoreMutation:()=>!0,stopEvent:e=>s.contains(e.target)&&e.type!==`mousedown`,destroy(){c?.()}}}}});function JP(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function YP(e,t,n,r){let i={date:n.date,remind:n.remind&&r?r:``,tz:n.remind&&r?JP():``};e.chain().focus().insertContentAt(t,[{type:`dateMention`,attrs:i},{type:`text`,text:` `}]).run()}function XP(e,t,n,r,i,a,o,s){let c=r.dates,l=document.createElement(`div`);l.className=`dw-date-pop`,l.setAttribute(`role`,`dialog`),l.setAttribute(`aria-label`,c.edit);let u=document.createElement(`input`);u.type=`date`,u.className=`dw-input`,u.value=n.attrs.date,u.setAttribute(`aria-label`,c.edit),u.addEventListener(`change`,()=>{BP(u.value)&&a({date:u.value})}),l.append(u);let d=n.attrs.remind;if(d&&d!==i){let e=document.createElement(`p`);e.className=`dw-date-pop__note`,e.textContent=c.someoneElse,l.append(e)}else if(i){let e=document.createElement(`label`);e.className=`dw-date-pop__check`;let t=document.createElement(`input`);t.type=`checkbox`,t.checked=d===i,t.addEventListener(`change`,()=>a(t.checked?{remind:i,tz:JP()}:{remind:``,tz:``})),e.append(t,document.createTextNode(c.remindMe));let n=document.createElement(`span`);n.className=`dw-date-pop__note`,n.textContent=c.reminderAt,l.append(e,n)}if(s){let e=document.createElement(`button`);e.type=`button`,e.className=`dw-date-pop__open`,e.textContent=c.openJournal??`Open journal`,e.addEventListener(`click`,()=>{let e=n.attrs.date;h(),BP(e)&&s(e)}),l.append(e)}document.body.append(l);let f=wj(e,l,()=>{Oj(e,l,{placement:`bottom-start`,strategy:`fixed`,middleware:[Tj(6),Dj(),Ej({padding:8})]}).then(({x:e,y:t})=>Object.assign(l.style,{left:`${e}px`,top:`${t}px`}))}),p=t=>{!l.contains(t.target)&&!e.contains(t.target)&&h()},m=e=>{e.key===`Escape`&&(e.preventDefault(),h(),t.commands.focus())};function h(){f(),l.remove(),document.removeEventListener(`mousedown`,p,!0),document.removeEventListener(`keydown`,m,!0),o()}return document.addEventListener(`mousedown`,p,!0),document.addEventListener(`keydown`,m,!0),u.focus(),h}function ZP(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 QP(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 $P(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 eF(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:$P(e)}function tF({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&&!QP(r)}function nF({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function rF({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 iF({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 aF({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 oF({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Tj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Dj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function sF(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 cF({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&&sF(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=wj(c,o,()=>{Oj(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 lF({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,_=aF({editor:e,items:n}),v=oF({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:cF({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 uF=new D(`suggestion`);function dF({pluginKey:e=uF,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=ZP,shouldShow:ne,shouldResetDismissed:re}){let ie=S?.(),ae=r&&!i,oe=(n,r)=>eF(t,n,r,e);function se(e){return tF({...e,editor:t,shouldResetDismissed:re,effectiveAllowSpaces:ae})}let ce=t=>nF({view:t,pluginKeyRef:e});return new E({key:e,view:()=>lF({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:iF({editor:t,char:n,effectiveAllowSpaces:ae,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:te,allow:ee,shouldShow:ne,shouldKeepDismissed:se,pluginKey:e}),props:rF({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:ie,dispatchExit:ce})})}var fF=dF,pF=e=>`/p/${encodeURIComponent(e)}`,mF=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function hF(e){return mF.exec(e)?.[1]??``}function gF(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:pF(n.id)}}]},{type:`text`,text:` `}]).run()}async function _F(e,t,n){if(!t.create)return;let{from:r,to:i,empty:a}=e.state.selection,o=a?``:e.state.doc.textBetween(r,i,` `).trim().slice(0,200),s=await t.create(o);a||!o?gF(e,{from:r,to:r},s,n):e.chain().focus().setTextSelection({from:r,to:i}).setLink({href:pF(s.id)}).run()}var vF=Tp.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(fF({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:Ij({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>gF(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!hF(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function yF(e,t,n){e.chain().focus().deleteRange(t).insertSyncedPage(n).run()}var bF=Jp.create({name:`syncedPage`,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,pages:void 0,labels:null,onNavigate:void 0,nested:void 0}},addAttributes(){return{page:{default:``,parseHTML:e=>e.getAttribute(`data-page`)??``,renderHTML:e=>({"data-page":e.page})},title:{default:``,parseHTML:e=>e.getAttribute(`data-title`)??``,renderHTML:e=>e.title?{"data-title":e.title}:{}},icon:{default:``,parseHTML:e=>e.getAttribute(`data-icon`)??``,renderHTML:e=>e.icon?{"data-icon":e.icon}:{}},folded:{default:!1,parseHTML:e=>e.hasAttribute(`data-folded`),renderHTML:e=>e.folded?{"data-folded":``}:{}}}},parseHTML(){return[{tag:`div[data-type='syncedPage']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=`${e.attrs.icon?`${e.attrs.icon} `:``}${e.attrs.title||`…`}`;return[`div`,A(t,{"data-type":`syncedPage`}),[`a`,{href:pF(String(e.attrs.page))},n]]},addCommands(){return{insertSyncedPage:e=>({commands:t})=>t.insertContent([{type:this.name,attrs:{page:e.id,title:e.title,icon:e.icon??``}},{type:`paragraph`}])}},addProseMirrorPlugins(){let{pages:e}=this.options,t=this.options.labels;return e?[fF({editor:this.editor,pluginKey:new D(`syncedPages`),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:Ij({label:t.blocks.syncedPage,empty:t.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>yF(e.editor,e.range,t)})})]:[]},addNodeView(){let{host:e,onNavigate:t,nested:n}=this.options,r=this.options.labels.blocks;return({node:i,editor:a,getPos:o})=>{let s=i,c=String(s.attrs.page),l=document.createElement(`div`);l.className=`dw-synced`,l.dataset.type=`syncedPage`,l.contentEditable=`false`;let u=document.createElement(`div`);u.className=`dw-synced__head`;let d=document.createElement(`a`);d.className=`dw-synced__title`,d.href=pF(c);let f=Fj(`copy`,14);f.classList.add(`dw-synced__badge`);let p=document.createElement(`button`);p.type=`button`,p.className=`dw-synced__btn`;let m=document.createElement(`button`);m.type=`button`,m.className=`dw-synced__btn`,m.textContent=r.syncedOpen,u.append(f,d,p,m);let h=document.createElement(`div`);h.className=`dw-synced__body`,l.append(u,h);let g=e=>{e.preventDefault(),t?t(pF(c)):window.location.assign(pF(c))};d.addEventListener(`click`,g),m.addEventListener(`click`,g);let _=e=>{let t=typeof o==`function`?o():void 0;t!==void 0&&a.view.dispatch(a.state.tr.setNodeMarkup(t,void 0,{...s.attrs,...e}))},v=null,y=()=>v??!!s.attrs.folded;p.addEventListener(`click`,()=>{a.isEditable?_({folded:!s.attrs.folded}):(v=!y(),re())});let b=null,x=null,S=null,ee=e=>{let t=document.createElement(`p`);t.className=`dw-synced__note`,t.textContent=e,h.replaceChildren(t)},te=()=>{S?.(),x?.destroy(),b?.destroy(),S=null,x=null,b=null},ne=()=>{if(x||!e||!n)return;if(c===e.self)return ee(r.syncedSelf);b=e.open(c),ee(r.syncedLoading);let t=b,i=()=>{t.status===`denied`?(te(),ee(r.syncedDenied)):t.synced&&!x&&(h.replaceChildren(),x=new Vp({element:h,editable:!1,extensions:n(t.doc),editorProps:{attributes:{class:`dw-prose`}}}))};S=t.onChange(i),i()};function re(){let t=s.attrs.title;d.textContent=`${s.attrs.icon?`${s.attrs.icon} `:``}${t||r.syncedPage}`;let n=y();l.classList.toggle(`is-folded`,n),p.textContent=n?r.syncedUnfold:r.syncedFold,p.setAttribute(`aria-expanded`,String(!n)),n?(te(),h.replaceChildren()):e?ne():h.replaceChildren()}return re(),e?.meta(c).then(e=>{e?a.isEditable&&(e.title!==s.attrs.title||e.icon!==s.attrs.icon)?_({title:e.title,icon:e.icon}):d.textContent=`${e.icon?`${e.icon} `:``}${e.title||r.syncedPage}`:y()||ee(r.syncedDenied)}),{dom:l,update(e){return e.type!==s.type||String(e.attrs.page)!==c?!1:(s=e,re(),!0)},ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof globalThis.Node&&(u.contains(e.target)||h.contains(e.target)),destroy:te}}}});function xF(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 SF(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function CF(e,t){return new File([e],t,{type:`image/svg+xml`})}function wF(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function TF(e,t,n){return new Promise(r=>{let i=xF(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,${wF(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 EF(e,t,n){let r=xF(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var DF=!1;function OF(e){return Jp.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})=>(DF=!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 SF(i.host,u):``,o=e===`drawio`?await TF(i.drawioUrl||`https://embed.diagrams.net`,t,a):await EF(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(CF(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&kF(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()),DF&&(DF=!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 kF(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var AF=OF(`drawio`),jF=OF(`excalidraw`),MF=null;function NF(e){MF?.();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,()=>{Oj(e.anchor,t,{placement:`bottom-start`,middleware:[Tj(6),Dj(),Ej({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(),MF===d&&(MF=null),n||e.onCancel?.())}let d=()=>u();return MF=d,n.focus(),e.multiline||n.select(),d}var PF=[{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 FF(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of PF){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function IF(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var LF=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function RF(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;NF({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(IF(t)),onCancel:()=>e(``)})})}async function zF(e,t,n,r){let i=await RF(e,t,t.blocks.embedUrl);i&&(FF(i)?e.chain().focus().insertEmbed(i).run():await VF(e,i,n,r))}async function BF(e,t,n,r){let i=await RF(e,t,t.blocks.linkUrl);i&&await VF(e,i,n,r)}async function VF(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 HF=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=IF(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=IF(e),i=FF(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}: ${LF(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=LF(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`)}}}}),UF=Jp.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=IF(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=IF(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||``)||LF(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||``)||LF(n),r.append(a),t.append(r);let o=IF(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}}}}),WF=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,GF=Jp.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 qp({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[Up({find:WF,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});async function KF(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,view:jj(n.mime,n.name)?`preview`:`card`}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var qF=GF.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 JF(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({editor:e,commands:t})=>{let n=e.getAttributes(this.name);return!e.isActive(this.name)||!jj(n.mime,n.name)?!1:t.updateAttributes(this.name,{view:n.view===`preview`?`card`:`preview`})}}},parseHTML(){return[{tag:`div[data-type=file]`,getAttrs:e=>({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`)??``,view:e.getAttribute(`data-view`)===`preview`?`preview`:`card`})}]},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,"data-view":e.attrs.view}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e})=>{let{host:t,loadPdf:n,labels:r}=this.options,i=document.createElement(`div`);i.className=`dw-file-block`,i.setAttribute(`data-type`,`file`);let a=document.createElement(`div`);a.className=`dw-file`;let o=document.createElement(`a`);o.className=`dw-file__name`,o.target=`_blank`,o.rel=`noopener`;let s=document.createElement(`span`);s.className=`dw-file__size`,a.append(o,s),i.append(a);let c=null,l=null,u=``,d=e=>{let a=String(e.attrs.url??``),d=t?t.resolve(a):a;o.href=d,o.textContent=String(e.attrs.name??`file`),s.textContent=JF(Number(e.attrs.size??0)),!(e.attrs.view===`preview`&&jj(e.attrs.mime,e.attrs.name)&&a)||!n||!r?(l?.(),l=null,c?.remove(),c=null,u=``):u!==d&&(l?.(),c||(c=document.createElement(`div`),c.className=`dw-pdf`,c.tabIndex=0,c.setAttribute(`role`,`document`),i.append(c)),c.setAttribute(`aria-label`,String(e.attrs.name??`PDF`)),u=d,l=Mj(c,d,n,r))};return d(e),{dom:i,update:t=>t.type===e.type&&(d(t),!0),stopEvent:e=>!!c&&c.contains(e.target)&&e.type!==`mousedown`,ignoreMutation:()=>!0,destroy:()=>l?.()}}}}),XF=Tp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[ZF(()=>this.editor,e,this.options.onError)]:[]}});function ZF(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(KF(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 QF=new D(`dwFind`),$F=``;function eI(e,t,n=!1){if(!t)return[];let r=n?t:t.toLowerCase(),i=[];return e.descendants((e,t)=>{if(!e.isTextblock)return!0;let a=``,o=[];e.forEach((e,n)=>{let r=t+1+n;if(e.isText){let t=e.text??``;for(let e=0;ee.from>=r);return a===-1&&(a=i.length?0:-1),{term:t,caseSensitive:n,matches:i,current:a}}function nI(e,t){return t&&e.setSelection(w.create(e.doc,t.from,t.to)).scrollIntoView(),e}var rI=Tp.create({name:`findReplace`,addCommands(){return{setFind:(e,t=!1)=>({state:n,tr:r,dispatch:i})=>{let a=tI(n.doc,e,t,n.selection.from);return r.setMeta(QF,{term:e,caseSensitive:t,near:n.selection.from}),i&&i(nI(r,a.matches[a.current])),!0},findStep:e=>({state:t,tr:n,dispatch:r})=>{let i=QF.getState(t);if(!i?.matches.length)return!1;let a=(i.current+e+i.matches.length)%i.matches.length;return n.setMeta(QF,{current:a}),r&&r(nI(n,i.matches[a])),!0},replaceCurrent:e=>({state:t,tr:n,dispatch:r})=>{let i=QF.getState(t),a=i?.matches[i.current];if(!i||!a)return!1;if(r){n.insertText(e,a.from,a.to),n.setMeta(QF,{term:i.term,caseSensitive:i.caseSensitive,near:a.from+e.length});let t=tI(n.doc,i.term,i.caseSensitive,a.from+e.length);r(nI(n,t.matches[t.current]))}return!0},replaceAll:e=>({state:t,tr:n,dispatch:r})=>{let i=QF.getState(t);if(!i?.matches.length)return!1;if(r){for(let t of[...i.matches].reverse())n.insertText(e,t.from,t.to);n.setMeta(QF,{term:i.term,caseSensitive:i.caseSensitive,near:0}),r(n)}return!0},clearFind:()=>({tr:e,dispatch:t})=>(t&&t(e.setMeta(QF,{clear:!0})),!0)}},addProseMirrorPlugins(){let e={term:``,caseSensitive:!1,matches:[],current:-1};return[new E({key:QF,state:{init:()=>e,apply(t,n,r,i){let a=t.getMeta(QF);if(a&&`clear`in a)return e;if(a&&`term`in a)return tI(i.doc,a.term,a.caseSensitive,a.near);if(a&&`current`in a)return{...n,current:a.current};if(!n.term||!t.docChanged)return n;let o=n.matches[n.current]?.from??0;return tI(i.doc,n.term,n.caseSensitive,t.mapping.map(o))}},props:{decorations(e){let t=QF.getState(e);return t?.matches.length?xs.create(e.doc,t.matches.map((e,n)=>vs.inline(e.from,e.to,{class:n===t.current?`dw-find dw-find-current`:`dw-find`}))):null}}})]}}),iI={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`},otherHeadings:{label:`Other headings`,description:`Headings 4 to 6`},h4:{label:`Heading 4`,description:`A heading below level 3`},h5:{label:`Heading 5`,description:`A heading below level 4`},h6:{label:`Heading 6`,description:`The smallest heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},todo:{label:`To-do list`,description:`Tasks to tick off (or type [])`},callout:{label:`Callout`,description:`Set a note apart with an emoji and colour`},table:{label:`Table`,description:`Rows and columns`},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`},syncedPage:{label:`Synced page`,description:`Show another page here, always up to date`},newPage:{label:`New page`,description:`Make a page and link it here`},today:{label:`Today`,description:`Insert today's date`},tomorrow:{label:`Tomorrow`,description:`Insert tomorrow's date`},yesterday:{label:`Yesterday`,description:`Insert yesterday's date`},now:{label:`Now`,description:`Insert the date and time`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`,underline:`Underline`,color:`Colour`,textColor:`Text colour`,highlight:`Highlight`,noColor:`Default`,align:`Align`,alignLeft:`Align left`,alignCenter:`Align centre`,alignRight:`Align right`,math:`Inline math`,linkedPage:`Make a linked page`},colors:{gray:`Grey`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,teal:`Teal`,blue:`Blue`,purple:`Purple`,pink:`Pink`},table:{toolbar:`Table`,dragRow:`Drag to move the row`,dragColumn:`Drag to move the column`,moveRowUp:`Move row up`,moveRowDown:`Move row down`,moveColumnLeft:`Move column left`,moveColumnRight:`Move column right`,addRowBefore:`Add row above`,addRowAfter:`Add row below`,addColumnBefore:`Add column left`,addColumnAfter:`Add column right`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Header row`,mergeCells:`Merge cells`,splitCell:`Split cell`,deleteTable:`Delete table`},blockMenu:{open:`Drag to move, click for actions`,turnInto:`Turn into`,moveUp:`Move up`,moveDown:`Move down`,duplicate:`Duplicate`,copy:`Copy`,delete:`Delete`,showLineNumbers:`Show line numbers`,hideLineNumbers:`Hide line numbers`,showPages:`Show pages`,showAsFile:`Show as file`},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.`,syncedPage:`Synced page`,syncedOpen:`Open`,syncedFold:`Fold`,syncedUnfold:`Unfold`,syncedLoading:`Loading the page…`,syncedDenied:`You can't open this page.`,syncedSelf:`A page can't show itself.`,linkUrl:`Address of the page to link`,copyBlockLink:`Copy link to this block`,calloutEmoji:`Change emoji`,calloutColor:`Change colour`,pdfLoading:`Loading PDF…`,pdfPage:`Page {n}`},find:{find:`Find in page`,replace:`Replace with`,previous:`Previous match`,next:`Next match`,replaceOne:`Replace`,replaceAll:`Replace all`,matchCase:`Match case`,close:`Close`,count:`{current} of {total}`,none:`No matches`},dates:{today:`Today`,tomorrow:`Tomorrow`,yesterday:`Yesterday`,nextWeek:`Next week`,remindWord:`remind`,remindMe:`Remind me`,reminderAt:`Reminder at 9:00 on the day`,someoneElse:`Someone else set a reminder on this date.`,edit:`Change date`,openJournal:`Open journal`}},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(aI,`-$1`).toLowerCase(),sI={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},cI=/[&><"']/g,lI=e=>String(e).replace(cI,e=>sI[e]),uI=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?uI(e.body[0]):e:e.type===`font`?uI(e.body):e,dI=new Set([`mathord`,`textord`,`atom`]),fI=e=>dI.has(uI(e).type),pI=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`},mI={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 hI(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 gI(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:hI(Array.isArray(e.type)?e.type[0]:e.type)}function _I(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?gI(r):a?a(i):i}var vI=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(mI)){var n=mI[t];n&&_I(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=pI(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},yI=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 OI[kI[this.id]]}sub(){return OI[AI[this.id]]}fracNum(){return OI[jI[this.id]]}fracDen(){return OI[MI[this.id]]}cramp(){return OI[NI[this.id]]}text(){return OI[PI[this.id]]}isTight(){return this.size>=2}},bI=0,xI=1,SI=2,CI=3,wI=4,TI=5,EI=6,DI=7,OI=[new yI(bI,0,!1),new yI(xI,0,!0),new yI(SI,1,!1),new yI(CI,1,!0),new yI(wI,2,!1),new yI(TI,2,!0),new yI(EI,3,!1),new yI(DI,3,!0)],kI=[wI,TI,wI,TI,EI,DI,EI,DI],AI=[TI,TI,TI,TI,DI,DI,DI,DI],jI=[SI,CI,wI,TI,EI,DI,EI,DI],MI=[CI,CI,TI,TI,DI,DI,DI,DI],NI=[xI,xI,CI,CI,TI,TI,DI,DI],PI=[bI,xI,SI,CI,SI,CI,SI,CI],L={DISPLAY:OI[bI],TEXT:OI[SI],SCRIPT:OI[wI],SCRIPTSCRIPT:OI[EI]},FI=[{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 II(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var LI=[];FI.forEach(e=>e.blocks.forEach(e=>LI.push(...e)));function RI(e){for(var t=0;t=LI[t]&&e<=LI[t+1])return!0;return!1}var zI=e=>e+` `+e,BI=80,VI=function(e,t){return`M95,`+(622+e+t)+` +`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=aP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>PM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>FM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return LM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>BM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>VM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return UM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>nN(e,t),mergeCells:()=>({state:e,dispatch:t})=>KM(e,t),splitCell:()=>({state:e,dispatch:t})=>qM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>QM(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>QM(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>$M(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>KM(e,t)?!0:qM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>YM(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>tN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>tN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&AM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=SM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:sP,"Mod-Backspace":sP,Delete:sP,"Mod-Delete":sP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],zN({allowTableNodeSelection:this.options.allowTableNodeSelection}),vP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),bP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(yP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(XN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(ZN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(QN.configure(this.options.tableRow)),e}}),xP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function SP(){return[Ik.configure({HTMLAttributes:{class:`dw-tasks`}}),Fk.configure({nested:!0})]}function CP(){return[bP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var wP=xP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),TP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),EP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,DP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,OP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,A(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)(?!\s)([^=]*[^=\s])(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Hp({find:EP,type:this.type})]},addPasteRules(){return[Yp({find:DP,type:this.type})]}}),kP=[`gray`,`red`,`orange`,`yellow`,`green`,`teal`,`blue`,`purple`,`pink`],AP=e=>typeof e==`string`&&kP.includes(e),jP=_p.create({name:`textColor`,addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return AP(t)?t:null},renderHTML:e=>e.color?{"data-color":e.color}:{}}}},parseHTML(){return[{tag:`span[data-color]`,getAttrs:e=>AP(e.getAttribute(`data-color`))?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{class:`dw-text-color`}),0]},addCommands(){return{setTextColor:e=>({commands:t})=>t.setMark(this.name,{color:e}),unsetTextColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),MP=OP.extend({addOptions(){return{...this.parent(),multicolor:!0}},addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return AP(t)?t:null},renderHTML:e=>({"data-color":AP(e.color)?e.color:`yellow`})}}},renderHTML({HTMLAttributes:e}){return[`mark`,A(e,{class:`dw-highlight`}),0]}}),NP=`💡`;function PP(e){let t=e.trim();return t&&[...t].length<=4?t:``}var FP=Jp.create({name:`callout`,group:`block`,content:`block+`,defining:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{emoji:{default:NP,parseHTML:e=>PP(e.getAttribute(`data-emoji`)??``)||NP,renderHTML:e=>({"data-emoji":e.emoji})},color:{default:`blue`,parseHTML:e=>{let t=e.getAttribute(`data-color`);return AP(t)?t:`blue`},renderHTML:e=>({"data-color":e.color})}}},parseHTML(){return[{tag:`aside[data-type=callout]`,contentElement:e=>e.querySelector(`:scope > .callout-body`)??e}]},renderHTML({HTMLAttributes:e}){return[`aside`,A(e,{"data-type":`callout`,class:`dw-callout`}),0]},addCommands(){return{setCallout:e=>({commands:t})=>t.wrapIn(this.name,e),unsetCallout:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{$from:t,empty:n}=e.state.selection;if(!n||t.parentOffset>0)return!1;for(let n=t.depth-1;n>0;n--){if(t.node(n).type.name===this.name)return t.index(n)!==0||t.start(n+1)!==t.start()?!1:e.commands.lift(this.name);if(t.index(n)!==0)return!1}return!1}}},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=this.options.labels,i=document.createElement(`aside`);i.className=`dw-callout`,i.setAttribute(`data-type`,`callout`);let a=document.createElement(`div`);a.className=`dw-callout__side`,a.contentEditable=`false`;let o=document.createElement(`button`);o.type=`button`,o.className=`dw-callout__emoji`;let s=document.createElement(`button`);s.type=`button`,s.className=`dw-callout__color`,a.append(o,s);let c=document.createElement(`div`);c.className=`dw-callout__body`,i.append(a,c);let l=e,u=e=>{let r=t();typeof r==`number`&&n.isEditable&&n.view.dispatch(n.state.tr.setNodeMarkup(r,void 0,{...l.attrs,...e}))};o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>{if(!n.isEditable)return;let e=PP(window.prompt(r?.blocks.calloutEmoji??`Emoji`,l.attrs.emoji)??``);e&&u({emoji:e})}),s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`click`,()=>{let e=kP.indexOf(l.attrs.color);u({color:kP[(e+1)%kP.length]})});let d=()=>{i.setAttribute(`data-color`,String(l.attrs.color)),o.textContent=String(l.attrs.emoji);let e=r?.blocks.calloutEmoji??`Emoji`;o.setAttribute(`aria-label`,e),o.title=e;let t=r?.blocks.calloutColor??`Colour`;s.setAttribute(`aria-label`,t),s.title=t};return d(),{dom:i,contentDOM:c,update:t=>t.type===e.type&&(l=t,d(),!0),stopEvent:e=>a.contains(e.target),ignoreMutation:e=>a.contains(e.target)}}}}),IP={database:`Database`,untitled:`Untitled database`,untitledRow:`Untitled`,newRow:`New record`,addColumn:`Add property`,columnName:`Property name`,search:`Search records`,filter:`Filter`,sort:`Sort`,group:`Group`,properties:`Properties`,more:`More`,addView:`Add view`,viewName:`View name`,renameView:`Rename view`,duplicateView:`Duplicate view`,deleteView:`Delete view`,layout:`Layout`,viewTable:`Table`,viewKanban:`Kanban`,viewCalendar:`Calendar`,noValue:`No value`,checked:`Checked`,unchecked:`Unchecked`,noRows:`No records`,noMatches:`No records match`,rename:`Rename`,type:`Type`,hide:`Hide in view`,show:`Show in view`,sortAscending:`Sort ascending`,sortDescending:`Sort descending`,filterBy:`Filter by this property`,insertLeft:`Insert left`,insertRight:`Insert right`,moveLeft:`Move left`,moveRight:`Move right`,duplicate:`Duplicate`,deleteColumn:`Delete property`,typeTitle:`Title`,typeText:`Text`,typeNumber:`Number`,typeCheckbox:`Checkbox`,typeSelect:`Select`,typeMultiSelect:`Multi-select`,typeDate:`Date`,typeProgress:`Progress`,typeLink:`Link`,typeAttachment:`Attachment`,typeMember:`Member`,typeCreatedTime:`Created time`,typeCreatedBy:`Created by`,opContains:`contains`,opNotContains:`does not contain`,opIs:`is`,opIsNot:`is not`,opIsEmpty:`is empty`,opIsNotEmpty:`is not empty`,opGt:`is greater than`,opLt:`is less than`,opGte:`is at least`,opLte:`is at most`,opBefore:`is before`,opAfter:`is after`,opChecked:`is checked`,opUnchecked:`is not checked`,addFilter:`Add filter`,matchAll:`Every filter matches`,matchAny:`Any filter matches`,remove:`Remove`,value:`Value`,noFilters:`No filters yet`,addSort:`Add sort`,ascending:`Ascending`,descending:`Descending`,noSorts:`No sorts yet`,groupBy:`Group by`,noGrouping:`No grouping`,showAll:`Show all`,hideAll:`Hide all`,dateColumn:`Date property`,today:`Today`,previousMonth:`Previous month`,nextMonth:`Next month`,noDateColumn:`Add a date property to place records on the calendar.`,noDate:`No date ({n})`,noGroupColumn:`Add a select, checkbox or member property to sort cards into columns.`,openRow:`Open`,deleteRow:`Delete record`,duplicateRow:`Duplicate record`,insertAbove:`Insert above`,insertBelow:`Insert below`,deleteRows:`Delete`,selected:`{n} selected`,selectRow:`Select record`,dragRow:`Drag to move`,close:`Close`,expand:`Full width`,collapse:`Narrow`,previousRow:`Previous record`,nextRow:`Next record`,bodyPlaceholder:`Write about this record…`,bodyReadOnly:`This record has no notes.`,searchOptions:`Find or create a choice`,createOption:`Create “{n}”`,optionColor:`Colour`,deleteOption:`Delete choice`,renameOption:`Rename choice`,searchPeople:`Find a person`,noPeople:`Nobody found`,upload:`Upload a file`,linkPlaceholder:`Paste a link`,clear:`Clear`,exportCsv:`Export as CSV`,importCsv:`Import CSV`,imported:`Added {n} records`,copyNotice:`Copied {n} cells`,readOnly:`Only people who can edit the page can change this database.`,resize:`Drag to change the width`,groupAsDatabase:`Group as database`,done:`Done`},LP={title:`typeTitle`,text:`typeText`,number:`typeNumber`,checkbox:`typeCheckbox`,select:`typeSelect`,multiSelect:`typeMultiSelect`,date:`typeDate`,progress:`typeProgress`,link:`typeLink`,attachment:`typeAttachment`,member:`typeMember`,createdTime:`typeCreatedTime`,createdBy:`typeCreatedBy`},RP=(e,t)=>e[LP[t]],zP={contains:`opContains`,notContains:`opNotContains`,is:`opIs`,isNot:`opIsNot`,isEmpty:`opIsEmpty`,isNotEmpty:`opIsNotEmpty`,gt:`opGt`,lt:`opLt`,gte:`opGte`,lte:`opLte`,before:`opBefore`,after:`opAfter`,checked:`opChecked`,unchecked:`opUnchecked`},BP=(e,t)=>e[zP[t]],VP=(e,t)=>t===`kanban`?e.viewKanban:t===`calendar`?e.viewCalendar:e.viewTable,HP=(e,t)=>e.replace(`{n}`,String(t)),UP={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`},otherHeadings:{label:`Other headings`,description:`Headings 4 to 6`},h4:{label:`Heading 4`,description:`A heading below level 3`},h5:{label:`Heading 5`,description:`A heading below level 4`},h6:{label:`Heading 6`,description:`The smallest heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},todo:{label:`To-do list`,description:`Tasks to tick off (or type [])`},callout:{label:`Callout`,description:`Set a note apart with an emoji and colour`},table:{label:`Table`,description:`Rows and columns`},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`},syncedPage:{label:`Synced page`,description:`Show another page here, always up to date`},database:{label:`Database`,description:`Records in a table, board or calendar`},newPage:{label:`New page`,description:`Make a page and link it here`},today:{label:`Today`,description:`Insert today's date`},tomorrow:{label:`Tomorrow`,description:`Insert tomorrow's date`},yesterday:{label:`Yesterday`,description:`Insert yesterday's date`},now:{label:`Now`,description:`Insert the date and time`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`,underline:`Underline`,color:`Colour`,textColor:`Text colour`,highlight:`Highlight`,noColor:`Default`,align:`Align`,alignLeft:`Align left`,alignCenter:`Align centre`,alignRight:`Align right`,math:`Inline math`,linkedPage:`Make a linked page`},colors:{gray:`Grey`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,teal:`Teal`,blue:`Blue`,purple:`Purple`,pink:`Pink`},table:{toolbar:`Table`,dragRow:`Drag to move the row`,dragColumn:`Drag to move the column`,moveRowUp:`Move row up`,moveRowDown:`Move row down`,moveColumnLeft:`Move column left`,moveColumnRight:`Move column right`,addRowBefore:`Add row above`,addRowAfter:`Add row below`,addColumnBefore:`Add column left`,addColumnAfter:`Add column right`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Header row`,mergeCells:`Merge cells`,splitCell:`Split cell`,deleteTable:`Delete table`},blockMenu:{open:`Drag to move, click for actions`,turnInto:`Turn into`,moveUp:`Move up`,moveDown:`Move down`,duplicate:`Duplicate`,copy:`Copy`,delete:`Delete`,showLineNumbers:`Show line numbers`,hideLineNumbers:`Hide line numbers`,showPages:`Show pages`,showAsFile:`Show as file`},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.`,syncedPage:`Synced page`,syncedOpen:`Open`,syncedFold:`Fold`,syncedUnfold:`Unfold`,syncedLoading:`Loading the page…`,syncedDenied:`You can't open this page.`,syncedSelf:`A page can't show itself.`,linkUrl:`Address of the page to link`,copyBlockLink:`Copy link to this block`,calloutEmoji:`Change emoji`,calloutColor:`Change colour`,pdfLoading:`Loading PDF…`,pdfPage:`Page {n}`},find:{find:`Find in page`,replace:`Replace with`,previous:`Previous match`,next:`Next match`,replaceOne:`Replace`,replaceAll:`Replace all`,matchCase:`Match case`,close:`Close`,count:`{current} of {total}`,none:`No matches`},dates:{today:`Today`,tomorrow:`Tomorrow`,yesterday:`Yesterday`,nextWeek:`Next week`,remindWord:`remind`,remindMe:`Remind me`,reminderAt:`Reminder at 9:00 on the day`,someoneElse:`Someone else set a reminder on this date.`,edit:`Change date`,openJournal:`Open journal`},database:IP};function I(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))if(n!=null&&n!==!1){if(e===`class`)r.className=String(n);else if(e===`on`)for(let[e,t]of Object.entries(n))r.addEventListener(e,t);else e===`dataset`?Object.assign(r.dataset,n):e===`style`?Object.assign(r.style,n):e in r&&typeof n!=`string`?r[e]=n:r.setAttribute(e,n===!0?``:String(n))}for(let e of n.flat())e!=null&&e!==!1&&r.append(e);return r}function WP(e,t=16){return Rj(e,t)}function GP(e,t,n,r){let i=I(`button`,{type:`button`,class:r?`dw-db__btn`:`dw-db__btn dw-db__btn--icon`,title:t,"aria-label":t},WP(e,15),r?I(`span`,{},r):null);return i.addEventListener(`click`,e=>{e.preventDefault(),n(e)}),i}var KP=null;function qP(e,t,n={}){KP?.close();let r=I(`div`,{class:`dw-db-pop ${n.class??``}`,role:`dialog`,"aria-label":n.label}),i=!1,a=()=>{i||(i=!0,c(),r.remove(),document.removeEventListener(`mousedown`,o,!0),document.removeEventListener(`keydown`,s,!0),KP?.box===r&&(KP=null),n.onClose?.())},o=t=>{let n=t.target;r.contains(n)||e.contains(n)||n instanceof Element&&n.closest(`.dw-block-menu`)||a()},s=t=>{t.key===`Escape`&&!document.querySelector(`.dw-block-menu`)&&(t.preventDefault(),t.stopPropagation(),a(),e instanceof HTMLElement&&e.focus())};document.body.append(r);let c=Dj(e,r,()=>{jj(e,r,{placement:n.placement??`bottom-start`,strategy:`fixed`,middleware:[Oj(4),Aj(),kj({padding:8})]}).then(({x:e,y:t})=>Object.assign(r.style,{left:`${e}px`,top:`${t}px`}))});return document.addEventListener(`mousedown`,o,!0),document.addEventListener(`keydown`,s,!0),t(r,a),KP={box:r,close:a},KP}function JP(){KP?.close()}function YP(e,t){let n=I(`input`,{type:t.type??`text`,class:t.class??`dw-db-input`,placeholder:t.placeholder,"aria-label":t.label??t.placeholder});n.value=e;let r=!1,i=()=>{r||(r=!0,t.onCommit(n.value))};return n.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(r=!0,t.onCancel?.())}),n.addEventListener(`blur`,i),n}function XP(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=I(`a`,{href:r,download:e});document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function ZP(e){return new Promise(t=>{let n=I(`input`,{type:`file`,accept:e});n.onchange=()=>t(n.files?.[0]??null),n.click()})}var QP=[`title`,`text`,`number`,`checkbox`,`select`,`multiSelect`,`date`,`progress`,`link`,`attachment`,`member`,`createdTime`,`createdBy`],$P=QP.filter(e=>e!==`title`),eF=[`table`,`kanban`,`calendar`];function tF(){let e=new Uint8Array(6);return crypto.getRandomValues(e),[...e].map(e=>e.toString(36).padStart(2,`0`)).join(``).slice(0,10)}function nF(e,t,n){let r=n.find(e=>rF.includes(e.type)),i=n.find(e=>e.type===`date`||e.type===`createdTime`);return{id:tF(),name:t,type:e,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:e===`kanban`?r?.id??null:null,dateColumn:e===`calendar`?i?.id??null:null,widths:{}}}var rF=[`select`,`multiSelect`,`checkbox`,`member`,`createdBy`];function iF(e){let t=sF(e)?e:{},n=(Array.isArray(t.columns)?t.columns:[]).flatMap(e=>{if(!sF(e)||typeof e.id!=`string`||!e.id)return[];let t=QP.includes(String(e.type))?e.type:`text`,n={id:e.id,name:typeof e.name==`string`?e.name:``,type:t};return Array.isArray(e.options)&&(n.options=e.options.flatMap(aF)),[n]});n.some(e=>e.type===`title`)||n.unshift({id:tF(),name:``,type:`title`});let r=(Array.isArray(t.rows)?t.rows:[]).flatMap(e=>{if(!sF(e)||typeof e.id!=`string`||!e.id)return[];let t={id:e.id,cells:sF(e.cells)?{...e.cells}:{},createdAt:typeof e.createdAt==`number`?e.createdAt:0,createdBy:oF(e.createdBy)};return Array.isArray(e.body)&&e.body.length&&(t.body=e.body,t.hasBody=!0),[t]}),i=new Set(n.map(e=>e.id)),a=(Array.isArray(t.views)?t.views:[]).flatMap(e=>{if(!sF(e)||typeof e.id!=`string`||!e.id)return[];let t=eF.includes(String(e.type))?e.type:`table`;return[{id:e.id,name:typeof e.name==`string`?e.name:``,type:t,hidden:Array.isArray(e.hidden)?e.hidden.filter(e=>typeof e==`string`):[],filters:Array.isArray(e.filters)?e.filters.filter(e=>sF(e)&&typeof e.column==`string`&&typeof e.op==`string`):[],filterMode:e.filterMode===`or`?`or`:`and`,sorts:Array.isArray(e.sorts)?e.sorts.flatMap(e=>sF(e)&&typeof e.column==`string`?[{column:e.column,desc:!!e.desc}]:[]):[],groupBy:typeof e.groupBy==`string`&&i.has(e.groupBy)?e.groupBy:null,dateColumn:typeof e.dateColumn==`string`&&i.has(e.dateColumn)?e.dateColumn:null,widths:sF(e.widths)?Object.fromEntries(Object.entries(e.widths).filter(e=>typeof e[1]==`number`)):{}}]});return{title:typeof t.title==`string`?t.title:``,columns:n,rows:r,views:a}}function aF(e){return!sF(e)||typeof e.id!=`string`?[]:[{id:e.id,name:typeof e.name==`string`?e.name:``,color:AP(e.color)?e.color:`gray`}]}function oF(e){return sF(e)&&typeof e.id==`string`?{id:e.id,name:typeof e.name==`string`?e.name:``}:null}function sF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cF(e){return e.columns.find(e=>e.type===`title`)??e.columns[0]}function lF(e,t){return t.type===`createdTime`?e.createdAt||null:t.type===`createdBy`?e.createdBy?[e.createdBy]:[]:e.cells[t.id]}function uF(e){return e==null||e===``||e===!1||Array.isArray(e)&&e.length===0}function dF(e){return typeof e==`number`&&e>0?fF(new Date(e)):typeof e==`string`&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):``}function fF(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function pF(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e.trim().replace(`,`,`.`));return Number.isFinite(t)?t:null}return null}function mF(e){return Array.isArray(e)?e:[]}function hF(e,t){let n=lF(e,t);switch(t.type){case`title`:case`text`:case`link`:return typeof n==`string`?n:``;case`number`:case`progress`:{let e=pF(n);return e===null?``:String(e)}case`checkbox`:return n===!0?`true`:`false`;case`select`:return t.options?.find(e=>e.id===n)?.name??``;case`multiSelect`:return mF(n).map(e=>t.options?.find(t=>t.id===e)?.name).filter(e=>!!e).join(`, `);case`date`:case`createdTime`:return dF(n);case`attachment`:return mF(n).map(e=>e?.name??``).join(`, `);case`member`:case`createdBy`:return mF(n).map(e=>e?.name??``).join(`, `)}}function gF(e){switch(e){case`number`:case`progress`:return[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`,`isEmpty`,`isNotEmpty`];case`checkbox`:return[`checked`,`unchecked`];case`select`:return[`is`,`isNot`,`isEmpty`,`isNotEmpty`];case`multiSelect`:case`member`:case`createdBy`:return[`contains`,`notContains`,`isEmpty`,`isNotEmpty`];case`date`:case`createdTime`:return[`is`,`before`,`after`,`isEmpty`,`isNotEmpty`];case`attachment`:return[`isEmpty`,`isNotEmpty`];default:return[`contains`,`notContains`,`is`,`isNot`,`isEmpty`,`isNotEmpty`]}}var _F=e=>![`isEmpty`,`isNotEmpty`,`checked`,`unchecked`].includes(e);function vF(e,t,n){let r=lF(e,t);if(n.op===`isEmpty`)return uF(r)||hF(e,t)===``;if(n.op===`isNotEmpty`)return!(uF(r)||hF(e,t)===``);if(n.op===`checked`)return r===!0;if(n.op===`unchecked`)return r!==!0;if(n.value===void 0||n.value===null||n.value===``)return!0;switch(t.type){case`number`:case`progress`:{let e=pF(r),t=pF(n.value);return t===null?!0:e===null?n.op===`isNot`:{is:e===t,isNot:e!==t,gt:e>t,lt:e=t,lte:e<=t}[n.op]}case`select`:return n.op===`is`?r===n.value:r!==n.value;case`multiSelect`:{let e=mF(r).includes(String(n.value));return n.op===`notContains`?!e:e}case`member`:case`createdBy`:{let e=String(n.value).toLowerCase(),t=mF(r).some(t=>t?.id===n.value||t?.name?.toLowerCase().includes(e));return n.op===`notContains`?!t:t}case`date`:case`createdTime`:{let e=dF(r),t=dF(n.value);return e?n.op===`before`?et:e===t:!1}default:{let r=hF(e,t).toLowerCase(),i=String(n.value).toLowerCase();switch(n.op){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`is`:return r===i;case`isNot`:return r!==i;default:return!0}}}}function yF(e,t,n){let r=hF(e,n)===``&&n.type!==`checkbox`,i=hF(t,n)===``&&n.type!==`checkbox`;if(r||i)return r===i?0:r?1:-1;switch(n.type){case`number`:case`progress`:return(pF(lF(e,n))??0)-(pF(lF(t,n))??0);case`checkbox`:return Number(lF(e,n)===!0)-Number(lF(t,n)===!0);case`createdTime`:return e.createdAt-t.createdAt;case`select`:{let r=e=>n.options?.findIndex(t=>t.id===lF(e,n))??-1;return r(e)-r(t)}default:return hF(e,n).localeCompare(hF(t,n),void 0,{numeric:!0,sensitivity:`base`})}}function bF(e,t,n=``){let r=new Map(e.columns.map(e=>[e.id,e])),i=t.filters.flatMap(e=>{let t=r.get(e.column);return t?[{f:e,col:t}]:[]}),a=n.trim().toLowerCase(),o=e.rows.filter(n=>{if(i.length){let e=({f:e,col:t})=>vF(n,t,e);if(t.filterMode===`or`?!i.some(e):!i.every(e))return!1}return!a||e.columns.some(e=>hF(n,e).toLowerCase().includes(a))}),s=t.sorts.flatMap(e=>{let t=r.get(e.column);return t?[{col:t,desc:e.desc}]:[]});return s.length&&(o=o.map((e,t)=>({r:e,i:t})).sort((e,t)=>{for(let n of s){let r=yF(e.r,t.r,n.col);if(r!==0){let i=hF(e.r,n.col)===``||hF(t.r,n.col)===``;return n.desc&&!(i&&n.col.type!==`checkbox`)?-r:r}}return e.i-t.i}).map(e=>e.r)),o}function xF(e,t){return e.columns.filter(e=>e.type===`title`||!t.hidden.includes(e.id))}function SF(e,t,n,r,i){let a=new Map,o=(e,t,n)=>(a.has(e)||a.set(e,{key:e,label:t,color:n,rows:[]}),a.get(e));if(t.type===`checkbox`)o(`false`,i),o(`true`,r);else{o(``,n);for(let e of t.options??[])o(e.id,e.name,e.color)}for(let n of e)for(let e of wF(n,t))(a.get(e)??o(e,CF(n,t,e)||e)).rows.push(n);return[...a.values()]}function CF(e,t,n){return mF(lF(e,t)).find(e=>e?.id===n)?.name??``}function wF(e,t){let n=lF(e,t);switch(t.type){case`checkbox`:return[n===!0?`true`:`false`];case`select`:return[typeof n==`string`&&t.options?.some(e=>e.id===n)?n:``];case`multiSelect`:{let e=mF(n).filter(e=>t.options?.some(t=>t.id===e));return e.length?e:[``]}case`member`:case`createdBy`:{let e=mF(n).flatMap(e=>e?.id?[e.id]:[]);return e.length?e:[``]}default:return[``]}}function TF(e,t,n,r,i=[]){let a=lF(e,t);switch(t.type){case`checkbox`:return r===`true`;case`select`:return r||null;case`multiSelect`:{let e=mF(a).filter(e=>e!==n&&e!==r);return r?[...e,r]:e}case`member`:{let e=mF(a).filter(e=>e?.id!==n&&e?.id!==r),t=i.find(e=>e.id===r)??mF(a).find(e=>e?.id===r);return r&&t?[...e,t]:e}default:return a}}function EF(e){let t=kP.filter(e=>e!==`gray`);return t[e.length%t.length]}function DF(e,t,n,r){if(t.type===n)return{value:e,options:r};let i=hF({id:``,cells:{[t.id]:e},createdAt:0,createdBy:null},t),a=e=>{let t=e.trim();if(!t)return null;let n=r.find(e=>e.name.toLowerCase()===t.toLowerCase());return n||(n={id:tF(),name:t,color:EF(r)},r=[...r,n]),n.id};switch(n){case`title`:case`text`:case`link`:return{value:i||null,options:r};case`number`:return{value:pF(i),options:r};case`progress`:{let e=pF(i);return{value:e===null?null:Math.max(0,Math.min(100,Math.round(e))),options:r}}case`checkbox`:return{value:[`true`,`yes`,`1`,`x`,`✓`,`done`].includes(i.trim().toLowerCase()),options:r};case`select`:return{value:a(i.split(`,`)[0]??``),options:r};case`multiSelect`:{let e=i.split(`,`).flatMap(e=>{let t=a(e);return t?[t]:[]});return{value:[...new Set(e)],options:r}}case`date`:return{value:dF(i)||null,options:r};case`member`:return{value:t.type===`member`||t.type===`createdBy`?e:[],options:r};default:return{value:null,options:r}}}function OF(e,t,n=1){let r=(new Date(e,t,1).getDay()-n+7)%7,i=new Date(e,t,1-r),a=new Date(e,t+1,0).getDate(),o=Math.ceil((r+a)/7);return Array.from({length:o*7},(e,t)=>fF(new Date(i.getFullYear(),i.getMonth(),i.getDate()+t)))}var kF={title:`text`,text:`type`,number:`sigma`,checkbox:`todo`,select:`tag`,multiSelect:`layers`,date:`calendar`,progress:`sliders`,link:`link`,attachment:`paperclip`,member:`users`,createdTime:`clock`,createdBy:`at`},AF=[`title`,`text`,`number`,`link`],jF=[`createdTime`,`createdBy`];function MF(e,t){let[n,r,i]=e.split(`-`).map(Number);return!n||!r||!i?e:new Date(n,r-1,i).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function NF(e,t,n){let r=I(`span`,{class:`dw-db-tag`,dataset:{color:t??`gray`}},e);if(n){let e=I(`button`,{type:`button`,class:`dw-db-tag__x`,"aria-label":`×`},`×`);e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{e.stopPropagation(),n()}),r.append(e)}return r}function PF(e){try{let t=new URL(e.includes(`://`)?e:`https://${e}`);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}function FF(e,t,n){let r=lF(t,n),i=e.labels;switch(n.type){case`title`:{let e=typeof r==`string`?r:``;return I(`span`,{class:e?`dw-db-cell__title`:`dw-db-cell__title is-empty`},e||i.untitledRow)}case`text`:return I(`span`,{class:`dw-db-cell__text`},typeof r==`string`?r:``);case`number`:{let t=pF(r);return I(`span`,{class:`dw-db-cell__number`},t===null?``:t.toLocaleString(e.locale))}case`checkbox`:return I(`span`,{class:r===!0?`dw-db-check is-on`:`dw-db-check`,role:`img`,"aria-label":r===!0?i.checked:i.unchecked},r===!0?WP(`check`,13):null);case`select`:{let e=n.options?.find(e=>e.id===r);return I(`span`,{class:`dw-db-tags`},e?NF(e.name,e.color):null)}case`multiSelect`:return I(`span`,{class:`dw-db-tags`},mF(r).flatMap(e=>{let t=n.options?.find(t=>t.id===e);return t?[NF(t.name,t.color)]:[]}));case`date`:case`createdTime`:{let t=dF(r);return I(`span`,{class:`dw-db-cell__text`},t?MF(t,e.locale):``)}case`progress`:{let e=pF(r);if(e===null)return I(`span`);let t=Math.max(0,Math.min(100,e));return I(`span`,{class:`dw-db-progress`},I(`span`,{class:`dw-db-progress__bar`},I(`span`,{class:`dw-db-progress__fill`,style:{width:`${t}%`}})),I(`span`,{class:`dw-db-progress__num`},`${t}%`))}case`link`:{let e=typeof r==`string`?r:``,t=e?PF(e):null;if(!t)return I(`span`,{class:`dw-db-cell__text`},e);let n=I(`a`,{class:`dw-db-cell__link`,href:t,target:`_blank`,rel:`noopener noreferrer`},e);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}case`attachment`:return I(`span`,{class:`dw-db-tags`},mF(r).map(t=>{let n=I(`a`,{class:`dw-db-file`,href:e.files?e.files.resolve(t.src):t.src,target:`_blank`,rel:`noopener noreferrer`},WP(`paperclip`,12),t.name);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}));case`member`:case`createdBy`:return I(`span`,{class:`dw-db-tags`},mF(r).map(e=>I(`span`,{class:`dw-db-person`},I(`span`,{class:`dw-db-person__dot`},(e?.name||`?`).slice(0,1).toUpperCase()),e?.name??``)))}}function IF(e,t,n,r,i){let a=e.store;if(!a||jF.includes(r.type))return i.onDone();let o=lF(n,r);if(r.type===`checkbox`)return a.setCell(n.id,r.id,o!==!0),i.onDone();e.setEditing(!0);let s=t=>{e.setEditing(!1),i.onDone(t)};if(AF.includes(r.type)){let e=i.initial??(r.type===`number`?pF(o)?.toString()??``:typeof o==`string`?o:``),c,l=YP(e,{class:`dw-db-cell__input`,type:(r.type,`text`),label:r.name,onCommit:e=>{let t=e.trim(),i=r.type===`number`?pF(t):r.type===`title`||r.type===`text`?e:t;i!==(o??null)&&(i!==``||o!==void 0)&&a.setCell(n.id,r.id,i),s(c)},onCancel:()=>s()});l.addEventListener(`keydown`,e=>{e.key===`Enter`&&(c=`down`),e.key===`Tab`&&(e.preventDefault(),c=e.shiftKey?`left`:`right`,l.blur())}),t.replaceChildren(l),t.classList.add(`is-editing`),l.focus(),i.initial===void 0?l.select():l.setSelectionRange(l.value.length,l.value.length);return}let c=(e,n=``)=>qP(t,e,{class:n,onClose:()=>s(),label:r.name});switch(r.type){case`select`:case`multiSelect`:c((t,a)=>LF(e,t,n,r,a,i.initial),`dw-db-pop--choices`);break;case`date`:c((t,i)=>{let s=I(`input`,{type:`date`,class:`dw-db-input`,"aria-label":r.name});s.value=dF(o),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,s.value||null)),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&i()});let c=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.clear);c.addEventListener(`click`,()=>{a.setCell(n.id,r.id,null),i()});let l=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.today);l.addEventListener(`click`,()=>{let e=new Date;a.setCell(n.id,r.id,`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`),i()}),t.append(s,I(`div`,{class:`dw-db-pop__row`},l,c)),s.focus({preventScroll:!0})});break;case`progress`:c((e,t)=>{let i=pF(o)??0,s=I(`input`,{type:`range`,min:`0`,max:`100`,step:`1`,class:`dw-db-range`,"aria-label":r.name});s.value=String(i);let c=I(`span`,{class:`dw-db-progress__num`},`${i}%`);s.addEventListener(`input`,()=>c.textContent=`${s.value}%`),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,Number(s.value))),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&t()}),e.append(I(`div`,{class:`dw-db-pop__row`},s,c)),s.focus({preventScroll:!0})});break;case`member`:c((t,i)=>RF(e,t,n,r,i),`dw-db-pop--choices`);break;case`attachment`:c(t=>zF(e,t,n,r),`dw-db-pop--choices`);break;default:s()}}function LF(e,t,n,r,i,a){let o=e.store,s=e.labels,c=r.type===`multiSelect`,l=[...r.options??[]],u=c?mF(lF(n,r)):[String(lF(n,r)??``)].filter(Boolean),d=0,f=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),p=I(`input`,{class:`dw-db-input`,placeholder:s.searchOptions,"aria-label":s.searchOptions});p.value=a??``;let m=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(f,p,m);let h=()=>o.setCell(n.id,r.id,c?u:u[0]??null),g=e=>{u=c?u.includes(e)?u.filter(t=>t!==e):[...u,e]:u[0]===e?[]:[e],h(),c?b():i()},_=e=>{let t={id:tF(),name:e,color:EF(l)};l=[...l,t],o.tx(()=>{o.setOptions(r.id,l),u=c?[...u,t.id]:[t.id],h()}),p.value=``,c?b():i()},v=(t,n)=>{Wj(t,[{id:`rename`,label:s.renameOption,icon:`pencil`,run:()=>{let e=window.prompt(s.renameOption,n.name)?.trim();e&&(l=l.map(t=>t.id===n.id?{...t,name:e}:t),o.setOptions(r.id,l),b())}},{id:`color`,label:s.optionColor,icon:`palette`,children:kP.map(t=>({id:t,label:e.colorNames[t]??t,icon:t===n.color?`check`:`drop`,run:()=>{l=l.map(e=>e.id===n.id?{...e,color:t}:e),o.setOptions(r.id,l),b()}}))},{id:`delete`,label:s.deleteOption,icon:`trash`,danger:!0,run:()=>{l=l.filter(e=>e.id!==n.id),u=u.filter(e=>e!==n.id),o.setOptions(r.id,l),b()}}],s.optionColor,()=>p.focus())},y=[];function b(){f.replaceChildren(...u.flatMap(e=>{let t=l.find(t=>t.id===e);return t?[NF(t.name,t.color,()=>g(e))]:[]}));let e=p.value.trim();y=l.filter(t=>t.name.toLowerCase().includes(e.toLowerCase())).map(e=>({kind:`option`,o:e})),e&&!l.some(t=>t.name.toLowerCase()===e.toLowerCase())&&y.push({kind:`create`,name:e}),d=Math.min(d,Math.max(0,y.length-1)),m.replaceChildren(...y.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===d?` is-active`:``}`,role:`option`,"aria-selected":String(e.kind===`option`&&u.includes(e.o.id))});if(n.addEventListener(`mousedown`,e=>e.preventDefault()),e.kind===`option`){n.append(I(`span`,{class:`dw-db-pop__check`},u.includes(e.o.id)?WP(`check`,13):null),NF(e.o.name,e.o.color));let t=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon dw-db-pop__more`,"aria-label":s.optionColor},WP(`more`,14));t.addEventListener(`click`,n=>{n.stopPropagation(),v(t,e.o)}),n.append(t),n.addEventListener(`click`,()=>g(e.o.id))}else n.append(I(`span`,{class:`dw-db-pop__check`},WP(`plus`,13)),I(`span`,{},HP(s.createOption,e.name))),n.addEventListener(`click`,()=>_(e.name));return n}))}p.addEventListener(`input`,()=>{d=0,b()}),p.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),y.length&&(d=(d+(e.key===`ArrowDown`?1:-1)+y.length)%y.length),b();else if(e.key===`Enter`){e.preventDefault();let t=y[d];t?.kind===`option`?g(t.o.id):t?.kind===`create`?_(t.name):i()}else e.key===`Backspace`&&!p.value&&c&&u.length&&g(u[u.length-1])}),b(),p.focus({preventScroll:!0}),p.setSelectionRange(p.value.length,p.value.length)}function RF(e,t,n,r,i){let a=e.store,o=e.labels,s=mF(lF(n,r)).filter(e=>e?.id),c=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),l=I(`input`,{class:`dw-db-input`,placeholder:o.searchPeople,"aria-label":o.searchPeople}),u=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(c,l,u);let d=()=>a.setCell(n.id,r.id,s),f=()=>c.replaceChildren(...s.map(e=>NF(e.name,`gray`,()=>{s=s.filter(t=>t.id!==e.id),d(),f()}))),p=0,m=[],h=0,g=()=>{u.replaceChildren(...m.length?m.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===h?` is-active`:``}`,role:`option`},I(`span`,{class:`dw-db-person__dot`},(e.name||`?`).slice(0,1).toUpperCase()),I(`span`,{},e.name));return n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>_(e)),n}):[I(`div`,{class:`dw-db-pop__empty`},l.value.trim()?o.noPeople:``)])},_=e=>{s.some(t=>t.id===e.id)||(s=[...s,e]),d(),l.value=``,m=[],f(),g()};l.addEventListener(`input`,async()=>{let t=l.value.trim(),n=++p,r=e.people&&t?await e.people.search(t).catch(()=>[]):[];n===p&&(m=r.slice(0,8).map(e=>({id:e.id,name:e.label})),h=0,g())}),l.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),m.length&&(h=(h+(e.key===`ArrowDown`?1:-1)+m.length)%m.length),g();else if(e.key===`Enter`){e.preventDefault();let t=m[h];t?_(t):i()}}),f(),g(),l.focus({preventScroll:!0})}function zF(e,t,n,r){let i=e.store,a=e.labels,o=mF(lF(n,r)).filter(e=>e?.src),s=I(`div`,{class:`dw-db-pop__list`}),c=()=>s.replaceChildren(...o.map((t,s)=>{let l=e.files?e.files.resolve(t.src):t.src,u=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":a.remove,title:a.remove},WP(`trash`,14));return u.addEventListener(`click`,()=>{o=o.filter((e,t)=>t!==s),i.setCell(n.id,r.id,o),c()}),I(`div`,{class:`dw-db-pop__item`},I(`a`,{class:`dw-db-file`,href:l,target:`_blank`,rel:`noopener noreferrer`},WP(`paperclip`,12),t.name),u)}));t.append(s);let l=e.files?.upload;if(l){let s=I(`button`,{type:`button`,class:`dw-db__btn`},WP(`upload`,14),I(`span`,{},a.upload));s.addEventListener(`click`,()=>{let t=I(`input`,{type:`file`,multiple:!0});t.onchange=async()=>{for(let a of[...t.files??[]])try{let t=await l.call(e.files,a);o=[...o,{name:t.name,src:t.url,size:t.size,mime:t.mime}],i.setCell(n.id,r.id,o),c()}catch{}},t.click()}),t.append(I(`div`,{class:`dw-db-pop__row`},s))}c()}var BF=class{host;db;rowId;order;onClose;dom;panel;head=I(`div`,{class:`dw-db-peek__head`});props=I(`div`,{class:`dw-db-peek__props`});bodyEl=I(`div`,{class:`dw-db-peek__body`});unmount=null;editing=0;pending=!1;wide=!1;returnFocus;constructor(e,t,n,r,i){this.host=e,this.db=t,this.rowId=n,this.order=r,this.onClose=i,this.returnFocus=document.activeElement,this.panel=I(`div`,{class:`dw-db-peek__panel`,role:`dialog`,"aria-modal":`true`,tabIndex:-1},this.head,this.props,this.bodyEl),this.dom=I(`div`,{class:`dw-db-peek`},this.panel),this.dom.addEventListener(`mousedown`,e=>{e.target===this.dom&&this.close()}),this.dom.addEventListener(`keydown`,e=>{e.key===`Escape`&&!document.querySelector(`.dw-db-pop, .dw-block-menu`)&&(e.preventDefault(),e.stopPropagation(),this.close())}),document.body.append(this.dom),this.draw(!0),this.panel.focus({preventScroll:!0})}get row(){return this.rowId}ctx(){return{...this.host.ctx,db:this.db,openRow:e=>this.show(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw(!1))}}}update(e,t){if(this.db=e,t&&(this.host={...this.host,ctx:{...this.host.ctx,...t}}),!e.rows.some(e=>e.id===this.rowId))return this.close();this.editing?this.pending=!0:this.draw(!1)}show(e){e!==this.rowId&&(this.rowId=e,this.draw(!0))}draw(e){let t=this.db.rows.find(e=>e.id===this.rowId);if(!t)return;let n=this.ctx(),r=n.labels,i=n.store;this.panel.classList.toggle(`is-wide`,this.wide);let a=this.order.indexOf(this.rowId),o=GP(`chevron-up`,r.previousRow,()=>this.show(this.order[a-1])),s=GP(`chevron-down`,r.nextRow,()=>this.show(this.order[a+1]));o.disabled=a<=0,s.disabled=a<0||a>=this.order.length-1,this.head.replaceChildren(I(`span`,{class:`dw-db-peek__db`},WP(`database`,14),this.db.title||r.untitled),I(`span`,{class:`dw-db-peek__grow`}),o,s,GP((this.wide,`width`),this.wide?r.collapse:r.expand,()=>{this.wide=!this.wide,this.panel.classList.toggle(`is-wide`,this.wide)}),GP(`close`,r.close,()=>this.close()));let c=cF(this.db),l=String(lF(t,c)??``),u=i?(()=>{let e=I(`input`,{class:`dw-db-peek__title`,placeholder:r.untitledRow,"aria-label":c.name||r.typeTitle});return e.value=l,e.addEventListener(`focus`,()=>n.setEditing(!0)),e.addEventListener(`blur`,()=>{e.value!==l&&i.setCell(t.id,c.id,e.value),n.setEditing(!1)}),e.addEventListener(`keydown`,t=>{t.stopPropagation(),t.key===`Enter`&&e.blur()}),e})():I(`h2`,{class:`dw-db-peek__title`},l||r.untitledRow);this.panel.setAttribute(`aria-label`,l||r.untitledRow);let d=[u,...this.db.columns.filter(e=>e.type!==`title`).map(e=>{let a=I(`div`,{class:`dw-db-peek__value dw-db-t__cell--${e.type}`,tabIndex:i&&!jF.includes(e.type)?0:-1},FF(n,t,e)),o=()=>{i&&IF(n,a,t,e,{onDone:()=>this.draw(!1)})};return a.addEventListener(`click`,e=>{e.target.closest(`a, button`)||o()}),a.addEventListener(`keydown`,e=>{e.target===a&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())}),I(`div`,{class:`dw-db-peek__prop`},I(`div`,{class:`dw-db-peek__label`},WP(kF[e.type],14),I(`span`,{},e.name||RP(r,e.type))),a)})];if(i){let e=GP(`plus`,r.addColumn,()=>Wj(e,$P.map(e=>({id:e,label:RP(r,e),icon:kF[e],run:()=>i.addColumn(e,RP(r,e))})),r.addColumn),r.addColumn);e.classList.add(`dw-db-peek__add`),d.push(e)}let f=this.props.contains(document.activeElement);this.props.replaceChildren(...d),f&&this.panel.focus({preventScroll:!0}),e&&(this.unmount?.(),this.bodyEl.replaceChildren(),this.unmount=this.host.mountBody(this.bodyEl,t))}close(){this.unmount?.(),this.unmount=null,this.dom.remove(),this.onClose(),this.returnFocus instanceof HTMLElement&&this.returnFocus.isConnected&&this.returnFocus.focus({preventScroll:!0})}},VF=`docwell-database`,HF=e=>e.getMap(`blocks`);function UF(e){let t=new Lb;t.set(`title`,e.title);let n=(e,t)=>{let n=new Pb;return n.push(e.map((e,n)=>WF(t(e),n))),n};return t.set(`columns`,n(e.columns,GF)),t.set(`rows`,n(e.rows,KF)),t.set(`views`,n(e.views,qF)),t}function WF(e,t){return e.set(`pos`,t),e}function GF(e){let t=new Lb;return t.set(`id`,e.id),t.set(`name`,e.name),t.set(`type`,e.type),e.options&&t.set(`options`,e.options),t}function KF(e){let t=new Lb;t.set(`id`,e.id),t.set(`createdAt`,e.createdAt),e.createdBy&&t.set(`createdBy`,e.createdBy);let n=new Lb;for(let[t,r]of Object.entries(e.cells))r!=null&&n.set(t,r);return t.set(`cells`,n),t}function qF(e){let t=new Lb;for(let[n,r]of Object.entries(e))t.set(n,r);return t}function JF(e){return e.toArray().filter(e=>e instanceof Lb).map((e,t)=>({m:e,p:YF(e,t),i:t})).sort((e,t)=>e.p-t.p||e.i-t.i).map(e=>e.m)}function YF(e,t){let n=e?.get(`pos`);return typeof n==`number`?n:t}function XF(e,t,n){let r=n?e.filter(e=>e!==n):e,i=Math.max(0,Math.min(t,r.length)),a=i>0?YF(r[i-1],i-1):null,o=i{let n=e.get(t);return n instanceof Pb?JF(n):[]},n=e=>{let t=e.toJSON();return delete t.pos,t},r=new Set,i=t(`rows`).map(e=>{let t=e.get(`cells`),n=e.get(`body`),i=e.get(`id`);return typeof i==`string`&&n instanceof ix&&n.length>0&&r.add(i),{id:i,createdAt:e.get(`createdAt`),createdBy:e.get(`createdBy`),cells:t instanceof Lb?t.toJSON():{}}}),a=iF({title:e.get(`title`),columns:t(`columns`).map(n),rows:i,views:t(`views`).map(n)});for(let e of a.rows)r.has(e.id)&&(e.hasBody=!0);return a}function QF(e,t=``){let n=[{id:tF(),name:e.columnName(`title`),type:`title`},{id:tF(),name:e.columnName(`select`),type:`select`,options:[]}],r=Date.now();return{title:t,columns:n,rows:[0,1,2].map(e=>({id:tF(),cells:{},createdAt:r+e,createdBy:null})),views:[nF(`table`,e.tableView,n)]}}var $F=e=>e==null||e===``||Array.isArray(e)&&!e.length,eI=class{doc;map;me;constructor(e,t,n){this.doc=e,this.map=t,this.me=n}snapshot(){return ZF(this.map)}observe(e){let t=()=>e();return this.map.observeDeep(t),()=>this.map.unobserveDeep(t)}tx(e){this.doc.transact(e,VF)}list(e){let t=this.map.get(e);return t instanceof Pb||(t=new Pb,this.map.set(e,t)),t}find(e,t){let n=JF(this.list(e)),r=n.findIndex(e=>e.get(`id`)===t);return r<0?null:{item:n[r],index:r}}insertAt(e,t,n){let r=this.list(e),i=JF(r),a=Math.max(0,Math.min(t??i.length,i.length));for(let e of n)e.set(`pos`,XF(i,a)),i.splice(a++,0,e);r.push(n)}moveTo(e,t,n){let r=this.find(e,t);r&&r.index!==n&&r.item.set(`pos`,XF(JF(this.list(e)),n,r.item))}remove(e,t){let n=this.list(e),r=n.toArray().indexOf(t);r>=0&&n.delete(r,1)}setTitle(e){this.tx(()=>this.map.set(`title`,e))}addColumn(e,t,n){let r={id:tF(),name:t,type:e};return(e===`select`||e===`multiSelect`)&&(r.options=[]),this.tx(()=>this.insertAt(`columns`,n,[GF(r)])),r.id}renameColumn(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`name`,t))}setOptions(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`options`,t))}changeType(e,t){let n=this.snapshot(),r=n.columns.find(t=>t.id===e);if(!r||r.type===t||r.type===`title`||t===`title`)return;let i=t===`select`||t===`multiSelect`?r.options??[]:[],a=new Map;for(let o of n.rows){let n=DF(o.cells[e],r,t,i);i=n.options,a.set(o.id,n.value)}this.tx(()=>{let n=this.find(`columns`,e);if(n){n.item.set(`type`,t),t===`select`||t===`multiSelect`?n.item.set(`options`,i):n.item.delete(`options`);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);if(!(n instanceof Lb))continue;let r=a.get(String(t.get(`id`)));$F(r)||r===!1?n.delete(e):n.set(e,r)}}})}deleteColumn(e){this.tx(()=>{let t=this.find(`columns`,e);if(t&&t.item.get(`type`)!==`title`){this.remove(`columns`,t.item);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Lb&&n.delete(e)}}})}moveColumn(e,t){this.tx(()=>this.moveTo(`columns`,e,t))}duplicateColumn(e,t){let n=this.snapshot().columns.find(t=>t.id===e);if(!n||n.type===`title`)return null;let r={...structuredClone(n),id:tF(),name:t};return this.tx(()=>{let t=this.find(`columns`,e);if(t){this.insertAt(`columns`,t.index+1,[GF(r)]);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Lb&&n.has(e)&&n.set(r.id,n.get(e))}}}),r.id}addRow(e={},t){return this.addRows([e],t)[0]}addRows(e,t){let n=this.me(),r=Date.now(),i=e.map((e,t)=>({id:tF(),cells:e,createdAt:r+t,createdBy:n}));return this.tx(()=>this.insertAt(`rows`,t,i.map(KF))),i.map(e=>e.id)}setCell(e,t,n){this.setCells([{row:e,col:t,value:n}])}setCells(e){this.tx(()=>{for(let{row:t,col:n,value:r}of e){let e=this.find(`rows`,t)?.item.get(`cells`);e instanceof Lb&&($F(r)?e.delete(n):e.set(n,r))}})}deleteRows(e){this.tx(()=>{let t=this.list(`rows`);for(let n=t.length-1;n>=0;n--)e.includes(String(t.get(n)?.get(`id`)))&&t.delete(n,1)})}moveRow(e,t){this.tx(()=>this.moveTo(`rows`,e,t))}duplicateRow(e){let t=this.find(`rows`,e);if(!t)return null;let n=tI(t.item,this.me());return this.tx(()=>this.insertAt(`rows`,t.index+1,[n])),String(n.get(`id`))}rowBody(e){let t=this.find(`rows`,e);if(!t)return null;let n=t.item.get(`body`);if(n instanceof ix)return n;let r=new ix;return this.tx(()=>t.item.set(`body`,r)),r}rowIndex(e){return this.find(`rows`,e)?.index??-1}addView(e,t){let n=nF(e,t,this.snapshot().columns);return this.tx(()=>this.insertAt(`views`,void 0,[qF(n)])),n.id}updateView(e,t){this.tx(()=>{let n=this.find(`views`,e);if(n)for(let[e,r]of Object.entries(t))n.item.set(e,r)})}duplicateView(e,t){let n=this.snapshot().views.find(t=>t.id===e);if(!n)return null;let r={...structuredClone(n),id:tF(),name:t};return this.tx(()=>{let t=this.find(`views`,e);this.insertAt(`views`,(t?.index??-1)+1,[qF(r)])}),r.id}deleteView(e){this.tx(()=>{let t=this.find(`views`,e);t&&this.list(`views`).length>1&&this.remove(`views`,t.item)})}moveView(e,t){this.tx(()=>this.moveTo(`views`,e,t))}};function tI(e,t){let n=new Lb;n.set(`id`,tF()),n.set(`createdAt`,Date.now());let r=t??e.get(`createdBy`);sF(r)&&n.set(`createdBy`,r);let i=new Lb,a=e.get(`cells`);if(a instanceof Lb)for(let[e,t]of a.entries())i.set(e,t);n.set(`cells`,i);let o=e.get(`body`);if(o instanceof ix&&o.length){let e=new ix;e.insert(0,o.toArray().map(e=>e.clone())),n.set(`body`,e)}return n}function nI(e,t){let n=ZF(e),r=e.get(`rows`);if(r instanceof Pb){let e=new Map;for(let t of r.toArray()){let n=t.get(`body`);n instanceof ix&&n.length&&e.set(String(t.get(`id`)),n)}for(let r of n.rows){let n=e.get(r.id);n&&(r.body=t(n))}}return n}function rI(e,t,n,r){e.transact(()=>{let i=UF(n);HF(e).set(t,i);let a=i.get(`rows`),o=new Map(n.rows.map(e=>[e.id,e]));for(let e of a.toArray()){let t=o.get(String(e.get(`id`)))?.body;if(!t?.length)continue;let n=new ix;e.set(`body`,n),r(t,n)}},VF)}function iI(e,t=`,`){let n=[],r=[],i=``,a=!1,o=0,s=e.replace(/^\uFEFF/,``);for(;oe.map(e=>aI(e,t)).join(t)).join(`\r +`)}function sI(e,t,n){return oI([t.map(e=>e.name),...n.map(e=>t.map(t=>hF(e,t)))])}function cI(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>pF(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function lI(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:tF(),name:e,color:EF(n)},n.push(t)),t.id};switch(t.type){case`number`:return pF(r);case`progress`:{let e=pF(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return dF(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function uI(e,t=`,`){let n=iI(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:tF(),name:e.trim()||`${t+1}`,type:t===0?`title`:cI(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=lI(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function dI(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function fI(e,t,n,r){let i=I(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=I(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var pI=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function mI(e,t,n,r){let i=e.labels;if(!_F(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return fI(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=I(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function hI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(fI(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=gF(l.type),d=I(`div`,{class:`dw-db-pop__line`},fI(n.column,pI(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:gF(t.type)[0]},s(),c()}),fI(n.op,u.map(e=>({value:e,label:BP(i,e)})),i.filter,e=>{o[r]={...n,op:e},_F(e)||delete o[r].value,s(),c()}),mI(e,l,n,e=>{o[r]={...o[r],value:e},s()}),bI(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(xI(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:gF(e.type)[0]}),s(),c()}))};c()}function gI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(I(`div`,{class:`dw-db-pop__line`},fI(e.column,pI(a),i.sort,t=>{o[n]={...e,column:t},s()}),fI(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),bI(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(xI(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function _I(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>rF.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||RP(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(I(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?fI(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function vI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(I(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?fI(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||RP(i,e.type)}))],i.dateColumn,e=>r?.updateView(n.id,{dateColumn:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noDateColumn))}function yI(e,t,n){let r=e.store,i=e.labels,a=[...n.hidden],o=()=>r?.updateView(n.id,{hidden:a}),s=()=>{t.replaceChildren();let n=e.db.columns.filter(e=>e.type!==`title`);if(r&&n.length){let e=I(`button`,{type:`button`,class:`dw-db__btn`},a.length?i.showAll:i.hideAll);e.addEventListener(`click`,()=>{a=a.length?[]:n.map(e=>e.id),o(),s()}),t.append(I(`div`,{class:`dw-db-pop__row dw-db-pop__row--end`},e))}for(let n of e.db.columns){let e=n.type===`title`||!a.includes(n.id),c=I(`button`,{type:`button`,class:`dw-db-pop__item`,role:`switch`,"aria-checked":String(e),disabled:n.type===`title`||!r},I(`span`,{class:`dw-db-pop__check`},WP(kF[n.type],14)),I(`span`,{class:`dw-db-pop__grow`},n.name||RP(i,n.type)),I(`span`,{class:e?`dw-db-switch is-on`:`dw-db-switch`}));c.addEventListener(`click`,()=>{a=e?[...a,n.id]:a.filter(e=>e!==n.id),o(),s()}),t.append(c)}};s()}function bI(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":e,title:e},WP(`close`,14));return n.addEventListener(`click`,t),n}function xI(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db-pop__add`},WP(`plus`,14),I(`span`,{},e));return n.addEventListener(`click`,t),n}var SI=200,CI=class{host;dom=I(`div`,{class:`dw-db`,dataset:{type:`database`},contentEditable:`false`});db;viewId=null;search=``;editing=0;pending=!1;limit=SI;collapsed=new Set;sel=null;anchor=null;picked=new Set;month;titleEl=I(`div`,{class:`dw-db__title`});tabs=I(`div`,{class:`dw-db__tabs`,role:`tablist`});tools=I(`div`,{class:`dw-db__tools`});body=I(`div`,{class:`dw-db__body`});bulk=I(`div`,{class:`dw-db__bulk`});searchInput;buttons;constructor(e,t){this.host=e,this.db=t;let n=new Date;this.month={y:n.getFullYear(),m:n.getMonth()};let r=e.labels;this.searchInput=I(`input`,{class:`dw-db-input dw-db__search`,placeholder:r.search,"aria-label":r.search,hidden:!0}),this.searchInput.addEventListener(`input`,()=>{this.search=this.searchInput.value,this.limit=SI,this.drawBody()}),this.searchInput.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Escape`&&(this.searchInput.value=``,this.search=``,this.searchInput.hidden=!0,this.drawBody())}),this.buttons={search:GP(`search`,r.search,()=>{this.searchInput.hidden=!this.searchInput.hidden,this.searchInput.hidden||this.searchInput.focus()}),filter:GP(`filter`,r.filter,e=>this.panel(e,`filter`),r.filter),sort:GP(`sort`,r.sort,e=>this.panel(e,`sort`),r.sort),group:GP(`layers`,r.group,e=>this.panel(e,`group`),r.group),props:GP(`sliders`,r.properties,e=>this.panel(e,`props`)),more:GP(`more`,r.more,()=>this.moreMenu()),add:GP(`plus`,r.newRow,()=>this.addRow(),r.newRow)},this.buttons.add.classList.add(`dw-db__btn--primary`);let i=I(`div`,{class:`dw-db__head`},this.titleEl),a=I(`div`,{class:`dw-db__bar`},this.tabs,this.tools);this.tools.append(this.searchInput,this.buttons.search,this.buttons.filter,this.buttons.sort,this.buttons.group,this.buttons.props,this.buttons.more,this.buttons.add),this.dom.append(i,a,this.bulk,this.body),this.draw()}get labels(){return this.host.labels}get editable(){return!!this.host.store}get view(){return this.db.views.find(e=>e.id===this.viewId)??this.db.views[0]??wI}ctx(){return{...this.host,db:this.db,openRow:e=>this.openRow(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw())}}}update(e,t){this.db=e,t&&(this.host={...this.host,...t}),this.editing?this.pending=!0:this.draw()}destroy(){JP()}draw(){this.drawTitle(),this.drawTabs(),this.drawTools(),this.drawBody()}drawTitle(){let e=this.labels,t=this.db.title;if(this.titleEl.querySelector(`input`)===document.activeElement)return;if(!this.editable){this.titleEl.replaceChildren(I(`span`,{class:t?``:`is-empty`},t||e.untitled));return}let n=I(`input`,{class:`dw-db__title-input`,placeholder:e.untitled,"aria-label":e.untitled});n.value=t,n.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&n.blur()}),n.addEventListener(`change`,()=>this.host.store?.setTitle(n.value)),this.titleEl.replaceChildren(n)}drawTabs(){let e=this.labels,t=this.view;if(this.tabs.replaceChildren(...this.db.views.map(n=>{let r=I(`button`,{type:`button`,class:n.id===t.id?`dw-db__tab is-active`:`dw-db__tab`,role:`tab`,"aria-selected":String(n.id===t.id)},WP(n.type===`kanban`?`cards`:n.type===`calendar`?`calendar`:`table`,14),I(`span`,{},n.name||VP(e,n.type)));return r.addEventListener(`click`,()=>{if(n.id===t.id&&this.editable)return this.viewMenu(r,n);this.viewId=n.id,this.sel=null,this.limit=SI,this.draw()}),r.addEventListener(`contextmenu`,e=>{this.editable&&(e.preventDefault(),this.viewMenu(r,n))}),r})),this.editable){let t=GP(`plus`,e.addView,()=>Wj(t,eF.map(t=>({id:t,label:VP(e,t),icon:t===`kanban`?`cards`:t===`calendar`?`calendar`:`table`,run:()=>{this.showView(this.host.store.addView(t,VP(e,t)))}})),e.addView));this.tabs.append(t)}}drawTools(){let e=this.view,t=this.buttons,n=(e,t)=>{e.classList.toggle(`is-on`,t>0);let n=e.querySelector(`span`);n&&(n.textContent=t?`${e.title} ${t}`:e.title)};n(t.filter,e.filters.length),n(t.sort,e.sorts.length),t.sort.hidden=e.type===`calendar`,t.group.classList.toggle(`is-on`,!!e.groupBy&&e.type===`table`),t.group.hidden=e.type===`calendar`,t.add.hidden=!this.editable,this.drawBulk()}drawBulk(){let e=[...this.picked].filter(e=>this.db.rows.some(t=>t.id===e));if(this.picked=new Set(e),this.bulk.hidden=!e.length||!this.editable,this.bulk.hidden)return this.bulk.replaceChildren();let t=this.labels;this.bulk.replaceChildren(I(`span`,{},HP(t.selected,e.length)),GP(`trash`,t.deleteRows,()=>{this.host.store?.deleteRows(e),this.picked.clear()},t.deleteRows),GP(`close`,t.close,()=>{this.picked.clear(),this.draw()}))}panel(e,t){let n=e.currentTarget;qP(n,e=>{let n=this.ctx(),r=this.view;t===`filter`?hI(n,e,r):t===`sort`?gI(n,e,r):t===`group`?_I(n,e,r):(r.type===`calendar`&&vI(n,e,r),r.type===`kanban`&&_I(n,e,r),yI(n,e,r))},{class:`dw-db-pop--panel`,label:n.title,placement:`bottom-end`})}viewMenu(e,t){let n=this.labels,r=this.host.store,i=[{id:`rename`,label:n.renameView,icon:`pencil`,run:()=>{let e=window.prompt(n.viewName,t.name)?.trim();e&&r.updateView(t.id,{name:e})}},{id:`layout`,label:n.layout,icon:`grid`,children:eF.map(e=>({id:e,label:VP(n,e),icon:e===t.type?`check`:e===`kanban`?`cards`:e===`calendar`?`calendar`:`table`,run:()=>this.setLayout(t,e)}))},{id:`duplicate`,label:n.duplicateView,icon:`copy`,run:()=>{this.showView(r.duplicateView(t.id,`${t.name||VP(n,t.type)} 2`))}}];this.db.views.length>1&&i.push({id:`delete`,label:n.deleteView,icon:`trash`,danger:!0,run:()=>r.deleteView(t.id)}),Wj(e,i,n.layout)}showView(e){e&&(this.viewId=e,this.sel=null,this.limit=SI,this.draw())}setLayout(e,t){let n={type:t},r=this.db.columns;t===`kanban`&&!e.groupBy&&(n.groupBy=r.find(e=>[`select`,`multiSelect`,`checkbox`,`member`].includes(e.type))?.id??null),t===`calendar`&&!e.dateColumn&&(n.dateColumn=r.find(e=>e.type===`date`)?.id??null),t===`calendar`&&!n.dateColumn&&!e.dateColumn&&this.host.store&&(n.dateColumn=this.host.store.addColumn(`date`,this.labels.typeDate)),this.host.store?.updateView(e.id,n)}moreMenu(){let e=this.labels,t=this.view,n=[{id:`csv`,label:e.exportCsv,icon:`download`,run:()=>{let n=xF(this.db,t);XP(`${(this.db.title||e.untitled).replace(/[\\/:*?"<>|]+/g,` `).trim()}.csv`,`\uFEFF${sI(this.db,n,bF(this.db,t,this.search))}`,`text/csv`)}}];this.editable&&(n.push({id:`import`,label:e.importCsv,icon:`upload`,run:()=>void this.importCsv()}),n.push({id:`view`,label:e.layout,icon:`grid`,run:()=>this.viewMenu(this.buttons.more,t)})),Wj(this.buttons.more,n,e.more)}async importCsv(){let e=this.host.store,t=await ZP(`.csv,text/csv,.tsv,text/tab-separated-values`);if(!e||!t)return;let n=await t.text(),r=t.name.endsWith(`.tsv`)?` `:`,`,i=iI(n,r).filter(e=>e.some(e=>e.trim()));i.length<2||e.tx(()=>{if(this.db.rows.every(e=>!hF(e,cF(this.db)))){let t=uI(n,r);e.deleteRows(this.db.rows.map(e=>e.id));let i=cF(this.db),[a,...o]=t.columns,s=new Map;a&&(e.renameColumn(i.id,a.name),s.set(a.id,i.id));for(let t of o){let n=this.db.columns.find(e=>e.name.toLowerCase()===t.name.toLowerCase()&&e.type!==`title`);n&&e.deleteColumn(n.id);let r=e.addColumn(t.type,t.name);t.options&&e.setOptions(r,t.options),s.set(t.id,r)}e.addRows(t.rows.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[s.get(e)??e,t])))),this.host.notify?.(HP(this.labels.imported,t.rows.length));return}let{index:t,missing:a}=dI(i[0],this.db.columns),o=new Map(a.map(t=>[t,e.addColumn(`text`,t)])),s=i[0].map((e,n)=>{let r=t[n];if(r)return r;let i=o.get(e.trim());return i?{id:i,name:e,type:`text`}:null}),c=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),l=i.slice(1).map(e=>{let t={};return s.forEach((n,r)=>{if(!n)return;let i=lI(e[r]??``,n,c.get(n.id)??[]);i!==null&&(t[n.id]=i)}),t});for(let t of this.db.columns){let n=c.get(t.id);n&&n.length!==(t.options?.length??0)&&e.setOptions(t.id,n)}e.addRows(l),this.host.notify?.(HP(this.labels.imported,l.length))})}addRow(e={},t=!1){let n=this.host.store;if(!n)return;let r=this.view;for(let t of r.filters){let n=this.db.columns.find(e=>e.id===t.column);!n||t.column in e||(t.op===`is`&&(n.type===`select`||n.type===`text`)&&t.value&&(e[n.id]=t.value),t.op===`contains`&&n.type===`multiSelect`&&t.value&&(e[n.id]=[t.value]),t.op===`checked`&&(e[n.id]=!0))}let i=n.addRow(e);t||r.type!==`table`?this.openRow(i):(this.sel={row:i,col:cF(this.db).id},queueMicrotask(()=>this.startEdit()))}openRow(e){let t=bF(this.db,this.view,this.search).map(e=>e.id);this.host.openRow(e,t)}drawBody(){let e=this.view;e.type===`kanban`?this.drawKanban(e):e.type===`calendar`?this.drawCalendar(e):this.drawTable(e)}tableRows=[];tableCols=[];grid=null;drawTable(e){let t=this.labels,n=xF(this.db,e),r=bF(this.db,e,this.search),i=e.groupBy?this.db.columns.find(t=>t.id===e.groupBy):void 0,a=i?SF(r,i,t.noValue,t.checked,t.unchecked).filter(e=>e.rows.length||e.key!==``):[{key:``,label:``,rows:r}];this.tableCols=n,this.tableRows=[];let o=this.editable,s=e.sorts.length>0,c=I(`colgroup`,{},I(`col`,{class:`dw-db-t__gutter-col`}),n.map(t=>I(`col`,{style:{width:`${e.widths[t.id]??(t.type===`title`?240:160)}px`}})),o?I(`col`,{class:`dw-db-t__add-col`}):null),l=I(`table`,{class:`dw-db-t`},c,I(`thead`,{},I(`tr`,{},I(`th`,{class:`dw-db-t__gutter`,"aria-hidden":`true`}),n.map((e,t)=>this.headerCell(e,t,c.children[t+1])),o?I(`th`,{class:`dw-db-t__add`},GP(`plus`,t.addColumn,e=>this.addColumnMenu(e.currentTarget))):null))),u=0;for(let r of a){let a=I(`tbody`,{}),c=`${e.id}:${r.key}`;if(i){let e=!this.collapsed.has(c),t=I(`button`,{type:`button`,class:`dw-db-t__group`,"aria-expanded":String(e)},WP(e?`chevron-down`:`chevron-right`,14),r.key&&i.type!==`checkbox`&&i.type!==`member`&&i.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:r.color??`gray`}},r.label):I(`span`,{},r.label),I(`span`,{class:`dw-db-t__count`},String(r.rows.length)));if(t.addEventListener(`click`,()=>{e?this.collapsed.add(c):this.collapsed.delete(c),this.drawBody()}),a.append(I(`tr`,{class:`dw-db-t__group-row`},I(`td`,{colSpan:n.length+2},t))),!e){l.append(a);continue}}for(let e of r.rows){if(u>=this.limit)break;u++,this.tableRows.push(e),a.append(this.tableRow(e,n,o&&!s))}if(o&&u{let e={};i&&r.key?e[i.id]=TF({id:``,cells:{},createdAt:0,createdBy:null},i,``,r.key,r.rows.flatMap(e=>TI(lF(e,i)))):i?.type===`checkbox`&&(e[i.id]=r.key===`true`),this.addRow(e)}),a.append(I(`tr`,{class:`dw-db-t__new-row`},I(`td`,{colSpan:n.length+2},e)))}l.append(a)}let d=[],f=I(`div`,{class:`dw-db-t__wrap`,role:`grid`,tabIndex:0,"aria-label":this.db.title||t.database},l);if(d.push(f),r.length||d.push(I(`p`,{class:`dw-db__empty`},this.db.rows.length?t.noMatches:t.noRows)),r.length>u&&u>=this.limit){let e=I(`button`,{type:`button`,class:`dw-db__btn dw-db__more`},`${t.more} (${r.length-u})`);e.addEventListener(`click`,()=>{this.limit+=SI,this.drawBody()}),d.push(e)}this.grid=f,f.addEventListener(`keydown`,e=>this.onGridKey(e)),f.addEventListener(`copy`,e=>this.onCopy(e)),f.addEventListener(`paste`,e=>this.onPaste(e));let p=this.body.querySelector(`.dw-db-t__wrap`)?.scrollLeft??0,m=this.body.contains(document.activeElement);this.body.replaceChildren(...d),f.scrollLeft=p,this.markSelection(),m&&this.sel&&f.focus({preventScroll:!0})}headerCell(e,t,n){let r=this.labels,i=I(`span`,{class:`dw-db-t__name`},e.name||RP(r,e.type)),a=I(`button`,{type:`button`,class:`dw-db-t__head`,"aria-haspopup":`menu`,draggable:this.editable},WP(kF[e.type],14),i),o=I(`th`,{dataset:{col:e.id}},a);if(a.addEventListener(`click`,()=>this.columnMenu(a,e,t)),this.editable){a.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-column`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),o.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-column`)&&(e.preventDefault(),o.classList.add(`is-drop`))}),o.addEventListener(`dragleave`,()=>o.classList.remove(`is-drop`)),o.addEventListener(`drop`,t=>{o.classList.remove(`is-drop`);let n=t.dataTransfer?.getData(`application/x-docwell-column`);n&&n!==e.id&&(t.preventDefault(),this.host.store?.moveColumn(n,this.db.columns.findIndex(t=>t.id===e.id)))});let t=I(`span`,{class:`dw-db-t__resize`,title:r.resize,"aria-hidden":`true`});t.addEventListener(`pointerdown`,r=>{r.preventDefault(),r.stopPropagation();let i=r.clientX,a=n.getBoundingClientRect().width||160,o=a;t.setPointerCapture(r.pointerId);let s=e=>{o=Math.max(72,Math.round(a+e.clientX-i)),n.style.width=`${o}px`},c=()=>{t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c);let n=this.view;o!==a&&this.host.store?.updateView(n.id,{widths:{...n.widths,[e.id]:o}})};t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c)}),o.append(t)}return o}columnMenu(e,t,n){let r=this.labels,i=this.host.store,a=this.view,o=e=>({id:e?`desc`:`asc`,label:e?r.sortDescending:r.sortAscending,icon:e?`arrow-down`:`arrow-up`,run:()=>i?.updateView(a.id,{sorts:[{column:t.id,desc:e}]})});if(!i){Wj(e,[o(!1),o(!0)],t.name);return}let s=this.db.columns,c=s.findIndex(e=>e.id===t.id),l=[{id:`rename`,label:r.rename,icon:`pencil`,run:()=>this.renameColumn(t)}];t.type!==`title`&&l.push({id:`type`,label:r.type,icon:kF[t.type],children:$P.map(e=>({id:e,label:RP(r,e),icon:e===t.type?`check`:kF[e],run:()=>i.changeType(t.id,e)}))}),l.push(o(!1),o(!0),{id:`filter`,label:r.filterBy,icon:`filter`,run:()=>{i.updateView(a.id,{filters:[...a.filters,{column:t.id,op:gF(t.type)[0]}]}),this.buttons.filter.click()}}),t.type!==`title`&&l.push({id:`hide`,label:r.hide,icon:`close`,run:()=>i.updateView(a.id,{hidden:[...a.hidden,t.id]})}),l.push({id:`left`,label:r.insertLeft,icon:`plus`,run:()=>this.insertColumn(c)},{id:`right`,label:r.insertRight,icon:`plus`,run:()=>this.insertColumn(c+1)}),c>0&&l.push({id:`moveLeft`,label:r.moveLeft,icon:`arrow-up`,run:()=>i.moveColumn(t.id,c-1)}),ci.moveColumn(t.id,c+1)}),t.type!==`title`&&l.push({id:`duplicate`,label:r.duplicate,icon:`copy`,run:()=>i.duplicateColumn(t.id,`${t.name} 2`)},{id:`delete`,label:r.deleteColumn,icon:`trash`,danger:!0,run:()=>i.deleteColumn(t.id)}),Wj(e,l,t.name||RP(r,t.type))}insertColumn(e){let t=this.host.store;if(!t)return;let n=t.addColumn(`text`,this.labels.typeText,e);queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}addColumnMenu(e){let t=this.labels;Wj(e,$P.map(e=>({id:e,label:RP(t,e),icon:kF[e],run:()=>{let n=this.host.store?.addColumn(e,RP(t,e));queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}})),t.addColumn)}renameColumn(e){let t=this.body.querySelector(`th[data-col="${CSS.escape(e.id)}"]`),n=this.host.store;if(!n)return;if(!t){let t=window.prompt(this.labels.columnName,e.name)?.trim();t&&n.renameColumn(e.id,t);return}let r=this.ctx();r.setEditing(!0);let i=YP(e.name,{class:`dw-db-t__name-input`,label:this.labels.columnName,onCommit:t=>{t.trim()&&t.trim()!==e.name&&n.renameColumn(e.id,t.trim()),r.setEditing(!1),this.drawBody()},onCancel:()=>{r.setEditing(!1),this.drawBody()}});t.replaceChildren(i),i.focus(),i.select()}tableRow(e,t,n){let r=this.labels,i=I(`tr`,{dataset:{row:e.id},class:this.picked.has(e.id)?`is-picked`:``}),a=I(`td`,{class:`dw-db-t__gutter`});if(this.editable){let t=I(`input`,{type:`checkbox`,class:`dw-db-t__pick`,"aria-label":r.selectRow,checked:this.picked.has(e.id)});if(t.addEventListener(`change`,()=>{t.checked?this.picked.add(e.id):this.picked.delete(e.id),i.classList.toggle(`is-picked`,t.checked),this.drawBulk()}),a.append(t),n){let t=I(`span`,{class:`dw-db-t__grip`,draggable:!0,title:r.dragRow,"aria-hidden":`true`},WP(`grip`,14));t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),t.dataTransfer?.setDragImage(i,0,0)}),a.append(t),i.addEventListener(`dragover`,e=>{if(!e.dataTransfer?.types.includes(`application/x-docwell-row`))return;e.preventDefault();let t=e.clientY>i.getBoundingClientRect().top+i.offsetHeight/2;i.classList.toggle(`is-drop-below`,t),i.classList.toggle(`is-drop-above`,!t)}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop-below`,`is-drop-above`)),i.addEventListener(`drop`,t=>{let n=i.classList.contains(`is-drop-below`);i.classList.remove(`is-drop-below`,`is-drop-above`);let r=t.dataTransfer?.getData(`application/x-docwell-row`),a=this.host.store;if(!r||r===e.id||!a)return;t.preventDefault();let o=a.rowIndex(r),s=a.rowIndex(e.id)+ +!!n;o{t.stopPropagation(),this.openRow(e.id)}),t.append(n)}t.addEventListener(`mousedown`,t=>{t.target.closest(`input, button, a`)||(this.anchor=t.shiftKey&&this.sel?this.anchor??this.sel:null,this.sel={row:e.id,col:n.id},t.shiftKey||(this.anchor=null),this.markSelection(),t.preventDefault(),this.grid?.focus({preventScroll:!0}))}),t.addEventListener(`click`,e=>{e.target.closest(`input, button, a`)||e.shiftKey||n.type===`checkbox`&&this.startEdit()}),t.addEventListener(`dblclick`,()=>this.startEdit()),i.append(t)}return this.editable&&i.append(I(`td`,{class:`dw-db-t__add`})),i.addEventListener(`contextmenu`,t=>{this.editable&&(t.preventDefault(),this.rowMenu(i,e))}),i}rowMenu(e,t){let n=this.labels,r=this.host.store,i=r.rowIndex(t.id);Wj(e,[{id:`open`,label:n.openRow,icon:`open`,run:()=>this.openRow(t.id)},{id:`above`,label:n.insertAbove,icon:`arrow-up`,run:()=>r.addRow({},i)},{id:`below`,label:n.insertBelow,icon:`arrow-down`,run:()=>r.addRow({},i+1)},{id:`duplicate`,label:n.duplicateRow,icon:`copy`,run:()=>r.duplicateRow(t.id)},{id:`delete`,label:n.deleteRow,icon:`trash`,danger:!0,run:()=>r.deleteRows([t.id])}],n.openRow)}range(){if(!this.sel)return null;let e=e=>this.tableRows.findIndex(t=>t.id===e),t=e=>this.tableCols.findIndex(t=>t.id===e),n=this.anchor??this.sel,[r,i,a,o]=[e(n.row),e(this.sel.row),t(n.col),t(this.sel.col)];if(i<0||o<0)return null;let s=r<0?i:r,c=a<0?o:a;return{r0:Math.min(s,i),r1:Math.max(s,i),c0:Math.min(c,o),c1:Math.max(c,o)}}markSelection(){if(!this.grid)return;for(let e of this.grid.querySelectorAll(`.is-selected, .is-in-range`))e.classList.remove(`is-selected`,`is-in-range`);let e=this.range();if(!e||!this.sel)return;for(let t=e.r0;t<=e.r1;t++)for(let n=e.c0;n<=e.c1;n++)this.cellEl(this.tableRows[t].id,this.tableCols[n].id)?.classList.add(`is-in-range`);let t=this.cellEl(this.sel.row,this.sel.col);t?.classList.add(`is-selected`),t?.scrollIntoView({block:`nearest`,inline:`nearest`})}cellEl(e,t){return this.grid?.querySelector(`tr[data-row="${CSS.escape(e)}"] td[data-col="${CSS.escape(t)}"]`)??null}startEdit(e){if(!this.sel||!this.host.store)return;let t=this.db.rows.find(e=>e.id===this.sel.row),n=this.db.columns.find(e=>e.id===this.sel.col),r=this.cellEl(this.sel.row,this.sel.col);t&&n&&r&&IF(this.ctx(),r,t,n,{initial:e,onDone:e=>{e&&this.moveSel(+(e===`down`),e===`right`?1:e===`left`?-1:0,!1),this.drawBody(),this.grid?.focus({preventScroll:!0})}})}moveSel(e,t,n){let r=this.tableRows,i=this.tableCols;if(!r.length||!i.length)return;if(!this.sel)return this.sel={row:r[0].id,col:i[0].id},this.markSelection();this.anchor=n?this.anchor??{...this.sel}:null;let a=Math.max(0,Math.min(r.length-1,r.findIndex(e=>e.id===this.sel.row)+e)),o=Math.max(0,Math.min(i.length-1,i.findIndex(e=>e.id===this.sel.col)+t));this.sel={row:r[a].id,col:i[o].id},this.markSelection()}onGridKey(e){if(e.target.closest(`input, select, textarea`))return;let t=e.ctrlKey||e.metaKey;if(t&&e.key.toLowerCase()===`z`)return e.preventDefault(),e.shiftKey?this.host.redo():this.host.undo();if(t&&e.key.toLowerCase()===`y`)return e.preventDefault(),this.host.redo();if(t)return;let n={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[e.key];if(n)return e.preventDefault(),this.moveSel(n[0],n[1],e.shiftKey);if(this.sel){if(e.key===`Tab`)return e.preventDefault(),this.moveSel(0,e.shiftKey?-1:1,!1);if(e.key===`Escape`)this.sel=null,this.anchor=null,this.markSelection();else{if(e.key===`Enter`||e.key===`F2`)return e.preventDefault(),this.startEdit();if(e.key===` `)return e.preventDefault(),this.db.columns.find(e=>e.id===this.sel.col)?.type===`title`?this.openRow(this.sel.row):this.startEdit();if((e.key===`Delete`||e.key===`Backspace`)&&this.host.store){e.preventDefault();let t=this.range();if(!t)return;let n=[];for(let e=t.r0;e<=t.r1;e++)for(let r=t.c0;r<=t.c1;r++){let t=this.tableCols[r];jF.includes(t.type)||n.push({row:this.tableRows[e].id,col:t.id,value:null})}this.host.store.setCells(n)}else if(e.key.length===1&&this.host.store){let t=this.db.columns.find(e=>e.id===this.sel.col);t&&(AF.includes(t.type)||t.type===`select`||t.type===`multiSelect`)&&(e.preventDefault(),this.startEdit(e.key))}}}}onCopy(e){if(e.target.closest(`input, textarea`))return;let t=this.range();if(!t||!e.clipboardData)return;e.preventDefault();let n=[];for(let e=t.r0;e<=t.r1;e++){let r=[];for(let n=t.c0;n<=t.c1;n++)r.push(hF(this.tableRows[e],this.tableCols[n]));n.push(r)}e.clipboardData.setData(`text/plain`,oI(n,` `)),this.host.notify?.(HP(this.labels.copyNotice,(t.r1-t.r0+1)*(t.c1-t.c0+1)))}onPaste(e){if(e.target.closest(`input, textarea`))return;let t=this.host.store,n=e.clipboardData?.getData(`text/plain`);if(!t||!n||!this.sel)return;e.preventDefault();let r=iI(n.replace(/\r?\n$/,``),(n.includes(` `),` `)),i=this.tableRows.findIndex(e=>e.id===this.sel.row),a=this.tableCols.findIndex(e=>e.id===this.sel.col);if(i<0||a<0)return;let o=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),s=[],c=[];r.forEach((e,t)=>{let n=this.tableRows[i+t],r={};e.forEach((e,t)=>{let i=this.tableCols[a+t];if(!i||jF.includes(i.type))return;let c=lI(e,i,o.get(i.id)??[]);n?s.push({row:n.id,col:i.id,value:c}):c!==null&&(r[i.id]=c)}),n||c.push(r)}),t.tx(()=>{for(let e of this.db.columns){let n=o.get(e.id);n&&n.length!==(e.options?.length??0)&&t.setOptions(e.id,n)}t.setCells(s),c.length&&t.addRows(c)})}drawKanban(e){let t=this.labels,n=this.db.columns.find(t=>t.id===e.groupBy);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noGroupColumn));return}let r=bF(this.db,e,this.search),i=SF(r,n,t.noValue,t.checked,t.unchecked),a=xF(this.db,e).filter(e=>e.type!==`title`&&e.id!==n.id),o=cF(this.db),s=r.flatMap(e=>TI(lF(e,n))),c=I(`div`,{class:`dw-db-k`});for(let r of i){if(!r.key&&!r.rows.length&&n.type!==`checkbox`&&(n.options?.length??0)>0)continue;let i=I(`div`,{class:`dw-db-k__cards`,dataset:{group:r.key}}),l=I(`div`,{class:`dw-db-k__head`},r.key&&n.type!==`checkbox`&&n.type!==`member`&&n.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:r.color??`gray`}},r.label):I(`span`,{class:`dw-db-k__label`},r.label),I(`span`,{class:`dw-db-t__count`},String(r.rows.length)));for(let e of r.rows.slice(0,this.limit)){let t=I(`div`,{class:`dw-db-k__card`,tabIndex:0,role:`button`,draggable:this.editable&&!jF.includes(n.type),dataset:{row:e.id}},I(`div`,{class:`dw-db-k__title`},FF(this.ctx(),e,o)),a.flatMap(t=>hF(e,t)===``||t.type===`checkbox`&&lF(e,t)!==!0?[]:[I(`div`,{class:`dw-db-k__prop`,title:t.name},FF(this.ctx(),e,t))]));t.addEventListener(`click`,()=>this.openRow(e.id)),t.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),this.openRow(e.id))}),t.addEventListener(`dragstart`,n=>{n.dataTransfer?.setData(`application/x-docwell-card`,JSON.stringify({row:e.id,from:r.key})),n.dataTransfer&&(n.dataTransfer.effectAllowed=`move`),t.classList.add(`is-dragging`)}),t.addEventListener(`dragend`,()=>t.classList.remove(`is-dragging`)),i.append(t)}if(this.editable){let a=I(`button`,{type:`button`,class:`dw-db-t__new`},WP(`plus`,14),I(`span`,{},t.newRow));a.addEventListener(`click`,()=>{let e={id:``,cells:{},createdAt:0,createdBy:null};this.addRow(r.key||n.type===`checkbox`?{[n.id]:TF(e,n,``,r.key,s)}:{},!0)}),i.append(a),i.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-card`)&&(e.preventDefault(),i.classList.add(`is-drop`))}),i.addEventListener(`dragleave`,e=>{i.contains(e.relatedTarget)||i.classList.remove(`is-drop`)}),i.addEventListener(`drop`,t=>{i.classList.remove(`is-drop`);let a=t.dataTransfer?.getData(`application/x-docwell-card`),o=this.host.store;if(!a||!o)return;t.preventDefault();let{row:c,from:l}=JSON.parse(a),u=this.db.rows.find(e=>e.id===c);if(!u)return;let d=t.target.closest(`.dw-db-k__card`);o.tx(()=>{l!==r.key&&o.setCell(c,n.id,TF(u,n,l,r.key,s));let t=d?.dataset.row;if(t&&t!==c&&!e.sorts.length){let e=o.rowIndex(c),n=o.rowIndex(t);et.id===e.dateColumn);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noDateColumn));return}let r=this.editable&&n.type===`date`,{y:i,m:a}=this.month,o=OF(i,a),s=bF(this.db,e,this.search),c=new Map,l=[];for(let e of s){let t=dF(lF(e,n));t?c.set(t,[...c.get(t)??[],e]):l.push(e)}let u=cF(this.db),d=fF(new Date),f=new Date(i,a,1).toLocaleDateString(this.host.locale,{month:`long`,year:`numeric`}),p=e=>{let t=new Date(i,a+e,1);this.month={y:t.getFullYear(),m:t.getMonth()},this.drawBody()},m=I(`div`,{class:`dw-db-c__nav`},I(`strong`,{class:`dw-db-c__month`},f),GP(`chevron-left`,t.previousMonth,()=>p(-1)),GP(`chevron-right`,t.nextMonth,()=>p(1)),GP(`calendar`,t.today,()=>{let e=new Date;this.month={y:e.getFullYear(),m:e.getMonth()},this.drawBody()},t.today)),h=o.slice(0,7).map(e=>{let[t,n,r]=e.split(`-`).map(Number);return I(`div`,{class:`dw-db-c__wd`},new Date(t,n-1,r).toLocaleDateString(this.host.locale,{weekday:`short`}))}),g=e=>{let n=I(`button`,{type:`button`,class:`dw-db-c__chip`,draggable:r,dataset:{row:e.id}},hF(e,u)||t.untitledRow);return n.addEventListener(`click`,()=>this.openRow(e.id)),n.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row-date`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),n},_=I(`div`,{class:`dw-db-c__grid`,role:`grid`},h);for(let e of o){let i=I(`div`,{class:`dw-db-c__day${Number(e.slice(5,7))===a+1?``:` is-out`}${e===d?` is-today`:``}`,role:`gridcell`,dataset:{day:e}},I(`span`,{class:`dw-db-c__num`},String(Number(e.slice(8)))),(c.get(e)??[]).map(g));if(this.editable&&n.type===`date`){let r=I(`button`,{type:`button`,class:`dw-db-c__add`,"aria-label":`${t.newRow} ${e}`,title:t.newRow},WP(`plus`,12));r.addEventListener(`click`,()=>this.addRow({[n.id]:e},!0)),i.append(r)}r&&(i.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-row-date`)&&(e.preventDefault(),i.classList.add(`is-drop`))}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop`)),i.addEventListener(`drop`,t=>{i.classList.remove(`is-drop`);let r=t.dataTransfer?.getData(`application/x-docwell-row-date`);r&&(t.preventDefault(),this.host.store?.setCell(r,n.id,e))})),_.append(i)}let v=[m,_];l.length&&v.push(I(`details`,{class:`dw-db-c__undated`},I(`summary`,{},HP(t.noDate,l.length)),I(`div`,{class:`dw-db-c__chips`},l.slice(0,this.limit).map(g)))),this.body.replaceChildren(I(`div`,{class:`dw-db-c`},v))}},wI={id:``,name:``,type:`table`,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:null,dateColumn:null,widths:{}};function TI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`):[]}var EI=e=>(e??UP).database;function DI(e){let t=EI(e);return{tableView:t.viewTable,columnName:e=>e===`title`?t.typeTitle:RP(t,e)}}var OI=e=>vw(e).content??[];function kI(e,t){let n=[];return e.forEach(e=>{e.type.name===`database`?n.push(t(e)):e.content.size?n.push(e.copy(kI(e.content,t))):n.push(e)}),s.from(n)}function AI(e){let t=!1;return e.descendants(e=>(e.type.name===`database`&&(t=!0),!t)),t}var jI=Jp.create({name:`database`,group:`block`,atom:!0,draggable:!0,selectable:!0,addOptions(){return{labels:null,doc:void 0,readOnlyDoc:!1,undoScope:!0,files:void 0,people:void 0,me:void 0,rowExtensions:void 0,notify:void 0}},addAttributes(){return{id:{default:``,parseHTML:e=>e.getAttribute(`data-id`)??``,renderHTML:e=>({"data-id":e.id})},data:{default:null,parseHTML:e=>{try{let t=e.getAttribute(`data-db`);return t?JSON.parse(t):null}catch{return null}},renderHTML:e=>e.data?{"data-db":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:`div[data-type='database']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=A(t,{"data-type":`database`});if(!e.attrs.data)return[`div`,n];let r=iF(e.attrs.data),i=r.views[0],a=r.columns.filter(e=>e.type===`title`||!i?.hidden.includes(e.id));return[`div`,n,[`p`,{},[`strong`,{},r.title||EI(this.options.labels).untitled]],[`table`,{},[`tr`,{},...a.map(e=>[`th`,{},e.name])],...r.rows.map(e=>[`tr`,{},...a.map(t=>[`td`,{},hF(e,t)])])]]},renderText({node:e}){let t=e.attrs.data?iF(e.attrs.data):null;if(!t)return``;let n=cF(t);return[t.title,...t.rows.map(e=>hF(e,n))].filter(Boolean).join(` +`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(NS.getState(this.editor.state)?.undoManager)?.addToScope(HF(e))},addCommands(){let e=e=>{let t=tF(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(rI(n,t,e,(e,t)=>MI(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??QF(DI(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=FI(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=EI(this.options.labels),o={id:tF(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:tF(),name:a.done,type:`checkbox`}:null;c&&s.push(c);let l=Date.now(),u={title:``,columns:s,rows:i.items.map((e,t)=>({id:tF(),cells:{[o.id]:e.text,...c&&e.checked?{[c.id]:!0}:{}},createdAt:l+t,createdBy:this.options.me?.()??null,body:e.rest.length?e.rest:void 0})),views:[nF(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(T.create(e.doc,i.from)),!0))}}},addKeyboardShortcuts(){return{"Mod-g":()=>this.editor.commands.groupAsDatabase()}},addProseMirrorPlugins(){let{doc:e,readOnlyDoc:t}=this.options,n=e&&!t?e:null,r=this.editor;return[new E({key:new D(`databaseClipboard`),props:{transformCopied:t=>!e||!AI(t.content)?t:new p(kI(t.content,t=>{let n=HF(e).get(String(t.attrs.id));return n instanceof Lb?t.type.create({...t.attrs,data:nI(n,OI)}):t}),t.openStart,t.openEnd),transformPasted:e=>AI(e.content)?new p(kI(e.content,e=>{let t=tF();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?iF(e.attrs.data):null,a=HF(n).get(String(e.attrs.id)),o=i??(a instanceof Lb?nI(a,OI):QF(DI(this.options.labels)));return rI(n,t,PI(o),(e,t)=>MI(r,e,t)),e.type.create({id:t,data:null})}),e.openStart,e.openEnd):e},appendTransaction:(e,t,i)=>{if(!n||!e.some(e=>e.docChanged&&!e.getMeta(MS))||!e.some(e=>e.steps.some(e=>AI(e.slice?.content??s.empty))))return null;let a=new Set,o=[];if(i.doc.descendants((e,t)=>{if(e.type.name!==`database`)return;let n=String(e.attrs.id);return n&&a.has(n)&&o.push({pos:t,node:e}),a.add(n),!1}),!o.length)return null;let c=i.tr;for(let{pos:e,node:t}of o){let i=HF(n).get(String(t.attrs.id)),a=tF();i instanceof Lb&&rI(n,a,PI(nI(i,OI)),(e,t)=>MI(r,e,t)),c.setNodeMarkup(e,void 0,{...t.attrs,id:a,data:null})}return c}})]},addNodeView(){let e=this.options;return({node:t,editor:n,getPos:r})=>{let i=t,a=e.labels??UP,o=e.doc,s=()=>n.isEditable&&!!o&&!e.readOnlyDoc,c=null,l=null,u=null,d=null,f=I(`div`,{class:`dw-db-node`}),p=()=>String(i.attrs.id),m=()=>{let e=o?HF(o).get(p()):void 0;return e instanceof Lb?e:null},h=()=>{let t=m();return t?ZF(t):i.attrs.data?iF(i.attrs.data):QF(DI(e.labels))},g=()=>({labels:a.database,colorNames:a.colors,locale:a.locale,files:e.files,people:e.people,store:c}),_=(t,n)=>{let r=e.rowExtensions;if(!r)return null;let i=m(),o=null;if(i&&(o=c?c.rowBody(n.id):NI(i,n.id),!o))return t.append(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),null;let s=new Vp({element:t,editable:!!c,extensions:r(o),content:o?void 0:{type:`doc`,content:n.body??[{type:`paragraph`}]},editorProps:{attributes:{class:`dw-prose dw-db-peek__prose`}}});return!o&&!n.body?.length&&t.replaceChildren(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),()=>s.destroy()},v=(e,t)=>{u?.close(),u=new BF({ctx:{...g()},mountBody:_},h(),e,t,()=>u=null)},y=()=>{let e=h();d?.update(e,{store:c}),u?.update(e,{store:c})},b=()=>{if(l?.(),l=null,c=null,!o)return;let t=m();if(!t&&s()){let a=i.attrs.data?iF(i.attrs.data):QF(DI(e.labels)),s=p()?p():tF();rI(o,s,a,(e,t)=>MI(n,e,t)),queueMicrotask(()=>{let e=typeof r==`function`?r():void 0;e!==void 0&&n.state.doc.nodeAt(e)?.type.name===`database`&&n.view.dispatch(n.state.tr.setNodeMarkup(e,void 0,{...i.attrs,id:s,data:null}).setMeta(`addToHistory`,!1))}),t=HF(o).get(s)}if(t){s()&&(c=new eI(o,t,()=>e.me?.()??null));let n=t,r=()=>y();n.observeDeep(r),l=()=>n.unobserveDeep(r)}else{let e=HF(o),t=e=>{e.keysChanged.has(p())&&(b(),y())};e.observe(t),l=()=>e.unobserve(t)}};b(),d=new CI({...g(),openRow:v,undo:()=>n.commands.undo?.(),redo:()=>n.commands.redo?.(),notify:e.notify},h()),f.append(d.dom);let x=s(),S=()=>{s()!==x&&(x=s(),b(),y())};return n.on(`update`,S),n.on(`transaction`,S),{dom:f,update(e){if(e.type!==i.type)return!1;let t=e.attrs.id!==i.attrs.id;return i=e,t&&b(),y(),!0},ignoreMutation:()=>!0,stopEvent:e=>e.type!==`dragstart`||e.target!==f,destroy(){l?.(),u?.close(),d?.destroy(),n.off(`update`,S),n.off(`transaction`,S)}}}}});function MI(e,t,n){try{yw(e.schema,{type:`doc`,content:t},n)}catch{}}function NI(e,t){let n=e.get(`rows`);if(!(n instanceof Pb))return null;for(let e of n.toArray())if(e.get(`id`)===t){let t=e.get(`body`);return t instanceof ix&&t.length?t:null}return null}function PI(e){return{...e,rows:e.rows.map(e=>({...e,id:tF()}))}}function FI(e,t){for(let t=e.depth;t>0;t--){let n=e.node(t);if([`bulletList`,`orderedList`,`taskList`].includes(n.type.name)){let r=[];return n.forEach(e=>{let t=e.firstChild,n=[];e.forEach((e,t,r)=>{r>0&&n.push(e.toJSON())}),r.push({text:t?.textContent??``,checked:!!e.attrs.checked,rest:n})}),{from:e.before(t),to:e.after(t),checks:n.type.name===`taskList`,items:r}}}if(e.depth<1)return null;let n=e.before(1),r=t.after(Math.min(1,t.depth)||1),i=[];return e.doc.nodesBetween(n,r,(e,t)=>t=r?!1:(e.isTextblock&&e.textContent.trim()&&i.push({text:e.textContent,checked:!1,rest:[]}),!e.isTextblock)),i.length>1?{from:n,to:r,checks:!1,items:i}:null}function II(e){let t=MS.getState(e);return t?.type&&t.binding&&t.doc?t:null}function LI(e,t){let n=II(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>jS(n.doc,n.type,ly(gg(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 RI=new D(`docwellComments`);function zI(e,t,n){let r=[];for(let i of t){let t=LI(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 BI=Tp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new E({key:RI,state:{init:()=>({marks:[],active:``,decos:xs.empty}),apply(e,t,n,r){let i=e.getMeta(RI);if(i)return{...i,decos:zI(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(MS)?.isChangeOrigin;return{...t,decos:a?zI(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>RI.getState(e)?.decos??xs.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}}),VI=/^(\d{4})-(\d{2})-(\d{2})$/;function HI(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function UI(e){let t=VI.exec(e);if(!t)return null;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return HI(n)===e?n:null}function WI(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function GI(e,t){return Math.round((t.getTime()-e.getTime())/864e5)}function KI(e,t,n=new Date){let r=UI(e);if(!r)return e;let i=t.dates,a=GI(WI(n,0),r);return a===0?i.today:a===1?i.tomorrow:a===-1?i.yesterday:new Intl.DateTimeFormat(t.locale,{month:`short`,day:`numeric`,year:r.getFullYear()===n.getFullYear()?void 0:`numeric`}).format(r)}function qI(e,t){let n=UI(e);return n?new Intl.DateTimeFormat(t.locale,{dateStyle:`full`}).format(n):e}function JI(e,t,n,r=new Date){let i=t.dates,a=e.trim().toLowerCase(),o=!1;for(let e of new Set([i.remindWord.toLowerCase(),`remind`])){if(a.startsWith(e)){o=!0,a=a.slice(e.length).trim();break}if(a.length>=3&&e.startsWith(a)){o=!0,a=``;break}}if(o&&!n)return[];let s=WI(r,0);if(!a)return o?[1,0,7].map(e=>({date:HI(WI(s,e)),remind:o})):[{date:HI(s),remind:!1},...n?[{date:HI(WI(s,1)),remind:!0}]:[]];let c=[{words:[i.today,`today`],date:s},{words:[i.tomorrow,`tomorrow`],date:WI(s,1)},{words:[i.nextWeek,`next week`],date:WI(s,7)}];o||c.push({words:[i.yesterday,`yesterday`],date:WI(s,-1)});let l=e=>new Intl.DateTimeFormat(e,{weekday:`long`});for(let e=1;e<=7;e++){let n=WI(s,e);c.push({words:[l(t.locale).format(n),l(`en`).format(n)],date:n})}let u=[];UI(a)&&u.push({date:a,remind:o});for(let e of c)e.words.some(e=>e.toLowerCase().startsWith(a))&&u.push({date:HI(e.date),remind:o});return u.filter((e,t)=>u.findIndex(t=>t.date===e.date)===t).slice(0,5)}function YI(e,t){let n=e.toLowerCase().split(` `),r=[t.dates.remindWord,`remind`,t.dates.nextWeek.split(` `)[0]??``,`next`];return n.length>1&&n.length<=3&&r.some(e=>e&&e.toLowerCase()===n[0])}var XI=Jp.create({name:`dateMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{labels:void 0,me:()=>void 0,onOpen:void 0}},addAttributes(){return{date:{default:``,parseHTML:e=>e.getAttribute(`data-date`)??``,renderHTML:e=>({"data-date":e.date})},remind:{default:``,parseHTML:e=>e.getAttribute(`data-remind`)??``,renderHTML:e=>e.remind?{"data-remind":e.remind}:{}},tz:{default:``,parseHTML:e=>e.getAttribute(`data-tz`)??``,renderHTML:e=>e.tz?{"data-tz":e.tz}:{}}}},parseHTML(){return[{tag:`span[data-type="date"]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,A({"data-type":`date`,class:`dw-date`},t),KI(e.attrs.date,this.options.labels)]},renderText({node:e}){return KI(e.attrs.date,this.options.labels)},addNodeView(){let{labels:e,me:t,onOpen:n}=this.options;return({node:r,editor:i,getPos:a})=>{let o=r,s=document.createElement(`span`);s.dataset.type=`date`,s.className=`dw-date`,s.contentEditable=`false`,s.classList.toggle(`is-link`,!!n);let c=null,l=()=>{let t=o.attrs.date,n=o.attrs.remind,r=!!UI(t)&&t{let t=typeof a==`function`?a():void 0;t!==void 0&&i.chain().command(({tr:n})=>(n.setNodeMarkup(t,void 0,{...o.attrs,...e}),!0)).run()};return s.addEventListener(`mousedown`,r=>{c||(i.isEditable?(r.preventDefault(),c=$I(s,i,o,e,t(),u,()=>c=null,n)):n&&UI(o.attrs.date)&&(r.preventDefault(),n(o.attrs.date)))}),{dom:s,update(e){return e.type===o.type&&(o=e,l(),!0)},ignoreMutation:()=>!0,stopEvent:e=>s.contains(e.target)&&e.type!==`mousedown`,destroy(){c?.()}}}}});function ZI(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function QI(e,t,n,r){let i={date:n.date,remind:n.remind&&r?r:``,tz:n.remind&&r?ZI():``};e.chain().focus().insertContentAt(t,[{type:`dateMention`,attrs:i},{type:`text`,text:` `}]).run()}function $I(e,t,n,r,i,a,o,s){let c=r.dates,l=document.createElement(`div`);l.className=`dw-date-pop`,l.setAttribute(`role`,`dialog`),l.setAttribute(`aria-label`,c.edit);let u=document.createElement(`input`);u.type=`date`,u.className=`dw-input`,u.value=n.attrs.date,u.setAttribute(`aria-label`,c.edit),u.addEventListener(`change`,()=>{UI(u.value)&&a({date:u.value})}),l.append(u);let d=n.attrs.remind;if(d&&d!==i){let e=document.createElement(`p`);e.className=`dw-date-pop__note`,e.textContent=c.someoneElse,l.append(e)}else if(i){let e=document.createElement(`label`);e.className=`dw-date-pop__check`;let t=document.createElement(`input`);t.type=`checkbox`,t.checked=d===i,t.addEventListener(`change`,()=>a(t.checked?{remind:i,tz:ZI()}:{remind:``,tz:``})),e.append(t,document.createTextNode(c.remindMe));let n=document.createElement(`span`);n.className=`dw-date-pop__note`,n.textContent=c.reminderAt,l.append(e,n)}if(s){let e=document.createElement(`button`);e.type=`button`,e.className=`dw-date-pop__open`,e.textContent=c.openJournal??`Open journal`,e.addEventListener(`click`,()=>{let e=n.attrs.date;h(),UI(e)&&s(e)}),l.append(e)}document.body.append(l);let f=Dj(e,l,()=>{jj(e,l,{placement:`bottom-start`,strategy:`fixed`,middleware:[Oj(6),Aj(),kj({padding:8})]}).then(({x:e,y:t})=>Object.assign(l.style,{left:`${e}px`,top:`${t}px`}))}),p=t=>{!l.contains(t.target)&&!e.contains(t.target)&&h()},m=e=>{e.key===`Escape`&&(e.preventDefault(),h(),t.commands.focus())};function h(){f(),l.remove(),document.removeEventListener(`mousedown`,p,!0),document.removeEventListener(`keydown`,m,!0),o()}return document.addEventListener(`mousedown`,p,!0),document.addEventListener(`keydown`,m,!0),u.focus(),h}function eL(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 tL(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 nL(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 rL(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:nL(e)}function iL({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&&!tL(r)}function aL({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function oL({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 sL({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 cL({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 lL({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Oj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Aj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function uL(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 dL({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&&uL(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Dj(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 fL({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,_=cL({editor:e,items:n}),v=lL({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:dL({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 pL=new D(`suggestion`);function mL({pluginKey:e=pL,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=eL,shouldShow:ne,shouldResetDismissed:re}){let ie=S?.(),ae=r&&!i,oe=(n,r)=>rL(t,n,r,e);function se(e){return iL({...e,editor:t,shouldResetDismissed:re,effectiveAllowSpaces:ae})}let ce=t=>aL({view:t,pluginKeyRef:e});return new E({key:e,view:()=>fL({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:sL({editor:t,char:n,effectiveAllowSpaces:ae,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:te,allow:ee,shouldShow:ne,shouldKeepDismissed:se,pluginKey:e}),props:oL({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:ie,dispatchExit:ce})})}var hL=mL,gL=e=>`/p/${encodeURIComponent(e)}`,_L=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function vL(e){return _L.exec(e)?.[1]??``}function yL(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:gL(n.id)}}]},{type:`text`,text:` `}]).run()}async function bL(e,t,n){if(!t.create)return;let{from:r,to:i,empty:a}=e.state.selection,o=a?``:e.state.doc.textBetween(r,i,` `).trim().slice(0,200),s=await t.create(o);a||!o?yL(e,{from:r,to:r},s,n):e.chain().focus().setTextSelection({from:r,to:i}).setLink({href:gL(s.id)}).run()}var xL=Tp.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(hL({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:zj({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>yL(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!vL(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function SL(e,t,n){e.chain().focus().deleteRange(t).insertSyncedPage(n).run()}var CL=Jp.create({name:`syncedPage`,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,pages:void 0,labels:null,onNavigate:void 0,nested:void 0}},addAttributes(){return{page:{default:``,parseHTML:e=>e.getAttribute(`data-page`)??``,renderHTML:e=>({"data-page":e.page})},title:{default:``,parseHTML:e=>e.getAttribute(`data-title`)??``,renderHTML:e=>e.title?{"data-title":e.title}:{}},icon:{default:``,parseHTML:e=>e.getAttribute(`data-icon`)??``,renderHTML:e=>e.icon?{"data-icon":e.icon}:{}},folded:{default:!1,parseHTML:e=>e.hasAttribute(`data-folded`),renderHTML:e=>e.folded?{"data-folded":``}:{}}}},parseHTML(){return[{tag:`div[data-type='syncedPage']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=`${e.attrs.icon?`${e.attrs.icon} `:``}${e.attrs.title||`…`}`;return[`div`,A(t,{"data-type":`syncedPage`}),[`a`,{href:gL(String(e.attrs.page))},n]]},addCommands(){return{insertSyncedPage:e=>({commands:t})=>t.insertContent([{type:this.name,attrs:{page:e.id,title:e.title,icon:e.icon??``}},{type:`paragraph`}])}},addProseMirrorPlugins(){let{pages:e}=this.options,t=this.options.labels;return e?[hL({editor:this.editor,pluginKey:new D(`syncedPages`),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:zj({label:t.blocks.syncedPage,empty:t.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>SL(e.editor,e.range,t)})})]:[]},addNodeView(){let{host:e,onNavigate:t,nested:n}=this.options,r=this.options.labels.blocks;return({node:i,editor:a,getPos:o})=>{let s=i,c=String(s.attrs.page),l=document.createElement(`div`);l.className=`dw-synced`,l.dataset.type=`syncedPage`,l.contentEditable=`false`;let u=document.createElement(`div`);u.className=`dw-synced__head`;let d=document.createElement(`a`);d.className=`dw-synced__title`,d.href=gL(c);let f=Rj(`copy`,14);f.classList.add(`dw-synced__badge`);let p=document.createElement(`button`);p.type=`button`,p.className=`dw-synced__btn`;let m=document.createElement(`button`);m.type=`button`,m.className=`dw-synced__btn`,m.textContent=r.syncedOpen,u.append(f,d,p,m);let h=document.createElement(`div`);h.className=`dw-synced__body`,l.append(u,h);let g=e=>{e.preventDefault(),t?t(gL(c)):window.location.assign(gL(c))};d.addEventListener(`click`,g),m.addEventListener(`click`,g);let _=e=>{let t=typeof o==`function`?o():void 0;t!==void 0&&a.view.dispatch(a.state.tr.setNodeMarkup(t,void 0,{...s.attrs,...e}))},v=null,y=()=>v??!!s.attrs.folded;p.addEventListener(`click`,()=>{a.isEditable?_({folded:!s.attrs.folded}):(v=!y(),re())});let b=null,x=null,S=null,ee=e=>{let t=document.createElement(`p`);t.className=`dw-synced__note`,t.textContent=e,h.replaceChildren(t)},te=()=>{S?.(),x?.destroy(),b?.destroy(),S=null,x=null,b=null},ne=()=>{if(x||!e||!n)return;if(c===e.self)return ee(r.syncedSelf);b=e.open(c),ee(r.syncedLoading);let t=b,i=()=>{t.status===`denied`?(te(),ee(r.syncedDenied)):t.synced&&!x&&(h.replaceChildren(),x=new Vp({element:h,editable:!1,extensions:n(t.doc),editorProps:{attributes:{class:`dw-prose`}}}))};S=t.onChange(i),i()};function re(){let t=s.attrs.title;d.textContent=`${s.attrs.icon?`${s.attrs.icon} `:``}${t||r.syncedPage}`;let n=y();l.classList.toggle(`is-folded`,n),p.textContent=n?r.syncedUnfold:r.syncedFold,p.setAttribute(`aria-expanded`,String(!n)),n?(te(),h.replaceChildren()):e?ne():h.replaceChildren()}return re(),e?.meta(c).then(e=>{e?a.isEditable&&(e.title!==s.attrs.title||e.icon!==s.attrs.icon)?_({title:e.title,icon:e.icon}):d.textContent=`${e.icon?`${e.icon} `:``}${e.title||r.syncedPage}`:y()||ee(r.syncedDenied)}),{dom:l,update(e){return e.type!==s.type||String(e.attrs.page)!==c?!1:(s=e,re(),!0)},ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof globalThis.Node&&(u.contains(e.target)||h.contains(e.target)),destroy:te}}}});function wL(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 TL(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function EL(e,t){return new File([e],t,{type:`image/svg+xml`})}function DL(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function OL(e,t,n){return new Promise(r=>{let i=wL(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,${DL(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 kL(e,t,n){let r=wL(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var AL=!1;function jL(e){return Jp.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})=>(AL=!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 TL(i.host,u):``,o=e===`drawio`?await OL(i.drawioUrl||`https://embed.diagrams.net`,t,a):await kL(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(EL(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&ML(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()),AL&&(AL=!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 ML(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var NL=jL(`drawio`),PL=jL(`excalidraw`),FL=null;function IL(e){FL?.();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=Dj(e.anchor,t,()=>{jj(e.anchor,t,{placement:`bottom-start`,middleware:[Oj(6),Aj(),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(),FL===d&&(FL=null),n||e.onCancel?.())}let d=()=>u();return FL=d,n.focus(),e.multiline||n.select(),d}var LL=[{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 RL(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of LL){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function zL(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var BL=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function VL(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;IL({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(zL(t)),onCancel:()=>e(``)})})}async function HL(e,t,n,r){let i=await VL(e,t,t.blocks.embedUrl);i&&(RL(i)?e.chain().focus().insertEmbed(i).run():await WL(e,i,n,r))}async function UL(e,t,n,r){let i=await VL(e,t,t.blocks.linkUrl);i&&await WL(e,i,n,r)}async function WL(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 GL=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=zL(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=zL(e),i=RL(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}: ${BL(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=BL(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`)}}}}),KL=Jp.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=zL(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=zL(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||``)||BL(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||``)||BL(n),r.append(a),t.append(r);let o=zL(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}}}}),qL=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,JL=Jp.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 qp({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[Up({find:qL,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});async function YL(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,view:Pj(n.mime,n.name)?`preview`:`card`}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var XL=JL.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 ZL(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({editor:e,commands:t})=>{let n=e.getAttributes(this.name);return!e.isActive(this.name)||!Pj(n.mime,n.name)?!1:t.updateAttributes(this.name,{view:n.view===`preview`?`card`:`preview`})}}},parseHTML(){return[{tag:`div[data-type=file]`,getAttrs:e=>({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`)??``,view:e.getAttribute(`data-view`)===`preview`?`preview`:`card`})}]},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,"data-view":e.attrs.view}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e})=>{let{host:t,loadPdf:n,labels:r}=this.options,i=document.createElement(`div`);i.className=`dw-file-block`,i.setAttribute(`data-type`,`file`);let a=document.createElement(`div`);a.className=`dw-file`;let o=document.createElement(`a`);o.className=`dw-file__name`,o.target=`_blank`,o.rel=`noopener`;let s=document.createElement(`span`);s.className=`dw-file__size`,a.append(o,s),i.append(a);let c=null,l=null,u=``,d=e=>{let a=String(e.attrs.url??``),d=t?t.resolve(a):a;o.href=d,o.textContent=String(e.attrs.name??`file`),s.textContent=ZL(Number(e.attrs.size??0)),!(e.attrs.view===`preview`&&Pj(e.attrs.mime,e.attrs.name)&&a)||!n||!r?(l?.(),l=null,c?.remove(),c=null,u=``):u!==d&&(l?.(),c||(c=document.createElement(`div`),c.className=`dw-pdf`,c.tabIndex=0,c.setAttribute(`role`,`document`),i.append(c)),c.setAttribute(`aria-label`,String(e.attrs.name??`PDF`)),u=d,l=Fj(c,d,n,r))};return d(e),{dom:i,update:t=>t.type===e.type&&(d(t),!0),stopEvent:e=>!!c&&c.contains(e.target)&&e.type!==`mousedown`,ignoreMutation:()=>!0,destroy:()=>l?.()}}}}),$L=Tp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[eR(()=>this.editor,e,this.options.onError)]:[]}});function eR(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(YL(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 tR=new D(`dwFind`),nR=``;function rR(e,t,n=!1){if(!t)return[];let r=n?t:t.toLowerCase(),i=[];return e.descendants((e,t)=>{if(!e.isTextblock)return!0;let a=``,o=[];e.forEach((e,n)=>{let r=t+1+n;if(e.isText){let t=e.text??``;for(let e=0;ee.from>=r);return a===-1&&(a=i.length?0:-1),{term:t,caseSensitive:n,matches:i,current:a}}function aR(e,t){return t&&e.setSelection(w.create(e.doc,t.from,t.to)).scrollIntoView(),e}var oR=Tp.create({name:`findReplace`,addCommands(){return{setFind:(e,t=!1)=>({state:n,tr:r,dispatch:i})=>{let a=iR(n.doc,e,t,n.selection.from);return r.setMeta(tR,{term:e,caseSensitive:t,near:n.selection.from}),i&&i(aR(r,a.matches[a.current])),!0},findStep:e=>({state:t,tr:n,dispatch:r})=>{let i=tR.getState(t);if(!i?.matches.length)return!1;let a=(i.current+e+i.matches.length)%i.matches.length;return n.setMeta(tR,{current:a}),r&&r(aR(n,i.matches[a])),!0},replaceCurrent:e=>({state:t,tr:n,dispatch:r})=>{let i=tR.getState(t),a=i?.matches[i.current];if(!i||!a)return!1;if(r){n.insertText(e,a.from,a.to),n.setMeta(tR,{term:i.term,caseSensitive:i.caseSensitive,near:a.from+e.length});let t=iR(n.doc,i.term,i.caseSensitive,a.from+e.length);r(aR(n,t.matches[t.current]))}return!0},replaceAll:e=>({state:t,tr:n,dispatch:r})=>{let i=tR.getState(t);if(!i?.matches.length)return!1;if(r){for(let t of[...i.matches].reverse())n.insertText(e,t.from,t.to);n.setMeta(tR,{term:i.term,caseSensitive:i.caseSensitive,near:0}),r(n)}return!0},clearFind:()=>({tr:e,dispatch:t})=>(t&&t(e.setMeta(tR,{clear:!0})),!0)}},addProseMirrorPlugins(){let e={term:``,caseSensitive:!1,matches:[],current:-1};return[new E({key:tR,state:{init:()=>e,apply(t,n,r,i){let a=t.getMeta(tR);if(a&&`clear`in a)return e;if(a&&`term`in a)return iR(i.doc,a.term,a.caseSensitive,a.near);if(a&&`current`in a)return{...n,current:a.current};if(!n.term||!t.docChanged)return n;let o=n.matches[n.current]?.from??0;return iR(i.doc,n.term,n.caseSensitive,t.mapping.map(o))}},props:{decorations(e){let t=tR.getState(e);return t?.matches.length?xs.create(e.doc,t.matches.map((e,n)=>vs.inline(e.from,e.to,{class:n===t.current?`dw-find dw-find-current`:`dw-find`}))):null}}})]}}),L=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(sR,`-$1`).toLowerCase(),lR={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},uR=/[&><"']/g,dR=e=>String(e).replace(uR,e=>lR[e]),fR=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?fR(e.body[0]):e:e.type===`font`?fR(e.body):e,pR=new Set([`mathord`,`textord`,`atom`]),mR=e=>pR.has(fR(e).type),hR=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`},gR={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 _R(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 vR(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:_R(Array.isArray(e.type)?e.type[0]:e.type)}function yR(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?vR(r):a?a(i):i}var bR=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(gR)){var n=gR[t];n&&yR(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 L(`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=hR(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},xR=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 AR[jR[this.id]]}sub(){return AR[MR[this.id]]}fracNum(){return AR[NR[this.id]]}fracDen(){return AR[PR[this.id]]}cramp(){return AR[FR[this.id]]}text(){return AR[IR[this.id]]}isTight(){return this.size>=2}},SR=0,CR=1,wR=2,TR=3,ER=4,DR=5,OR=6,kR=7,AR=[new xR(SR,0,!1),new xR(CR,0,!0),new xR(wR,1,!1),new xR(TR,1,!0),new xR(ER,2,!1),new xR(DR,2,!0),new xR(OR,3,!1),new xR(kR,3,!0)],jR=[ER,DR,ER,DR,OR,kR,OR,kR],MR=[DR,DR,DR,DR,kR,kR,kR,kR],NR=[wR,TR,ER,DR,OR,kR,OR,kR],PR=[TR,TR,DR,DR,kR,kR,kR,kR],FR=[CR,CR,TR,TR,DR,DR,kR,kR],IR=[SR,CR,wR,TR,wR,TR,wR,TR],R={DISPLAY:AR[SR],TEXT:AR[wR],SCRIPT:AR[ER],SCRIPTSCRIPT:AR[OR]},LR=[{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 RR(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var zR=[];LR.forEach(e=>e.blocks.forEach(e=>zR.push(...e)));function BR(e){for(var t=0;t=zR[t]&&e<=zR[t+1])return!0;return!1}var VR=e=>e+` `+e,HR=80,UR=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 @@ -171,7 +175,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`},HI=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`},WR=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+` @@ -181,7 +185,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`},UI=function(e,t){return`M983 `+(10+e+t)+` +M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},GR=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 @@ -190,7 +194,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`},WI=function(e,t){return`M424,`+(2398+e+t)+` +M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},KR=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 @@ -200,18 +204,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`},GI=function(e,t){return`M473,`+(2713+e+t)+` +h400000v`+(40+e)+`h-400000z`},qR=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`},KI=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},qI=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`},JR=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},YR=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`},JI=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=VI(t,BI);break;case`sqrtSize1`:r=HI(t,BI);break;case`sqrtSize2`:r=UI(t,BI);break;case`sqrtSize3`:r=WI(t,BI);break;case`sqrtSize4`:r=GI(t,BI);break;case`sqrtTall`:r=qI(t,BI,n)}return r},YI=function(e,t){switch(e){case`⎜`:return zI(`M291 0 H417 V`+t+` H291z`);case`∣`:return zI(`M145 0 H188 V`+t+` H145z`);case`∥`:return zI(`M145 0 H188 V`+t+` H145z`)+zI(`M367 0 H410 V`+t+` H367z`);case`⎟`:return zI(`M457 0 H583 V`+t+` H457z`);case`⎢`:return zI(`M319 0 H403 V`+t+` H319z`);case`⎥`:return zI(`M263 0 H347 V`+t+` H263z`);case`⎪`:return zI(`M384 0 H504 V`+t+` H384z`);case`⏐`:return zI(`M312 0 H355 V`+t+` H312z`);case`‖`:return zI(`M257 0 H300 V`+t+` H257z`)+zI(`M478 0 H521 V`+t+` H478z`);default:return``}},XI={doubleleftarrow:`M262 157 +219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},XR=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=UR(t,HR);break;case`sqrtSize1`:r=WR(t,HR);break;case`sqrtSize2`:r=GR(t,HR);break;case`sqrtSize3`:r=KR(t,HR);break;case`sqrtSize4`:r=qR(t,HR);break;case`sqrtTall`:r=YR(t,HR,n)}return r},ZR=function(e,t){switch(e){case`⎜`:return VR(`M291 0 H417 V`+t+` H291z`);case`∣`:return VR(`M145 0 H188 V`+t+` H145z`);case`∥`:return VR(`M145 0 H188 V`+t+` H145z`)+VR(`M367 0 H410 V`+t+` H367z`);case`⎟`:return VR(`M457 0 H583 V`+t+` H457z`);case`⎢`:return VR(`M319 0 H403 V`+t+` H319z`);case`⎥`:return VR(`M263 0 H347 V`+t+` H263z`);case`⎪`:return VR(`M384 0 H504 V`+t+` H384z`);case`⏐`:return VR(`M312 0 H355 V`+t+` H312z`);case`‖`:return VR(`M257 0 H300 V`+t+` H257z`)+VR(`M478 0 H521 V`+t+` H478z`);default:return``}},QR={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 @@ -257,10 +261,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:zI(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:zI(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:zI(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:zI(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23 + 71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:VR(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:VR(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:VR(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:VR(`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:zI(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334 + 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:VR(`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 @@ -309,7 +313,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:zI(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:zI(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:zI(`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:VR(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:VR(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:VR(`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 @@ -382,7 +386,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`},ZI=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`},$R=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 @@ -410,17 +414,17 @@ 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 QI(e){return`toText`in e}var $I=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(QI(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},eL={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},tL={ex:!0,em:!0,mu:!0},nL=function(e){return typeof e!=`string`&&(e=e.unit),e in eL||e in tL||e===`ex`},rL=function(e,t){var n;if(e.unit in eL)n=eL[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`},iL=function(e){return e.filter(e=>e).join(` `)},aL=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=oI(n)+`:`+r+`;`)}return t},oL=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)}},sL=function(e){var t=document.createElement(e);t.className=iL(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]/,lL=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+lI(iL(this.classes))+`"`);var n=aL(this.style);n&&(t+=` style="`+lI(n)+`"`);for(var r of Object.keys(this.attributes)){if(cL.test(r))throw new I(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+lI(this.attributes[r])+`"`}t+=`>`;for(var i=0;i`,t},uL=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,oL.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return sL.call(this,`span`)}toMarkup(){return lL.call(this,`span`)}},dL=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,oL.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 sL.call(this,`a`)}toMarkup(){return lL.call(this,`a`)}},fL=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=``+lI(this.alt)+``,e}},pL={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},mL=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=II(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=pL[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=iL(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+=aL(this.style),n&&(e=!0,t+=` style="`+lI(n)+`"`);var r=lI(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},hL=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}},gL=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`,XI[this.pathName]),e}toMarkup(){return this.alternate?``:``}},_L=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 vL(e){if(e instanceof mL)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function yL(e){if(e instanceof uL)return e;throw Error(`Expected span but got `+String(e)+`.`)}var bL=e=>e instanceof uL||e instanceof dL||e instanceof $I,xL={"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]}},SL={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]},CL={Å:`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 wL(e,t){xL[e]=t}function TL(e,t,n){if(!xL[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=xL[t][r];if(!i&&e[0]in CL&&(r=CL[e[0]].charCodeAt(0),i=xL[t][r]),!i&&n===`text`&&RI(r)&&(i=xL[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var EL={};function DL(e){var t=e>=5?0:e>=3?1:2;if(!EL[t]){var n=EL[t]={cssEmPerMu:SL.quad[t]/18};for(var r of Object.keys(SL))n[r]=SL[r][t]}return EL[t]}var OL={math:{},text:{}};function z(e,t,n,r,i,a){OL[e][i]={font:t,group:n,replace:r},a&&r&&(OL[e][r]=OL[e][i])}var B=`math`,V=`text`,H=`main`,U=`ams`,kL=`accent-token`,W=`bin`,AL=`close`,jL=`inner`,G=`mathord`,ML=`op-token`,NL=`open`,PL=`punct`,K=`rel`,FL=`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,PL,`.`,`\\ldotp`),z(B,H,PL,`⋅`,`\\cdotp`),z(B,H,PL,`⋅`,`·`),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,AL,`⎱`,`\\rmoustache`,!0),z(B,H,NL,`⎰`,`\\lmoustache`,!0),z(B,H,AL,`⟯`,`\\rgroup`,!0),z(B,H,NL,`⟮`,`\\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,NL,`┌`,`\\@ulcorner`,!0),z(B,U,AL,`┐`,`\\@urcorner`,!0),z(B,U,NL,`└`,`\\@llcorner`,!0),z(B,U,AL,`┘`,`\\@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,NL,`⟨`,`\\langle`,!0),z(B,H,NL,`∣`,`\\lvert`),z(B,H,NL,`∥`,`\\lVert`),z(B,H,AL,`?`,`?`),z(B,H,AL,`!`,`!`),z(B,H,AL,`⟩`,`\\rangle`,!0),z(B,H,AL,`∣`,`\\rvert`),z(B,H,AL,`∥`,`\\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,FL,`\xA0`,`\\ `),z(B,H,FL,`\xA0`,`\\space`),z(B,H,FL,`\xA0`,`\\nobreakspace`),z(V,H,FL,`\xA0`,`\\ `),z(V,H,FL,`\xA0`,` `),z(V,H,FL,`\xA0`,`\\space`),z(V,H,FL,`\xA0`,`\\nobreakspace`),z(B,H,FL,``,`\\nobreak`),z(B,H,FL,``,`\\allowbreak`),z(B,H,PL,`,`,`,`),z(B,H,PL,`;`,`;`),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,NL,`{`,`\\{`),z(V,H,q,`{`,`\\{`),z(V,H,q,`{`,`\\textbraceleft`),z(B,H,AL,`}`,`\\}`),z(V,H,q,`}`,`\\}`),z(V,H,q,`}`,`\\textbraceright`),z(B,H,NL,`{`,`\\lbrace`),z(B,H,AL,`}`,`\\rbrace`),z(B,H,NL,`[`,`\\lbrack`,!0),z(V,H,q,`[`,`\\lbrack`,!0),z(B,H,AL,`]`,`\\rbrack`,!0),z(V,H,q,`]`,`\\rbrack`,!0),z(B,H,NL,`(`,`\\lparen`,!0),z(B,H,AL,`)`,`\\rparen`,!0),z(V,H,q,`<`,`\\textless`,!0),z(V,H,q,`>`,`\\textgreater`,!0),z(B,H,NL,`⌊`,`\\lfloor`,!0),z(B,H,AL,`⌋`,`\\rfloor`,!0),z(B,H,NL,`⌈`,`\\lceil`,!0),z(B,H,AL,`⌉`,`\\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,ML,`∐`,`\\coprod`),z(B,H,ML,`⋁`,`\\bigvee`),z(B,H,ML,`⋀`,`\\bigwedge`),z(B,H,ML,`⨄`,`\\biguplus`),z(B,H,ML,`⋂`,`\\bigcap`),z(B,H,ML,`⋃`,`\\bigcup`),z(B,H,ML,`∫`,`\\int`),z(B,H,ML,`∫`,`\\intop`),z(B,H,ML,`∬`,`\\iint`),z(B,H,ML,`∭`,`\\iiint`),z(B,H,ML,`∏`,`\\prod`),z(B,H,ML,`∑`,`\\sum`),z(B,H,ML,`⨂`,`\\bigotimes`),z(B,H,ML,`⨁`,`\\bigoplus`),z(B,H,ML,`⨀`,`\\bigodot`),z(B,H,ML,`∮`,`\\oint`),z(B,H,ML,`∯`,`\\oiint`),z(B,H,ML,`∰`,`\\oiiint`),z(B,H,ML,`⨆`,`\\bigsqcup`),z(B,H,ML,`∫`,`\\smallint`),z(V,H,jL,`…`,`\\textellipsis`),z(B,H,jL,`…`,`\\mathellipsis`),z(V,H,jL,`…`,`\\ldots`,!0),z(B,H,jL,`…`,`\\ldots`,!0),z(B,H,jL,`⋯`,`\\@cdots`,!0),z(B,H,jL,`⋱`,`\\ddots`,!0),z(B,H,q,`⋮`,`\\varvdots`),z(V,H,q,`⋮`,`\\varvdots`),z(B,H,kL,`ˊ`,`\\acute`),z(B,H,kL,`ˋ`,`\\grave`),z(B,H,kL,`¨`,`\\ddot`),z(B,H,kL,`~`,`\\tilde`),z(B,H,kL,`ˉ`,`\\bar`),z(B,H,kL,`˘`,`\\breve`),z(B,H,kL,`ˇ`,`\\check`),z(B,H,kL,`^`,`\\hat`),z(B,H,kL,`⃗`,`\\vec`),z(B,H,kL,`˙`,`\\dot`),z(B,H,kL,`˚`,`\\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,kL,`ˊ`,`\\'`),z(V,H,kL,`ˋ`,"\\`"),z(V,H,kL,`ˆ`,`\\^`),z(V,H,kL,`˜`,`\\~`),z(V,H,kL,`ˉ`,`\\=`),z(V,H,kL,`˘`,`\\u`),z(V,H,kL,`˙`,`\\.`),z(V,H,kL,`¸`,`\\c`),z(V,H,kL,`˚`,`\\r`),z(V,H,kL,`ˇ`,`\\v`),z(V,H,kL,`¨`,`\\"`),z(V,H,kL,`˝`,`\\H`),z(V,H,kL,`◯`,`\\textcircled`);var IL={"--":!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 LL=`0123456789/@."`,RL=0;RL{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return dR[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return fR[Math.floor((r-120782)/10)];if(r===120485||r===120486)return dR[0];if(120486{if(iL(e.classes)!==iL(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},bR=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 uL(e,t,n,r);return xR(i),i},SR=(e,t,n,r)=>new uL(e,t,n,r),CR=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},wR=function(e,t,n,r){var i=new dL(e,t,n,r);return xR(i),i},TR=function(e){var t=new $I(e);return xR(t),t},ER=function(e,t){return e instanceof $I?Y([],[e],t):e},DR=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=rL(e,t);return n.style.marginRight=R(r),n},AR=(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},jR={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`}},MR={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},NR=function(e,t){var n=MR[e],r=n[0],i=n[1],a=n[2],o=SR([`katex-overlay`],[new hL([new gL(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},PR={number:3,unit:`mu`},FR={number:4,unit:`mu`},IR={number:5,unit:`mu`},LR={mord:{mop:PR,mbin:FR,mrel:IR,minner:PR},mop:{mord:PR,mop:PR,mrel:IR,minner:PR},mbin:{mord:FR,mop:FR,mopen:FR,minner:FR},mrel:{mord:IR,mop:IR,mopen:IR,minner:IR},mopen:{},mclose:{mop:PR,mbin:FR,mrel:IR,minner:PR},mpunct:{mord:PR,mop:PR,mrel:IR,mopen:PR,mclose:PR,mpunct:PR,minner:PR},minner:{mord:PR,mop:PR,mbin:FR,mrel:IR,mopen:PR,mpunct:PR,minner:PR}},RR={mord:{mop:PR},mop:{mord:PR,mop:PR},mbin:{},mrel:{},mopen:{},mclose:{mop:PR},mpunct:{},minner:{mop:PR}},zR={},BR={},VR={};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`&&KR.has(r)?t.classes[0]=`mord`:r===`mbin`&&GR.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),XR(i,(e,t)=>{var n=$R(t),r=$R(e),i=n&&r?e.hasClass(`mtight`)?RR[n]?.[r]:LR[n]?.[r]:null;if(i)return kR(i,c)},{node:u},d,f),i},XR=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()},ZR=function(e){return e instanceof $I||e instanceof dL||e instanceof uL&&e.hasClass(`enclosing`)?e:null},QR=function(e,t){var n=ZR(e);if(n){var r=n.children;if(r.length){if(t===`right`)return QR(r[r.length-1],`right`);if(t===`left`)return QR(r[0],`left`)}}return e},$R=function(e,t){return e?(t&&(e=QR(e,t)),JR[e.classes[0]]||null):null},ez=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return Y(t.concat(n))},tz=function(e,t,n){if(!e)return Y();if(BR[e.type]){var r=BR[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 nz(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 rz(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=YR(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(nz(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(nz(o,t));var l;n?(l=nz(YR(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 iz(e){return new $I(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=iL(this.classes));for(var i=0;i0&&(e+=` class ="`+lI(iL(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},az=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return lI(this.toText())}toText(){return this.text}},oz=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:` `}},sz=new Set([`\\imath`,`\\jmath`]),cz=new Set([`mrow`,`mtable`]),lz=function(e,t,n){var r,i;return OL[t][e]&&OL[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(IL,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=OL[t][e].replace),new az(e)},uz=function(e){return e.length===1?e[0]:new Z(`mrow`,e)},dz={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`},fz=(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=dz[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(sz.has(a))return null;if(OL[r][a]){var o=OL[r][a].replace;o&&(a=o)}var s=jR[n].fontName;return TL(a,s,r)?jR[n].variant:null};function pz(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof az&&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 az&&n.text===`,`}return!1}var mz=function(e,t,n){if(e.length===1){var r=gz(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`||pz(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 az&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof az&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},hz=function(e,t,n){return uz(mz(e,t,n))},gz=function(e,t){if(!e)return new Z(`mrow`);if(VR[e.type])return VR[e.type](e,t);throw new I(`Got group of unknown type: '`+e.type+`'`)};function _z(e,t,n,r,i){var a=mz(e,n),o=a.length===1&&a[0]instanceof Z&&cz.has(a[0].type)?a[0]:new Z(`mrow`,a),s=new Z(`annotation`,[new az(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 vz=[[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]],yz=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],bz=function(e,t){return t.size<2?e:vz[e-1][t.size-1]},xz=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=yz[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:bz(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:yz[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=bz(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||=DL(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};xz.BASESIZE=6;var Sz=function(e){return new xz({style:e.displayMode?L.DISPLAY:L.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},Cz=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},wz=function(e,t,n){var r=Sz(n),i;return n.output===`mathml`?_z(e,t,r,n.displayMode,!0):(i=n.output===`html`?Y([`katex`],[rz(e,r)]):Y([`katex`],[_z(e,t,r,n.displayMode,!1),rz(e,r)]),Cz(i,n))},Tz=function(e,t,n){return Cz(Y([`katex`],[rz(e,Sz(n))]),n)},Ez={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":`=`},Dz=function(e){var t=new Z(`mo`,[new az(Ez[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},Oz={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]},kz=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),Az=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(kz.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:SR([],[new hL([new gL(o)],{width:`100%`,height:R(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=Oz[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},jz=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 _L({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new _L({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=SR([],[new hL(c,{width:`100%`,height:R(o)})],i)}return a.height=o,a.style.height=R(o),a},Mz=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],Nz=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],Pz=new Set(Mz),Fz=new Set(Nz);function Iz(e){return Pz.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 Lz(e){var t=Rz(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function Rz(e){return e.type===`atom`||Fz.has(e.type)?e:null}function zz(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 Bz=e=>{if(e instanceof mL)return e;if(bL(e)&&e.children.length===1)return Bz(e.children[0])},Vz=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Q(e.base,`accent`),n=r.base,e.base=n,i=yL(tz(e,t)),e.base=r):(r=Q(e,`accent`),n=r.base);var a=tz(n,t.havingCrampedStyle()),o=r.isShifty&&fI(n),s=0;o&&(s=Bz(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=Az(r,t),u=OR({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=NR(`vec`,t),f=MR.vec[1]):(d=vR({type:`textord`,mode:r.mode,text:r.label},t),d=vL(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=OR({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},Hz=(e,t)=>{var n=e.isStretchy?Dz(e.label):new Z(`mo`,[lz(e.label,e.mode)]),r=new Z(`mover`,[gz(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},Uz=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=UR(t[0]),r=!Uz.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:Vz,mathmlBuilder:Hz}),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=tz(e.base,t),r=Az(e,t),i=e.label===`\\utilde`?.12:0;return Y([`mord`,`accentunder`],[OR({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=Dz(e.label),r=new Z(`munder`,[gz(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var Wz=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=ER(tz(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=ER(tz(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=Az(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=OR({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=OR({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=Dz(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=Wz(gz(e.body,t));r=e.below?new Z(`munderover`,[n,Wz(gz(e.below,t)),i]):new Z(`mover`,[n,i])}else e.below?r=new Z(`munder`,[n,Wz(gz(e.below,t))]):(r=Wz(),r=new Z(`mover`,[n,r]));return r}});function Gz(e,t){var n=YR(e.body,t,!0);return Y([e.mclass],n,t)}function Kz(e,t){var n,r=mz(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:WR(i),isCharacterBox:fI(i)}},htmlBuilder:Gz,mathmlBuilder:Kz});var qz=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:qz(t[0]),body:WR(t[1]),isCharacterBox:fI(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`:qz(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:WR(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:fI(c)}}}),X({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:qz(t[0]),body:WR(t[0])}},htmlBuilder(e,t){var n=YR(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`,mz(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var Jz={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},Yz=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),Xz=e=>e.type===`textord`&&e.text===`@`,Zz=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function Qz(e,t,n){var r=Jz[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 $z(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:[Qz(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=Yz()}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=ER(tz(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`,[gz(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=ER(tz(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Z(`mrow`,[gz(e.fragment,t)])}}),X({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=zz(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:WR(i)}},htmlBuilder:(e,t)=>TR(YR(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Z(`mstyle`,mz(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(rL(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(rL(e.size,t)))),n}});var eB={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},tB=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new I(`Expected a control sequence`,e);return t},nB=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},rB=(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(eB[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=eB[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===eB[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=tB(t.gullet.popToken());return t.gullet.consumeSpaces(),rB(t,r,nB(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=tB(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return rB(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var iB=function(e,t,n){var r=TL(OL.math[e]&&OL.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},aB=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},oB=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},sB=function(e,t,n,r,i,a){var o=aB(hR(e,`Main-Regular`,i,r),t,r,a);return n&&oB(o,r,t),o},cB=function(e,t,n,r){return hR(e,`Size`+t+`-Regular`,n,r)},lB=function(e,t,n,r,i,a){var o=cB(e,t,i,r),s=aB(Y([`delimsizing`,`size`+t],[o],r),L.TEXT,r,a);return n&&oB(s,r,L.TEXT),s},uB=function(e,t,n){return{type:`elem`,elem:Y([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[Y([],[hR(e,t,n)])])}},dB=function(e,t,n){var r=xL[`Size4-Regular`][e.charCodeAt(0)]?xL[`Size4-Regular`][e.charCodeAt(0)][4]:xL[`Size1-Regular`][e.charCodeAt(0)][4],i=SR([],[new hL([new gL(`inner`,YI(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}},fB=.008,pB={type:`kern`,size:-1*fB},mB=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),hB=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),gB=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`):mB.has(e)?(c=`∣`,u=`vert`,d=333):hB.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=iB(o,f,i),m=p.height+p.depth,h=iB(c,f,i),g=h.height+h.depth,_=iB(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=iB(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=ZI(u,Math.round(ie*1e3)),se=new gL(u,oe),ce=R(d/1e3),le=R(ae/1e3),ue=SR([],[new hL([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(uB(l,f,i)),re.push(pB),s===null){var de=ee-m-v+2*fB;re.push(dB(c,de,r))}else{var fe=(ee-m-v-y)/2+2*fB;re.push(dB(c,fe,r)),re.push(pB),re.push(uB(s,f,i)),re.push(pB),re.push(dB(c,fe,r))}re.push(pB),re.push(uB(o,f,i))}var pe=r.havingBaseStyle(L.TEXT);return aB(Y([`delimsizing`,`mult`],[OR({positionType:`bottom`,positionData:ne,children:re})],pe),L.TEXT,r,a)},_B=80,vB=.08,yB=function(e,t,n,r,i){return SR([`hide-tail`],[new hL([new gL(e,JI(e,r,n))],{width:`400em`,height:R(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},bB=function(e,t){var n=t.havingBaseSizing(),r=AB(`\\surd`,e*n.sizeMultiplier,OB,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+_B,e<1?i=1:e<1.4&&(i=.7),s=(1+a+vB)/i,c=(1+a)/i,o=yB(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+_B)*wB[r.size],c=(wB[r.size]+a)/i,s=(wB[r.size]+a+vB)/i,o=yB(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+vB,c=e+a,l=Math.floor(1e3*e+a)+_B,o=yB(`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}},xB=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),SB=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),CB=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),wB=[0,1.2,1.8,2.4,3],TB=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),xB.has(e)||CB.has(e))return lB(e,t,!1,n,r,i);if(SB.has(e))return gB(e,wB[t],!1,n,r,i);throw new I(`Illegal delimiter: '`+e+`'`)},EB=[{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}],DB=[{type:`small`,style:L.SCRIPTSCRIPT},{type:`small`,style:L.SCRIPT},{type:`small`,style:L.TEXT},{type:`stack`}],OB=[{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`}],kB=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.`)},AB=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},jB=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=CB.has(e)?EB:xB.has(e)?OB:DB,s=AB(e,t,o,r);return s.type===`small`?sB(e,s.style,n,r,i,a):s.type===`large`?lB(e,s.size,n,r,i,a):gB(e,t,n,r,i,a)},MB=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 jB(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},NB={"\\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}},PB=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 FB(e){return`isMiddle`in e}function IB(e,t){var n=Rz(e);if(n&&PB.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=IB(UR(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:NB[e.funcName].size,mclass:NB[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?Y([e.mclass]):TB(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(lz(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(wB[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function LB(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:IB(t[0],e).text,color:n}}}),X({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=IB(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)=>{LB(e);for(var n=YR(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{LB(e);var n=mz(e.body,t);if(e.left!==`.`){var r=new Z(`mo`,[lz(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Z(`mo`,[lz(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return uz(n)}}),X({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=IB(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=ez(t,[]):(n=TB(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===`|`?lz(`|`,`text`):lz(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=ER(tz(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=fI(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=rL({number:.6,unit:`pt`},t),l=rL({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=SR([`hide-tail`],[new hL([new gL(`phase`,KI(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=jz(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=OR({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=OR({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`,[gz(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 RB={};function zB(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.`)},GB=new Set([`gather`,`gather*`]);function KB(e){if(!e.includes(`ed`))return!e.includes(`*`)}function qB(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 HB(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(UB(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=CR(`katex-hline`,t,l),Oe=CR(`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=OR({positionType:`individualShift`,children:ke})}if(ce.length===0)return Y([`mord`],[Ee],t);var Me=Y([`katex-tag`],[OR({positionType:`individualShift`,children:ce})],t);return TR([Ee,Me])},XB={c:`center `,l:`left `,r:`right `},ZB=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+=XB[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};zB({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(Rz(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=Lz(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 qB(e.parser,r,JB(e.envName))},htmlBuilder:YB,mathmlBuilder:ZB}),zB({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=qB(e.parser,r,JB(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:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=qB(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(Rz(t[0])?[t[0]]:Q(t[0],`ordgroup`).body).map(function(e){var t=Lz(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=qB(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:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=qB(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},JB(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:QB,htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){GB.has(e.envName)&&WB(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:KB(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return qB(e.parser,t,`display`)},htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:QB,htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){WB(e);var t={autoTag:KB(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return qB(e.parser,t,`display`)},htmlBuilder:YB,mathmlBuilder:ZB}),zB({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return WB(e),$z(e.parser)},htmlBuilder:YB,mathmlBuilder:ZB}),$(`\\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 $B=RB;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=zz(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call($B,a))throw new I(`No such environment: `+a,i);var o=$B[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 eV=(e,t)=>{var n=e.font,r=t.withFont(n);return tz(e.body,r)},tV=(e,t)=>{var n=e.font,r=t.withFont(n);return gz(e.body,r)},nV={"\\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=UR(t[0]),a=r in nV?nV[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:eV,mathmlBuilder:tV}),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:qz(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:fI(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 rV=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=tz(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`,[gz(e.numer,t),gz(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=rL(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 az(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Z(`mo`,[new az(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return uz(i)}return n},aV=(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`),aV({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:rV,mathmlBuilder:iV}),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 oV=[`display`,`text`,`script`,`scriptscript`],sV=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=UR(t[0]),o=a.type===`atom`&&a.family===`open`?sV(a.text):null,s=UR(t[1]),c=s.type===`atom`&&s.family===`close`?sV(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=oV[Number(m.text)]}}else p=Q(p,`textord`),f=oV[Number(p.text)];return aV({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 cV=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?tz(e.sup,t.havingStyle(n.sup()),t):tz(e.sub,t.havingStyle(n.sub()),t),i=Q(e.base,`horizBrace`)):i=Q(e,`horizBrace`);var a=tz(i.base,t.havingBaseStyle(L.DISPLAY)),o=Az(i,t),s=i.isOver?OR({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):OR({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?OR({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):OR({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:cV,mathmlBuilder:(e,t)=>{var n=Dz(e.label);return new Z(e.isOver?`mover`:`munder`,[gz(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:WR(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=YR(e.body,t,!1);return wR(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=hz(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=YR(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)=>hz(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:WR(t[0]),mathml:WR(t[1])}),htmlBuilder:(e,t)=>TR(YR(e.html,t,!1)),mathmlBuilder:(e,t)=>hz(e.mathml,t)});var lV=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(!nL(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=rL(e.height,t),r=0;e.totalheight.number>0&&(r=rL(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=rL(e.width,t));var a={height:R(n+r)};i>0&&(a.width=R(i)),r>0&&(a.verticalAlign=R(-r));var o=new fL(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=rL(e.height,t),i=0;if(e.totalheight.number>0&&(i=rL(e.totalheight,t)-r,n.setAttribute(`valign`,R(-i))),n.setAttribute(`height`,R(r+i)),e.width.number>0){var a=rL(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 kR(e.dimension,t)},mathmlBuilder(e,t){return new oz(rL(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([],[tz(e.body,t)]),n=Y([`katex-inner`],[n],t)):n=Y([`katex-inner`],[tz(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`,[gz(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 uV=(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:WR(t[0]),text:WR(t[1]),script:WR(t[2]),scriptscript:WR(t[3])}),htmlBuilder:(e,t)=>TR(YR(uV(e,t),t,!1)),mathmlBuilder:(e,t)=>hz(uV(e,t),t)});var dV=(e,t,n,r,i,a,o)=>{e=Y([],[e]);var s=n&&fI(n),c,l;if(t){var u=tz(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=tz(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=OR({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=OR({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=OR({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)},fV=new Set([`\\smallint`]),pV=(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&&!fV.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=hR(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=NR(d+`Size`+(s?`2`:`1`),t);c=OR({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=YR(a.body,t,!0);p.length===1&&p[0]instanceof mL?(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`,[lz(e.name,e.mode)]),fV.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Z(`mo`,mz(e.body,t));else{n=new Z(`mi`,[new az(e.name.slice(1))]);var r=new Z(`mo`,[lz(`⁡`,`text`)]);n=e.parentIsSupSub?new Z(`mrow`,[n,r]):iz([n,r])}return n},hV={"∏":`\\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=hV[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:pV,mathmlBuilder:mV}),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:WR(r)}}});var gV={"∫":`\\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=gV[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var _V=(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=YR(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:WR(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:_V,mathmlBuilder:(e,t)=>{for(var n=mz(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`,[lz(`⁡`,`text`)]);return e.parentIsSupSub?new Z(`mrow`,[s,c]):iz([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),HR({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?TR(YR(e.body,t,!1)):Y([`mord`],YR(e.body,t,!0),t)},mathmlBuilder(e,t){return hz(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=tz(e.body,t.havingCrampedStyle()),r=CR(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-overline`],[OR({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 az(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`mover`,[gz(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:WR(r)}},htmlBuilder:(e,t)=>TR(YR(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Z(`mphantom`,mz(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`],[tz(e.body,t.withPhantom())]),Y([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Z(`mpadded`,[new Z(`mphantom`,mz(WR(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=tz(e.body,t);return OR({positionType:`shift`,positionData:-rL(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Z(`mpadded`,[gz(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var vV=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});X({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:vV,htmlBuilder(e,t){return Y([`mord`,`reflectbox`],[tz(e.body,t)],t)},mathmlBuilder(e,t){return gz(e.body,t)}}),X({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:vV}),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=rL(e.width,t),i=rL(e.height,t),a=e.shift?rL(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=rL(e.width,t),r=rL(e.height,t),i=e.shift?rL(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 yV(e,t,n){for(var r=YR(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:bV.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return yV(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Z(`mstyle`,mz(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([],[tz(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`,[gz(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=tz(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=ER(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=OR({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=tz(e.index,p,t);return Y([`mord`,`sqrt`],[Y([`katex-root`],[OR({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`,[gz(n,t),gz(r,t)]):new Z(`msqrt`,[gz(n,t)])}});var xV={display:L.DISPLAY,text:L.TEXT,script:L.SCRIPT,scriptscript:L.SCRIPTSCRIPT};function SV(e){return e in xV}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(!SV(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=xV[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),yV(e.body,r,t)},mathmlBuilder(e,t){var n=xV[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Z(`mstyle`,mz(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 CV=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===L.DISPLAY.size||n.alwaysHandleSupSub)?pV:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===L.DISPLAY.size||n.limits)?_V:null:n.type===`accent`?fI(n.base)?Vz:null:n.type===`horizBrace`&&!e.sub===n.isOver?cV:null:null};HR({type:`supsub`,htmlBuilder(e,t){var n=CV(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=tz(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&fI(r);if(i){var p=t.havingStyle(t.style.sup());s=tz(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=tz(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 mL||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=OR({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=OR({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=OR({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return Y([$R(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=[gz(e.base,t)];e.sub&&a.push(gz(e.sub,t)),e.sup&&a.push(gz(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)}}),HR({type:`atom`,htmlBuilder(e,t){return gR(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Z(`mo`,[lz(e.text,e.mode)]);if(e.family===`bin`){var r=fz(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 wV={mi:`italic`,mn:`normal`,mtext:`normal`};HR({type:`mathord`,htmlBuilder(e,t){return vR(e,t)},mathmlBuilder(e,t){var n=new Z(`mi`,[lz(e.text,e.mode,t)]),r=fz(e,t)||`italic`;return r!==wV[n.type]&&n.setAttribute(`mathvariant`,r),n}}),HR({type:`textord`,htmlBuilder(e,t){return vR(e,t)},mathmlBuilder(e,t){var n=lz(e.text,e.mode,t),r=fz(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!==wV[i.type]&&i.setAttribute(`mathvariant`,r),i}});var TV=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),EV=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);HR({type:`spacing`,htmlBuilder(e,t){var n=EV.get(e.text),r=TV.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=vR(e,t);return a.classes.push(i),a}return Y([`mspace`,i],[gR(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(EV.has(e.text))n=new Z(`mtext`,[new az(`\xA0`)]);else if(TV.has(e.text))return new Z(`mspace`);else throw new I(`Unknown type of space "`+e.text+`"`);return n}});var DV=()=>{var e=new Z(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};HR({type:`tag`,mathmlBuilder(e,t){var n=new Z(`mtable`,[new Z(`mtr`,[DV(),new Z(`mtd`,[hz(e.body,t)]),DV(),new Z(`mtd`,[hz(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var OV={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},kV={"\\textbf":`textbf`,"\\textmd":`textmd`},AV={"\\textit":`textit`,"\\textup":`textup`},jV=(e,t)=>{var n=e.font;return n?OV[n]?t.withTextFontFamily(OV[n]):kV[n]?t.withTextFontWeight(kV[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(AV[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:WR(i),font:r}},htmlBuilder(e,t){var n=jV(e,t);return Y([`mord`,`text`],YR(e.body,n,!0),n)},mathmlBuilder(e,t){var n=jV(e,t);return hz(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=tz(e.body,t),r=CR(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return Y([`mord`,`katex-underline`],[OR({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 az(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Z(`munder`,[gz(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=tz(e.body,t),r=t.fontMetrics().axisHeight;return OR({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`,[gz(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=MV(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),NV=zR,PV=`[ \r - ]`,FV=`\\\\[a-zA-Z@]+`,IV=`\\\\[^\ud800-\udfff]`,LV=`(`+FV+`)`+PV+`*`,RV=`\\\\( +-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 ez(e){return`toText`in e}var tz=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(ez(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},nz={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},rz={ex:!0,em:!0,mu:!0},iz=function(e){return typeof e!=`string`&&(e=e.unit),e in nz||e in rz||e===`ex`},az=function(e,t){var n;if(e.unit in nz)n=nz[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new L(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},oz=function(e){return e.filter(e=>e).join(` `)},sz=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=cR(n)+`:`+r+`;`)}return t},cz=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)}},lz=function(e){var t=document.createElement(e);t.className=oz(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]/,dz=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+dR(oz(this.classes))+`"`);var n=sz(this.style);n&&(t+=` style="`+dR(n)+`"`);for(var r of Object.keys(this.attributes)){if(uz.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+dR(this.attributes[r])+`"`}t+=`>`;for(var i=0;i`,t},fz=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,cz.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return lz.call(this,`span`)}toMarkup(){return dz.call(this,`span`)}},pz=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,cz.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 lz.call(this,`a`)}toMarkup(){return dz.call(this,`a`)}},mz=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=``+dR(this.alt)+``,e}},hz={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},gz=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=RR(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=hz[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=oz(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:`+z(this.italic)+`;`),n+=sz(this.style),n&&(e=!0,t+=` style="`+dR(n)+`"`);var r=dR(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},_z=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}},vz=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`,QR[this.pathName]),e}toMarkup(){return this.alternate?``:``}},yz=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 bz(e){if(e instanceof gz)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function xz(e){if(e instanceof fz)return e;throw Error(`Expected span but got `+String(e)+`.`)}var Sz=e=>e instanceof fz||e instanceof pz||e instanceof tz,Cz={"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]}},wz={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]},Tz={Å:`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 Ez(e,t){Cz[e]=t}function Dz(e,t,n){if(!Cz[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=Cz[t][r];if(!i&&e[0]in Tz&&(r=Tz[e[0]].charCodeAt(0),i=Cz[t][r]),!i&&n===`text`&&BR(r)&&(i=Cz[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var Oz={};function kz(e){var t=e>=5?0:e>=3?1:2;if(!Oz[t]){var n=Oz[t]={cssEmPerMu:wz.quad[t]/18};for(var r of Object.keys(wz))n[r]=wz[r][t]}return Oz[t]}var Az={math:{},text:{}};function B(e,t,n,r,i,a){Az[e][i]={font:t,group:n,replace:r},a&&r&&(Az[e][r]=Az[e][i])}var V=`math`,H=`text`,U=`main`,W=`ams`,jz=`accent-token`,G=`bin`,Mz=`close`,Nz=`inner`,K=`mathord`,Pz=`op-token`,Fz=`open`,Iz=`punct`,q=`rel`,Lz=`spacing`,J=`textord`;B(V,U,q,`≡`,`\\equiv`,!0),B(V,U,q,`≺`,`\\prec`,!0),B(V,U,q,`≻`,`\\succ`,!0),B(V,U,q,`∼`,`\\sim`,!0),B(V,U,q,`⊥`,`\\perp`),B(V,U,q,`⪯`,`\\preceq`,!0),B(V,U,q,`⪰`,`\\succeq`,!0),B(V,U,q,`≃`,`\\simeq`,!0),B(V,U,q,`∣`,`\\mid`,!0),B(V,U,q,`≪`,`\\ll`,!0),B(V,U,q,`≫`,`\\gg`,!0),B(V,U,q,`≍`,`\\asymp`,!0),B(V,U,q,`∥`,`\\parallel`),B(V,U,q,`⋈`,`\\bowtie`,!0),B(V,U,q,`⌣`,`\\smile`,!0),B(V,U,q,`⊑`,`\\sqsubseteq`,!0),B(V,U,q,`⊒`,`\\sqsupseteq`,!0),B(V,U,q,`≐`,`\\doteq`,!0),B(V,U,q,`⌢`,`\\frown`,!0),B(V,U,q,`∋`,`\\ni`,!0),B(V,U,q,`∝`,`\\propto`,!0),B(V,U,q,`⊢`,`\\vdash`,!0),B(V,U,q,`⊣`,`\\dashv`,!0),B(V,U,q,`∋`,`\\owns`),B(V,U,Iz,`.`,`\\ldotp`),B(V,U,Iz,`⋅`,`\\cdotp`),B(V,U,Iz,`⋅`,`·`),B(H,U,J,`⋅`,`·`),B(V,U,J,`#`,`\\#`),B(H,U,J,`#`,`\\#`),B(V,U,J,`&`,`\\&`),B(H,U,J,`&`,`\\&`),B(V,U,J,`ℵ`,`\\aleph`,!0),B(V,U,J,`∀`,`\\forall`,!0),B(V,U,J,`ℏ`,`\\hbar`,!0),B(V,U,J,`∃`,`\\exists`,!0),B(V,U,J,`∇`,`\\nabla`,!0),B(V,U,J,`♭`,`\\flat`,!0),B(V,U,J,`ℓ`,`\\ell`,!0),B(V,U,J,`♮`,`\\natural`,!0),B(V,U,J,`♣`,`\\clubsuit`,!0),B(V,U,J,`℘`,`\\wp`,!0),B(V,U,J,`♯`,`\\sharp`,!0),B(V,U,J,`♢`,`\\diamondsuit`,!0),B(V,U,J,`ℜ`,`\\Re`,!0),B(V,U,J,`♡`,`\\heartsuit`,!0),B(V,U,J,`ℑ`,`\\Im`,!0),B(V,U,J,`♠`,`\\spadesuit`,!0),B(V,U,J,`§`,`\\S`,!0),B(H,U,J,`§`,`\\S`),B(V,U,J,`¶`,`\\P`,!0),B(H,U,J,`¶`,`\\P`),B(V,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\textdagger`),B(V,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\textdaggerdbl`),B(V,U,Mz,`⎱`,`\\rmoustache`,!0),B(V,U,Fz,`⎰`,`\\lmoustache`,!0),B(V,U,Mz,`⟯`,`\\rgroup`,!0),B(V,U,Fz,`⟮`,`\\lgroup`,!0),B(V,U,G,`∓`,`\\mp`,!0),B(V,U,G,`⊖`,`\\ominus`,!0),B(V,U,G,`⊎`,`\\uplus`,!0),B(V,U,G,`⊓`,`\\sqcap`,!0),B(V,U,G,`∗`,`\\ast`),B(V,U,G,`⊔`,`\\sqcup`,!0),B(V,U,G,`◯`,`\\bigcirc`,!0),B(V,U,G,`∙`,`\\bullet`,!0),B(V,U,G,`‡`,`\\ddagger`),B(V,U,G,`≀`,`\\wr`,!0),B(V,U,G,`⨿`,`\\amalg`),B(V,U,G,`&`,`\\And`),B(V,U,q,`⟵`,`\\longleftarrow`,!0),B(V,U,q,`⇐`,`\\Leftarrow`,!0),B(V,U,q,`⟸`,`\\Longleftarrow`,!0),B(V,U,q,`⟶`,`\\longrightarrow`,!0),B(V,U,q,`⇒`,`\\Rightarrow`,!0),B(V,U,q,`⟹`,`\\Longrightarrow`,!0),B(V,U,q,`↔`,`\\leftrightarrow`,!0),B(V,U,q,`⟷`,`\\longleftrightarrow`,!0),B(V,U,q,`⇔`,`\\Leftrightarrow`,!0),B(V,U,q,`⟺`,`\\Longleftrightarrow`,!0),B(V,U,q,`↦`,`\\mapsto`,!0),B(V,U,q,`⟼`,`\\longmapsto`,!0),B(V,U,q,`↗`,`\\nearrow`,!0),B(V,U,q,`↩`,`\\hookleftarrow`,!0),B(V,U,q,`↪`,`\\hookrightarrow`,!0),B(V,U,q,`↘`,`\\searrow`,!0),B(V,U,q,`↼`,`\\leftharpoonup`,!0),B(V,U,q,`⇀`,`\\rightharpoonup`,!0),B(V,U,q,`↙`,`\\swarrow`,!0),B(V,U,q,`↽`,`\\leftharpoondown`,!0),B(V,U,q,`⇁`,`\\rightharpoondown`,!0),B(V,U,q,`↖`,`\\nwarrow`,!0),B(V,U,q,`⇌`,`\\rightleftharpoons`,!0),B(V,W,q,`≮`,`\\nless`,!0),B(V,W,q,``,`\\@nleqslant`),B(V,W,q,``,`\\@nleqq`),B(V,W,q,`⪇`,`\\lneq`,!0),B(V,W,q,`≨`,`\\lneqq`,!0),B(V,W,q,``,`\\@lvertneqq`),B(V,W,q,`⋦`,`\\lnsim`,!0),B(V,W,q,`⪉`,`\\lnapprox`,!0),B(V,W,q,`⊀`,`\\nprec`,!0),B(V,W,q,`⋠`,`\\npreceq`,!0),B(V,W,q,`⋨`,`\\precnsim`,!0),B(V,W,q,`⪹`,`\\precnapprox`,!0),B(V,W,q,`≁`,`\\nsim`,!0),B(V,W,q,``,`\\@nshortmid`),B(V,W,q,`∤`,`\\nmid`,!0),B(V,W,q,`⊬`,`\\nvdash`,!0),B(V,W,q,`⊭`,`\\nvDash`,!0),B(V,W,q,`⋪`,`\\ntriangleleft`),B(V,W,q,`⋬`,`\\ntrianglelefteq`,!0),B(V,W,q,`⊊`,`\\subsetneq`,!0),B(V,W,q,``,`\\@varsubsetneq`),B(V,W,q,`⫋`,`\\subsetneqq`,!0),B(V,W,q,``,`\\@varsubsetneqq`),B(V,W,q,`≯`,`\\ngtr`,!0),B(V,W,q,``,`\\@ngeqslant`),B(V,W,q,``,`\\@ngeqq`),B(V,W,q,`⪈`,`\\gneq`,!0),B(V,W,q,`≩`,`\\gneqq`,!0),B(V,W,q,``,`\\@gvertneqq`),B(V,W,q,`⋧`,`\\gnsim`,!0),B(V,W,q,`⪊`,`\\gnapprox`,!0),B(V,W,q,`⊁`,`\\nsucc`,!0),B(V,W,q,`⋡`,`\\nsucceq`,!0),B(V,W,q,`⋩`,`\\succnsim`,!0),B(V,W,q,`⪺`,`\\succnapprox`,!0),B(V,W,q,`≆`,`\\ncong`,!0),B(V,W,q,``,`\\@nshortparallel`),B(V,W,q,`∦`,`\\nparallel`,!0),B(V,W,q,`⊯`,`\\nVDash`,!0),B(V,W,q,`⋫`,`\\ntriangleright`),B(V,W,q,`⋭`,`\\ntrianglerighteq`,!0),B(V,W,q,``,`\\@nsupseteqq`),B(V,W,q,`⊋`,`\\supsetneq`,!0),B(V,W,q,``,`\\@varsupsetneq`),B(V,W,q,`⫌`,`\\supsetneqq`,!0),B(V,W,q,``,`\\@varsupsetneqq`),B(V,W,q,`⊮`,`\\nVdash`,!0),B(V,W,q,`⪵`,`\\precneqq`,!0),B(V,W,q,`⪶`,`\\succneqq`,!0),B(V,W,q,``,`\\@nsubseteqq`),B(V,W,G,`⊴`,`\\unlhd`),B(V,W,G,`⊵`,`\\unrhd`),B(V,W,q,`↚`,`\\nleftarrow`,!0),B(V,W,q,`↛`,`\\nrightarrow`,!0),B(V,W,q,`⇍`,`\\nLeftarrow`,!0),B(V,W,q,`⇏`,`\\nRightarrow`,!0),B(V,W,q,`↮`,`\\nleftrightarrow`,!0),B(V,W,q,`⇎`,`\\nLeftrightarrow`,!0),B(V,W,q,`△`,`\\vartriangle`),B(V,W,J,`ℏ`,`\\hslash`),B(V,W,J,`▽`,`\\triangledown`),B(V,W,J,`◊`,`\\lozenge`),B(V,W,J,`Ⓢ`,`\\circledS`),B(V,W,J,`®`,`\\circledR`),B(H,W,J,`®`,`\\circledR`),B(V,W,J,`∡`,`\\measuredangle`,!0),B(V,W,J,`∄`,`\\nexists`),B(V,W,J,`℧`,`\\mho`),B(V,W,J,`Ⅎ`,`\\Finv`,!0),B(V,W,J,`⅁`,`\\Game`,!0),B(V,W,J,`‵`,`\\backprime`),B(V,W,J,`▲`,`\\blacktriangle`),B(V,W,J,`▼`,`\\blacktriangledown`),B(V,W,J,`■`,`\\blacksquare`),B(V,W,J,`⧫`,`\\blacklozenge`),B(V,W,J,`★`,`\\bigstar`),B(V,W,J,`∢`,`\\sphericalangle`,!0),B(V,W,J,`∁`,`\\complement`,!0),B(V,W,J,`ð`,`\\eth`,!0),B(H,U,J,`ð`,`ð`),B(V,W,J,`╱`,`\\diagup`),B(V,W,J,`╲`,`\\diagdown`),B(V,W,J,`□`,`\\square`),B(V,W,J,`□`,`\\Box`),B(V,W,J,`◊`,`\\Diamond`),B(V,W,J,`¥`,`\\yen`,!0),B(H,W,J,`¥`,`\\yen`,!0),B(V,W,J,`✓`,`\\checkmark`,!0),B(H,W,J,`✓`,`\\checkmark`),B(V,W,J,`ℶ`,`\\beth`,!0),B(V,W,J,`ℸ`,`\\daleth`,!0),B(V,W,J,`ℷ`,`\\gimel`,!0),B(V,W,J,`ϝ`,`\\digamma`,!0),B(V,W,J,`ϰ`,`\\varkappa`),B(V,W,Fz,`┌`,`\\@ulcorner`,!0),B(V,W,Mz,`┐`,`\\@urcorner`,!0),B(V,W,Fz,`└`,`\\@llcorner`,!0),B(V,W,Mz,`┘`,`\\@lrcorner`,!0),B(V,W,q,`≦`,`\\leqq`,!0),B(V,W,q,`⩽`,`\\leqslant`,!0),B(V,W,q,`⪕`,`\\eqslantless`,!0),B(V,W,q,`≲`,`\\lesssim`,!0),B(V,W,q,`⪅`,`\\lessapprox`,!0),B(V,W,q,`≊`,`\\approxeq`,!0),B(V,W,G,`⋖`,`\\lessdot`),B(V,W,q,`⋘`,`\\lll`,!0),B(V,W,q,`≶`,`\\lessgtr`,!0),B(V,W,q,`⋚`,`\\lesseqgtr`,!0),B(V,W,q,`⪋`,`\\lesseqqgtr`,!0),B(V,W,q,`≑`,`\\doteqdot`),B(V,W,q,`≓`,`\\risingdotseq`,!0),B(V,W,q,`≒`,`\\fallingdotseq`,!0),B(V,W,q,`∽`,`\\backsim`,!0),B(V,W,q,`⋍`,`\\backsimeq`,!0),B(V,W,q,`⫅`,`\\subseteqq`,!0),B(V,W,q,`⋐`,`\\Subset`,!0),B(V,W,q,`⊏`,`\\sqsubset`,!0),B(V,W,q,`≼`,`\\preccurlyeq`,!0),B(V,W,q,`⋞`,`\\curlyeqprec`,!0),B(V,W,q,`≾`,`\\precsim`,!0),B(V,W,q,`⪷`,`\\precapprox`,!0),B(V,W,q,`⊲`,`\\vartriangleleft`),B(V,W,q,`⊴`,`\\trianglelefteq`),B(V,W,q,`⊨`,`\\vDash`,!0),B(V,W,q,`⊪`,`\\Vvdash`,!0),B(V,W,q,`⌣`,`\\smallsmile`),B(V,W,q,`⌢`,`\\smallfrown`),B(V,W,q,`≏`,`\\bumpeq`,!0),B(V,W,q,`≎`,`\\Bumpeq`,!0),B(V,W,q,`≧`,`\\geqq`,!0),B(V,W,q,`⩾`,`\\geqslant`,!0),B(V,W,q,`⪖`,`\\eqslantgtr`,!0),B(V,W,q,`≳`,`\\gtrsim`,!0),B(V,W,q,`⪆`,`\\gtrapprox`,!0),B(V,W,G,`⋗`,`\\gtrdot`),B(V,W,q,`⋙`,`\\ggg`,!0),B(V,W,q,`≷`,`\\gtrless`,!0),B(V,W,q,`⋛`,`\\gtreqless`,!0),B(V,W,q,`⪌`,`\\gtreqqless`,!0),B(V,W,q,`≖`,`\\eqcirc`,!0),B(V,W,q,`≗`,`\\circeq`,!0),B(V,W,q,`≜`,`\\triangleq`,!0),B(V,W,q,`∼`,`\\thicksim`),B(V,W,q,`≈`,`\\thickapprox`),B(V,W,q,`⫆`,`\\supseteqq`,!0),B(V,W,q,`⋑`,`\\Supset`,!0),B(V,W,q,`⊐`,`\\sqsupset`,!0),B(V,W,q,`≽`,`\\succcurlyeq`,!0),B(V,W,q,`⋟`,`\\curlyeqsucc`,!0),B(V,W,q,`≿`,`\\succsim`,!0),B(V,W,q,`⪸`,`\\succapprox`,!0),B(V,W,q,`⊳`,`\\vartriangleright`),B(V,W,q,`⊵`,`\\trianglerighteq`),B(V,W,q,`⊩`,`\\Vdash`,!0),B(V,W,q,`∣`,`\\shortmid`),B(V,W,q,`∥`,`\\shortparallel`),B(V,W,q,`≬`,`\\between`,!0),B(V,W,q,`⋔`,`\\pitchfork`,!0),B(V,W,q,`∝`,`\\varpropto`),B(V,W,q,`◀`,`\\blacktriangleleft`),B(V,W,q,`∴`,`\\therefore`,!0),B(V,W,q,`∍`,`\\backepsilon`),B(V,W,q,`▶`,`\\blacktriangleright`),B(V,W,q,`∵`,`\\because`,!0),B(V,W,q,`⋘`,`\\llless`),B(V,W,q,`⋙`,`\\gggtr`),B(V,W,G,`⊲`,`\\lhd`),B(V,W,G,`⊳`,`\\rhd`),B(V,W,q,`≂`,`\\eqsim`,!0),B(V,U,q,`⋈`,`\\Join`),B(V,W,q,`≑`,`\\Doteq`,!0),B(V,W,G,`∔`,`\\dotplus`,!0),B(V,W,G,`∖`,`\\smallsetminus`),B(V,W,G,`⋒`,`\\Cap`,!0),B(V,W,G,`⋓`,`\\Cup`,!0),B(V,W,G,`⩞`,`\\doublebarwedge`,!0),B(V,W,G,`⊟`,`\\boxminus`,!0),B(V,W,G,`⊞`,`\\boxplus`,!0),B(V,W,G,`⋇`,`\\divideontimes`,!0),B(V,W,G,`⋉`,`\\ltimes`,!0),B(V,W,G,`⋊`,`\\rtimes`,!0),B(V,W,G,`⋋`,`\\leftthreetimes`,!0),B(V,W,G,`⋌`,`\\rightthreetimes`,!0),B(V,W,G,`⋏`,`\\curlywedge`,!0),B(V,W,G,`⋎`,`\\curlyvee`,!0),B(V,W,G,`⊝`,`\\circleddash`,!0),B(V,W,G,`⊛`,`\\circledast`,!0),B(V,W,G,`⋅`,`\\centerdot`),B(V,W,G,`⊺`,`\\intercal`,!0),B(V,W,G,`⋒`,`\\doublecap`),B(V,W,G,`⋓`,`\\doublecup`),B(V,W,G,`⊠`,`\\boxtimes`,!0),B(V,W,q,`⇢`,`\\dashrightarrow`,!0),B(V,W,q,`⇠`,`\\dashleftarrow`,!0),B(V,W,q,`⇇`,`\\leftleftarrows`,!0),B(V,W,q,`⇆`,`\\leftrightarrows`,!0),B(V,W,q,`⇚`,`\\Lleftarrow`,!0),B(V,W,q,`↞`,`\\twoheadleftarrow`,!0),B(V,W,q,`↢`,`\\leftarrowtail`,!0),B(V,W,q,`↫`,`\\looparrowleft`,!0),B(V,W,q,`⇋`,`\\leftrightharpoons`,!0),B(V,W,q,`↶`,`\\curvearrowleft`,!0),B(V,W,q,`↺`,`\\circlearrowleft`,!0),B(V,W,q,`↰`,`\\Lsh`,!0),B(V,W,q,`⇈`,`\\upuparrows`,!0),B(V,W,q,`↿`,`\\upharpoonleft`,!0),B(V,W,q,`⇃`,`\\downharpoonleft`,!0),B(V,U,q,`⊶`,`\\origof`,!0),B(V,U,q,`⊷`,`\\imageof`,!0),B(V,W,q,`⊸`,`\\multimap`,!0),B(V,W,q,`↭`,`\\leftrightsquigarrow`,!0),B(V,W,q,`⇉`,`\\rightrightarrows`,!0),B(V,W,q,`⇄`,`\\rightleftarrows`,!0),B(V,W,q,`↠`,`\\twoheadrightarrow`,!0),B(V,W,q,`↣`,`\\rightarrowtail`,!0),B(V,W,q,`↬`,`\\looparrowright`,!0),B(V,W,q,`↷`,`\\curvearrowright`,!0),B(V,W,q,`↻`,`\\circlearrowright`,!0),B(V,W,q,`↱`,`\\Rsh`,!0),B(V,W,q,`⇊`,`\\downdownarrows`,!0),B(V,W,q,`↾`,`\\upharpoonright`,!0),B(V,W,q,`⇂`,`\\downharpoonright`,!0),B(V,W,q,`⇝`,`\\rightsquigarrow`,!0),B(V,W,q,`⇝`,`\\leadsto`),B(V,W,q,`⇛`,`\\Rrightarrow`,!0),B(V,W,q,`↾`,`\\restriction`),B(V,U,J,`‘`,"`"),B(V,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\textdollar`),B(V,U,J,`%`,`\\%`),B(H,U,J,`%`,`\\%`),B(V,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\textunderscore`),B(V,U,J,`∠`,`\\angle`,!0),B(V,U,J,`∞`,`\\infty`,!0),B(V,U,J,`′`,`\\prime`),B(V,U,J,`△`,`\\triangle`),B(V,U,J,`Γ`,`\\Gamma`,!0),B(V,U,J,`Δ`,`\\Delta`,!0),B(V,U,J,`Θ`,`\\Theta`,!0),B(V,U,J,`Λ`,`\\Lambda`,!0),B(V,U,J,`Ξ`,`\\Xi`,!0),B(V,U,J,`Π`,`\\Pi`,!0),B(V,U,J,`Σ`,`\\Sigma`,!0),B(V,U,J,`Υ`,`\\Upsilon`,!0),B(V,U,J,`Φ`,`\\Phi`,!0),B(V,U,J,`Ψ`,`\\Psi`,!0),B(V,U,J,`Ω`,`\\Omega`,!0),B(V,U,J,`A`,`Α`),B(V,U,J,`B`,`Β`),B(V,U,J,`E`,`Ε`),B(V,U,J,`Z`,`Ζ`),B(V,U,J,`H`,`Η`),B(V,U,J,`I`,`Ι`),B(V,U,J,`K`,`Κ`),B(V,U,J,`M`,`Μ`),B(V,U,J,`N`,`Ν`),B(V,U,J,`O`,`Ο`),B(V,U,J,`P`,`Ρ`),B(V,U,J,`T`,`Τ`),B(V,U,J,`X`,`Χ`),B(V,U,J,`¬`,`\\neg`,!0),B(V,U,J,`¬`,`\\lnot`),B(V,U,J,`⊤`,`\\top`),B(V,U,J,`⊥`,`\\bot`),B(V,U,J,`∅`,`\\emptyset`),B(V,W,J,`∅`,`\\varnothing`),B(V,U,K,`α`,`\\alpha`,!0),B(V,U,K,`β`,`\\beta`,!0),B(V,U,K,`γ`,`\\gamma`,!0),B(V,U,K,`δ`,`\\delta`,!0),B(V,U,K,`ϵ`,`\\epsilon`,!0),B(V,U,K,`ζ`,`\\zeta`,!0),B(V,U,K,`η`,`\\eta`,!0),B(V,U,K,`θ`,`\\theta`,!0),B(V,U,K,`ι`,`\\iota`,!0),B(V,U,K,`κ`,`\\kappa`,!0),B(V,U,K,`λ`,`\\lambda`,!0),B(V,U,K,`μ`,`\\mu`,!0),B(V,U,K,`ν`,`\\nu`,!0),B(V,U,K,`ξ`,`\\xi`,!0),B(V,U,K,`ο`,`\\omicron`,!0),B(V,U,K,`π`,`\\pi`,!0),B(V,U,K,`ρ`,`\\rho`,!0),B(V,U,K,`σ`,`\\sigma`,!0),B(V,U,K,`τ`,`\\tau`,!0),B(V,U,K,`υ`,`\\upsilon`,!0),B(V,U,K,`ϕ`,`\\phi`,!0),B(V,U,K,`χ`,`\\chi`,!0),B(V,U,K,`ψ`,`\\psi`,!0),B(V,U,K,`ω`,`\\omega`,!0),B(V,U,K,`ε`,`\\varepsilon`,!0),B(V,U,K,`ϑ`,`\\vartheta`,!0),B(V,U,K,`ϖ`,`\\varpi`,!0),B(V,U,K,`ϱ`,`\\varrho`,!0),B(V,U,K,`ς`,`\\varsigma`,!0),B(V,U,K,`φ`,`\\varphi`,!0),B(V,U,G,`∗`,`*`,!0),B(V,U,G,`+`,`+`),B(V,U,G,`−`,`-`,!0),B(V,U,G,`⋅`,`\\cdot`,!0),B(V,U,G,`∘`,`\\circ`,!0),B(V,U,G,`÷`,`\\div`,!0),B(V,U,G,`±`,`\\pm`,!0),B(V,U,G,`×`,`\\times`,!0),B(V,U,G,`∩`,`\\cap`,!0),B(V,U,G,`∪`,`\\cup`,!0),B(V,U,G,`∖`,`\\setminus`,!0),B(V,U,G,`∧`,`\\land`),B(V,U,G,`∨`,`\\lor`),B(V,U,G,`∧`,`\\wedge`,!0),B(V,U,G,`∨`,`\\vee`,!0),B(V,U,J,`√`,`\\surd`),B(V,U,Fz,`⟨`,`\\langle`,!0),B(V,U,Fz,`∣`,`\\lvert`),B(V,U,Fz,`∥`,`\\lVert`),B(V,U,Mz,`?`,`?`),B(V,U,Mz,`!`,`!`),B(V,U,Mz,`⟩`,`\\rangle`,!0),B(V,U,Mz,`∣`,`\\rvert`),B(V,U,Mz,`∥`,`\\rVert`),B(V,U,q,`=`,`=`),B(V,U,q,`:`,`:`),B(V,U,q,`≈`,`\\approx`,!0),B(V,U,q,`≅`,`\\cong`,!0),B(V,U,q,`≥`,`\\ge`),B(V,U,q,`≥`,`\\geq`,!0),B(V,U,q,`←`,`\\gets`),B(V,U,q,`>`,`\\gt`,!0),B(V,U,q,`∈`,`\\in`,!0),B(V,U,q,``,`\\@not`),B(V,U,q,`⊂`,`\\subset`,!0),B(V,U,q,`⊃`,`\\supset`,!0),B(V,U,q,`⊆`,`\\subseteq`,!0),B(V,U,q,`⊇`,`\\supseteq`,!0),B(V,W,q,`⊈`,`\\nsubseteq`,!0),B(V,W,q,`⊉`,`\\nsupseteq`,!0),B(V,U,q,`⊨`,`\\models`),B(V,U,q,`←`,`\\leftarrow`,!0),B(V,U,q,`≤`,`\\le`),B(V,U,q,`≤`,`\\leq`,!0),B(V,U,q,`<`,`\\lt`,!0),B(V,U,q,`→`,`\\rightarrow`,!0),B(V,U,q,`→`,`\\to`),B(V,W,q,`≱`,`\\ngeq`,!0),B(V,W,q,`≰`,`\\nleq`,!0),B(V,U,Lz,`\xA0`,`\\ `),B(V,U,Lz,`\xA0`,`\\space`),B(V,U,Lz,`\xA0`,`\\nobreakspace`),B(H,U,Lz,`\xA0`,`\\ `),B(H,U,Lz,`\xA0`,` `),B(H,U,Lz,`\xA0`,`\\space`),B(H,U,Lz,`\xA0`,`\\nobreakspace`),B(V,U,Lz,``,`\\nobreak`),B(V,U,Lz,``,`\\allowbreak`),B(V,U,Iz,`,`,`,`),B(V,U,Iz,`;`,`;`),B(V,W,G,`⊼`,`\\barwedge`,!0),B(V,W,G,`⊻`,`\\veebar`,!0),B(V,U,G,`⊙`,`\\odot`,!0),B(V,U,G,`⊕`,`\\oplus`,!0),B(V,U,G,`⊗`,`\\otimes`,!0),B(V,U,J,`∂`,`\\partial`,!0),B(V,U,G,`⊘`,`\\oslash`,!0),B(V,W,G,`⊚`,`\\circledcirc`,!0),B(V,W,G,`⊡`,`\\boxdot`,!0),B(V,U,G,`△`,`\\bigtriangleup`),B(V,U,G,`▽`,`\\bigtriangledown`),B(V,U,G,`†`,`\\dagger`),B(V,U,G,`⋄`,`\\diamond`),B(V,U,G,`⋆`,`\\star`),B(V,U,G,`◃`,`\\triangleleft`),B(V,U,G,`▹`,`\\triangleright`),B(V,U,Fz,`{`,`\\{`),B(H,U,J,`{`,`\\{`),B(H,U,J,`{`,`\\textbraceleft`),B(V,U,Mz,`}`,`\\}`),B(H,U,J,`}`,`\\}`),B(H,U,J,`}`,`\\textbraceright`),B(V,U,Fz,`{`,`\\lbrace`),B(V,U,Mz,`}`,`\\rbrace`),B(V,U,Fz,`[`,`\\lbrack`,!0),B(H,U,J,`[`,`\\lbrack`,!0),B(V,U,Mz,`]`,`\\rbrack`,!0),B(H,U,J,`]`,`\\rbrack`,!0),B(V,U,Fz,`(`,`\\lparen`,!0),B(V,U,Mz,`)`,`\\rparen`,!0),B(H,U,J,`<`,`\\textless`,!0),B(H,U,J,`>`,`\\textgreater`,!0),B(V,U,Fz,`⌊`,`\\lfloor`,!0),B(V,U,Mz,`⌋`,`\\rfloor`,!0),B(V,U,Fz,`⌈`,`\\lceil`,!0),B(V,U,Mz,`⌉`,`\\rceil`,!0),B(V,U,J,`\\`,`\\backslash`),B(V,U,J,`∣`,`|`),B(V,U,J,`∣`,`\\vert`),B(H,U,J,`|`,`\\textbar`,!0),B(V,U,J,`∥`,`\\|`),B(V,U,J,`∥`,`\\Vert`),B(H,U,J,`∥`,`\\textbardbl`),B(H,U,J,`~`,`\\textasciitilde`),B(H,U,J,`\\`,`\\textbackslash`),B(H,U,J,`^`,`\\textasciicircum`),B(V,U,q,`↑`,`\\uparrow`,!0),B(V,U,q,`⇑`,`\\Uparrow`,!0),B(V,U,q,`↓`,`\\downarrow`,!0),B(V,U,q,`⇓`,`\\Downarrow`,!0),B(V,U,q,`↕`,`\\updownarrow`,!0),B(V,U,q,`⇕`,`\\Updownarrow`,!0),B(V,U,Pz,`∐`,`\\coprod`),B(V,U,Pz,`⋁`,`\\bigvee`),B(V,U,Pz,`⋀`,`\\bigwedge`),B(V,U,Pz,`⨄`,`\\biguplus`),B(V,U,Pz,`⋂`,`\\bigcap`),B(V,U,Pz,`⋃`,`\\bigcup`),B(V,U,Pz,`∫`,`\\int`),B(V,U,Pz,`∫`,`\\intop`),B(V,U,Pz,`∬`,`\\iint`),B(V,U,Pz,`∭`,`\\iiint`),B(V,U,Pz,`∏`,`\\prod`),B(V,U,Pz,`∑`,`\\sum`),B(V,U,Pz,`⨂`,`\\bigotimes`),B(V,U,Pz,`⨁`,`\\bigoplus`),B(V,U,Pz,`⨀`,`\\bigodot`),B(V,U,Pz,`∮`,`\\oint`),B(V,U,Pz,`∯`,`\\oiint`),B(V,U,Pz,`∰`,`\\oiiint`),B(V,U,Pz,`⨆`,`\\bigsqcup`),B(V,U,Pz,`∫`,`\\smallint`),B(H,U,Nz,`…`,`\\textellipsis`),B(V,U,Nz,`…`,`\\mathellipsis`),B(H,U,Nz,`…`,`\\ldots`,!0),B(V,U,Nz,`…`,`\\ldots`,!0),B(V,U,Nz,`⋯`,`\\@cdots`,!0),B(V,U,Nz,`⋱`,`\\ddots`,!0),B(V,U,J,`⋮`,`\\varvdots`),B(H,U,J,`⋮`,`\\varvdots`),B(V,U,jz,`ˊ`,`\\acute`),B(V,U,jz,`ˋ`,`\\grave`),B(V,U,jz,`¨`,`\\ddot`),B(V,U,jz,`~`,`\\tilde`),B(V,U,jz,`ˉ`,`\\bar`),B(V,U,jz,`˘`,`\\breve`),B(V,U,jz,`ˇ`,`\\check`),B(V,U,jz,`^`,`\\hat`),B(V,U,jz,`⃗`,`\\vec`),B(V,U,jz,`˙`,`\\dot`),B(V,U,jz,`˚`,`\\mathring`),B(V,U,K,``,`\\@imath`),B(V,U,K,``,`\\@jmath`),B(V,U,J,`ı`,`ı`),B(V,U,J,`ȷ`,`ȷ`),B(H,U,J,`ı`,`\\i`,!0),B(H,U,J,`ȷ`,`\\j`,!0),B(H,U,J,`ß`,`\\ss`,!0),B(H,U,J,`æ`,`\\ae`,!0),B(H,U,J,`œ`,`\\oe`,!0),B(H,U,J,`ø`,`\\o`,!0),B(H,U,J,`Æ`,`\\AE`,!0),B(H,U,J,`Œ`,`\\OE`,!0),B(H,U,J,`Ø`,`\\O`,!0),B(H,U,jz,`ˊ`,`\\'`),B(H,U,jz,`ˋ`,"\\`"),B(H,U,jz,`ˆ`,`\\^`),B(H,U,jz,`˜`,`\\~`),B(H,U,jz,`ˉ`,`\\=`),B(H,U,jz,`˘`,`\\u`),B(H,U,jz,`˙`,`\\.`),B(H,U,jz,`¸`,`\\c`),B(H,U,jz,`˚`,`\\r`),B(H,U,jz,`ˇ`,`\\v`),B(H,U,jz,`¨`,`\\"`),B(H,U,jz,`˝`,`\\H`),B(H,U,jz,`◯`,`\\textcircled`);var Rz={"--":!0,"---":!0,"``":!0,"''":!0};B(H,U,J,`–`,`--`,!0),B(H,U,J,`–`,`\\textendash`),B(H,U,J,`—`,`---`,!0),B(H,U,J,`—`,`\\textemdash`),B(H,U,J,`‘`,"`",!0),B(H,U,J,`‘`,`\\textquoteleft`),B(H,U,J,`’`,`'`,!0),B(H,U,J,`’`,`\\textquoteright`),B(H,U,J,`“`,"``",!0),B(H,U,J,`“`,`\\textquotedblleft`),B(H,U,J,`”`,`''`,!0),B(H,U,J,`”`,`\\textquotedblright`),B(V,U,J,`°`,`\\degree`,!0),B(H,U,J,`°`,`\\degree`),B(H,U,J,`°`,`\\textdegree`,!0),B(V,U,J,`£`,`\\pounds`),B(V,U,J,`£`,`\\mathsterling`,!0),B(H,U,J,`£`,`\\pounds`),B(H,U,J,`£`,`\\textsterling`,!0),B(V,W,J,`✠`,`\\maltese`),B(H,W,J,`✠`,`\\maltese`);for(var zz=`0123456789/@."`,Bz=0;Bz{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return pB[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return mB[Math.floor((r-120782)/10)];if(r===120485||r===120486)return pB[0];if(120486{if(oz(e.classes)!==oz(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},SB=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},X=function(e,t,n,r){var i=new fz(e,t,n,r);return CB(i),i},wB=(e,t,n,r)=>new fz(e,t,n,r),TB=function(e,t,n){var r=X([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=z(r.height),r.maxFontSize=1,r},EB=function(e,t,n,r){var i=new pz(e,t,n,r);return CB(i),i},DB=function(e){var t=new tz(e);return CB(t),t},OB=function(e,t){return e instanceof tz?X([],[e],t):e},kB=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=X([`mspace`],[],t),r=az(e,t);return n.style.marginRight=z(r),n},MB=(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},NB={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`}},PB={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},FB=function(e,t){var n=PB[e],r=n[0],i=n[1],a=n[2],o=wB([`katex-overlay`],[new _z([new vz(r)],{width:z(i),height:z(a),style:`width:`+z(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=z(a),o.style.width=z(i),o},IB={number:3,unit:`mu`},LB={number:4,unit:`mu`},RB={number:5,unit:`mu`},zB={mord:{mop:IB,mbin:LB,mrel:RB,minner:IB},mop:{mord:IB,mop:IB,mrel:RB,minner:IB},mbin:{mord:LB,mop:LB,mopen:LB,minner:LB},mrel:{mord:RB,mop:RB,mopen:RB,minner:RB},mopen:{},mclose:{mop:IB,mbin:LB,mrel:RB,minner:IB},mpunct:{mord:IB,mop:IB,mrel:RB,mopen:IB,mclose:IB,mpunct:IB,minner:IB},minner:{mord:IB,mop:IB,mbin:LB,mrel:RB,mopen:IB,mpunct:IB,minner:IB}},BB={mord:{mop:IB},mop:{mord:IB,mop:IB},mbin:{},mrel:{},mopen:{},mclose:{mop:IB},mpunct:{},minner:{mop:IB}},VB={},HB={},UB={};function Z(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`&&JB.has(r)?t.classes[0]=`mord`:r===`mbin`&&qB.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),QB(i,(e,t)=>{var n=tV(t),r=tV(e),i=n&&r?e.hasClass(`mtight`)?BB[n]?.[r]:zB[n]?.[r]:null;if(i)return jB(i,c)},{node:u},d,f),i},QB=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()},$B=function(e){return e instanceof tz||e instanceof pz||e instanceof fz&&e.hasClass(`enclosing`)?e:null},eV=function(e,t){var n=$B(e);if(n){var r=n.children;if(r.length){if(t===`right`)return eV(r[r.length-1],`right`);if(t===`left`)return eV(r[0],`left`)}}return e},tV=function(e,t){return e?(t&&(e=eV(e,t)),XB[e.classes[0]]||null):null},nV=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return X(t.concat(n))},rV=function(e,t,n){if(!e)return X();if(HB[e.type]){var r=HB[e.type](e,t);if(n&&t.size!==n.size){r=X(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new L(`Got group of unknown type: '`+e.type+`'`)};function iV(e,t){var n=X([`katex-base`],e,t),r=X([`katex-strut`]);return r.style.height=z(n.height+n.depth),n.depth&&(r.style.verticalAlign=z(-n.depth)),n.children.unshift(r),n}function aV(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=ZB(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(iV(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(iV(o,t));var l;n?(l=iV(ZB(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=X([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=z(u.height+u.depth),u.depth&&(d.style.verticalAlign=z(-u.depth))}return u}function oV(e){return new tz(e)}var Q=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=oz(this.classes));for(var i=0;i0&&(e+=` class ="`+dR(oz(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},sV=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return dR(this.toText())}toText(){return this.text}},cV=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`,z(this.width)),e}toMarkup(){return this.character?``+this.character+``:``}toText(){return this.character?this.character:` `}},lV=new Set([`\\imath`,`\\jmath`]),uV=new Set([`mrow`,`mtable`]),dV=function(e,t,n){var r,i;return Az[t][e]&&Az[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(Rz,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=Az[t][e].replace),new sV(e)},fV=function(e){return e.length===1?e[0]:new Q(`mrow`,e)},pV={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`},mV=(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=pV[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(lV.has(a))return null;if(Az[r][a]){var o=Az[r][a].replace;o&&(a=o)}var s=NB[n].fontName;return Dz(a,s,r)?NB[n].variant:null};function hV(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof sV&&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 sV&&n.text===`,`}return!1}var gV=function(e,t,n){if(e.length===1){var r=vV(e[0],t);return n&&r instanceof Q&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o=1&&(a.type===`mn`||hV(a))){var c=s.children[0];c instanceof Q&&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 sV&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof sV&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},_V=function(e,t,n){return fV(gV(e,t,n))},vV=function(e,t){if(!e)return new Q(`mrow`);if(UB[e.type])return UB[e.type](e,t);throw new L(`Got group of unknown type: '`+e.type+`'`)};function yV(e,t,n,r,i){var a=gV(e,n),o=a.length===1&&a[0]instanceof Q&&uV.has(a[0].type)?a[0]:new Q(`mrow`,a),s=new Q(`annotation`,[new sV(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new Q(`math`,[new Q(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),X([i?`katex`:`katex-mathml`],[c])}var bV=[[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]],xV=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],SV=function(e,t){return t.size<2?e:bV[e-1][t.size-1]},CV=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=xV[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:SV(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:xV[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=SV(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||=kz(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};CV.BASESIZE=6;var wV=function(e){return new CV({style:e.displayMode?R.DISPLAY:R.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},TV=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=X(n,[e])}return e},EV=function(e,t,n){var r=wV(n),i;return n.output===`mathml`?yV(e,t,r,n.displayMode,!0):(i=n.output===`html`?X([`katex`],[aV(e,r)]):X([`katex`],[yV(e,t,r,n.displayMode,!1),aV(e,r)]),TV(i,n))},DV=function(e,t,n){return TV(X([`katex`],[aV(e,wV(n))]),n)},OV={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":`=`},kV=function(e){var t=new Q(`mo`,[new sV(OV[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},AV={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]},jV=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),MV=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(jV.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:wB([],[new _z([new vz(o)],{width:`100%`,height:z(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=AV[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=z(a)),i},NV=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=X([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new yz({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new yz({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=wB([],[new _z(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},PV=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],FV=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],IV=new Set(PV),LV=new Set(FV);function RV(e){return IV.has(e)}function zV(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 BV(e){var t=VV(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function VV(e){return e.type===`atom`||LV.has(e.type)?e:null}function HV(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new L(t,e);return r}var UV=e=>{if(e instanceof gz)return e;if(Sz(e)&&e.children.length===1)return UV(e.children[0])},WV=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=zV(e.base,`accent`),n=r.base,e.base=n,i=xz(rV(e,t)),e.base=r):(r=zV(e,`accent`),n=r.base);var a=rV(n,t.havingCrampedStyle()),o=r.isShifty&&mR(n),s=0;o&&(s=UV(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=MV(r,t),u=AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=FB(`vec`,t),f=PB.vec[1]):(d=bB({type:`textord`,mode:r.mode,text:r.label},t),d=bz(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=X([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=X([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},GV=(e,t)=>{var n=e.isStretchy?kV(e.label):new Q(`mo`,[dV(e.label,e.mode)]),r=new Q(`mover`,[vV(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},KV=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));Z({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=GB(t[0]),r=!KV.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:WV,mathmlBuilder:GV}),Z({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),Z({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=rV(e.base,t),r=MV(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[AB({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=kV(e.label),r=new Q(`munder`,[vV(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var qV=e=>{var t=new Q(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};Z({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\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=OB(rV(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=OB(rV(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=MV(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=AB({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=AB({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return X([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=kV(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=qV(vV(e.body,t));r=e.below?new Q(`munderover`,[n,qV(vV(e.below,t)),i]):new Q(`mover`,[n,i])}else e.below?r=new Q(`munder`,[n,qV(vV(e.below,t))]):(r=qV(),r=new Q(`mover`,[n,r]));return r}});function JV(e,t){var n=ZB(e.body,t,!0);return X([e.mclass],n,t)}function YV(e,t){var n,r=gV(e.body,t);return e.mclass===`minner`?n=new Q(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new Q(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new Q(`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}Z({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:KB(i),isCharacterBox:mR(i)}},htmlBuilder:JV,mathmlBuilder:YV});var XV=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`};Z({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:XV(t[0]),body:KB(t[1]),isCharacterBox:mR(t[1])}}}),Z({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`:XV(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:KB(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:mR(c)}}}),Z({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:XV(t[0]),body:KB(t[0])}},htmlBuilder(e,t){var n=ZB(e.body,t,!0),r=X([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new Q(`mstyle`,gV(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var ZV={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},QV=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),$V=e=>e.type===`textord`&&e.text===`@`,eH=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function tH(e,t,n){var r=ZV[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 nH(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 L(`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:[tH(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=QV()}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([])}}Z({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=OB(rV(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=z(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new Q(`mrow`,[vV(e.label,t)]);return n=new Q(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new Q(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),Z({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=OB(rV(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Q(`mrow`,[vV(e.fragment,t)])}}),Z({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=HV(zV(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new L(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new L(`\\@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}}}),Z({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=zV(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:KB(i)}},htmlBuilder:(e,t)=>DB(ZB(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Q(`mstyle`,gV(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),Z({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=zV(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}}}),Z({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&&zV(i,`size`).value}},htmlBuilder(e,t){var n=X([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=z(az(e.size,t)))),n},mathmlBuilder(e,t){var n=new Q(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,z(az(e.size,t)))),n}});var rH={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},iH=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new L(`Expected a control sequence`,e);return t},aH=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},oH=(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)};Z({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(rH[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=rH[r.text]),zV(t.parseFunction(),`internal`);throw new L(`Invalid token after macro prefix`,r)}}),Z({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 L(`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 L(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new L(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new L(`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===rH[n]),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=iH(t.gullet.popToken());return t.gullet.consumeSpaces(),oH(t,r,aH(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=iH(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return oH(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var sH=function(e,t,n){var r=Dz(Az.math[e]&&Az.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},cH=function(e,t,n,r){var i=n.havingBaseStyle(t),a=X(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},lH=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=z(i),e.height-=i,e.depth+=i},uH=function(e,t,n,r,i,a){var o=cH(_B(e,`Main-Regular`,i,r),t,r,a);return n&&lH(o,r,t),o},dH=function(e,t,n,r){return _B(e,`Size`+t+`-Regular`,n,r)},fH=function(e,t,n,r,i,a){var o=dH(e,t,i,r),s=cH(X([`delimsizing`,`size`+t],[o],r),R.TEXT,r,a);return n&&lH(s,r,R.TEXT),s},pH=function(e,t,n){return{type:`elem`,elem:X([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[X([],[_B(e,t,n)])])}},mH=function(e,t,n){var r=Cz[`Size4-Regular`][e.charCodeAt(0)]?Cz[`Size4-Regular`][e.charCodeAt(0)][4]:Cz[`Size1-Regular`][e.charCodeAt(0)][4],i=wB([],[new _z([new vz(`inner`,ZR(e,Math.round(1e3*t)))],{width:z(r),height:z(t),style:`width:`+z(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=z(t),i.style.width=z(r),{type:`elem`,elem:i}},hH=.008,gH={type:`kern`,size:-1*hH},_H=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),vH=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),yH=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`):_H.has(e)?(c=`∣`,u=`vert`,d=333):vH.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=sH(o,f,i),m=p.height+p.depth,h=sH(c,f,i),g=h.height+h.depth,_=sH(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=sH(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=$R(u,Math.round(ie*1e3)),se=new vz(u,oe),ce=z(d/1e3),le=z(ae/1e3),ue=wB([],[new _z([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(pH(l,f,i)),re.push(gH),s===null){var de=ee-m-v+2*hH;re.push(mH(c,de,r))}else{var fe=(ee-m-v-y)/2+2*hH;re.push(mH(c,fe,r)),re.push(gH),re.push(pH(s,f,i)),re.push(gH),re.push(mH(c,fe,r))}re.push(gH),re.push(pH(o,f,i))}var pe=r.havingBaseStyle(R.TEXT);return cH(X([`delimsizing`,`mult`],[AB({positionType:`bottom`,positionData:ne,children:re})],pe),R.TEXT,r,a)},bH=80,xH=.08,SH=function(e,t,n,r,i){return wB([`hide-tail`],[new _z([new vz(e,XR(e,r,n))],{width:`400em`,height:z(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},CH=function(e,t){var n=t.havingBaseSizing(),r=NH(`\\surd`,e*n.sizeMultiplier,jH,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+bH,e<1?i=1:e<1.4&&(i=.7),s=(1+a+xH)/i,c=(1+a)/i,o=SH(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+bH)*DH[r.size],c=(DH[r.size]+a)/i,s=(DH[r.size]+a+xH)/i,o=SH(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+xH,c=e+a,l=Math.floor(1e3*e+a)+bH,o=SH(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=z(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},wH=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),TH=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),EH=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),DH=[0,1.2,1.8,2.4,3],OH=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),wH.has(e)||EH.has(e))return fH(e,t,!1,n,r,i);if(TH.has(e))return yH(e,DH[t],!1,n,r,i);throw new L(`Illegal delimiter: '`+e+`'`)},kH=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],AH=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`stack`}],jH=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],MH=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.`)},NH=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},PH=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=EH.has(e)?kH:wH.has(e)?jH:AH,s=NH(e,t,o,r);return s.type===`small`?uH(e,s.style,n,r,i,a):s.type===`large`?fH(e,s.size,n,r,i,a):yH(e,t,n,r,i,a)},FH=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 PH(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},IH={"\\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}},LH=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 RH(e){return`isMiddle`in e}function zH(e,t){var n=VV(e);if(n&&LH.has(n.text))return n;throw n?new L(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new L(`Invalid delimiter type '`+e.type+`'`,e)}Z({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=zH(GB(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:IH[e.funcName].size,mclass:IH[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?X([e.mclass]):OH(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(dV(e.delim,e.mode));var n=new Q(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=z(DH[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function BH(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}Z({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 L(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:zH(t[0],e).text,color:n}}}),Z({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=zH(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=zV(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{BH(e);for(var n=ZB(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{BH(e);var n=gV(e.body,t);if(e.left!==`.`){var r=new Q(`mo`,[dV(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Q(`mo`,[dV(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return fV(n)}}),Z({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=zH(t[0],e);if(!e.parser.leftrightDepth)throw new L(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=nV(t,[]):(n=OH(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new Q(`mo`,[e.delim===`\\vert`||e.delim===`|`?dV(`|`,`text`):dV(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),Z({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=zV(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=OB(rV(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=mR(e.body);if(r===`sout`)a=X([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=az({number:.6,unit:`pt`},t),l=az({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=z(d/2+c);var f=Math.floor(1e3*d*i);a=wB([`hide-tail`],[new _z([new vz(`phase`,JR(f))],{width:`400em`,height:z(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=z(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=NV(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=z(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=z(h),a.style.borderRightWidth=z(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=AB({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=AB({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?X([`mord`,`cancel-lap`],[g],t):X([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new Q(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[vV(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: `+z(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),Z({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=zV(t[0],`color-token`).color,o=zV(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),Z({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]}}}),Z({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}}}),Z({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}}}),Z({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 VH={};function HH(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 L(`{`+e.envName+`} can be used only in display mode.`)},JH=new Set([`gather`,`gather*`]);function YH(e){if(!e.includes(`ed`))return!e.includes(`*`)}function XH(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 L(`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 GH(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(KH(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 L(`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=X([`arraycolsep`],[]),oe.style.width=z(ye),ae.push(oe)));var be=[];for(n=0;n0){for(var De=TB(`katex-hline`,t,l),Oe=TB(`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=AB({positionType:`individualShift`,children:ke})}if(ce.length===0)return X([`mord`],[Ee],t);var Me=X([`katex-tag`],[AB({positionType:`individualShift`,children:ce})],t);return DB([Ee,Me])},$H={c:`center `,l:`left `,r:`right `},eU=function(e,t){for(var n=[],r=new Q(`mtd`,[],[`mtr-glue`]),i=new Q(`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+=$H[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};HH({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(VV(t[0])?[t[0]]:zV(t[0],`ordgroup`).body).map(function(e){var t=BV(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 L(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return XH(e.parser,r,ZH(e.envName))},htmlBuilder:QH,mathmlBuilder:eU}),HH({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 L(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=XH(e.parser,r,ZH(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:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=XH(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(VV(t[0])?[t[0]]:zV(t[0],`ordgroup`).body).map(function(e){var t=BV(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new L(`Unknown column alignment: `+t,e)});if(n.length>1)throw new L(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=XH(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new L(`{subarray} can contain only one column`);return i},htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=XH(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},ZH(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:tU,htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){JH.has(e.envName)&&qH(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:YH(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return XH(e.parser,t,`display`)},htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:tU,htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){qH(e);var t={autoTag:YH(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return XH(e.parser,t,`display`)},htmlBuilder:QH,mathmlBuilder:eU}),HH({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return qH(e),nH(e.parser)},htmlBuilder:QH,mathmlBuilder:eU}),$(`\\nonumber`,`\\gdef\\@eqnsw{0}`),$(`\\notag`,`\\nonumber`),Z({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new L(e.funcName+` valid only within array environment`)}});var nU=VH;Z({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 L(`Invalid environment name`,i);var a=HV(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(nU,a))throw new L(`No such environment: `+a,i);var o=nU[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=zV(n.parseFunction(),`environment`);if(p.name!==a)throw new L(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var rU=(e,t)=>{var n=e.font,r=t.withFont(n);return rV(e.body,r)},iU=(e,t)=>{var n=e.font,r=t.withFont(n);return vV(e.body,r)},aU={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};Z({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=GB(t[0]),a=r in aU?aU[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:rU,mathmlBuilder:iU}),Z({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:XV(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:mR(r)}}}),Z({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 oU=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=rV(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 Q(`mfrac`,[vV(e.numer,t),vV(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=az(e.barSize,t);n.setAttribute(`linethickness`,z(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new Q(`mo`,[new sV(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Q(`mo`,[new sV(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return fV(i)}return n},cU=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;Z({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`),cU({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:oU,mathmlBuilder:sU}),Z({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 lU=[`display`,`text`,`script`,`scriptscript`],uU=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};Z({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=GB(t[0]),o=a.type===`atom`&&a.family===`open`?uU(a.text):null,s=GB(t[1]),c=s.type===`atom`&&s.family===`close`?uU(s.text):null,l=zV(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=zV(p.body[0],`textord`);f=lU[Number(m.text)]}}else p=zV(p,`textord`),f=lU[Number(p.text)];return cU({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),Z({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:zV(t[0],`size`).value,token:r}}}),Z({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=zV(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 dU=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?rV(e.sup,t.havingStyle(n.sup()),t):rV(e.sub,t.havingStyle(n.sub()),t),i=zV(e.base,`horizBrace`)):i=zV(e,`horizBrace`);var a=rV(i.base,t.havingBaseStyle(R.DISPLAY)),o=MV(i,t),s=i.isOver?AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):AB({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=X([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):AB({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return X([`minner`,i.isOver?`mover`:`munder`],[s],t)};Z({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:dU,mathmlBuilder:(e,t)=>{var n=kV(e.label);return new Q(e.isOver?`mover`:`munder`,[vV(e.base,t),n])}}),Z({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=zV(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:KB(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=ZB(e.body,t,!1);return EB(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=_V(e.body,t);return n instanceof Q||(n=new Q(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),Z({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=zV(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=zV(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=ZB(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=X(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)=>_V(e.body,t)}),Z({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:KB(t[0]),mathml:KB(t[1])}),htmlBuilder:(e,t)=>DB(ZB(e.html,t,!1)),mathmlBuilder:(e,t)=>_V(e.mathml,t)});var fU=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 L(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!iz(n))throw new L(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};Z({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=zV(n[0],`raw`).string.split(`,`),l=0;l{var n=az(e.height,t),r=0;e.totalheight.number>0&&(r=az(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=az(e.width,t));var a={height:z(n+r)};i>0&&(a.width=z(i)),r>0&&(a.verticalAlign=z(-r));var o=new mz(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new Q(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=az(e.height,t),i=0;if(e.totalheight.number>0&&(i=az(e.totalheight,t)-r,n.setAttribute(`valign`,z(-i))),n.setAttribute(`height`,z(r+i)),e.width.number>0){var a=az(e.width,t);n.setAttribute(`width`,z(a))}return n.setAttribute(`src`,e.src),n}}),Z({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=zV(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 jB(e.dimension,t)},mathmlBuilder(e,t){return new cV(az(e.dimension,t))}}),Z({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=X([],[rV(e.body,t)]),n=X([`katex-inner`],[n],t)):n=X([`katex-inner`],[rV(e.body,t)]);var r=X([`katex-fix`],[]),i=X([e.alignment],[n,r],t),a=X([`katex-strut`]);return a.style.height=z(i.height+i.depth),i.depth&&(a.style.verticalAlign=z(-i.depth)),i.children.unshift(a),i=X([`katex-thinbox`],[i],t),X([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[vV(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}}),Z({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}}}),Z({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new L(`Mismatched `+e.funcName)}});var pU=(e,t)=>{switch(t.style.size){case R.DISPLAY.size:return e.display;case R.TEXT.size:return e.text;case R.SCRIPT.size:return e.script;case R.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};Z({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:KB(t[0]),text:KB(t[1]),script:KB(t[2]),scriptscript:KB(t[3])}),htmlBuilder:(e,t)=>DB(ZB(pU(e,t),t,!1)),mathmlBuilder:(e,t)=>_V(pU(e,t),t)});var mU=(e,t,n,r,i,a,o)=>{e=X([],[e]);var s=n&&mR(n),c,l;if(t){var u=rV(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=rV(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=AB({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:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=AB({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=AB({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=X([`mspace`],[],r);m.style.marginRight=z(a),p.unshift(m)}return X([`mop`,`op-limits`],p,r)},hU=new Set([`\\smallint`]),gU=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=zV(e.base,`op`),i=!0):a=zV(e,`op`);var o=t.style,s=!1;o.size===R.DISPLAY.size&&a.symbol&&!hU.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=_B(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=FB(d+`Size`+(s?`2`:`1`),t);c=AB({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=ZB(a.body,t,!0);p.length===1&&p[0]instanceof gz?(c=p[0],c.classes[0]=`mop`):c=X([`mop`],p,t)}else{for(var m=[],h=1;h{var n;if(e.symbol)n=new Q(`mo`,[dV(e.name,e.mode)]),hU.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Q(`mo`,gV(e.body,t));else{n=new Q(`mi`,[new sV(e.name.slice(1))]);var r=new Q(`mo`,[dV(`⁡`,`text`)]);n=e.parentIsSupSub?new Q(`mrow`,[n,r]):oV([n,r])}return n},vU={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};Z({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=vU[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:gU,mathmlBuilder:_U}),Z({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:KB(r)}}});var yU={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};Z({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}}}),Z({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}}}),Z({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=yU[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var bU=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=zV(e.base,`operatorname`),i=!0):a=zV(e,`operatorname`);var o;if(a.body.length>0){for(var s=ZB(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:KB(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:bU,mathmlBuilder:(e,t)=>{for(var n=gV(e.body,t.withFont(`mathrm`)),r=!0,i=0;ie.toText()).join(``))]);var s=new Q(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new Q(`mo`,[dV(`⁡`,`text`)]);return e.parentIsSupSub?new Q(`mrow`,[s,c]):oV([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),WB({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?DB(ZB(e.body,t,!1)):X([`mord`],ZB(e.body,t,!0),t)},mathmlBuilder(e,t){return _V(e.body,t,!0)}}),Z({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=rV(e.body,t.havingCrampedStyle()),r=TB(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-overline`],[AB({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 Q(`mo`,[new sV(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`mover`,[vV(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),Z({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:KB(r)}},htmlBuilder:(e,t)=>DB(ZB(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Q(`mphantom`,gV(e.body,t))}),$(`\\hphantom`,`\\smash{\\phantom{#1}}`),Z({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)=>X([`mord`,`rlap`],[X([`katex-inner`],[rV(e.body,t.withPhantom())]),X([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[new Q(`mphantom`,gV(KB(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),Z({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=zV(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=rV(e.body,t);return AB({positionType:`shift`,positionData:-az(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Q(`mpadded`,[vV(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var xU=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});Z({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:xU,htmlBuilder(e,t){return X([`mord`,`reflectbox`],[rV(e.body,t)],t)},mathmlBuilder(e,t){return vV(e.body,t)}}),Z({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:xU}),Z({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),Z({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=zV(t[0],`size`),o=zV(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&zV(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=X([`mord`,`katex-rule`],[],t),r=az(e.width,t),i=az(e.height,t),a=e.shift?az(e.shift,t):0;return n.style.borderRightWidth=z(r),n.style.borderTopWidth=z(i),n.style.bottom=z(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=az(e.width,t),r=az(e.height,t),i=e.shift?az(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new Q(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,z(n)),o.setAttribute(`height`,z(r));var s=new Q(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,z(i)):(s.setAttribute(`height`,z(i)),s.setAttribute(`depth`,z(-i))),s.setAttribute(`voffset`,z(i)),s}});function SU(e,t,n){for(var r=ZB(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:CU.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return SU(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Q(`mstyle`,gV(e.body,n));return r.setAttribute(`mathsize`,z(n.sizeMultiplier)),r}}),Z({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]&&zV(n[0],`ordgroup`);if(o)for(var s,c=0;c{var n=X([],[rV(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 X([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r{var n=new Q(`mpadded`,[vV(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),Z({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=rV(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=OB(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=z(l);var f=AB({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(R.SCRIPTSCRIPT),m=rV(e.index,p,t);return X([`mord`,`sqrt`],[X([`katex-root`],[AB({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return X([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new Q(`mroot`,[vV(n,t),vV(r,t)]):new Q(`msqrt`,[vV(n,t)])}});var wU={display:R.DISPLAY,text:R.TEXT,script:R.SCRIPT,scriptscript:R.SCRIPTSCRIPT};function TU(e){return e in wU}Z({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(!TU(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=wU[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),SU(e.body,r,t)},mathmlBuilder(e,t){var n=wU[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Q(`mstyle`,gV(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 EU=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===R.DISPLAY.size||n.alwaysHandleSupSub)?gU:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===R.DISPLAY.size||n.limits)?bU:null:n.type===`accent`?mR(n.base)?WV:null:n.type===`horizBrace`&&!e.sub===n.isOver?dU:null:null};WB({type:`supsub`,htmlBuilder(e,t){var n=EU(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=rV(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&mR(r);if(i){var p=t.havingStyle(t.style.sup());s=rV(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=rV(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===R.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=z(.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 gz||y)&&(v=z(-(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=AB({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=AB({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=AB({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return X([tV(o,`right`)||`mord`],[o,X([`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=[vV(e.base,t)];e.sub&&a.push(vV(e.sub,t)),e.sup&&a.push(vV(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===R.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===R.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===R.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===R.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===R.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===R.DISPLAY)?`munder`:`msub`}return new Q(o,a)}}),WB({type:`atom`,htmlBuilder(e,t){return vB(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Q(`mo`,[dV(e.text,e.mode)]);if(e.family===`bin`){var r=mV(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 DU={mi:`italic`,mn:`normal`,mtext:`normal`};WB({type:`mathord`,htmlBuilder(e,t){return bB(e,t)},mathmlBuilder(e,t){var n=new Q(`mi`,[dV(e.text,e.mode,t)]),r=mV(e,t)||`italic`;return r!==DU[n.type]&&n.setAttribute(`mathvariant`,r),n}}),WB({type:`textord`,htmlBuilder(e,t){return bB(e,t)},mathmlBuilder(e,t){var n=dV(e.text,e.mode,t),r=mV(e,t)||`normal`,i=e.mode===`text`?new Q(`mtext`,[n]):/[0-9]/.test(e.text)?new Q(`mn`,[n]):e.text===`\\prime`?new Q(`mo`,[n]):new Q(`mi`,[n]);return r!==DU[i.type]&&i.setAttribute(`mathvariant`,r),i}});var OU=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),kU=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);WB({type:`spacing`,htmlBuilder(e,t){var n=kU.get(e.text),r=OU.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=bB(e,t);return a.classes.push(i),a}return X([`mspace`,i],[vB(e.text,e.mode,t)],t)}if(r)return X([`mspace`,r],[],t);throw new L(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(kU.has(e.text))n=new Q(`mtext`,[new sV(`\xA0`)]);else if(OU.has(e.text))return new Q(`mspace`);else throw new L(`Unknown type of space "`+e.text+`"`);return n}});var AU=()=>{var e=new Q(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};WB({type:`tag`,mathmlBuilder(e,t){var n=new Q(`mtable`,[new Q(`mtr`,[AU(),new Q(`mtd`,[_V(e.body,t)]),AU(),new Q(`mtd`,[_V(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var jU={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},MU={"\\textbf":`textbf`,"\\textmd":`textmd`},NU={"\\textit":`textit`,"\\textup":`textup`},PU=(e,t)=>{var n=e.font;return n?jU[n]?t.withTextFontFamily(jU[n]):MU[n]?t.withTextFontWeight(MU[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(NU[n]):t};Z({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:KB(i),font:r}},htmlBuilder(e,t){var n=PU(e,t);return X([`mord`,`text`],ZB(e.body,n,!0),n)},mathmlBuilder(e,t){var n=PU(e,t);return _V(e.body,n)}}),Z({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=rV(e.body,t),r=TB(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-underline`],[AB({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 Q(`mo`,[new sV(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`munder`,[vV(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),Z({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=rV(e.body,t),r=t.fontMetrics().axisHeight;return AB({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new Q(`mrow`,[new Q(`mpadded`,[vV(e.body,t)],[`vcenter`])])}}),Z({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new L(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=FU(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),IU=VB,LU=`[ \r + ]`,RU=`\\\\[a-zA-Z@]+`,zU=`\\\\[^\ud800-\udfff]`,BU=`(`+RU+`)`+LU+`*`,VU=`\\\\( |[ \r ]+ -?)[ \r ]*`,zV=`[̀-ͯ]`,BV=RegExp(zV+`+$`),VV=`(`+PV+`+)|`+(RV+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(zV+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(zV+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+LV)+(`|`+IV+`)`),HV=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(VV,`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 HB(`EOF`,new VB(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new I(`Unexpected character: '`+e[t]+`'`,new HB(e[t],new VB(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 HB(r,new VB(this,t,this.tokenRegex.lastIndex))}},UV=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}},WV=BB;$(`\\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 GV={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=GV[t.text],r==null||r>=n)throw new I(`Invalid base-`+n+` digit `+t.text);for(var i;(i=GV[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=>KV(e,!1,!0,!1)),$(`\\renewcommand`,e=>KV(e,!0,!1,!1)),$(`\\providecommand`,e=>KV(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),NV[n],OL.math[n],OL.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 qV={",":`\\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`},JV=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in qV?t=qV[n]:(n.slice(0,4)===`\\not`||n in OL.math&&JV.has(OL.math[n].group))&&(t=`\\dotsb`),t});var YV={")":!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 YV?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in YV&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in YV?`\\@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 XV=R(xL[`Main-Regular`][84][1]-.7*xL[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+XV+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+XV+`}{\\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 ZV=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`,ZV(!1)),$(`\\bra@set`,ZV(!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 QV={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},$V=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 UV(WV,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new HV(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 HB(`EOF`,n.loc)),this.pushTokens(r),new HB(``,VB.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 HB(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 HV(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(NV,e)||Object.prototype.hasOwnProperty.call(OL.math,e)||Object.prototype.hasOwnProperty.call(OL.text,e)||Object.prototype.hasOwnProperty.call(QV,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(NV,e)&&!NV[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},eH=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,tH=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`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),nH={"́":{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`}},rH={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},iH=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 $V(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 HB(`}`)),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&&NV[i.text]&&NV[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&&(RI(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:VB.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 lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{dH.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)}}}}}),pH=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},mH=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:pH,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{dH.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)}}}}}),hH=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[fH.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),mH.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function gH(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;NF({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 hH.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function _H({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 vH(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>_H({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function yH(e,t){let n=vH(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var bH=Jp.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=yH(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},...$f({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:yH(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 vH(this).map(dF)}});function xH(e,t){return bH.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,findSuggestionMatch:t=>{let n=ZP({...t,allowSpaces:!0});return n&&KP(n.query,e)?n:ZP({...t,allowSpaces:!1})},items:async({query:n})=>{if(!t)return[];let r=GP(n,e,!!t.me).map(e=>({date:e})),i=(await t.search(n).catch(()=>[])).map(e=>({person:e}));return n.trim()?[...r,...i].slice(0,8):[...i.slice(0,6),...r]},render:Ij({label:e.mentions,empty:e.noPeople,toItem:t=>`person`in t?{label:t.person.label,description:t.person.hint,icon:`at`}:{label:UP(t.date.date,e),description:t.date.remind?`${e.dates.remindMe} · ${WP(t.date.date,e)}`:WP(t.date.date,e),icon:t.date.remind?`bell`:`calendar`},pick:(e,n)=>{`person`in n?e.command({id:n.person.id,label:n.person.label}):YP(e.editor,e.range,n.date,t?.me)}})}})}var SH=`flowchart LR - Idea --> Draft --> Review --> Published`,CH=null;function wH(e){return CH??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),CH}var TH=0;async function EH(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 wH(r)).render(`dw-mermaid-${++TH}`,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 DH=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=SH)=>({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 EH(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;NF({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void EH(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),EH(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void EH(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),EH(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function OH(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 kH(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...o(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),o(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).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(),zF(t,e,a,n)}),o(`linkCard`,`link`,[`bookmark`,`preview`,`card`,`url`,`web`],(t,r)=>{t.chain().focus().deleteRange(r).run(),BF(t,e,a,n)})],c=e=>{let t=new Date;return zP(new Date(t.getFullYear(),t.getMonth(),t.getDate()+e))};if(s.push(o(`today`,`calendar`,[`date`,`day`],(e,t)=>YP(e,t,{date:c(0),remind:!1})),o(`tomorrow`,`calendar`,[`date`,`day`],(e,t)=>YP(e,t,{date:c(1),remind:!1})),o(`yesterday`,`calendar`,[`date`,`day`],(e,t)=>YP(e,t,{date:c(-1),remind:!1})),o(`now`,`clock`,[`time`,`date`,`timestamp`],(t,n)=>{YP(t,n,{date:c(0),remind:!1});let r=new Intl.DateTimeFormat(e.locale,{hour:`numeric`,minute:`2-digit`}).format(new Date);t.chain().focus().insertContent(`${r} `).run()})),r&&(s.push(o(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),s.push(o(`syncedPage`,`copy`,[`embed`,`transclude`,`include`,`mirror`,`![[`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`![[`).run())),r.create&&s.push(o(`newPage`,`page-plus`,[`page`,`doc`,`subpage`,`create`],(e,t)=>{e.chain().focus().deleteRange(t).run(),_F(e,r,``).catch(n)}))),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),OH(e).then(e=>KF(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 AH(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n));return e.flatMap(e=>{let t=e.children?.filter(r)??[];return t.length?t:r(e)?[e]:[]})}var jH=Tp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[fF({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})=>AH(this.options.commands,e),render:Ij({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),children:e=>e.children,pick:(e,t)=>t.run(e.editor,e.range)})})]}});function MH(e,t){let n=!0,r=e.firstChild?.childCount??0;return e.forEach(e=>{t===`column`&&e.childCount!==r&&(n=!1),e.forEach(e=>{((t===`row`?e.attrs.rowspan:e.attrs.colspan)??1)>1&&(n=!1)})}),n}function NH(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}var PH=e=>{let t=[];return e.forEach(e=>t.push(e)),t};function FH(e,t,n,r,i,a=0){let o=e.doc.nodeAt(t);if(!o||o.type.name!==`table`||!MH(o,n))return null;let c=PH(o),l=n===`row`?c.length:c[0]?.childCount??0;if(r===i||r<0||i<0||r>=l||i>=l)return null;let u=n===`row`?NH(c,r,i):c.map(e=>e.copy(s.fromArray(NH(PH(e),r,i)))),d=e.tr.replaceWith(t,t+o.nodeSize,o.copy(s.fromArray(u))),[f,p]=n===`row`?[i,0]:[Math.min(a,u.length-1),i],m=t+1;for(let e=0;e0;e--)if(n.node(e).type.name===`table`)return{tablePos:n.before(e),row:n.index(e),column:e+1<=n.depth?n.index(e+1):0};return null}var LH=Tp.create({name:`tableMove`,addOptions(){return{labels:null}},addCommands(){let e=e=>t=>({state:n,dispatch:r})=>{let i=IH(n,n.selection.from);if(!i)return!1;let a=e===`row`?i.row:i.column,o=FH(n,i.tablePos,e,a,a+t,i.row);return o?(r?.(o),!0):!1};return{moveTableRow:e(`row`),moveTableColumn:e(`column`)}},addKeyboardShortcuts(){return{"Mod-Alt-ArrowUp":()=>this.editor.commands.moveTableRow(-1),"Mod-Alt-ArrowDown":()=>this.editor.commands.moveTableRow(1),"Mod-Alt-ArrowLeft":()=>this.editor.commands.moveTableColumn(-1),"Mod-Alt-ArrowRight":()=>this.editor.commands.moveTableColumn(1)}},addProseMirrorPlugins(){let e=this.options.labels?.table;return[new E({key:new D(`tableMove`),view:t=>new RH(t,{row:e?.dragRow??`Drag to move the row`,column:e?.dragColumn??`Drag to move the column`})})]}}),RH=class{view;grips={row:document.createElement(`button`),column:document.createElement(`button`)};line=document.createElement(`div`);cell=null;drag=null;constructor(e,t){this.view=e;for(let e of[`row`,`column`]){let n=this.grips[e];n.type=`button`,n.className=`dw-table-grip dw-table-grip--${e}`,n.contentEditable=`false`,n.setAttribute(`aria-label`,t[e]),n.title=t[e],n.hidden=!0,n.tabIndex=-1,n.addEventListener(`pointerdown`,t=>this.start(t,e)),n.addEventListener(`mouseleave`,this.leave)}this.line.className=`dw-table-drop`,this.line.hidden=!0,e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.line.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.grips.row,this.grips.column,this.line)),e}hide=()=>{this.drag||(this.grips.row.hidden=!0,this.grips.column.hidden=!0,this.cell=null)};leave=e=>{let t=e.relatedTarget;t&&(this.grips.row.contains(t)||this.grips.column.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.drag)return;let t=e.target?.closest?.(`td, th`),n=this.host;if(!this.view.editable||!n||!(t instanceof HTMLTableCellElement)||!this.view.dom.contains(t))return this.hide();let r=this.locate(t),i=r&&this.view.state.doc.nodeAt(r.tablePos);if(!r||!i)return this.hide();this.cell=t;let a=n.getBoundingClientRect(),o=t.closest(`table`).getBoundingClientRect(),s=t.parentElement.getBoundingClientRect(),c=t.getBoundingClientRect(),l=i.childCount>1&&MH(i,`row`),u=(i.firstChild?.childCount??0)>1&&MH(i,`column`);Object.assign(this.grips.row.style,{top:`${s.top-a.top+s.height/2-11}px`,left:`${o.left-a.left-7}px`}),Object.assign(this.grips.column.style,{top:`${o.top-a.top-7}px`,left:`${c.left-a.left+c.width/2-11}px`}),this.grips.row.hidden=!l,this.grips.column.hidden=!u};locate(e){try{return IH(this.view.state,this.view.posAtDOM(e,0))}catch{return null}}start(e,t){let n=this.cell;if(!n||e.button!==0)return;let r=this.locate(n),i=n.parentElement?.parentElement;if(!r||!i)return;e.preventDefault();let a=this.grips[t];a.setPointerCapture(e.pointerId);let o=[...i.children].filter(e=>e instanceof HTMLTableRowElement),s=t===`row`?r.row:r.column,c=t===`row`?o:[...o[0]?.children??[]],l=t===`row`?[o[s]]:o.map(e=>e.children[s]).filter(Boolean);for(let e of l)e.classList.add(`dw-table-dragging`);this.drag={axis:t,tablePos:r.tablePos,from:s,slots:c,dimmed:l,to:s,cursorRow:r.row},a.addEventListener(`pointermove`,this.dragMove),a.addEventListener(`pointerup`,this.drop),a.addEventListener(`pointercancel`,this.cancel)}dragMove=e=>{let t=this.drag,n=this.host;if(!t||!n)return;let r=t.axis===`row`,i=r?e.clientY:e.clientX,a=t.slots.length;for(let[e,n]of t.slots.entries()){let t=n.getBoundingClientRect();if(i<(r?t.top+t.height/2:t.left+t.width/2)){a=e;break}}t.to=a>t.from?a-1:a;let o=n.getBoundingClientRect(),s=t.slots[0].closest(`table`).getBoundingClientRect(),c=t.slots.at(-1).getBoundingClientRect(),l=t.slots[a]?.getBoundingClientRect(),u=r?l?.top??c.bottom:l?.left??c.right;Object.assign(this.line.style,r?{top:`${u-o.top-1}px`,left:`${s.left-o.left}px`,width:`${s.width}px`,height:`2px`}:{top:`${s.top-o.top}px`,left:`${u-o.left-1}px`,width:`2px`,height:`${s.height}px`}),this.line.hidden=t.to===t.from};drop=()=>{let e=this.drag;if(this.cancel(),!e||e.to===e.from)return;let t=FH(this.view.state,e.tablePos,e.axis,e.from,e.to,e.cursorRow);t&&this.view.dispatch(t),this.view.focus()};cancel=()=>{let e=this.drag;for(let t of e?.dimmed??[])t.classList.remove(`dw-table-dragging`);this.drag=null,this.line.hidden=!0;for(let e of Object.values(this.grips))e.removeEventListener(`pointermove`,this.dragMove),e.removeEventListener(`pointerup`,this.drop),e.removeEventListener(`pointercancel`,this.cancel);this.hide()};update(){this.cell&&!this.cell.isConnected&&this.hide()}destroy(){this.cancel();for(let e of Object.values(this.grips))e.remove();this.line.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}};function zH(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 BH(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 VH=Jp.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=zH(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(),BH(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)}}}}),HH=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},UH=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=HH(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},WH=(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||HH(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=Nw.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new Nw(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},GH=Jp.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]},...Xf({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=HH(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})=>WH(e,`right`),ArrowDown:({editor:e})=>WH(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(HH(a.pos,r))return;let o=UH(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}}},...Xf({nodeName:`detailsContent`})}),qH=Jp.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]},...Xf({nodeName:`detailsSummary`,content:`inline`})});function JH(e){return[GH.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))}}),qH,KH]}function YH(e={}){let t=e.labels??iI,n=null,r=Tp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Hk.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,link:{openOnClick:!1,autolink:!0},undoRedo:e.collab||e.syncedDoc?!1:void 0}),lT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),qF.configure({host:e.files}),YF.configure({host:e.files,loadPdf:e.loadPdf,labels:t}),Aj.configure({lineNumbers:e.codeLineNumbers??!1}),SP,xP,OP,kP,...yP(),...bP(),LH.configure({labels:t}),MP.configure({labels:t}),XF.configure({host:e.files,onError:e.onError}),xH(t,e.mentions),qP.configure({labels:t,me:()=>e.mentions?.me,onOpen:e.onOpenDate}),jH.configure({commands:kH(t,e.files,e.onError,e.pages,!!e.loadExcalidraw,e.links),labels:t}),LP.configure({onSelect:e.onCommentSelect}),gH(t,()=>n),DH.configure({labels:t,load:e.loadMermaid}),VH.configure({labels:t}),AF.configure(i),jF.configure(i),vF.configure({host:e.pages,labels:t,onNavigate:e.onNavigate}),bF.configure({host:e.syncedPages,pages:e.pages,labels:t,onNavigate:e.onNavigate,nested:t=>YH({syncedDoc:t,files:e.files,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:``})}),...JH(t),HF.configure({labels:t}),UF.configure({labels:t}),Jj.configure({labels:t,link:e.blockLink,onCopied:e.onBlockLinkCopied}),rI];return e.syncedDoc?a.push(Tw.configure({document:e.syncedDoc})):e.collab&&a.push(Tw.configure({document:e.collab.provider.doc}),Aw.configure({provider:e.collab.provider,user:e.collab.user,render:XH})),a}function XH(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 ZH=3e4,QH=class extends um{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Mh();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&&$H(this,t,`timeout`)},dm(ZH/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:Mh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Qh(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}},$H=(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]))},eU=(e,t,n=e.states)=>{let r=t.length,i=Mm();j(i,r);for(let a=0;a{let r=fh(t),i=Mh(),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])},nU=(e,t)=>{j(e,0),Wm(e,Gv(t))},rU=(e,t,n)=>{j(e,1),Wm(e,zv(t,n))},iU=(e,t,n)=>rU(t,n,hh(e)),aU=(e,t,n,r)=>{try{Iv(t,hh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},oU=(e,t)=>{j(e,2),Wm(e,t)},sU=aU,cU=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:iU(e,t,n);break;case 1:aU(e,n,r,i);break;case 2:sU(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},lU=0,uU=1,dU=4401,fU=4404,pU=4409,mU=class{opts;doc=new bv;awareness=new QH(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),e.readOnly&&this.awareness.setLocalState(null),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),$H(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=Mm();j(t,lU),nU(t,this.doc),e.send(Fm(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);$H(this.awareness,n,this),this.destroyed||(t.code===dU||t.code===fU?this.set(`denied`,!1):t.code===pU?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=fh(e),n=M(t);if(n===lU){let e=Mm();j(e,lU);let n=cU(t,e,this.doc,this);Pm(e)>1&&!this.opts.readOnly&&this.ws?.send(Fm(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===uU&&tU(this.awareness,hh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.opts.readOnly||this.ws?.readyState!==WebSocket.OPEN)return;let n=Mm();j(n,lU),oU(n,e),this.ws.send(Fm(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r===this||this.opts.readOnly||this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=Mm();j(t,uU),Wm(t,eU(this.awareness,e)),this.ws.send(Fm(t))}onUnload=()=>$H(this.awareness,[this.doc.clientID],`unload`)},hU={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(),underline:e=>e.chain().focus().toggleUnderline().run(),taskList:e=>e.chain().focus().toggleTaskList().run(),callout:e=>e.isActive(`callout`)?e.chain().focus().unsetCallout().run():e.chain().focus().setCallout().run(),table:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},gU=[[`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`)],[`underline`,e=>e.isActive(`underline`)],[`taskList`,e=>e.isActive(`taskList`)],[`callout`,e=>e.isActive(`callout`)],[`table`,e=>e.isActive(`table`)]],_U=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:2})}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:2}),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`setLayout`:{let t=document.documentElement.classList;t.toggle(`dw-full-width`,e.fullWidth),t.toggle(`dw-font-serif`,e.font===`serif`),t.toggle(`dw-font-mono`,e.font===`mono`);return}case`command`:{let t=hU[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 mU({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 Vp({element:this.el,editable:this.editable,extensions:YH({...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:gU.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 vU(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var yU=new _U(document.getElementById(`editor`),vU);window.docwell={receive:e=>yU.receive(e)}; +?)[ \r ]*`,HU=`[̀-ͯ]`,UU=RegExp(HU+`+$`),WU=`(`+LU+`+)|`+(VU+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(HU+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(HU+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+BU)+(`|`+zU+`)`),GU=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(WU,`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 GH(`EOF`,new WH(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new GH(e[t],new WH(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 GH(r,new WH(this,t,this.tokenRegex.lastIndex))}},KU=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new L(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;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}},qU=UH;$(`\\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 JU={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new L("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=JU[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=JU[e.future().text])!=null&&i{var i=e.consumeArg().tokens;if(i.length!==1)throw new L(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new L(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new L(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new L(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>YU(e,!1,!0,!1)),$(`\\renewcommand`,e=>YU(e,!0,!1,!1)),$(`\\providecommand`,e=>YU(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),IU[n],Az.math[n],Az.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 XU={",":`\\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`},ZU=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in XU?t=XU[n]:(n.slice(0,4)===`\\not`||n in Az.math&&ZU.has(Az.math[n].group))&&(t=`\\dotsb`),t});var QU={")":!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 QU?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in QU&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in QU?`\\@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 L(`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 $U=z(Cz[`Main-Regular`][84][1]-.7*Cz[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+$U+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+$U+`}{\\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 eW=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`,eW(!1)),$(`\\bra@set`,eW(!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 tW={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},nW=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 KU(qU,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new GU(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 GH(`EOF`,n.loc)),this.pushTokens(r),new GH(``,WH.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 L(`Extra }`,i)}else if(i.text===`EOF`)throw new L(`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 L(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;rthis.settings.maxExpand)throw new L(`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 L(`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 L(`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 L(`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 GH(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 GU(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(IU,e)||Object.prototype.hasOwnProperty.call(Az.math,e)||Object.prototype.hasOwnProperty.call(Az.text,e)||Object.prototype.hasOwnProperty.call(tW,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(IU,e)&&!IU[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},rW=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,iW=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`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),aW={"́":{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`}},oW={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},sW=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 nW(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 L(`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 GH(`}`)),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&&IU[i.text]&&IU[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&&(BR(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:WH.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 lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{mW.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)}}}}}),gW=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},_W=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:gW,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{mW.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)}}}}}),vW=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[hW.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),_W.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function yW(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;IL({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 vW.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function bW({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 xW(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>bW({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function SW(e,t){let n=xW(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var CW=Jp.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=SW(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},...$f({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:SW(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 xW(this).map(mL)}});function wW(e,t){return CW.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,findSuggestionMatch:t=>{let n=eL({...t,allowSpaces:!0});return n&&YI(n.query,e)?n:eL({...t,allowSpaces:!1})},items:async({query:n})=>{if(!t)return[];let r=JI(n,e,!!t.me).map(e=>({date:e})),i=(await t.search(n).catch(()=>[])).map(e=>({person:e}));return n.trim()?[...r,...i].slice(0,8):[...i.slice(0,6),...r]},render:zj({label:e.mentions,empty:e.noPeople,toItem:t=>`person`in t?{label:t.person.label,description:t.person.hint,icon:`at`}:{label:KI(t.date.date,e),description:t.date.remind?`${e.dates.remindMe} · ${qI(t.date.date,e)}`:qI(t.date.date,e),icon:t.date.remind?`bell`:`calendar`},pick:(e,n)=>{`person`in n?e.command({id:n.person.id,label:n.person.label}):QI(e.editor,e.range,n.date,t?.me)}})}})}var TW=`flowchart LR + Idea --> Draft --> Review --> Published`,EW=null;function DW(e){return EW??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),EW}var OW=0;async function kW(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 DW(r)).render(`dw-mermaid-${++OW}`,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 AW=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=TW)=>({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 kW(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;IL({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void kW(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),kW(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void kW(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),kW(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function jW(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 MW(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...o(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),o(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),o(`database`,`database`,[`kanban`,`board`,`calendar`,`records`,`tracker`,`notion`],(e,t)=>e.chain().focus().deleteRange(t).insertDatabase().run()),o(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),o(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),o(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),o(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),o(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),o(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),o(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focus().deleteRange(t).insertInlineMath({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(),HL(t,e,a,n)}),o(`linkCard`,`link`,[`bookmark`,`preview`,`card`,`url`,`web`],(t,r)=>{t.chain().focus().deleteRange(r).run(),UL(t,e,a,n)})],c=e=>{let t=new Date;return HI(new Date(t.getFullYear(),t.getMonth(),t.getDate()+e))};if(s.push(o(`today`,`calendar`,[`date`,`day`],(e,t)=>QI(e,t,{date:c(0),remind:!1})),o(`tomorrow`,`calendar`,[`date`,`day`],(e,t)=>QI(e,t,{date:c(1),remind:!1})),o(`yesterday`,`calendar`,[`date`,`day`],(e,t)=>QI(e,t,{date:c(-1),remind:!1})),o(`now`,`clock`,[`time`,`date`,`timestamp`],(t,n)=>{QI(t,n,{date:c(0),remind:!1});let r=new Intl.DateTimeFormat(e.locale,{hour:`numeric`,minute:`2-digit`}).format(new Date);t.chain().focus().insertContent(`${r} `).run()})),r&&(s.push(o(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),s.push(o(`syncedPage`,`copy`,[`embed`,`transclude`,`include`,`mirror`,`![[`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`![[`).run())),r.create&&s.push(o(`newPage`,`page-plus`,[`page`,`doc`,`subpage`,`create`],(e,t)=>{e.chain().focus().deleteRange(t).run(),bL(e,r,``).catch(n)}))),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),jW(e).then(e=>YL(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 NW(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n));return e.flatMap(e=>{let t=e.children?.filter(r)??[];return t.length?t:r(e)?[e]:[]})}var PW=Tp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[hL({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})=>NW(this.options.commands,e),render:zj({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),children:e=>e.children,pick:(e,t)=>t.run(e.editor,e.range)})})]}});function FW(e,t){let n=!0,r=e.firstChild?.childCount??0;return e.forEach(e=>{t===`column`&&e.childCount!==r&&(n=!1),e.forEach(e=>{((t===`row`?e.attrs.rowspan:e.attrs.colspan)??1)>1&&(n=!1)})}),n}function IW(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}var LW=e=>{let t=[];return e.forEach(e=>t.push(e)),t};function RW(e,t,n,r,i,a=0){let o=e.doc.nodeAt(t);if(!o||o.type.name!==`table`||!FW(o,n))return null;let c=LW(o),l=n===`row`?c.length:c[0]?.childCount??0;if(r===i||r<0||i<0||r>=l||i>=l)return null;let u=n===`row`?IW(c,r,i):c.map(e=>e.copy(s.fromArray(IW(LW(e),r,i)))),d=e.tr.replaceWith(t,t+o.nodeSize,o.copy(s.fromArray(u))),[f,p]=n===`row`?[i,0]:[Math.min(a,u.length-1),i],m=t+1;for(let e=0;e0;e--)if(n.node(e).type.name===`table`)return{tablePos:n.before(e),row:n.index(e),column:e+1<=n.depth?n.index(e+1):0};return null}var BW=Tp.create({name:`tableMove`,addOptions(){return{labels:null}},addCommands(){let e=e=>t=>({state:n,dispatch:r})=>{let i=zW(n,n.selection.from);if(!i)return!1;let a=e===`row`?i.row:i.column,o=RW(n,i.tablePos,e,a,a+t,i.row);return o?(r?.(o),!0):!1};return{moveTableRow:e(`row`),moveTableColumn:e(`column`)}},addKeyboardShortcuts(){return{"Mod-Alt-ArrowUp":()=>this.editor.commands.moveTableRow(-1),"Mod-Alt-ArrowDown":()=>this.editor.commands.moveTableRow(1),"Mod-Alt-ArrowLeft":()=>this.editor.commands.moveTableColumn(-1),"Mod-Alt-ArrowRight":()=>this.editor.commands.moveTableColumn(1)}},addProseMirrorPlugins(){let e=this.options.labels?.table;return[new E({key:new D(`tableMove`),view:t=>new VW(t,{row:e?.dragRow??`Drag to move the row`,column:e?.dragColumn??`Drag to move the column`})})]}}),VW=class{view;grips={row:document.createElement(`button`),column:document.createElement(`button`)};line=document.createElement(`div`);cell=null;drag=null;constructor(e,t){this.view=e;for(let e of[`row`,`column`]){let n=this.grips[e];n.type=`button`,n.className=`dw-table-grip dw-table-grip--${e}`,n.contentEditable=`false`,n.setAttribute(`aria-label`,t[e]),n.title=t[e],n.hidden=!0,n.tabIndex=-1,n.addEventListener(`pointerdown`,t=>this.start(t,e)),n.addEventListener(`mouseleave`,this.leave)}this.line.className=`dw-table-drop`,this.line.hidden=!0,e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.line.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.grips.row,this.grips.column,this.line)),e}hide=()=>{this.drag||(this.grips.row.hidden=!0,this.grips.column.hidden=!0,this.cell=null)};leave=e=>{let t=e.relatedTarget;t&&(this.grips.row.contains(t)||this.grips.column.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.drag)return;let t=e.target?.closest?.(`td, th`),n=this.host;if(!this.view.editable||!n||!(t instanceof HTMLTableCellElement)||!this.view.dom.contains(t))return this.hide();let r=this.locate(t),i=r&&this.view.state.doc.nodeAt(r.tablePos);if(!r||!i)return this.hide();this.cell=t;let a=n.getBoundingClientRect(),o=t.closest(`table`).getBoundingClientRect(),s=t.parentElement.getBoundingClientRect(),c=t.getBoundingClientRect(),l=i.childCount>1&&FW(i,`row`),u=(i.firstChild?.childCount??0)>1&&FW(i,`column`);Object.assign(this.grips.row.style,{top:`${s.top-a.top+s.height/2-11}px`,left:`${o.left-a.left-7}px`}),Object.assign(this.grips.column.style,{top:`${o.top-a.top-7}px`,left:`${c.left-a.left+c.width/2-11}px`}),this.grips.row.hidden=!l,this.grips.column.hidden=!u};locate(e){try{return zW(this.view.state,this.view.posAtDOM(e,0))}catch{return null}}start(e,t){let n=this.cell;if(!n||e.button!==0)return;let r=this.locate(n),i=n.parentElement?.parentElement;if(!r||!i)return;e.preventDefault();let a=this.grips[t];a.setPointerCapture(e.pointerId);let o=[...i.children].filter(e=>e instanceof HTMLTableRowElement),s=t===`row`?r.row:r.column,c=t===`row`?o:[...o[0]?.children??[]],l=t===`row`?[o[s]]:o.map(e=>e.children[s]).filter(Boolean);for(let e of l)e.classList.add(`dw-table-dragging`);this.drag={axis:t,tablePos:r.tablePos,from:s,slots:c,dimmed:l,to:s,cursorRow:r.row},a.addEventListener(`pointermove`,this.dragMove),a.addEventListener(`pointerup`,this.drop),a.addEventListener(`pointercancel`,this.cancel)}dragMove=e=>{let t=this.drag,n=this.host;if(!t||!n)return;let r=t.axis===`row`,i=r?e.clientY:e.clientX,a=t.slots.length;for(let[e,n]of t.slots.entries()){let t=n.getBoundingClientRect();if(i<(r?t.top+t.height/2:t.left+t.width/2)){a=e;break}}t.to=a>t.from?a-1:a;let o=n.getBoundingClientRect(),s=t.slots[0].closest(`table`).getBoundingClientRect(),c=t.slots.at(-1).getBoundingClientRect(),l=t.slots[a]?.getBoundingClientRect(),u=r?l?.top??c.bottom:l?.left??c.right;Object.assign(this.line.style,r?{top:`${u-o.top-1}px`,left:`${s.left-o.left}px`,width:`${s.width}px`,height:`2px`}:{top:`${s.top-o.top}px`,left:`${u-o.left-1}px`,width:`2px`,height:`${s.height}px`}),this.line.hidden=t.to===t.from};drop=()=>{let e=this.drag;if(this.cancel(),!e||e.to===e.from)return;let t=RW(this.view.state,e.tablePos,e.axis,e.from,e.to,e.cursorRow);t&&this.view.dispatch(t),this.view.focus()};cancel=()=>{let e=this.drag;for(let t of e?.dimmed??[])t.classList.remove(`dw-table-dragging`);this.drag=null,this.line.hidden=!0;for(let e of Object.values(this.grips))e.removeEventListener(`pointermove`,this.dragMove),e.removeEventListener(`pointerup`,this.drop),e.removeEventListener(`pointercancel`,this.cancel);this.hide()};update(){this.cell&&!this.cell.isConnected&&this.hide()}destroy(){this.cancel();for(let e of Object.values(this.grips))e.remove();this.line.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}};function HW(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 UW(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 WW=Jp.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=HW(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(),UW(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)}}}}),GW=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},KW=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=GW(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},qW=(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||GW(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=Iw.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new Iw(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},JW=Jp.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]},...Xf({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=GW(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})=>qW(e,`right`),ArrowDown:({editor:e})=>qW(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(GW(a.pos,r))return;let o=KW(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}}},...Xf({nodeName:`detailsContent`})}),XW=Jp.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]},...Xf({nodeName:`detailsSummary`,content:`inline`})});function ZW(e){return[JW.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))}}),XW,YW]}function QW(e={}){let t=e.labels??UP,n=null,r=Tp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Gk.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,link:{openOnClick:!1,autolink:!0},undoRedo:e.collab||e.syncedDoc||e.rowBody||e.rowFragmentReadOnly?!1:void 0}),fT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),XL.configure({host:e.files}),QL.configure({host:e.files,loadPdf:e.loadPdf,labels:t}),Nj.configure({lineNumbers:e.codeLineNumbers??!1}),TP,wP,jP,MP,...SP(),...CP(),BW.configure({labels:t}),FP.configure({labels:t}),$L.configure({host:e.files,onError:e.onError}),wW(t,e.mentions),XI.configure({labels:t,me:()=>e.mentions?.me,onOpen:e.onOpenDate}),PW.configure({commands:MW(t,e.files,e.onError,e.pages,!!e.loadExcalidraw,e.links),labels:t}),BI.configure({onSelect:e.onCommentSelect}),yW(t,()=>n),AW.configure({labels:t,load:e.loadMermaid}),WW.configure({labels:t}),NL.configure(i),PL.configure(i),xL.configure({host:e.pages,labels:t,onNavigate:e.onNavigate}),CL.configure({host:e.syncedPages,pages:e.pages,labels:t,onNavigate:e.onNavigate,nested:t=>QW({syncedDoc:t,files:e.files,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:``})}),...ZW(t),GL.configure({labels:t}),KL.configure({labels:t}),Zj.configure({labels:t,link:e.blockLink,onCopied:e.onBlockLinkCopied}),oR,jI.configure({labels:t,doc:e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc,readOnlyDoc:!!e.syncedDoc,undoScope:!e.rowBody,files:e.files,people:e.mentions,me:()=>{let t=e.mentions?.me;return t?{id:t,name:e.collab?.user.name??``}:null},rowExtensions:n=>{let r=e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc;return QW({rowBody:n&&r&&!e.syncedDoc?{doc:r,fragment:n}:void 0,files:e.files,mentions:e.mentions,pages:e.pages,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadExcalidraw:e.loadExcalidraw,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:t.database.bodyPlaceholder,rowFragmentReadOnly:n&&e.syncedDoc?n:void 0})}})],o={trackedOrigins:[VF]};return e.rowBody?a.push(Ow.configure({document:e.rowBody.doc,fragment:e.rowBody.fragment,yUndoOptions:o})):e.rowFragmentReadOnly?a.push(Ow.configure({fragment:e.rowFragmentReadOnly})):e.syncedDoc?a.push(Ow.configure({document:e.syncedDoc})):e.collab&&a.push(Ow.configure({document:e.collab.provider.doc,yUndoOptions:o}),Nw.configure({provider:e.collab.provider,user:e.collab.user,render:$W})),a}function $W(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 eG=3e4,tG=class extends um{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Mh();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&&nG(this,t,`timeout`)},dm(eG/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:Mh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Qh(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}},nG=(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]))},rG=(e,t,n=e.states)=>{let r=t.length,i=Mm();j(i,r);for(let a=0;a{let r=fh(t),i=Mh(),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])},aG=(e,t)=>{j(e,0),Wm(e,Gv(t))},oG=(e,t,n)=>{j(e,1),Wm(e,zv(t,n))},sG=(e,t,n)=>oG(t,n,hh(e)),cG=(e,t,n,r)=>{try{Iv(t,hh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},lG=(e,t)=>{j(e,2),Wm(e,t)},uG=cG,dG=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:sG(e,t,n);break;case 1:cG(e,n,r,i);break;case 2:uG(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},fG=0,pG=1,mG=4401,hG=4404,gG=4409,_G=class{opts;doc=new bv;awareness=new tG(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),e.readOnly&&this.awareness.setLocalState(null),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),nG(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=Mm();j(t,fG),aG(t,this.doc),e.send(Fm(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);nG(this.awareness,n,this),this.destroyed||(t.code===mG||t.code===hG?this.set(`denied`,!1):t.code===gG?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=fh(e),n=M(t);if(n===fG){let e=Mm();j(e,fG);let n=dG(t,e,this.doc,this);Pm(e)>1&&!this.opts.readOnly&&this.ws?.send(Fm(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===pG&&iG(this.awareness,hh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.opts.readOnly||this.ws?.readyState!==WebSocket.OPEN)return;let n=Mm();j(n,fG),lG(n,e),this.ws.send(Fm(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r===this||this.opts.readOnly||this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=Mm();j(t,pG),Wm(t,rG(this.awareness,e)),this.ws.send(Fm(t))}onUnload=()=>nG(this.awareness,[this.doc.clientID],`unload`)},vG={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(),underline:e=>e.chain().focus().toggleUnderline().run(),taskList:e=>e.chain().focus().toggleTaskList().run(),callout:e=>e.isActive(`callout`)?e.chain().focus().unsetCallout().run():e.chain().focus().setCallout().run(),table:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},yG=[[`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`)],[`underline`,e=>e.isActive(`underline`)],[`taskList`,e=>e.isActive(`taskList`)],[`callout`,e=>e.isActive(`callout`)],[`table`,e=>e.isActive(`table`)]],bG=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:2})}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:2}),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`setLayout`:{let t=document.documentElement.classList;t.toggle(`dw-full-width`,e.fullWidth),t.toggle(`dw-font-serif`,e.font===`serif`),t.toggle(`dw-font-mono`,e.font===`mono`);return}case`command`:{let t=vG[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 _G({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 Vp({element:this.el,editable:this.editable,extensions:QW({...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:yG.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 xG(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var SG=new bG(document.getElementById(`editor`),xG);window.docwell={receive:e=>SG.receive(e)}; diff --git a/Packages/editor/src/DocwellEditor.vue b/Packages/editor/src/DocwellEditor.vue index 32eb87a..f688fb8 100644 --- a/Packages/editor/src/DocwellEditor.vue +++ b/Packages/editor/src/DocwellEditor.vue @@ -273,6 +273,7 @@ function shouldShow({ editor: e, from, to }: { editor: Editor; from: number; to: "tableOfContents", "embed", "linkCard", + "database", ]; if (from === to || blocks.some((b) => e.isActive(b)) || e.state.selection instanceof CellSelection) return false; return e.isEditable || props.canComment; diff --git a/Packages/editor/src/blockmenu.ts b/Packages/editor/src/blockmenu.ts index 8de7284..b3981f4 100644 --- a/Packages/editor/src/blockmenu.ts +++ b/Packages/editor/src/blockmenu.ts @@ -99,6 +99,21 @@ export function blockActions(editor: Editor, pos: number, labels: EditorLabels, })), }); } + if (["bulletList", "orderedList", "taskList"].includes(node.type.name)) { + out.push({ + id: "groupAsDatabase", + label: labels.database.groupAsDatabase, + icon: "database", + run: () => { + editor + .chain() + .focus() + .setTextSelection(pos + 2) + .groupAsDatabase() + .run(); + }, + }); + } if (node.type.name === "codeBlock") { const byDefault = !!editor.extensionManager.extensions.find((e) => e.name === "codeBlock")?.options.lineNumbers; const on = showsLineNumbers(node.attrs.lineNumbers, byDefault); diff --git a/Packages/editor/src/database/cells.ts b/Packages/editor/src/database/cells.ts new file mode 100644 index 0000000..5499b6a --- /dev/null +++ b/Packages/editor/src/database/cells.ts @@ -0,0 +1,562 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// How each property type shows in a cell, and how it is edited: text-like +// cells edit in place, the rest in a small panel next to the cell. + +import type { IconName } from "@docwell/ui/icons"; +import { openBlockMenu } from "../blockmenu"; +import { palette, type PaletteColor } from "../colors"; +import type { FileHost } from "../files"; +import type { MentionHost } from "../mention"; +import { h, icon, popover, textInput } from "./dom"; +import { fill, type DatabaseLabels } from "./labels"; +import { + asList, + asNumber, + cellValue, + dateOf, + newId, + nextColor, + type Attachment, + type Column, + type ColumnType, + type DbData, + type Person, + type Row, + type SelectOption, +} from "./model"; +import type { DbStore } from "./store"; + +/** What cells, views and panels need from the block. */ +export interface DbContext { + db: DbData; + /** null when the reader cannot edit. */ + store: DbStore | null; + labels: DatabaseLabels; + colorNames: Record; + locale?: string; + files?: FileHost; + people?: MentionHost; + /** Opens a row as a page. */ + openRow: (id: string) => void; + /** Called while a cell is being edited (true) and after (false); the block holds back redraws meanwhile. */ + setEditing: (on: boolean) => void; +} + +export const typeIcons: Record = { + title: "text", + text: "type", + number: "sigma", + checkbox: "todo", + select: "tag", + multiSelect: "layers", + date: "calendar", + progress: "sliders", + link: "link", + attachment: "paperclip", + member: "users", + createdTime: "clock", + createdBy: "at", +}; + +/** Types whose cells edit as a line of text in place. */ +export const inlineTypes: ColumnType[] = ["title", "text", "number", "link"]; + +/** Types that cannot be edited at all. */ +export const readOnlyTypes: ColumnType[] = ["createdTime", "createdBy"]; + +export function formatDay(iso: string, locale?: string): string { + const [y, m, d] = iso.split("-").map(Number); + if (!y || !m || !d) return iso; + return new Date(y, m - 1, d).toLocaleDateString(locale, { year: "numeric", month: "short", day: "numeric" }); +} + +export function tag(name: string, color: PaletteColor | undefined, onRemove?: () => void): HTMLElement { + const el = h("span", { class: "dw-db-tag", dataset: { color: color ?? "gray" } }, name); + if (onRemove) { + const x = h("button", { type: "button", class: "dw-db-tag__x", "aria-label": "×" }, "×"); + x.addEventListener("mousedown", (e) => e.preventDefault()); + x.addEventListener("click", (e) => { + e.stopPropagation(); + onRemove(); + }); + el.append(x); + } + return el; +} + +function safeHref(url: string): string | null { + try { + const u = new URL(url.includes("://") ? url : `https://${url}`); + return u.protocol === "http:" || u.protocol === "https:" || u.protocol === "mailto:" ? u.href : null; + } catch { + return null; + } +} + +/** A cell's content for display. */ +export function renderCell(ctx: DbContext, row: Row, col: Column): Node { + const v = cellValue(row, col); + const l = ctx.labels; + switch (col.type) { + case "title": { + const text = typeof v === "string" ? v : ""; + return h("span", { class: text ? "dw-db-cell__title" : "dw-db-cell__title is-empty" }, text || l.untitledRow); + } + case "text": + return h("span", { class: "dw-db-cell__text" }, typeof v === "string" ? v : ""); + case "number": { + const n = asNumber(v); + return h("span", { class: "dw-db-cell__number" }, n === null ? "" : n.toLocaleString(ctx.locale)); + } + case "checkbox": + return h( + "span", + { class: v === true ? "dw-db-check is-on" : "dw-db-check", role: "img", "aria-label": v === true ? l.checked : l.unchecked }, + v === true ? icon("check", 13) : null, + ); + case "select": { + const o = col.options?.find((x) => x.id === v); + return h("span", { class: "dw-db-tags" }, o ? tag(o.name, o.color) : null); + } + case "multiSelect": + return h( + "span", + { class: "dw-db-tags" }, + asList(v).flatMap((id) => { + const o = col.options?.find((x) => x.id === id); + return o ? [tag(o.name, o.color)] : []; + }), + ); + case "date": + case "createdTime": { + const d = dateOf(v); + return h("span", { class: "dw-db-cell__text" }, d ? formatDay(d, ctx.locale) : ""); + } + case "progress": { + const n = asNumber(v); + if (n === null) return h("span"); + const pct = Math.max(0, Math.min(100, n)); + return h( + "span", + { class: "dw-db-progress" }, + h("span", { class: "dw-db-progress__bar" }, h("span", { class: "dw-db-progress__fill", style: { width: `${pct}%` } })), + h("span", { class: "dw-db-progress__num" }, `${pct}%`), + ); + } + case "link": { + const url = typeof v === "string" ? v : ""; + const href = url ? safeHref(url) : null; + if (!href) return h("span", { class: "dw-db-cell__text" }, url); + const a = h("a", { class: "dw-db-cell__link", href, target: "_blank", rel: "noopener noreferrer" }, url); + // A plain click selects the cell; Ctrl/Cmd+click follows the link. + a.addEventListener("click", (e) => { + if (!e.ctrlKey && !e.metaKey) e.preventDefault(); + }); + return a; + } + case "attachment": + return h( + "span", + { class: "dw-db-tags" }, + asList(v).map((f) => { + const href = ctx.files ? ctx.files.resolve(f.src) : f.src; + const a = h("a", { class: "dw-db-file", href, target: "_blank", rel: "noopener noreferrer" }, icon("paperclip", 12), f.name); + a.addEventListener("click", (e) => { + if (!e.ctrlKey && !e.metaKey) e.preventDefault(); + }); + return a; + }), + ); + case "member": + case "createdBy": + return h( + "span", + { class: "dw-db-tags" }, + asList(v).map((p) => h("span", { class: "dw-db-person" }, h("span", { class: "dw-db-person__dot" }, (p?.name || "?").slice(0, 1).toUpperCase()), p?.name ?? "")), + ); + } +} + +export interface EditOptions { + /** Called when editing ends; move is where the selection should go next (Enter/Tab). */ + onDone: (move?: "down" | "right" | "left") => void; + /** Text typed to start editing; replaces the value. */ + initial?: string; +} + +/** + * Starts editing a cell drawn in el: text-like types get an input inside it, + * the rest a panel next to it. Checkboxes toggle at once. + */ +export function editCell(ctx: DbContext, el: HTMLElement, row: Row, col: Column, opts: EditOptions) { + const store = ctx.store; + if (!store || readOnlyTypes.includes(col.type)) return opts.onDone(); + const v = cellValue(row, col); + if (col.type === "checkbox") { + store.setCell(row.id, col.id, v !== true); + return opts.onDone(); + } + ctx.setEditing(true); + const finish = (move?: "down" | "right" | "left") => { + ctx.setEditing(false); + opts.onDone(move); + }; + if (inlineTypes.includes(col.type)) { + const start = opts.initial ?? (col.type === "number" ? (asNumber(v)?.toString() ?? "") : typeof v === "string" ? v : ""); + let move: "down" | "right" | "left" | undefined; + const input = textInput(start, { + class: "dw-db-cell__input", + type: col.type === "number" ? "text" : "text", + label: col.name, + onCommit: (text) => { + const t = text.trim(); + const value = col.type === "number" ? asNumber(t) : col.type === "title" || col.type === "text" ? text : t; + if (value !== (v ?? null) && !(value === "" && v === undefined)) store.setCell(row.id, col.id, value); + finish(move); + }, + onCancel: () => finish(), + }); + input.addEventListener("keydown", (e) => { + if (e.key === "Enter") move = "down"; + if (e.key === "Tab") { + e.preventDefault(); + move = e.shiftKey ? "left" : "right"; + input.blur(); + } + }); + el.replaceChildren(input); + el.classList.add("is-editing"); + input.focus(); + if (opts.initial !== undefined) input.setSelectionRange(input.value.length, input.value.length); + else input.select(); + return; + } + const panel = (fillBox: (box: HTMLDivElement, close: () => void) => void, cls = "") => + popover(el, fillBox, { class: cls, onClose: () => finish(), label: col.name }); + switch (col.type) { + case "select": + case "multiSelect": + panel((box, close) => choicePanel(ctx, box, row, col, close, opts.initial), "dw-db-pop--choices"); + break; + case "date": + panel((box, close) => { + const input = h("input", { type: "date", class: "dw-db-input", "aria-label": col.name }); + input.value = dateOf(v); + input.addEventListener("change", () => store.setCell(row.id, col.id, input.value || null)); + input.addEventListener("keydown", (e) => { + if (e.key === "Enter") close(); + }); + const clear = h("button", { type: "button", class: "dw-db__btn" }, ctx.labels.clear); + clear.addEventListener("click", () => { + store.setCell(row.id, col.id, null); + close(); + }); + const today = h("button", { type: "button", class: "dw-db__btn" }, ctx.labels.today); + today.addEventListener("click", () => { + const d = new Date(); + store.setCell(row.id, col.id, `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`); + close(); + }); + box.append(input, h("div", { class: "dw-db-pop__row" }, today, clear)); + input.focus({ preventScroll: true }); + }); + break; + case "progress": + panel((box, close) => { + const n = asNumber(v) ?? 0; + const range = h("input", { type: "range", min: "0", max: "100", step: "1", class: "dw-db-range", "aria-label": col.name }); + range.value = String(n); + const num = h("span", { class: "dw-db-progress__num" }, `${n}%`); + range.addEventListener("input", () => (num.textContent = `${range.value}%`)); + range.addEventListener("change", () => store.setCell(row.id, col.id, Number(range.value))); + range.addEventListener("keydown", (e) => { + if (e.key === "Enter") close(); + }); + box.append(h("div", { class: "dw-db-pop__row" }, range, num)); + range.focus({ preventScroll: true }); + }); + break; + case "member": + panel((box, close) => memberPanel(ctx, box, row, col, close), "dw-db-pop--choices"); + break; + case "attachment": + panel((box) => attachmentPanel(ctx, box, row, col), "dw-db-pop--choices"); + break; + default: + finish(); + } +} + +/** The choice list of a select cell: pick, find or create, and edit choices. */ +function choicePanel(ctx: DbContext, box: HTMLDivElement, row: Row, col: Column, close: () => void, initial?: string) { + const store = ctx.store!; + const l = ctx.labels; + const multi = col.type === "multiSelect"; + let options: SelectOption[] = [...(col.options ?? [])]; + let picked: string[] = multi ? asList(cellValue(row, col)) : [String(cellValue(row, col) ?? "")].filter(Boolean); + let active = 0; + const chosen = h("div", { class: "dw-db-tags dw-db-pop__chosen" }); + const input = h("input", { class: "dw-db-input", placeholder: l.searchOptions, "aria-label": l.searchOptions }); + input.value = initial ?? ""; + const list = h("div", { class: "dw-db-pop__list", role: "listbox" }); + box.append(chosen, input, list); + + const save = () => store.setCell(row.id, col.id, multi ? picked : (picked[0] ?? null)); + const toggle = (id: string) => { + if (multi) picked = picked.includes(id) ? picked.filter((x) => x !== id) : [...picked, id]; + else picked = picked[0] === id ? [] : [id]; + save(); + if (!multi) close(); + else draw(); + }; + const create = (name: string) => { + const o: SelectOption = { id: newId(), name, color: nextColor(options) }; + options = [...options, o]; + store.tx(() => { + store.setOptions(col.id, options); + picked = multi ? [...picked, o.id] : [o.id]; + save(); + }); + input.value = ""; + if (!multi) close(); + else draw(); + }; + const editOption = (anchor: HTMLElement, o: SelectOption) => { + openBlockMenu( + anchor, + [ + { + id: "rename", + label: l.renameOption, + icon: "pencil", + run: () => { + const name = window.prompt(l.renameOption, o.name)?.trim(); + if (!name) return; + options = options.map((x) => (x.id === o.id ? { ...x, name } : x)); + store.setOptions(col.id, options); + draw(); + }, + }, + { + id: "color", + label: l.optionColor, + icon: "palette", + children: palette.map((c) => ({ + id: c, + label: ctx.colorNames[c] ?? c, + icon: c === o.color ? "check" : "drop", + run: () => { + options = options.map((x) => (x.id === o.id ? { ...x, color: c } : x)); + store.setOptions(col.id, options); + draw(); + }, + })), + }, + { + id: "delete", + label: l.deleteOption, + icon: "trash", + danger: true, + run: () => { + options = options.filter((x) => x.id !== o.id); + picked = picked.filter((x) => x !== o.id); + store.setOptions(col.id, options); + draw(); + }, + }, + ], + l.optionColor, + () => input.focus(), + ); + }; + + type Item = { kind: "option"; o: SelectOption } | { kind: "create"; name: string }; + let items: Item[] = []; + function draw() { + chosen.replaceChildren( + ...picked.flatMap((id) => { + const o = options.find((x) => x.id === id); + return o ? [tag(o.name, o.color, () => toggle(id))] : []; + }), + ); + const q = input.value.trim(); + const found = options.filter((o) => o.name.toLowerCase().includes(q.toLowerCase())); + items = found.map((o) => ({ kind: "option" as const, o })); + if (q && !options.some((o) => o.name.toLowerCase() === q.toLowerCase())) items.push({ kind: "create", name: q }); + active = Math.min(active, Math.max(0, items.length - 1)); + list.replaceChildren( + ...items.map((it, i) => { + const rowEl = h("div", { + class: `dw-db-pop__item${i === active ? " is-active" : ""}`, + role: "option", + "aria-selected": String(it.kind === "option" && picked.includes(it.o.id)), + }); + rowEl.addEventListener("mousedown", (e) => e.preventDefault()); + if (it.kind === "option") { + rowEl.append( + h("span", { class: "dw-db-pop__check" }, picked.includes(it.o.id) ? icon("check", 13) : null), + tag(it.o.name, it.o.color), + ); + const more = h("button", { type: "button", class: "dw-db__btn dw-db__btn--icon dw-db-pop__more", "aria-label": l.optionColor }, icon("more", 14)); + more.addEventListener("click", (e) => { + e.stopPropagation(); + editOption(more, it.o); + }); + rowEl.append(more); + rowEl.addEventListener("click", () => toggle(it.o.id)); + } else { + rowEl.append(h("span", { class: "dw-db-pop__check" }, icon("plus", 13)), h("span", {}, fill(l.createOption, it.name))); + rowEl.addEventListener("click", () => create(it.name)); + } + return rowEl; + }), + ); + } + input.addEventListener("input", () => { + active = 0; + draw(); + }); + input.addEventListener("keydown", (e) => { + if (e.key === "ArrowDown" || e.key === "ArrowUp") { + e.preventDefault(); + if (items.length) active = (active + (e.key === "ArrowDown" ? 1 : -1) + items.length) % items.length; + draw(); + } else if (e.key === "Enter") { + e.preventDefault(); + const it = items[active]; + if (it?.kind === "option") toggle(it.o.id); + else if (it?.kind === "create") create(it.name); + else close(); + } else if (e.key === "Backspace" && !input.value && multi && picked.length) { + toggle(picked[picked.length - 1]!); + } + }); + draw(); + // Focus at once (not on the next frame), so keys typed right away land here. + input.focus({ preventScroll: true }); + input.setSelectionRange(input.value.length, input.value.length); +} + +/** People in a member cell: remove them, or find and add more. */ +function memberPanel(ctx: DbContext, box: HTMLDivElement, row: Row, col: Column, close: () => void) { + const store = ctx.store!; + const l = ctx.labels; + let people = asList(cellValue(row, col)).filter((p) => p?.id); + const chosen = h("div", { class: "dw-db-tags dw-db-pop__chosen" }); + const input = h("input", { class: "dw-db-input", placeholder: l.searchPeople, "aria-label": l.searchPeople }); + const list = h("div", { class: "dw-db-pop__list", role: "listbox" }); + box.append(chosen, input, list); + const save = () => store.setCell(row.id, col.id, people); + const drawChosen = () => + chosen.replaceChildren( + ...people.map((p) => + tag(p.name, "gray", () => { + people = people.filter((x) => x.id !== p.id); + save(); + drawChosen(); + }), + ), + ); + let seq = 0; + let found: Person[] = []; + let active = 0; + const drawList = () => { + list.replaceChildren( + ...(found.length + ? found.map((p, i) => { + const el = h( + "div", + { class: `dw-db-pop__item${i === active ? " is-active" : ""}`, role: "option" }, + h("span", { class: "dw-db-person__dot" }, (p.name || "?").slice(0, 1).toUpperCase()), + h("span", {}, p.name), + ); + el.addEventListener("mousedown", (e) => e.preventDefault()); + el.addEventListener("click", () => add(p)); + return el; + }) + : [h("div", { class: "dw-db-pop__empty" }, input.value.trim() ? l.noPeople : "")]), + ); + }; + const add = (p: Person) => { + if (!people.some((x) => x.id === p.id)) people = [...people, p]; + save(); + input.value = ""; + found = []; + drawChosen(); + drawList(); + }; + input.addEventListener("input", async () => { + const q = input.value.trim(); + const n = ++seq; + const res = ctx.people && q ? await ctx.people.search(q).catch(() => []) : []; + if (n !== seq) return; + found = res.slice(0, 8).map((p) => ({ id: p.id, name: p.label })); + active = 0; + drawList(); + }); + input.addEventListener("keydown", (e) => { + if (e.key === "ArrowDown" || e.key === "ArrowUp") { + e.preventDefault(); + if (found.length) active = (active + (e.key === "ArrowDown" ? 1 : -1) + found.length) % found.length; + drawList(); + } else if (e.key === "Enter") { + e.preventDefault(); + const p = found[active]; + if (p) add(p); + else close(); + } + }); + drawChosen(); + drawList(); + input.focus({ preventScroll: true }); +} + +/** Files in an attachment cell: open, remove, or upload more. */ +function attachmentPanel(ctx: DbContext, box: HTMLDivElement, row: Row, col: Column) { + const store = ctx.store!; + const l = ctx.labels; + let files = asList(cellValue(row, col)).filter((f) => f?.src); + const list = h("div", { class: "dw-db-pop__list" }); + const draw = () => + list.replaceChildren( + ...files.map((f, i) => { + const href = ctx.files ? ctx.files.resolve(f.src) : f.src; + const rm = h("button", { type: "button", class: "dw-db__btn dw-db__btn--icon", "aria-label": l.remove, title: l.remove }, icon("trash", 14)); + rm.addEventListener("click", () => { + files = files.filter((_, j) => j !== i); + store.setCell(row.id, col.id, files); + draw(); + }); + return h( + "div", + { class: "dw-db-pop__item" }, + h("a", { class: "dw-db-file", href, target: "_blank", rel: "noopener noreferrer" }, icon("paperclip", 12), f.name), + rm, + ); + }), + ); + box.append(list); + const upload = ctx.files?.upload; + if (upload) { + const btn = h("button", { type: "button", class: "dw-db__btn" }, icon("upload", 14), h("span", {}, l.upload)); + btn.addEventListener("click", () => { + const input = h("input", { type: "file", multiple: true }); + input.onchange = async () => { + for (const file of [...(input.files ?? [])]) { + try { + const up = await upload.call(ctx.files, file); + files = [...files, { name: up.name, src: up.url, size: up.size, mime: up.mime }]; + store.setCell(row.id, col.id, files); + draw(); + } catch { + /* the host reports upload errors */ + } + } + }; + input.click(); + }); + box.append(h("div", { class: "dw-db-pop__row" }, btn)); + } + draw(); +} diff --git a/Packages/editor/src/database/csv.ts b/Packages/editor/src/database/csv.ts new file mode 100644 index 0000000..7bec579 --- /dev/null +++ b/Packages/editor/src/database/csv.ts @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// CSV for import and export, and tab-separated text for copying and pasting +// cells to and from spreadsheets. + +import { + asNumber, + cellText, + dateOf, + newId, + nextColor, + type Column, + type ColumnType, + type DbData, + type Row, + type SelectOption, +} from "./model"; + +/** Parses CSV (or TSV with sep "\t") into rows of fields; quotes may hold separators and line breaks. */ +export function parseDelimited(text: string, sep = ","): string[][] { + const out: string[][] = []; + let row: string[] = []; + let field = ""; + let quoted = false; + let i = 0; + const src = text.replace(/^\uFEFF/, ""); + while (i < src.length) { + const ch = src[i]!; + if (quoted) { + if (ch === '"') { + if (src[i + 1] === '"') { + field += '"'; + i += 2; + continue; + } + quoted = false; + } else field += ch; + i++; + continue; + } + if (ch === '"' && field === "") quoted = true; + else if (ch === sep) { + row.push(field); + field = ""; + } else if (ch === "\n" || ch === "\r") { + row.push(field); + out.push(row); + row = []; + field = ""; + if (ch === "\r" && src[i + 1] === "\n") i++; + } else field += ch; + i++; + } + if (field !== "" || row.length) { + row.push(field); + out.push(row); + } + return out; +} + +function quote(s: string, sep: string): string { + return s.includes(sep) || /["\r\n]/.test(s) || /^\s|\s$/.test(s) ? `"${s.replace(/"/g, '""')}"` : s; +} + +export function formatDelimited(rows: string[][], sep = ","): string { + return rows.map((r) => r.map((f) => quote(f, sep)).join(sep)).join("\r\n"); +} + +/** A database as CSV: a header of column names, then one line per row. */ +export function toCSV(db: DbData, columns: Column[], rows: Row[]): string { + return formatDelimited([columns.map((c) => c.name), ...rows.map((r) => columns.map((c) => cellText(r, c)))]); +} + +/** Guesses a column's type from its values: numbers, dates, yes/no, or a few repeated words. */ +export function guessType(values: string[]): ColumnType { + const filled = values.map((v) => v.trim()).filter(Boolean); + if (!filled.length) return "text"; + if (filled.every((v) => asNumber(v) !== null)) return "number"; + if (filled.every((v) => /^\d{4}-\d{2}-\d{2}/.test(v))) return "date"; + if (filled.every((v) => /^(true|false|yes|no)$/i.test(v))) return "checkbox"; + if (filled.every((v) => /^https?:\/\/\S+$/.test(v))) return "link"; + const distinct = new Set(filled.map((v) => v.toLowerCase())); + if (filled.length >= 4 && distinct.size <= Math.max(2, filled.length / 3) && filled.every((v) => v.length <= 40)) { + return "select"; + } + return "text"; +} + +/** A text value as a cell of col; choices missing from options are added to it (options is mutated). */ +export function parseCell(text: string, col: Column, options: SelectOption[]): unknown { + const t = text.trim(); + if (!t) return null; + const choice = (name: string) => { + let o = options.find((x) => x.name.toLowerCase() === name.toLowerCase()); + if (!o) { + o = { id: newId(), name, color: nextColor(options) }; + options.push(o); + } + return o.id; + }; + switch (col.type) { + case "number": + return asNumber(t); + case "progress": { + const n = asNumber(t.replace("%", "")); + return n === null ? null : Math.max(0, Math.min(100, Math.round(n))); + } + case "checkbox": + return /^(true|yes|1|x|✓|done)$/i.test(t); + case "date": + return dateOf(t) || null; + case "select": + return choice(t); + case "multiSelect": + return [ + ...new Set( + t + .split(/[,;]/) + .map((s) => s.trim()) + .filter(Boolean) + .map(choice), + ), + ]; + case "member": + case "attachment": + case "createdBy": + case "createdTime": + return null; + default: + return t; + } +} + +/** + * The columns and rows of a CSV file for a new database: the header names + * the columns, the first column is the title, and types are guessed. + */ +export function fromCSV(text: string, sep = ","): { columns: Column[]; rows: Record[] } { + const lines = parseDelimited(text, sep).filter((r) => r.some((f) => f.trim())); + const head = lines[0] ?? []; + const body = lines.slice(1); + const columns: Column[] = head.map((name, i) => ({ + id: newId(), + name: name.trim() || `${i + 1}`, + type: i === 0 ? "title" : guessType(body.map((r) => r[i] ?? "")), + })); + for (const c of columns) if (c.type === "select") c.options = []; + const rows = body.map((r) => { + const cells: Record = {}; + columns.forEach((c, i) => { + const v = parseCell(r[i] ?? "", c, c.options ?? []); + if (v !== null && !(Array.isArray(v) && !v.length)) cells[c.id] = v; + }); + return cells; + }); + return { columns, rows }; +} + +/** + * Matches CSV header names to an existing database's columns (by name, + * ignoring case). Unknown names come back in missing, to be added as text. + */ +export function matchHeader(head: string[], columns: Column[]): { index: (Column | null)[]; missing: string[] } { + const missing: string[] = []; + const index = head.map((name) => { + const c = columns.find((x) => x.name.trim().toLowerCase() === name.trim().toLowerCase()); + if (!c && name.trim()) missing.push(name.trim()); + return c ?? null; + }); + return { index, missing }; +} diff --git a/Packages/editor/src/database/database.test.ts b/Packages/editor/src/database/database.test.ts new file mode 100644 index 0000000..3926eee --- /dev/null +++ b/Packages/editor/src/database/database.test.ts @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +import { describe, expect, it } from "vitest"; +import * as Y from "yjs"; +import { formatDelimited, fromCSV, parseDelimited, toCSV } from "./csv"; +import { convertValue, defaultView, groupRows, monthGrid, moveToGroup, normalize, viewRows, type Column, type DbData, type Row } from "./model"; +import { blocksOf, DbStore, readDb, seedDb } from "./store"; + +const title: Column = { id: "t", name: "Name", type: "title" }; +const status: Column = { + id: "s", + name: "Status", + type: "select", + options: [ + { id: "todo", name: "To do", color: "gray" }, + { id: "done", name: "Done", color: "green" }, + ], +}; +const points: Column = { id: "p", name: "Points", type: "number" }; +const row = (id: string, cells: Record): Row => ({ id, cells, createdAt: 1, createdBy: null }); + +function sample(): DbData { + return { + title: "Tasks", + columns: [title, status, points], + rows: [row("a", { t: "Write", s: "todo", p: 3 }), row("b", { t: "Read", s: "done", p: 1 }), row("c", { t: "Ship", p: 5 })], + views: [defaultView("table", "Table", [title, status, points])], + }; +} + +describe("database model", () => { + it("filters, searches and sorts rows, keeping empty cells last", () => { + const db = sample(); + const v = db.views[0]!; + expect(viewRows(db, { ...v, filters: [{ column: "s", op: "is", value: "todo" }] }).map((r) => r.id)).toEqual(["a"]); + expect(viewRows(db, { ...v, filters: [{ column: "s", op: "isEmpty" }] }).map((r) => r.id)).toEqual(["c"]); + expect(viewRows(db, { ...v, filters: [{ column: "p", op: "gt", value: 2 }] }).map((r) => r.id)).toEqual(["a", "c"]); + expect(viewRows(db, v, "rea").map((r) => r.id)).toEqual(["b"]); + expect(viewRows(db, { ...v, sorts: [{ column: "p", desc: true }] }).map((r) => r.id)).toEqual(["c", "a", "b"]); + // Choices sort in their own order; the row without one goes last either way. + expect(viewRows(db, { ...v, sorts: [{ column: "s", desc: true }] }).map((r) => r.id)).toEqual(["b", "a", "c"]); + }); + + it("groups rows by a choice, with a group for rows without one", () => { + const db = sample(); + const groups = groupRows(db.rows, status, "No value", "Yes", "No"); + expect(groups.map((g) => [g.key, g.rows.map((r) => r.id)])).toEqual([ + ["", ["c"]], + ["todo", ["a"]], + ["done", ["b"]], + ]); + expect(moveToGroup(db.rows[0]!, status, "todo", "done")).toBe("done"); + }); + + it("converts values when a column changes type", () => { + const text: Column = { id: "x", name: "X", type: "text" }; + const out = convertValue("Red, Blue", text, "multiSelect", []); + expect(out.options.map((o) => o.name)).toEqual(["Red", "Blue"]); + expect(out.value).toEqual(out.options.map((o) => o.id)); + expect(convertValue("done", status, "text", []).value).toBe("Done"); + expect(convertValue("12,5", text, "number", []).value).toBe(12.5); + }); + + it("normalizes untrusted data and always has a title column", () => { + const db = normalize({ columns: [{ id: "a", type: "bogus" }], rows: [{ id: 3 }, { id: "r", cells: { a: "x" } }] }); + expect(db.columns.map((c) => c.type)).toEqual(["title", "text"]); + expect(db.rows.map((r) => r.id)).toEqual(["r"]); + }); + + it("lays out a month from Monday", () => { + const days = monthGrid(2026, 10); // November 2026 starts on a Sunday + expect(days[0]).toBe("2026-10-26"); + expect(days.length % 7).toBe(0); + expect(days).toContain("2026-11-30"); + }); +}); + +describe("CSV", () => { + it("reads quoted fields with separators and line breaks", () => { + expect(parseDelimited('a,"b,c","d ""e""\nf"\r\n1,2,3')).toEqual([ + ["a", "b,c", 'd "e"\nf'], + ["1", "2", "3"], + ]); + expect(formatDelimited([["a", "b,c"], ['x"y', ""]])).toBe('a,"b,c"\r\n"x""y",'); + }); + + it("guesses column types on import and writes them back", () => { + const { columns, rows } = fromCSV("Name,Points,Due,Done\nA,1,2026-11-01,yes\nB,2.5,2026-11-02,no\n"); + expect(columns.map((c) => c.type)).toEqual(["title", "number", "date", "checkbox"]); + expect(rows[1]).toEqual({ [columns[0]!.id]: "B", [columns[1]!.id]: 2.5, [columns[2]!.id]: "2026-11-02", [columns[3]!.id]: false }); + const db = sample(); + expect(toCSV(db, db.columns, db.rows).split("\r\n")[1]).toBe("Write,To do,3"); + }); +}); + +describe("database store", () => { + it("edits a database in the Y.Doc and moves rows without recreating them", () => { + const doc = new Y.Doc(); + seedDb(doc, "db1", sample(), () => {}); + const store = new DbStore(doc, blocksOf(doc).get("db1")!, () => ({ id: "u1", name: "Ann" })); + store.setCell("a", "p", 8); + const id = store.addRow({ t: "New" }, 0); + expect(store.snapshot().rows.map((r) => r.id)).toEqual([id, "a", "b", "c"]); + expect(store.snapshot().rows[0]!.createdBy).toEqual({ id: "u1", name: "Ann" }); + + const body = store.rowBody("a")!; + store.moveRow("a", 3); + expect(store.snapshot().rows.map((r) => r.id)).toEqual([id, "b", "c", "a"]); + expect(store.rowBody("a")).toBe(body); + expect(store.snapshot().rows.find((r) => r.id === "a")!.cells.p).toBe(8); + + store.changeType("s", "text"); + expect(readDb(store.map).rows.find((r) => r.id === "b")!.cells.s).toBe("Done"); + store.deleteColumn("s"); + expect(store.snapshot().columns.map((c) => c.id)).toEqual(["t", "p"]); + }); + + it("merges concurrent edits to different cells of a row", () => { + const a = new Y.Doc(); + seedDb(a, "db", sample(), () => {}); + const b = new Y.Doc(); + Y.applyUpdate(b, Y.encodeStateAsUpdate(a)); + new DbStore(a, blocksOf(a).get("db")!, () => null).setCell("a", "t", "Write more"); + new DbStore(b, blocksOf(b).get("db")!, () => null).setCell("a", "p", 13); + Y.applyUpdate(a, Y.encodeStateAsUpdate(b)); + Y.applyUpdate(b, Y.encodeStateAsUpdate(a)); + for (const d of [a, b]) { + expect(readDb(blocksOf(d).get("db")!).rows[0]!.cells).toEqual({ t: "Write more", s: "todo", p: 13 }); + } + }); +}); diff --git a/Packages/editor/src/database/dom.ts b/Packages/editor/src/database/dom.ts new file mode 100644 index 0000000..24d72b8 --- /dev/null +++ b/Packages/editor/src/database/dom.ts @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// Small DOM helpers for the database block, which (like the rest of the +// editor's blocks) draws plain DOM so it also runs in the mobile bridge. + +import { autoUpdate, computePosition, flip, offset, shift, type Placement } from "@floating-ui/dom"; +import type { IconName } from "@docwell/ui/icons"; +import { svgIcon } from "../suggestion"; + +type Child = Node | string | null | undefined | false; +type Props = Record & { + class?: string; + on?: Partial<{ [K in keyof HTMLElementEventMap]: (e: HTMLElementEventMap[K]) => void }>; + dataset?: Record; + style?: Partial; +}; + +/** Makes an element: h("button", { class: "x", on: { click } }, "Text"). */ +export function h( + tag: K, + props: Props = {}, + ...children: (Child | Child[])[] +): HTMLElementTagNameMap[K] { + const el = document.createElement(tag); + for (const [k, v] of Object.entries(props)) { + if (v === undefined || v === null || v === false) continue; + if (k === "class") el.className = String(v); + else if (k === "on") { + for (const [ev, fn] of Object.entries(v as Record)) el.addEventListener(ev, fn); + } else if (k === "dataset") Object.assign(el.dataset, v); + else if (k === "style") Object.assign(el.style, v); + else if (k in el && typeof v !== "string") (el as unknown as Record)[k] = v; + else el.setAttribute(k, v === true ? "" : String(v)); + } + for (const c of children.flat()) { + if (c === null || c === undefined || c === false) continue; + el.append(c); + } + return el; +} + +export function icon(name: IconName, size = 16): SVGSVGElement { + return svgIcon(name, size); +} + +/** A small button with an icon and, optionally, text; label is its accessible name. */ +export function iconButton(name: IconName, label: string, onClick: (e: MouseEvent) => void, text?: string) { + const b = h( + "button", + { type: "button", class: text ? "dw-db__btn" : "dw-db__btn dw-db__btn--icon", title: label, "aria-label": label }, + icon(name, 15), + text ? h("span", {}, text) : null, + ); + b.addEventListener("click", (e) => { + e.preventDefault(); + onClick(e); + }); + return b; +} + +export interface Popover { + box: HTMLDivElement; + close: () => void; +} + +let current: Popover | null = null; + +/** + * A floating panel next to anchor (one at a time). Escape or a click outside + * closes it; onClose runs once. The panel's content is up to the caller. + */ +export function popover( + anchor: Element, + fill: (box: HTMLDivElement, close: () => void) => void, + opts: { placement?: Placement; class?: string; onClose?: () => void; label?: string } = {}, +): Popover { + current?.close(); + const box = h("div", { class: `dw-db-pop ${opts.class ?? ""}`, role: "dialog", "aria-label": opts.label }); + let closed = false; + const close = () => { + if (closed) return; + closed = true; + stop(); + box.remove(); + document.removeEventListener("mousedown", onDown, true); + document.removeEventListener("keydown", onKey, true); + if (current?.box === box) current = null; + opts.onClose?.(); + }; + const onDown = (e: MouseEvent) => { + const t = e.target as Node; + // Menus opened from this panel (block menus, other popovers) are siblings in body. + if (box.contains(t) || anchor.contains(t) || (t instanceof Element && t.closest(".dw-block-menu"))) return; + close(); + }; + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape" && !document.querySelector(".dw-block-menu")) { + e.preventDefault(); + e.stopPropagation(); + close(); + if (anchor instanceof HTMLElement) anchor.focus(); + } + }; + document.body.append(box); + const stop = autoUpdate(anchor, box, () => { + void computePosition(anchor, box, { + placement: opts.placement ?? "bottom-start", + strategy: "fixed", + middleware: [offset(4), flip(), shift({ padding: 8 })], + }).then(({ x, y }) => Object.assign(box.style, { left: `${x}px`, top: `${y}px` })); + }); + document.addEventListener("mousedown", onDown, true); + document.addEventListener("keydown", onKey, true); + fill(box, close); + current = { box, close }; + return current; +} + +/** Closes the open popover, if any. */ +export function closePopover() { + current?.close(); +} + +/** A text input that commits on Enter or blur and cancels on Escape. */ +export function textInput( + value: string, + opts: { placeholder?: string; label?: string; class?: string; type?: string; onCommit: (v: string) => void; onCancel?: () => void }, +): HTMLInputElement { + const input = h("input", { + type: opts.type ?? "text", + class: opts.class ?? "dw-db-input", + placeholder: opts.placeholder, + "aria-label": opts.label ?? opts.placeholder, + }); + input.value = value; + let done = false; + const commit = () => { + if (done) return; + done = true; + opts.onCommit(input.value); + }; + input.addEventListener("keydown", (e) => { + e.stopPropagation(); + if (e.key === "Enter") { + e.preventDefault(); + commit(); + } else if (e.key === "Escape") { + done = true; + opts.onCancel?.(); + } + }); + input.addEventListener("blur", commit); + return input; +} + +/** Offers a file for download. */ +export function download(name: string, text: string, mime: string) { + const url = URL.createObjectURL(new Blob([text], { type: mime })); + const a = h("a", { href: url, download: name }); + document.body.append(a); + a.click(); + a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); +} + +/** Opens the system file picker for one file. */ +export function pickFile(accept: string): Promise { + return new Promise((resolve) => { + const input = h("input", { type: "file", accept }); + input.onchange = () => resolve(input.files?.[0] ?? null); + input.click(); + }); +} diff --git a/Packages/editor/src/database/index.ts b/Packages/editor/src/database/index.ts new file mode 100644 index 0000000..d062cd6 --- /dev/null +++ b/Packages/editor/src/database/index.ts @@ -0,0 +1,502 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// The database block (ADR-13). The node keeps only an id; its records live +// in ydoc.getMap("blocks"). Editors without a live document (share links, +// history previews) draw it read-only from the node's data attribute, which +// the server fills in when it turns the document into JSON. + +import { Editor, mergeAttributes, Node, type AnyExtension, type JSONContent } from "@tiptap/core"; +import { Fragment, Slice, type Node as PMNode } from "@tiptap/pm/model"; +import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state"; +import { prosemirrorJSONToYXmlFragment, ySyncPluginKey, yUndoPluginKey, yXmlFragmentToProsemirrorJSON } from "@tiptap/y-tiptap"; +import * as Y from "yjs"; +import type { FileHost } from "../files"; +import { englishLabels, type EditorLabels } from "../labels"; +import type { MentionHost } from "../mention"; +import { h } from "./dom"; +import { cellText, defaultView, newId, normalize, titleColumn, type Column, type DbData, type Person, type Row } from "./model"; +import { RowPeek } from "./peek"; +import { blocksOf, DbStore, emptyDb, exportDb, readDb, seedDb } from "./store"; +import { DatabaseView } from "./view"; +import { typeLabel } from "./labels"; + +export interface DatabaseOptions { + labels: EditorLabels | null; + /** The page's live document; without it databases show read-only from their data attribute. */ + doc?: Y.Doc; + /** The document is shown read-only (a synced page). */ + readOnlyDoc?: boolean; + /** Adds database edits to the editor's undo history (not in row bodies, whose page has it). */ + undoScope?: boolean; + files?: FileHost; + people?: MentionHost; + /** The signed-in person, recorded as the creator of new rows. */ + me?: () => Person | null; + /** + * The extensions of a row body's editor: bound to fragment, or (null) for + * a read-only body from JSON. + */ + rowExtensions?: (fragment: Y.XmlFragment | null) => AnyExtension[]; + /** Shows a short message, e.g. "Copied 6 cells". */ + notify?: (text: string) => void; +} + +declare module "@tiptap/core" { + interface Commands { + database: { + /** Inserts a database; data defaults to an empty one. */ + insertDatabase: (data?: DbData) => ReturnType; + /** Turns the list (or paragraphs) around the selection into a database, one row per item. */ + groupAsDatabase: () => ReturnType; + }; + } +} + +const dbLabels = (l: EditorLabels | null) => (l ?? englishLabels).database; + +function dbDefaults(l: EditorLabels | null) { + const d = dbLabels(l); + return { tableView: d.viewTable, columnName: (t: Column["type"]) => (t === "title" ? d.typeTitle : typeLabel(d, t)) }; +} + +/** The ProseMirror JSON of a row body fragment, as nodes. */ +const bodyJSON = (f: Y.XmlFragment) => (yXmlFragmentToProsemirrorJSON(f).content as unknown[] | undefined) ?? []; + +/** Copies database nodes in a fragment through fn (copy and paste). */ +function mapDatabases(fragment: Fragment, fn: (node: PMNode) => PMNode): Fragment { + const out: PMNode[] = []; + fragment.forEach((child) => { + if (child.type.name === "database") out.push(fn(child)); + else if (child.content.size) out.push(child.copy(mapDatabases(child.content, fn))); + else out.push(child); + }); + return Fragment.from(out); +} + +function hasDatabase(fragment: Fragment): boolean { + let found = false; + fragment.descendants((n) => { + if (n.type.name === "database") found = true; + return !found; + }); + return found; +} + +export const Database = Node.create({ + name: "database", + group: "block", + atom: true, + draggable: true, + selectable: true, + + addOptions() { + return { + labels: null, + doc: undefined, + readOnlyDoc: false, + undoScope: true, + files: undefined, + people: undefined, + me: undefined, + rowExtensions: undefined, + notify: undefined, + }; + }, + + addAttributes() { + return { + id: { + default: "", + parseHTML: (el) => el.getAttribute("data-id") ?? "", + renderHTML: (a) => ({ "data-id": a.id }), + }, + // The records as JSON, only where there is no live map: read-only + // readers, the clipboard, and documents written by the server. + data: { + default: null, + parseHTML: (el) => { + try { + const raw = el.getAttribute("data-db"); + return raw ? JSON.parse(raw) : null; + } catch { + return null; + } + }, + renderHTML: (a) => (a.data ? { "data-db": JSON.stringify(a.data) } : {}), + }, + }; + }, + + parseHTML() { + return [{ tag: "div[data-type='database']" }]; + }, + + // As HTML (copying to other apps), a database is a table of its records. + renderHTML({ node, HTMLAttributes }) { + const attrs = mergeAttributes(HTMLAttributes, { "data-type": "database" }); + if (!node.attrs.data) return ["div", attrs]; + const db = normalize(node.attrs.data); + const view = db.views[0]; + const cols = db.columns.filter((c) => c.type === "title" || !view?.hidden.includes(c.id)); + return [ + "div", + attrs, + ["p", {}, ["strong", {}, db.title || dbLabels(this.options.labels).untitled]], + [ + "table", + {}, + ["tr", {}, ...cols.map((c) => ["th", {}, c.name])], + ...db.rows.map((r) => ["tr", {}, ...cols.map((c) => ["td", {}, cellText(r, c)])]), + ], + ]; + }, + + renderText({ node }) { + const db = node.attrs.data ? normalize(node.attrs.data) : null; + if (!db) return ""; + const title = titleColumn(db); + return [db.title, ...db.rows.map((r) => cellText(r, title))].filter(Boolean).join("\n"); + }, + + onCreate() { + const { doc, readOnlyDoc, undoScope } = this.options; + if (!doc || readOnlyDoc || !undoScope) return; + // Database edits are undone with the page's own Ctrl+Z. + const um = yUndoPluginKey.getState(this.editor.state)?.undoManager as Y.UndoManager | undefined; + um?.addToScope(blocksOf(doc)); + }, + + addCommands() { + /** A new node's attributes. With a live document the map goes in first, so peers never see a node without data. */ + const attrsFor = (db: DbData) => { + const id = newId(); + const { doc, readOnlyDoc } = this.options; + if (!doc || readOnlyDoc) return { id, data: db }; + seedDb(doc, id, db, (json, f) => writeBody(this.editor, json, f)); + return { id, data: null }; + }; + return { + insertDatabase: + (data) => + ({ commands }) => + commands.insertContent([ + { type: this.name, attrs: attrsFor(data ?? emptyDb(dbDefaults(this.options.labels))) }, + { type: "paragraph" }, + ]), + groupAsDatabase: + () => + ({ state, dispatch, commands }) => { + const found = listAt(state.selection.$from, state.selection.$to); + if (!found) return false; + if (!dispatch) return true; + const l = dbLabels(this.options.labels); + const title: Column = { id: newId(), name: l.typeTitle, type: "title" }; + const columns: Column[] = [title]; + const done: Column | null = found.checks ? { id: newId(), name: l.done, type: "checkbox" } : null; + if (done) columns.push(done); + const now = Date.now(); + const rows: Row[] = found.items.map((it, i) => ({ + id: newId(), + cells: { [title.id]: it.text, ...(done && it.checked ? { [done.id]: true } : {}) }, + createdAt: now + i, + createdBy: this.options.me?.() ?? null, + body: it.rest.length ? it.rest : undefined, + })); + const db: DbData = { title: "", columns, rows, views: [defaultView("table", l.viewTable, columns)] }; + const node = this.type.create(attrsFor(db)); + return commands.command(({ tr }) => { + // The list itself is replaced, whatever sits next to it. + tr.replaceWith(found.from, found.to, node); + tr.setSelection(NodeSelection.create(tr.doc, found.from)); + return true; + }); + }, + }; + }, + + addKeyboardShortcuts() { + return { + "Mod-g": () => this.editor.commands.groupAsDatabase(), + }; + }, + + addProseMirrorPlugins() { + const { doc, readOnlyDoc } = this.options; + const live = doc && !readOnlyDoc ? doc : null; + const editor = this.editor; + return [ + new Plugin({ + key: new PluginKey("databaseClipboard"), + props: { + // A copied database carries its records, so it pastes as its own copy. + transformCopied: (slice) => { + if (!doc || !hasDatabase(slice.content)) return slice; + const content = mapDatabases(slice.content, (n) => { + const m = blocksOf(doc).get(String(n.attrs.id)); + return m instanceof Y.Map ? n.type.create({ ...n.attrs, data: exportDb(m, bodyJSON) }) : n; + }); + return new Slice(content, slice.openStart, slice.openEnd); + }, + transformPasted: (slice) => { + if (!hasDatabase(slice.content)) return slice; + const content = mapDatabases(slice.content, (n) => { + const id = newId(); + if (!live) return n.type.create({ ...n.attrs, id }); + const source = n.attrs.data ? normalize(n.attrs.data) : null; + const m = blocksOf(live).get(String(n.attrs.id)); + const data = source ?? (m instanceof Y.Map ? exportDb(m, bodyJSON) : emptyDb(dbDefaults(this.options.labels))); + seedDb(live, id, freshIds(data), (json, f) => writeBody(editor, json, f)); + return n.type.create({ id, data: null }); + }); + return new Slice(content, slice.openStart, slice.openEnd); + }, + }, + // Two nodes never share one map: a duplicated block gets a copy of the records. + appendTransaction: (trs, _old, state) => { + if (!live || !trs.some((tr) => tr.docChanged && !tr.getMeta(ySyncPluginKey))) return null; + if (!trs.some((tr) => tr.steps.some((s) => hasDatabase((s as unknown as { slice?: Slice }).slice?.content ?? Fragment.empty)))) return null; + const seen = new Set(); + const fix: { pos: number; node: PMNode }[] = []; + state.doc.descendants((n, pos) => { + if (n.type.name !== "database") return; + const id = String(n.attrs.id); + if (id && seen.has(id)) fix.push({ pos, node: n }); + seen.add(id); + return false; + }); + if (!fix.length) return null; + const tr = state.tr; + for (const { pos, node } of fix) { + const m = blocksOf(live).get(String(node.attrs.id)); + const id = newId(); + if (m instanceof Y.Map) seedDb(live, id, freshIds(exportDb(m, bodyJSON)), (json, f) => writeBody(editor, json, f)); + tr.setNodeMarkup(pos, undefined, { ...node.attrs, id, data: null }); + } + return tr; + }, + }), + ]; + }, + + addNodeView() { + const opts = this.options; + return ({ node: initial, editor, getPos }) => { + let node = initial; + const labels = opts.labels ?? englishLabels; + const doc = opts.doc; + const canEdit = () => editor.isEditable && !!doc && !opts.readOnlyDoc; + + let store: DbStore | null = null; + let stop: (() => void) | null = null; + let peek: RowPeek | null = null; + let view: DatabaseView | null = null; + const wrap = h("div", { class: "dw-db-node" }); + + const id = () => String(node.attrs.id); + const mapOf = () => { + const m = doc ? blocksOf(doc).get(id()) : undefined; + return m instanceof Y.Map ? m : null; + }; + const snapshot = (): DbData => { + const m = mapOf(); + if (m) return readDb(m); + return node.attrs.data ? normalize(node.attrs.data) : emptyDb(dbDefaults(opts.labels)); + }; + + const host = () => ({ + labels: labels.database, + colorNames: labels.colors, + locale: labels.locale, + files: opts.files, + people: opts.people, + store, + }); + + const mountBody = (el: HTMLElement, row: Row) => { + const make = opts.rowExtensions; + if (!make) return null; + const m = mapOf(); + let fragment: Y.XmlFragment | null = null; + if (m) { + fragment = store ? store.rowBody(row.id) : findBody(m, row.id); + if (!fragment) { + el.append(h("p", { class: "dw-db-peek__note" }, labels.database.bodyReadOnly)); + return null; + } + } + const editable = !!store; + const ed = new Editor({ + element: el, + editable, + extensions: make(fragment), + content: fragment ? undefined : { type: "doc", content: (row.body as JSONContent[] | undefined) ?? [{ type: "paragraph" }] }, + editorProps: { attributes: { class: "dw-prose dw-db-peek__prose" } }, + }); + if (!fragment && !row.body?.length) el.replaceChildren(h("p", { class: "dw-db-peek__note" }, labels.database.bodyReadOnly)); + return () => ed.destroy(); + }; + + const openRow = (rowId: string, order: string[]) => { + peek?.close(); + peek = new RowPeek({ ctx: { ...host(), }, mountBody }, snapshot(), rowId, order, () => (peek = null)); + }; + + const refresh = () => { + const db = snapshot(); + view?.update(db, { store }); + peek?.update(db, { store }); + }; + + /** Binds to the database's map, making it when an editor finds none. */ + const bind = () => { + stop?.(); + stop = null; + store = null; + if (!doc) return; + let m = mapOf(); + if (!m && canEdit()) { + const data = node.attrs.data ? normalize(node.attrs.data) : emptyDb(dbDefaults(opts.labels)); + const newIdNeeded = !id(); + const key = newIdNeeded ? newId() : id(); + seedDb(doc, key, data, (json, f) => writeBody(editor, json, f)); + // Keep only the id in the document from now on. + queueMicrotask(() => { + const pos = typeof getPos === "function" ? getPos() : undefined; + if (pos !== undefined && editor.state.doc.nodeAt(pos)?.type.name === "database") { + editor.view.dispatch(editor.state.tr.setNodeMarkup(pos, undefined, { ...node.attrs, id: key, data: null }).setMeta("addToHistory", false)); + } + }); + m = blocksOf(doc).get(key) as Y.Map; + } + if (m) { + if (canEdit()) store = new DbStore(doc, m, () => opts.me?.() ?? null); + const watched = m; + const h1 = () => refresh(); + watched.observeDeep(h1); + stop = () => watched.unobserveDeep(h1); + } else { + // A peer's map may still be on its way. + const blocks = blocksOf(doc); + const h2 = (e: Y.YMapEvent>) => { + if (e.keysChanged.has(id())) { + bind(); + refresh(); + } + }; + blocks.observe(h2); + stop = () => blocks.unobserve(h2); + } + }; + bind(); + + view = new DatabaseView( + { + ...host(), + openRow, + undo: () => editor.commands.undo?.(), + redo: () => editor.commands.redo?.(), + notify: opts.notify, + }, + snapshot(), + ); + wrap.append(view.dom); + + let wasEditable = canEdit(); + const onEditable = () => { + if (canEdit() === wasEditable) return; + wasEditable = canEdit(); + bind(); + refresh(); + }; + editor.on("update", onEditable); + editor.on("transaction", onEditable); + + return { + dom: wrap, + update(next) { + if (next.type !== node.type) return false; + const changed = next.attrs.id !== node.attrs.id; + node = next; + if (changed) bind(); + refresh(); + return true; + }, + ignoreMutation: () => true, + // The block handles its own clicks, keys, drags and clipboard, except the drag of the whole block. + stopEvent: (e) => !(e.type === "dragstart" && (e.target as HTMLElement) === wrap), + destroy() { + stop?.(); + peek?.close(); + view?.destroy(); + editor.off("update", onEditable); + editor.off("transaction", onEditable); + }, + }; + }; + }, +}); + +/** Writes ProseMirror nodes into a row body fragment with the editor's schema. */ +function writeBody(editor: Editor, json: unknown[], f: Y.XmlFragment) { + try { + prosemirrorJSONToYXmlFragment(editor.schema, { type: "doc", content: json }, f); + } catch { + /* a body with nodes this editor does not know stays empty */ + } +} + +function findBody(m: Y.Map, rowId: string): Y.XmlFragment | null { + const rows = m.get("rows"); + if (!(rows instanceof Y.Array)) return null; + for (const r of rows.toArray() as Y.Map[]) { + if (r.get("id") === rowId) { + const b = r.get("body"); + return b instanceof Y.XmlFragment && b.length ? b : null; + } + } + return null; +} + +/** A copy of a database with new row ids (column and view ids stay, they are local to it). */ +function freshIds(db: DbData): DbData { + return { ...db, rows: db.rows.map((r) => ({ ...r, id: newId() })) }; +} + +interface ListFound { + from: number; + to: number; + checks: boolean; + items: { text: string; checked: boolean; rest: JSONContent[] }[]; +} + +/** + * The list around the selection (or the top-level blocks it spans) as items: + * each item's first line is its title, the rest its body. + */ +function listAt($from: import("@tiptap/pm/model").ResolvedPos, $to: import("@tiptap/pm/model").ResolvedPos): ListFound | null { + for (let d = $from.depth; d > 0; d--) { + const n = $from.node(d); + if (["bulletList", "orderedList", "taskList"].includes(n.type.name)) { + const items: ListFound["items"] = []; + n.forEach((item) => { + const first = item.firstChild; + const rest: JSONContent[] = []; + item.forEach((c, _o, i) => { + if (i > 0) rest.push(c.toJSON() as JSONContent); + }); + items.push({ text: first?.textContent ?? "", checked: !!item.attrs.checked, rest }); + }); + return { from: $from.before(d), to: $from.after(d), checks: n.type.name === "taskList", items }; + } + } + if ($from.depth < 1) return null; + const from = $from.before(1); + const to = $to.after(Math.min(1, $to.depth) || 1); + const items: ListFound["items"] = []; + $from.doc.nodesBetween(from, to, (n, pos) => { + if (pos < from || pos >= to) return false; + if (n.isTextblock && n.textContent.trim()) items.push({ text: n.textContent, checked: false, rest: [] }); + return !n.isTextblock; + }); + return items.length > 1 ? { from, to, checks: false, items } : null; +} diff --git a/Packages/editor/src/database/labels.ts b/Packages/editor/src/database/labels.ts new file mode 100644 index 0000000..499c62b --- /dev/null +++ b/Packages/editor/src/database/labels.ts @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +import type { ColumnType, FilterOp, ViewType } from "./model"; + +/** The database block's words. "{n}" is filled in by the editor. */ +export const englishDatabaseLabels = { + database: "Database", + untitled: "Untitled database", + untitledRow: "Untitled", + newRow: "New record", + addColumn: "Add property", + columnName: "Property name", + search: "Search records", + filter: "Filter", + sort: "Sort", + group: "Group", + properties: "Properties", + more: "More", + addView: "Add view", + viewName: "View name", + renameView: "Rename view", + duplicateView: "Duplicate view", + deleteView: "Delete view", + layout: "Layout", + viewTable: "Table", + viewKanban: "Kanban", + viewCalendar: "Calendar", + noValue: "No value", + checked: "Checked", + unchecked: "Unchecked", + noRows: "No records", + noMatches: "No records match", + rename: "Rename", + type: "Type", + hide: "Hide in view", + show: "Show in view", + sortAscending: "Sort ascending", + sortDescending: "Sort descending", + filterBy: "Filter by this property", + insertLeft: "Insert left", + insertRight: "Insert right", + moveLeft: "Move left", + moveRight: "Move right", + duplicate: "Duplicate", + deleteColumn: "Delete property", + typeTitle: "Title", + typeText: "Text", + typeNumber: "Number", + typeCheckbox: "Checkbox", + typeSelect: "Select", + typeMultiSelect: "Multi-select", + typeDate: "Date", + typeProgress: "Progress", + typeLink: "Link", + typeAttachment: "Attachment", + typeMember: "Member", + typeCreatedTime: "Created time", + typeCreatedBy: "Created by", + opContains: "contains", + opNotContains: "does not contain", + opIs: "is", + opIsNot: "is not", + opIsEmpty: "is empty", + opIsNotEmpty: "is not empty", + opGt: "is greater than", + opLt: "is less than", + opGte: "is at least", + opLte: "is at most", + opBefore: "is before", + opAfter: "is after", + opChecked: "is checked", + opUnchecked: "is not checked", + addFilter: "Add filter", + matchAll: "Every filter matches", + matchAny: "Any filter matches", + remove: "Remove", + value: "Value", + noFilters: "No filters yet", + addSort: "Add sort", + ascending: "Ascending", + descending: "Descending", + noSorts: "No sorts yet", + groupBy: "Group by", + noGrouping: "No grouping", + showAll: "Show all", + hideAll: "Hide all", + dateColumn: "Date property", + today: "Today", + previousMonth: "Previous month", + nextMonth: "Next month", + noDateColumn: "Add a date property to place records on the calendar.", + noDate: "No date ({n})", + noGroupColumn: "Add a select, checkbox or member property to sort cards into columns.", + openRow: "Open", + deleteRow: "Delete record", + duplicateRow: "Duplicate record", + insertAbove: "Insert above", + insertBelow: "Insert below", + deleteRows: "Delete", + selected: "{n} selected", + selectRow: "Select record", + dragRow: "Drag to move", + close: "Close", + expand: "Full width", + collapse: "Narrow", + previousRow: "Previous record", + nextRow: "Next record", + bodyPlaceholder: "Write about this record…", + bodyReadOnly: "This record has no notes.", + searchOptions: "Find or create a choice", + createOption: "Create “{n}”", + optionColor: "Colour", + deleteOption: "Delete choice", + renameOption: "Rename choice", + searchPeople: "Find a person", + noPeople: "Nobody found", + upload: "Upload a file", + linkPlaceholder: "Paste a link", + clear: "Clear", + exportCsv: "Export as CSV", + importCsv: "Import CSV", + imported: "Added {n} records", + copyNotice: "Copied {n} cells", + readOnly: "Only people who can edit the page can change this database.", + resize: "Drag to change the width", + groupAsDatabase: "Group as database", + done: "Done", +}; + +export type DatabaseLabels = typeof englishDatabaseLabels; + +const typeKeys: Record = { + title: "typeTitle", + text: "typeText", + number: "typeNumber", + checkbox: "typeCheckbox", + select: "typeSelect", + multiSelect: "typeMultiSelect", + date: "typeDate", + progress: "typeProgress", + link: "typeLink", + attachment: "typeAttachment", + member: "typeMember", + createdTime: "typeCreatedTime", + createdBy: "typeCreatedBy", +}; + +export const typeLabel = (l: DatabaseLabels, t: ColumnType) => l[typeKeys[t]]; + +const opKeys: Record = { + contains: "opContains", + notContains: "opNotContains", + is: "opIs", + isNot: "opIsNot", + isEmpty: "opIsEmpty", + isNotEmpty: "opIsNotEmpty", + gt: "opGt", + lt: "opLt", + gte: "opGte", + lte: "opLte", + before: "opBefore", + after: "opAfter", + checked: "opChecked", + unchecked: "opUnchecked", +}; + +export const opLabel = (l: DatabaseLabels, op: FilterOp) => l[opKeys[op]]; + +export const viewLabel = (l: DatabaseLabels, t: ViewType) => + t === "kanban" ? l.viewKanban : t === "calendar" ? l.viewCalendar : l.viewTable; + +export const fill = (s: string, n: number | string) => s.replace("{n}", String(n)); diff --git a/Packages/editor/src/database/model.ts b/Packages/editor/src/database/model.ts new file mode 100644 index 0000000..ce4690b --- /dev/null +++ b/Packages/editor/src/database/model.ts @@ -0,0 +1,594 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// The shape of a database block (ADR-13) and the pure rules over it: how a +// cell reads as text, filtering, sorting, grouping and changing a column's +// type. The live data is a Y.Map (store.ts); views render a plain snapshot. + +import type { JSONContent } from "@tiptap/core"; +import { isPaletteColor, palette, type PaletteColor } from "../colors"; + +export const columnTypes = [ + "title", + "text", + "number", + "checkbox", + "select", + "multiSelect", + "date", + "progress", + "link", + "attachment", + "member", + "createdTime", + "createdBy", +] as const; +export type ColumnType = (typeof columnTypes)[number]; + +/** Types a column can be changed to (the title column stays the title). */ +export const editableTypes = columnTypes.filter((t) => t !== "title"); + +export interface SelectOption { + id: string; + name: string; + color: PaletteColor; +} + +export interface Column { + id: string; + name: string; + type: ColumnType; + /** The choices of a select or multi-select column. */ + options?: SelectOption[]; +} + +export interface Person { + id: string; + name: string; +} + +export interface Attachment { + name: string; + src: string; + size?: number; + mime?: string; +} + +export interface Row { + id: string; + cells: Record; + /** Milliseconds since the epoch. */ + createdAt: number; + createdBy: Person | null; + /** Whether the row was opened as a page and has a body. */ + hasBody?: boolean; + /** The body as ProseMirror nodes, in snapshots read from JSON (see ADR-13). */ + body?: JSONContent[]; +} + +export const viewTypes = ["table", "kanban", "calendar"] as const; +export type ViewType = (typeof viewTypes)[number]; + +export type FilterOp = + | "contains" + | "notContains" + | "is" + | "isNot" + | "isEmpty" + | "isNotEmpty" + | "gt" + | "lt" + | "gte" + | "lte" + | "before" + | "after" + | "checked" + | "unchecked"; + +export interface Filter { + column: string; + op: FilterOp; + value?: unknown; +} + +export interface Sort { + column: string; + desc: boolean; +} + +export interface View { + id: string; + name: string; + type: ViewType; + /** Column ids the view leaves out. */ + hidden: string[]; + filters: Filter[]; + /** Whether a row must match every filter or any. */ + filterMode: "and" | "or"; + sorts: Sort[]; + /** The column rows are grouped by (kanban always groups). */ + groupBy: string | null; + /** The date column a calendar places rows by. */ + dateColumn: string | null; + /** Column widths in pixels, by column id. */ + widths: Record; +} + +export interface DbData { + title: string; + columns: Column[]; + rows: Row[]; + views: View[]; +} + +/** A short random id, unique enough within one document. */ +export function newId(): string { + const bytes = new Uint8Array(6); + crypto.getRandomValues(bytes); + return [...bytes].map((b) => b.toString(36).padStart(2, "0")).join("").slice(0, 10); +} + +export function defaultView(type: ViewType, name: string, columns: Column[]): View { + const groupable = columns.find((c) => groupableTypes.includes(c.type)); + const date = columns.find((c) => c.type === "date" || c.type === "createdTime"); + return { + id: newId(), + name, + type, + hidden: [], + filters: [], + filterMode: "and", + sorts: [], + groupBy: type === "kanban" ? (groupable?.id ?? null) : null, + dateColumn: type === "calendar" ? (date?.id ?? null) : null, + widths: {}, + }; +} + +/** Columns rows can be grouped by, and kanban boards built on. */ +export const groupableTypes: ColumnType[] = ["select", "multiSelect", "checkbox", "member", "createdBy"]; + +/** Reads a database from untrusted JSON (a node's data attribute, a paste), dropping what does not fit. */ +export function normalize(raw: unknown): DbData { + const o = isObject(raw) ? raw : {}; + const columns = (Array.isArray(o.columns) ? o.columns : []).flatMap((c): Column[] => { + if (!isObject(c) || typeof c.id !== "string" || !c.id) return []; + const type = (columnTypes as readonly string[]).includes(String(c.type)) ? (c.type as ColumnType) : "text"; + const col: Column = { id: c.id, name: typeof c.name === "string" ? c.name : "", type }; + if (Array.isArray(c.options)) col.options = c.options.flatMap(option); + return [col]; + }); + if (!columns.some((c) => c.type === "title")) columns.unshift({ id: newId(), name: "", type: "title" }); + const rows = (Array.isArray(o.rows) ? o.rows : []).flatMap((r): Row[] => { + if (!isObject(r) || typeof r.id !== "string" || !r.id) return []; + const row: Row = { + id: r.id, + cells: isObject(r.cells) ? { ...r.cells } : {}, + createdAt: typeof r.createdAt === "number" ? r.createdAt : 0, + createdBy: person(r.createdBy), + }; + if (Array.isArray(r.body) && r.body.length) { + row.body = r.body as JSONContent[]; + row.hasBody = true; + } + return [row]; + }); + const ids = new Set(columns.map((c) => c.id)); + const views = (Array.isArray(o.views) ? o.views : []).flatMap((v): View[] => { + if (!isObject(v) || typeof v.id !== "string" || !v.id) return []; + const type = (viewTypes as readonly string[]).includes(String(v.type)) ? (v.type as ViewType) : "table"; + return [ + { + id: v.id, + name: typeof v.name === "string" ? v.name : "", + type, + hidden: Array.isArray(v.hidden) ? v.hidden.filter((h): h is string => typeof h === "string") : [], + filters: Array.isArray(v.filters) + ? v.filters.filter((f): f is Filter => isObject(f) && typeof f.column === "string" && typeof f.op === "string") + : [], + filterMode: v.filterMode === "or" ? "or" : "and", + sorts: Array.isArray(v.sorts) + ? v.sorts.flatMap((s) => (isObject(s) && typeof s.column === "string" ? [{ column: s.column, desc: !!s.desc }] : [])) + : [], + groupBy: typeof v.groupBy === "string" && ids.has(v.groupBy) ? v.groupBy : null, + dateColumn: typeof v.dateColumn === "string" && ids.has(v.dateColumn) ? v.dateColumn : null, + widths: isObject(v.widths) + ? Object.fromEntries(Object.entries(v.widths).filter((e): e is [string, number] => typeof e[1] === "number")) + : {}, + }, + ]; + }); + return { title: typeof o.title === "string" ? o.title : "", columns, rows, views }; +} + +function option(o: unknown): SelectOption[] { + if (!isObject(o) || typeof o.id !== "string") return []; + return [{ id: o.id, name: typeof o.name === "string" ? o.name : "", color: isPaletteColor(o.color) ? o.color : "gray" }]; +} + +function person(p: unknown): Person | null { + return isObject(p) && typeof p.id === "string" ? { id: p.id, name: typeof p.name === "string" ? p.name : "" } : null; +} + +export function isObject(v: unknown): v is Record { + return typeof v === "object" && v !== null && !Array.isArray(v); +} + +/** The title column (normalize makes sure there is one). */ +export function titleColumn(db: DbData): Column { + return db.columns.find((c) => c.type === "title") ?? db.columns[0]!; +} + +/** The value a row has in a column; created time and creator come from the row itself. */ +export function cellValue(row: Row, col: Column): unknown { + if (col.type === "createdTime") return row.createdAt || null; + if (col.type === "createdBy") return row.createdBy ? [row.createdBy] : []; + return row.cells[col.id]; +} + +export function isEmptyValue(v: unknown): boolean { + return v === undefined || v === null || v === "" || v === false || (Array.isArray(v) && v.length === 0); +} + +/** "YYYY-MM-DD" of a date cell, or "" when it holds none. */ +export function dateOf(v: unknown): string { + if (typeof v === "number" && v > 0) return isoDay(new Date(v)); + if (typeof v === "string" && /^\d{4}-\d{2}-\d{2}/.test(v)) return v.slice(0, 10); + return ""; +} + +export function isoDay(d: Date): string { + const p = (n: number) => String(n).padStart(2, "0"); + return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`; +} + +export function asNumber(v: unknown): number | null { + if (typeof v === "number" && Number.isFinite(v)) return v; + if (typeof v === "string" && v.trim() !== "") { + const n = Number(v.trim().replace(",", ".")); + return Number.isFinite(n) ? n : null; + } + return null; +} + +export function asList(v: unknown): T[] { + return Array.isArray(v) ? (v as T[]) : []; +} + +/** A cell as plain text: for CSV, search, sorting text and copying. */ +export function cellText(row: Row, col: Column): string { + const v = cellValue(row, col); + switch (col.type) { + case "title": + case "text": + case "link": + return typeof v === "string" ? v : ""; + case "number": + case "progress": { + const n = asNumber(v); + return n === null ? "" : String(n); + } + case "checkbox": + return v === true ? "true" : "false"; + case "select": + return col.options?.find((o) => o.id === v)?.name ?? ""; + case "multiSelect": { + const names = asList(v).map((id) => col.options?.find((o) => o.id === id)?.name); + return names.filter((n): n is string => !!n).join(", "); + } + case "date": + case "createdTime": + return dateOf(v); + case "attachment": + return asList(v) + .map((a) => a?.name ?? "") + .join(", "); + case "member": + case "createdBy": + return asList(v) + .map((p) => p?.name ?? "") + .join(", "); + } +} + +/** The filter operators a column type offers, the first being the default. */ +export function filterOps(type: ColumnType): FilterOp[] { + switch (type) { + case "number": + case "progress": + return ["is", "isNot", "gt", "lt", "gte", "lte", "isEmpty", "isNotEmpty"]; + case "checkbox": + return ["checked", "unchecked"]; + case "select": + return ["is", "isNot", "isEmpty", "isNotEmpty"]; + case "multiSelect": + case "member": + case "createdBy": + return ["contains", "notContains", "isEmpty", "isNotEmpty"]; + case "date": + case "createdTime": + return ["is", "before", "after", "isEmpty", "isNotEmpty"]; + case "attachment": + return ["isEmpty", "isNotEmpty"]; + default: + return ["contains", "notContains", "is", "isNot", "isEmpty", "isNotEmpty"]; + } +} + +/** Whether a filter operator compares against a value the user types or picks. */ +export const opTakesValue = (op: FilterOp) => !["isEmpty", "isNotEmpty", "checked", "unchecked"].includes(op); + +export function matchesFilter(row: Row, col: Column, f: Filter): boolean { + const v = cellValue(row, col); + if (f.op === "isEmpty") return isEmptyValue(v) || cellText(row, col) === ""; + if (f.op === "isNotEmpty") return !(isEmptyValue(v) || cellText(row, col) === ""); + if (f.op === "checked") return v === true; + if (f.op === "unchecked") return v !== true; + // A filter without a value yet matches everything, as in a spreadsheet. + if (f.value === undefined || f.value === null || f.value === "") return true; + switch (col.type) { + case "number": + case "progress": { + const n = asNumber(v); + const want = asNumber(f.value); + if (want === null) return true; + if (n === null) return f.op === "isNot"; + return { is: n === want, isNot: n !== want, gt: n > want, lt: n < want, gte: n >= want, lte: n <= want }[ + f.op as "is" + ]; + } + case "select": + return f.op === "is" ? v === f.value : v !== f.value; + case "multiSelect": { + const has = asList(v).includes(String(f.value)); + return f.op === "notContains" ? !has : has; + } + case "member": + case "createdBy": { + const want = String(f.value).toLowerCase(); + const has = asList(v).some((p) => p?.id === f.value || p?.name?.toLowerCase().includes(want)); + return f.op === "notContains" ? !has : has; + } + case "date": + case "createdTime": { + const d = dateOf(v); + const want = dateOf(f.value); + if (!d) return false; + return f.op === "before" ? d < want : f.op === "after" ? d > want : d === want; + } + default: { + const text = cellText(row, col).toLowerCase(); + const want = String(f.value).toLowerCase(); + switch (f.op) { + case "contains": + return text.includes(want); + case "notContains": + return !text.includes(want); + case "is": + return text === want; + case "isNot": + return text !== want; + default: + return true; + } + } + } +} + +/** Compares two rows by one column, empty cells last. */ +export function compareRows(a: Row, b: Row, col: Column): number { + const ea = cellText(a, col) === "" && col.type !== "checkbox"; + const eb = cellText(b, col) === "" && col.type !== "checkbox"; + if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1; + switch (col.type) { + case "number": + case "progress": + return (asNumber(cellValue(a, col)) ?? 0) - (asNumber(cellValue(b, col)) ?? 0); + case "checkbox": + return Number(cellValue(a, col) === true) - Number(cellValue(b, col) === true); + case "createdTime": + return a.createdAt - b.createdAt; + case "select": { + // Choices sort in their own order, like a status column. + const order = (r: Row) => col.options?.findIndex((o) => o.id === cellValue(r, col)) ?? -1; + return order(a) - order(b); + } + default: + return cellText(a, col).localeCompare(cellText(b, col), undefined, { numeric: true, sensitivity: "base" }); + } +} + +/** The rows a view shows, filtered, searched and sorted (stable: ties keep the manual order). */ +export function viewRows(db: DbData, view: View, search = ""): Row[] { + const byId = new Map(db.columns.map((c) => [c.id, c])); + const filters = view.filters.flatMap((f) => { + const col = byId.get(f.column); + return col ? [{ f, col }] : []; + }); + const q = search.trim().toLowerCase(); + let rows = db.rows.filter((r) => { + if (filters.length) { + const test = ({ f, col }: (typeof filters)[number]) => matchesFilter(r, col, f); + if (view.filterMode === "or" ? !filters.some(test) : !filters.every(test)) return false; + } + return !q || db.columns.some((c) => cellText(r, c).toLowerCase().includes(q)); + }); + const sorts = view.sorts.flatMap((s) => { + const col = byId.get(s.column); + return col ? [{ col, desc: s.desc }] : []; + }); + if (sorts.length) { + rows = rows + .map((r, i) => ({ r, i })) + .sort((x, y) => { + for (const s of sorts) { + const c = compareRows(x.r, y.r, s.col); + // Empty cells stay last in both directions. + if (c !== 0) { + const empty = cellText(x.r, s.col) === "" || cellText(y.r, s.col) === ""; + return s.desc && !(empty && s.col.type !== "checkbox") ? -c : c; + } + } + return x.i - y.i; + }) + .map((x) => x.r); + } + return rows; +} + +/** The columns a view shows, in order. The title column always shows. */ +export function visibleColumns(db: DbData, view: View): Column[] { + return db.columns.filter((c) => c.type === "title" || !view.hidden.includes(c.id)); +} + +export interface Group { + /** The value rows in this group have: an option id, "true"/"false", a person id; "" = none. */ + key: string; + label: string; + color?: PaletteColor; + rows: Row[]; +} + +/** Splits rows into groups by a column: one per choice (in order) plus "No value". */ +export function groupRows(rows: Row[], col: Column, noValue: string, yes: string, no: string): Group[] { + const groups = new Map(); + const add = (key: string, label: string, color?: PaletteColor) => { + if (!groups.has(key)) groups.set(key, { key, label, color, rows: [] }); + return groups.get(key)!; + }; + if (col.type === "checkbox") { + add("false", no); + add("true", yes); + } else { + add("", noValue); + for (const o of col.options ?? []) add(o.id, o.name, o.color); + } + for (const r of rows) { + for (const key of groupKeys(r, col)) { + const g = groups.get(key) ?? add(key, personName(r, col, key) || key); + g.rows.push(r); + } + } + return [...groups.values()]; +} + +function personName(r: Row, col: Column, id: string): string { + return asList(cellValue(r, col)).find((p) => p?.id === id)?.name ?? ""; +} + +/** The groups a row belongs to in a column (several for multi-select and members). */ +export function groupKeys(r: Row, col: Column): string[] { + const v = cellValue(r, col); + switch (col.type) { + case "checkbox": + return [v === true ? "true" : "false"]; + case "select": + return [typeof v === "string" && col.options?.some((o) => o.id === v) ? v : ""]; + case "multiSelect": { + const ids = asList(v).filter((id) => col.options?.some((o) => o.id === id)); + return ids.length ? ids : [""]; + } + case "member": + case "createdBy": { + const ids = asList(v).flatMap((p) => (p?.id ? [p.id] : [])); + return ids.length ? ids : [""]; + } + default: + return [""]; + } +} + +/** + * The cell value after moving a row from one group to another (kanban drag): + * select takes the new choice, multi-select swaps the old one for the new. + */ +export function moveToGroup(r: Row, col: Column, from: string, to: string, people: Person[] = []): unknown { + const v = cellValue(r, col); + switch (col.type) { + case "checkbox": + return to === "true"; + case "select": + return to || null; + case "multiSelect": { + const ids = asList(v).filter((id) => id !== from && id !== to); + return to ? [...ids, to] : ids; + } + case "member": { + const list = asList(v).filter((p) => p?.id !== from && p?.id !== to); + const p = people.find((x) => x.id === to) ?? asList(v).find((x) => x?.id === to); + return to && p ? [...list, p] : list; + } + default: + return v; + } +} + +/** The next palette colour for a new choice, so neighbours differ. */ +export function nextColor(options: SelectOption[]): PaletteColor { + const choices = palette.filter((c) => c !== "gray"); + return choices[options.length % choices.length]!; +} + +/** + * A cell's value after its column changed type. Text becomes choices (new + * options are returned to add), numbers parse, choices become their names. + */ +export function convertValue( + v: unknown, + from: Column, + to: ColumnType, + options: SelectOption[], +): { value: unknown; options: SelectOption[] } { + if (from.type === to) return { value: v, options }; + const text = cellText({ id: "", cells: { [from.id]: v }, createdAt: 0, createdBy: null }, from); + const choice = (name: string) => { + const n = name.trim(); + if (!n) return null; + let o = options.find((x) => x.name.toLowerCase() === n.toLowerCase()); + if (!o) { + o = { id: newId(), name: n, color: nextColor(options) }; + options = [...options, o]; + } + return o.id; + }; + switch (to) { + case "title": + case "text": + case "link": + return { value: text || null, options }; + case "number": + return { value: asNumber(text), options }; + case "progress": { + const n = asNumber(text); + return { value: n === null ? null : Math.max(0, Math.min(100, Math.round(n))), options }; + } + case "checkbox": + return { value: ["true", "yes", "1", "x", "✓", "done"].includes(text.trim().toLowerCase()), options }; + case "select": + return { value: choice(text.split(",")[0] ?? ""), options }; + case "multiSelect": { + const ids = text.split(",").flatMap((t) => { + const id = choice(t); + return id ? [id] : []; + }); + return { value: [...new Set(ids)], options }; + } + case "date": + return { value: dateOf(text) || null, options }; + case "member": + return { value: from.type === "member" || from.type === "createdBy" ? v : [], options }; + default: + return { value: null, options }; + } +} + +/** Days of the month grid around a month (Monday first): 5 or 6 weeks of "YYYY-MM-DD". */ +export function monthGrid(year: number, month: number, weekStart = 1): string[] { + const first = new Date(year, month, 1); + const lead = (first.getDay() - weekStart + 7) % 7; + const start = new Date(year, month, 1 - lead); + const days = new Date(year, month + 1, 0).getDate(); + const weeks = Math.ceil((lead + days) / 7); + return Array.from({ length: weeks * 7 }, (_, i) => + isoDay(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i)), + ); +} diff --git a/Packages/editor/src/database/panels.ts b/Packages/editor/src/database/panels.ts new file mode 100644 index 0000000..3b8fddd --- /dev/null +++ b/Packages/editor/src/database/panels.ts @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// The view settings panels: filters, sorts, grouping and which properties show. + +import type { DbContext } from "./cells"; +import { typeIcons } from "./cells"; +import { h, icon } from "./dom"; +import { opLabel, typeLabel } from "./labels"; +import { + filterOps, + groupableTypes, + opTakesValue, + type Column, + type Filter, + type FilterOp, + type View, +} from "./model"; + +function select( + value: T | "", + choices: { value: T | ""; label: string }[], + label: string, + onChange: (v: T) => void, +): HTMLSelectElement { + const s = h("select", { class: "dw-db-select", "aria-label": label }); + for (const c of choices) { + const o = h("option", { value: c.value }, c.label); + if (c.value === value) o.selected = true; + s.append(o); + } + s.addEventListener("change", () => onChange(s.value as T)); + s.addEventListener("keydown", (e) => e.stopPropagation()); + return s; +} + +const columnChoices = (cols: Column[]) => cols.map((c) => ({ value: c.id, label: c.name || "…" })); + +/** The value field of a filter, by the column's type. */ +function filterValue(ctx: DbContext, col: Column, f: Filter, set: (v: unknown) => void): HTMLElement | null { + const l = ctx.labels; + if (!opTakesValue(f.op)) return null; + if (col.type === "select" || col.type === "multiSelect") { + return select( + typeof f.value === "string" ? f.value : "", + [{ value: "", label: "—" }, ...(col.options ?? []).map((o) => ({ value: o.id, label: o.name }))], + l.value, + set, + ); + } + const type = col.type === "date" || col.type === "createdTime" ? "date" : col.type === "number" || col.type === "progress" ? "number" : "text"; + const input = h("input", { class: "dw-db-input dw-db-input--small", type, "aria-label": l.value, placeholder: l.value }); + input.value = f.value === undefined || f.value === null ? "" : String(f.value); + input.addEventListener("keydown", (e) => e.stopPropagation()); + input.addEventListener("change", () => set(type === "number" ? (input.value === "" ? null : Number(input.value)) : input.value)); + return input; +} + +export function filterPanel(ctx: DbContext, box: HTMLElement, view: View) { + const store = ctx.store; + const l = ctx.labels; + const cols = ctx.db.columns; + const filters = structuredClone(view.filters); + const save = () => store?.updateView(view.id, { filters }); + const draw = () => { + box.replaceChildren(); + if (filters.length > 1) { + box.append( + select(view.filterMode, [ + { value: "and", label: l.matchAll }, + { value: "or", label: l.matchAny }, + ], l.filter, (v) => { + view.filterMode = v as "and" | "or"; + store?.updateView(view.id, { filterMode: view.filterMode }); + }), + ); + } + if (!filters.length) box.append(h("p", { class: "dw-db-pop__empty" }, l.noFilters)); + filters.forEach((f, i) => { + const col = cols.find((c) => c.id === f.column); + if (!col) return; + const ops = filterOps(col.type); + const line = h( + "div", + { class: "dw-db-pop__line" }, + select(f.column, columnChoices(cols), l.filter, (id) => { + const c = cols.find((x) => x.id === id)!; + filters[i] = { column: id, op: filterOps(c.type)[0]! }; + save(); + draw(); + }), + select(f.op, ops.map((op) => ({ value: op, label: opLabel(l, op) })), l.filter, (op) => { + filters[i] = { ...f, op }; + if (!opTakesValue(op)) delete filters[i]!.value; + save(); + draw(); + }), + filterValue(ctx, col, f, (v) => { + filters[i] = { ...filters[i]!, value: v }; + save(); + }), + removeButton(l.remove, () => { + filters.splice(i, 1); + save(); + draw(); + }), + ); + box.append(line); + }); + if (store) { + box.append( + addButton(l.addFilter, () => { + const col = cols.find((c) => c.type !== "title") ?? cols[0]!; + filters.push({ column: col.id, op: filterOps(col.type)[0]! }); + save(); + draw(); + }), + ); + } + }; + draw(); +} + +export function sortPanel(ctx: DbContext, box: HTMLElement, view: View) { + const store = ctx.store; + const l = ctx.labels; + const cols = ctx.db.columns; + const sorts = structuredClone(view.sorts); + const save = () => store?.updateView(view.id, { sorts }); + const draw = () => { + box.replaceChildren(); + if (!sorts.length) box.append(h("p", { class: "dw-db-pop__empty" }, l.noSorts)); + sorts.forEach((s, i) => { + box.append( + h( + "div", + { class: "dw-db-pop__line" }, + select(s.column, columnChoices(cols), l.sort, (id) => { + sorts[i] = { ...s, column: id }; + save(); + }), + select(s.desc ? "desc" : "asc", [ + { value: "asc", label: l.ascending }, + { value: "desc", label: l.descending }, + ], l.sort, (v) => { + sorts[i] = { ...s, desc: v === "desc" }; + save(); + }), + removeButton(l.remove, () => { + sorts.splice(i, 1); + save(); + draw(); + }), + ), + ); + }); + if (store) { + box.append( + addButton(l.addSort, () => { + const used = new Set(sorts.map((s) => s.column)); + const col = cols.find((c) => !used.has(c.id)) ?? cols[0]!; + sorts.push({ column: col.id, desc: false }); + save(); + draw(); + }), + ); + } + }; + draw(); +} + +/** Grouping (table and kanban) and, for calendars, the date property. */ +export function groupPanel(ctx: DbContext, box: HTMLElement, view: View) { + const store = ctx.store; + const l = ctx.labels; + const groupable = ctx.db.columns.filter((c) => groupableTypes.includes(c.type)); + const choices = groupable.map((c) => ({ value: c.id, label: c.name || typeLabel(l, c.type) })); + if (view.type !== "kanban") choices.unshift({ value: "", label: l.noGrouping }); + box.append( + h("label", { class: "dw-db-pop__label" }, l.groupBy), + groupable.length || view.type !== "kanban" + ? select(view.groupBy ?? "", choices, l.groupBy, (v) => store?.updateView(view.id, { groupBy: v || null })) + : h("p", { class: "dw-db-pop__empty" }, l.noGroupColumn), + ); +} + +export function datePanel(ctx: DbContext, box: HTMLElement, view: View) { + const store = ctx.store; + const l = ctx.labels; + const dates = ctx.db.columns.filter((c) => c.type === "date" || c.type === "createdTime"); + box.append( + h("label", { class: "dw-db-pop__label" }, l.dateColumn), + dates.length + ? select( + view.dateColumn ?? "", + [{ value: "", label: "—" }, ...dates.map((c) => ({ value: c.id, label: c.name || typeLabel(l, c.type) }))], + l.dateColumn, + (v) => store?.updateView(view.id, { dateColumn: v || null }), + ) + : h("p", { class: "dw-db-pop__empty" }, l.noDateColumn), + ); +} + +/** Which properties the view shows. */ +export function propertiesPanel(ctx: DbContext, box: HTMLElement, view: View) { + const store = ctx.store; + const l = ctx.labels; + let hidden = [...view.hidden]; + const save = () => store?.updateView(view.id, { hidden }); + const draw = () => { + box.replaceChildren(); + const others = ctx.db.columns.filter((c) => c.type !== "title"); + if (store && others.length) { + const all = h("button", { type: "button", class: "dw-db__btn" }, hidden.length ? l.showAll : l.hideAll); + all.addEventListener("click", () => { + hidden = hidden.length ? [] : others.map((c) => c.id); + save(); + draw(); + }); + box.append(h("div", { class: "dw-db-pop__row dw-db-pop__row--end" }, all)); + } + for (const c of ctx.db.columns) { + const shown = c.type === "title" || !hidden.includes(c.id); + const toggle = h( + "button", + { + type: "button", + class: "dw-db-pop__item", + role: "switch", + "aria-checked": String(shown), + disabled: c.type === "title" || !store, + }, + h("span", { class: "dw-db-pop__check" }, icon(typeIcons[c.type], 14)), + h("span", { class: "dw-db-pop__grow" }, c.name || typeLabel(l, c.type)), + h("span", { class: shown ? "dw-db-switch is-on" : "dw-db-switch" }), + ); + toggle.addEventListener("click", () => { + hidden = shown ? [...hidden, c.id] : hidden.filter((x) => x !== c.id); + save(); + draw(); + }); + box.append(toggle); + } + }; + draw(); +} + +function removeButton(label: string, onClick: () => void) { + const b = h("button", { type: "button", class: "dw-db__btn dw-db__btn--icon", "aria-label": label, title: label }, icon("close", 14)); + b.addEventListener("click", onClick); + return b; +} + +function addButton(label: string, onClick: () => void) { + const b = h("button", { type: "button", class: "dw-db__btn dw-db-pop__add" }, icon("plus", 14), h("span", {}, label)); + b.addEventListener("click", onClick); + return b; +} diff --git a/Packages/editor/src/database/peek.ts b/Packages/editor/src/database/peek.ts new file mode 100644 index 0000000..b0d5314 --- /dev/null +++ b/Packages/editor/src/database/peek.ts @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// A row opened as a page: a panel over the page with the row's title and +// properties on top and its own body below, edited by a second editor bound +// to the row's fragment (ADR-13). + +import { openBlockMenu } from "../blockmenu"; +import { editCell, readOnlyTypes, renderCell, typeIcons, type DbContext } from "./cells"; +import { h, icon, iconButton } from "./dom"; +import { typeLabel } from "./labels"; +import { cellValue, editableTypes, titleColumn, type DbData, type Row } from "./model"; + +export interface PeekHost { + ctx: Omit; + /** Draws the row's body into el; returns a cleanup. */ + mountBody: (el: HTMLElement, row: Row) => (() => void) | null; +} + +export class RowPeek { + private dom: HTMLDivElement; + private panel: HTMLDivElement; + private head = h("div", { class: "dw-db-peek__head" }); + private props = h("div", { class: "dw-db-peek__props" }); + private bodyEl = h("div", { class: "dw-db-peek__body" }); + private unmount: (() => void) | null = null; + private editing = 0; + private pending = false; + private wide = false; + private returnFocus: Element | null; + + constructor( + private host: PeekHost, + private db: DbData, + private rowId: string, + private order: string[], + private onClose: () => void, + ) { + this.returnFocus = document.activeElement; + this.panel = h("div", { class: "dw-db-peek__panel", role: "dialog", "aria-modal": "true", tabIndex: -1 }, this.head, this.props, this.bodyEl); + this.dom = h("div", { class: "dw-db-peek" }, this.panel); + this.dom.addEventListener("mousedown", (e) => { + if (e.target === this.dom) this.close(); + }); + this.dom.addEventListener("keydown", (e) => { + if (e.key === "Escape" && !document.querySelector(".dw-db-pop, .dw-block-menu")) { + e.preventDefault(); + e.stopPropagation(); + this.close(); + } + }); + document.body.append(this.dom); + this.draw(true); + this.panel.focus({ preventScroll: true }); + } + + get row(): string { + return this.rowId; + } + + private ctx(): DbContext { + return { + ...this.host.ctx, + db: this.db, + openRow: (id) => this.show(id), + setEditing: (on) => { + this.editing = Math.max(0, this.editing + (on ? 1 : -1)); + if (!this.editing && this.pending) { + this.pending = false; + this.draw(false); + } + }, + }; + } + + update(db: DbData, host?: Partial) { + this.db = db; + if (host) this.host = { ...this.host, ctx: { ...this.host.ctx, ...host } }; + if (!db.rows.some((r) => r.id === this.rowId)) return this.close(); + if (this.editing) { + this.pending = true; + return; + } + this.draw(false); + } + + private show(id: string) { + if (id === this.rowId) return; + this.rowId = id; + this.draw(true); + } + + private draw(withBody: boolean) { + const row = this.db.rows.find((r) => r.id === this.rowId); + if (!row) return; + const ctx = this.ctx(); + const l = ctx.labels; + const store = ctx.store; + this.panel.classList.toggle("is-wide", this.wide); + const i = this.order.indexOf(this.rowId); + const prev = iconButton("chevron-up", l.previousRow, () => this.show(this.order[i - 1]!)); + const next = iconButton("chevron-down", l.nextRow, () => this.show(this.order[i + 1]!)); + prev.disabled = i <= 0; + next.disabled = i < 0 || i >= this.order.length - 1; + this.head.replaceChildren( + h("span", { class: "dw-db-peek__db" }, icon("database", 14), this.db.title || l.untitled), + h("span", { class: "dw-db-peek__grow" }), + prev, + next, + iconButton(this.wide ? "width" : "width", this.wide ? l.collapse : l.expand, () => { + this.wide = !this.wide; + this.panel.classList.toggle("is-wide", this.wide); + }), + iconButton("close", l.close, () => this.close()), + ); + + const title = titleColumn(this.db); + const titleText = String(cellValue(row, title) ?? ""); + const titleEl = store + ? (() => { + const input = h("input", { class: "dw-db-peek__title", placeholder: l.untitledRow, "aria-label": title.name || l.typeTitle }); + input.value = titleText; + input.addEventListener("focus", () => ctx.setEditing(true)); + input.addEventListener("blur", () => { + if (input.value !== titleText) store.setCell(row.id, title.id, input.value); + ctx.setEditing(false); + }); + input.addEventListener("keydown", (e) => { + e.stopPropagation(); + if (e.key === "Enter") input.blur(); + }); + return input; + })() + : h("h2", { class: "dw-db-peek__title" }, titleText || l.untitledRow); + this.panel.setAttribute("aria-label", titleText || l.untitledRow); + + const lines = this.db.columns + .filter((c) => c.type !== "title") + .map((c) => { + const value = h("div", { class: `dw-db-peek__value dw-db-t__cell--${c.type}`, tabIndex: store && !readOnlyTypes.includes(c.type) ? 0 : -1 }, renderCell(ctx, row, c)); + const edit = () => { + if (!store) return; + editCell(ctx, value, row, c, { onDone: () => this.draw(false) }); + }; + value.addEventListener("click", (e) => { + if ((e.target as HTMLElement).closest("a, button")) return; + edit(); + }); + value.addEventListener("keydown", (e) => { + if (e.target === value && (e.key === "Enter" || e.key === " ")) { + e.preventDefault(); + edit(); + } + }); + return h( + "div", + { class: "dw-db-peek__prop" }, + h("div", { class: "dw-db-peek__label" }, icon(typeIcons[c.type], 14), h("span", {}, c.name || typeLabel(l, c.type))), + value, + ); + }); + const children: Node[] = [titleEl, ...lines]; + if (store) { + const add = iconButton("plus", l.addColumn, () => + openBlockMenu( + add, + editableTypes.map((t) => ({ id: t, label: typeLabel(l, t), icon: typeIcons[t], run: () => store.addColumn(t, typeLabel(l, t)) })), + l.addColumn, + ), + l.addColumn); + add.classList.add("dw-db-peek__add"); + children.push(add); + } + const hadFocus = this.props.contains(document.activeElement); + this.props.replaceChildren(...children); + if (hadFocus) this.panel.focus({ preventScroll: true }); + + if (withBody) { + this.unmount?.(); + this.bodyEl.replaceChildren(); + this.unmount = this.host.mountBody(this.bodyEl, row); + } + } + + close() { + this.unmount?.(); + this.unmount = null; + this.dom.remove(); + this.onClose(); + if (this.returnFocus instanceof HTMLElement && this.returnFocus.isConnected) this.returnFocus.focus({ preventScroll: true }); + } +} diff --git a/Packages/editor/src/database/store.ts b/Packages/editor/src/database/store.ts new file mode 100644 index 0000000..0c29bb3 --- /dev/null +++ b/Packages/editor/src/database/store.ts @@ -0,0 +1,480 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// A database's live data in the page's Y.Doc (ADR-13): +// ydoc.getMap("blocks").get(id) → Y.Map { title, columns, rows, views }. +// Every edit runs in one transaction with DB_ORIGIN, which the page's undo +// manager tracks, so Ctrl+Z undoes it like typing. + +import * as Y from "yjs"; +import { + convertValue, + defaultView, + isObject, + newId, + normalize, + type Column, + type ColumnType, + type DbData, + type Person, + type Row, + type SelectOption, + type View, + type ViewType, +} from "./model"; + +/** The transaction origin of database edits; the Collaboration undo manager tracks it. */ +export const DB_ORIGIN = "docwell-database"; + +export const blocksOf = (doc: Y.Doc) => doc.getMap>("blocks"); + +type Key = "columns" | "rows" | "views"; +type YItem = Y.Map; + +/** Writes a database (from JSON) as a new Y.Map, to put into the blocks map. */ +export function dbToY(data: DbData): YItem { + const m = new Y.Map(); + m.set("title", data.title); + const list = (items: T[], toY: (x: T) => YItem) => { + const a = new Y.Array(); + a.push(items.map((x, i) => withPos(toY(x), i))); + return a; + }; + m.set("columns", list(data.columns, columnToY)); + m.set("rows", list(data.rows, rowToY)); + m.set("views", list(data.views, viewToY)); + return m; +} + +function withPos(m: YItem, pos: number): YItem { + m.set("pos", pos); + return m; +} + +function columnToY(c: Column): YItem { + const m = new Y.Map(); + m.set("id", c.id); + m.set("name", c.name); + m.set("type", c.type); + if (c.options) m.set("options", c.options); + return m; +} + +function rowToY(r: Row): YItem { + const m = new Y.Map(); + m.set("id", r.id); + m.set("createdAt", r.createdAt); + if (r.createdBy) m.set("createdBy", r.createdBy); + const cells = new Y.Map(); + for (const [k, v] of Object.entries(r.cells)) if (v !== undefined && v !== null) cells.set(k, v); + m.set("cells", cells); + return m; +} + +function viewToY(v: View): YItem { + const m = new Y.Map(); + for (const [k, val] of Object.entries(v)) m.set(k, val); + return m; +} + +/** + * Items of a list in display order. Order is a fractional "pos" on each + * item, not the array order, so moving one only changes its pos: concurrent + * edits to the moved item survive, and a row's open body stays bound. + */ +export function ordered(a: Y.Array): YItem[] { + return a + .toArray() + .filter((m): m is YItem => m instanceof Y.Map) + .map((m, i) => ({ m, p: posOf(m, i), i })) + .sort((x, y) => x.p - y.p || x.i - y.i) + .map((x) => x.m); +} + +function posOf(m: YItem | undefined, fallback: number): number { + const p = m?.get("pos"); + return typeof p === "number" ? p : fallback; +} + +/** A pos that sorts at index at of list (display order), between its neighbours. */ +function posAt(list: YItem[], at: number, skip?: YItem): number { + const rest = skip ? list.filter((m) => m !== skip) : list; + const i = Math.max(0, Math.min(at, rest.length)); + const before = i > 0 ? posOf(rest[i - 1], i - 1) : null; + const after = i < rest.length ? posOf(rest[i], i) : null; + if (before === null && after === null) return 0; + if (before === null) return after! - 1; + if (after === null) return before + 1; + return (before + after) / 2; +} + +/** A plain snapshot of the Y.Map, for rendering. */ +export function readDb(m: YItem): DbData { + const arr = (key: Key) => { + const a = m.get(key); + return a instanceof Y.Array ? ordered(a as Y.Array) : []; + }; + const plain = (x: YItem) => { + const o = x.toJSON() as Record; + delete o.pos; + return o; + }; + const bodies = new Set(); + const rows = arr("rows").map((r) => { + const cells = r.get("cells"); + const body = r.get("body"); + const id = r.get("id"); + if (typeof id === "string" && body instanceof Y.XmlFragment && body.length > 0) bodies.add(id); + return { + id, + createdAt: r.get("createdAt"), + createdBy: r.get("createdBy"), + cells: cells instanceof Y.Map ? cells.toJSON() : {}, + }; + }); + const db = normalize({ + title: m.get("title"), + columns: arr("columns").map(plain), + rows, + views: arr("views").map(plain), + }); + for (const r of db.rows) if (bodies.has(r.id)) r.hasBody = true; + return db; +} + +export interface DbLabels { + tableView: string; + /** The default names of new columns, by type. */ + columnName: (type: ColumnType) => string; +} + +/** A new, empty database: a title column, a status column, three rows and one table view. */ +export function emptyDb(labels: DbLabels, title = ""): DbData { + const name: Column = { id: newId(), name: labels.columnName("title"), type: "title" }; + const status: Column = { id: newId(), name: labels.columnName("select"), type: "select", options: [] }; + const columns = [name, status]; + const now = Date.now(); + return { + title, + columns, + rows: [0, 1, 2].map((i) => ({ id: newId(), cells: {}, createdAt: now + i, createdBy: null })), + views: [defaultView("table", labels.tableView, columns)], + }; +} + +const isEmpty = (v: unknown) => v === undefined || v === null || v === "" || (Array.isArray(v) && !v.length); + +/** Edits one database. Methods are no-ops for ids that no longer exist (a peer deleted them). */ +export class DbStore { + constructor( + readonly doc: Y.Doc, + readonly map: YItem, + private readonly me: () => Person | null, + ) {} + + snapshot(): DbData { + return readDb(this.map); + } + + /** Calls fn after every change, local or remote; returns the unsubscribe. */ + observe(fn: () => void): () => void { + const h = () => fn(); + this.map.observeDeep(h); + return () => this.map.unobserveDeep(h); + } + + /** Runs fn as one undo step. */ + tx(fn: () => void) { + this.doc.transact(fn, DB_ORIGIN); + } + + private list(key: Key): Y.Array { + let a = this.map.get(key); + if (!(a instanceof Y.Array)) { + a = new Y.Array(); + this.map.set(key, a); + } + return a as Y.Array; + } + + /** The item with id and its index in display order. */ + private find(key: Key, id: string): { item: YItem; index: number } | null { + const list = ordered(this.list(key)); + const index = list.findIndex((m) => m.get("id") === id); + return index < 0 ? null : { item: list[index]!, index }; + } + + /** Inserts items at index at of the display order (the end by default). */ + private insertAt(key: Key, at: number | undefined, items: YItem[]) { + const a = this.list(key); + const list = ordered(a); + let i = Math.max(0, Math.min(at ?? list.length, list.length)); + for (const item of items) { + item.set("pos", posAt(list, i)); + list.splice(i++, 0, item); + } + a.push(items); + } + + private moveTo(key: Key, id: string, to: number) { + const found = this.find(key, id); + if (!found || found.index === to) return; + found.item.set("pos", posAt(ordered(this.list(key)), to, found.item)); + } + + private remove(key: Key, item: YItem) { + const a = this.list(key); + const i = a.toArray().indexOf(item); + if (i >= 0) a.delete(i, 1); + } + + setTitle(title: string) { + this.tx(() => this.map.set("title", title)); + } + + // ---- columns ---- + + addColumn(type: ColumnType, name: string, at?: number): string { + const col: Column = { id: newId(), name, type }; + if (type === "select" || type === "multiSelect") col.options = []; + this.tx(() => this.insertAt("columns", at, [columnToY(col)])); + return col.id; + } + + renameColumn(id: string, name: string) { + this.tx(() => this.find("columns", id)?.item.set("name", name)); + } + + setOptions(id: string, options: SelectOption[]) { + this.tx(() => this.find("columns", id)?.item.set("options", options)); + } + + /** Changes a column's type and converts every row's value. */ + changeType(id: string, type: ColumnType) { + const db = this.snapshot(); + const col = db.columns.find((c) => c.id === id); + if (!col || col.type === type || col.type === "title" || type === "title") return; + let options = type === "select" || type === "multiSelect" ? (col.options ?? []) : []; + const values = new Map(); + for (const r of db.rows) { + const out = convertValue(r.cells[id], col, type, options); + options = out.options; + values.set(r.id, out.value); + } + this.tx(() => { + const found = this.find("columns", id); + if (!found) return; + found.item.set("type", type); + if (type === "select" || type === "multiSelect") found.item.set("options", options); + else found.item.delete("options"); + for (const yr of this.list("rows").toArray()) { + const cells = yr.get("cells"); + if (!(cells instanceof Y.Map)) continue; + const v = values.get(String(yr.get("id"))); + if (isEmpty(v) || v === false) cells.delete(id); + else cells.set(id, v); + } + }); + } + + deleteColumn(id: string) { + this.tx(() => { + const found = this.find("columns", id); + if (!found || found.item.get("type") === "title") return; + this.remove("columns", found.item); + for (const yr of this.list("rows").toArray()) { + const cells = yr.get("cells"); + if (cells instanceof Y.Map) cells.delete(id); + } + }); + } + + moveColumn(id: string, to: number) { + this.tx(() => this.moveTo("columns", id, to)); + } + + duplicateColumn(id: string, name: string): string | null { + const col = this.snapshot().columns.find((c) => c.id === id); + if (!col || col.type === "title") return null; + const copy: Column = { ...structuredClone(col), id: newId(), name }; + this.tx(() => { + const found = this.find("columns", id); + if (!found) return; + this.insertAt("columns", found.index + 1, [columnToY(copy)]); + for (const yr of this.list("rows").toArray()) { + const cells = yr.get("cells"); + if (cells instanceof Y.Map && cells.has(id)) cells.set(copy.id, cells.get(id)); + } + }); + return copy.id; + } + + // ---- rows ---- + + /** Adds a row with these cells at index at (the end by default); returns its id. */ + addRow(cells: Record = {}, at?: number): string { + return this.addRows([cells], at)[0]!; + } + + /** Adds many rows in one undo step (paste, CSV import). */ + addRows(list: Record[], at?: number): string[] { + const me = this.me(); + const now = Date.now(); + const rows: Row[] = list.map((cells, i) => ({ id: newId(), cells, createdAt: now + i, createdBy: me })); + this.tx(() => this.insertAt("rows", at, rows.map(rowToY))); + return rows.map((r) => r.id); + } + + setCell(row: string, col: string, value: unknown) { + this.setCells([{ row, col, value }]); + } + + /** Sets several cells in one undo step. Empty values are removed. */ + setCells(changes: { row: string; col: string; value: unknown }[]) { + this.tx(() => { + for (const { row, col, value } of changes) { + const cells = this.find("rows", row)?.item.get("cells"); + if (!(cells instanceof Y.Map)) continue; + if (isEmpty(value)) cells.delete(col); + else cells.set(col, value); + } + }); + } + + deleteRows(ids: string[]) { + this.tx(() => { + const a = this.list("rows"); + for (let i = a.length - 1; i >= 0; i--) { + if (ids.includes(String(a.get(i)?.get("id")))) a.delete(i, 1); + } + }); + } + + /** Moves a row to index to of the full, unfiltered order. */ + moveRow(id: string, to: number) { + this.tx(() => this.moveTo("rows", id, to)); + } + + duplicateRow(id: string): string | null { + const found = this.find("rows", id); + if (!found) return null; + const copy = cloneRow(found.item, this.me()); + this.tx(() => this.insertAt("rows", found.index + 1, [copy])); + return String(copy.get("id")); + } + + /** The row's body fragment, made on first use (opening a row as a page). */ + rowBody(id: string): Y.XmlFragment | null { + const found = this.find("rows", id); + if (!found) return null; + const body = found.item.get("body"); + if (body instanceof Y.XmlFragment) return body; + const fresh = new Y.XmlFragment(); + this.tx(() => found.item.set("body", fresh)); + return fresh; + } + + /** The row's index in the full order, or -1. */ + rowIndex(id: string): number { + return this.find("rows", id)?.index ?? -1; + } + + // ---- views ---- + + addView(type: ViewType, name: string): string { + const view = defaultView(type, name, this.snapshot().columns); + this.tx(() => this.insertAt("views", undefined, [viewToY(view)])); + return view.id; + } + + updateView(id: string, patch: Partial>) { + this.tx(() => { + const found = this.find("views", id); + if (!found) return; + for (const [k, v] of Object.entries(patch)) found.item.set(k, v); + }); + } + + duplicateView(id: string, name: string): string | null { + const view = this.snapshot().views.find((v) => v.id === id); + if (!view) return null; + const copy: View = { ...structuredClone(view), id: newId(), name }; + this.tx(() => { + const found = this.find("views", id); + this.insertAt("views", (found?.index ?? -1) + 1, [viewToY(copy)]); + }); + return copy.id; + } + + deleteView(id: string) { + this.tx(() => { + const found = this.find("views", id); + if (found && this.list("views").length > 1) this.remove("views", found.item); + }); + } + + moveView(id: string, to: number) { + this.tx(() => this.moveTo("views", id, to)); + } +} + +/** Copies a row map with a new id, its cells and its body. */ +function cloneRow(m: YItem, me: Person | null): YItem { + const out = new Y.Map(); + out.set("id", newId()); + out.set("createdAt", Date.now()); + const by = me ?? m.get("createdBy"); + if (isObject(by)) out.set("createdBy", by); + const cells = new Y.Map(); + const old = m.get("cells"); + if (old instanceof Y.Map) for (const [k, v] of old.entries()) cells.set(k, v); + out.set("cells", cells); + const body = m.get("body"); + if (body instanceof Y.XmlFragment && body.length) { + const copy = new Y.XmlFragment(); + copy.insert( + 0, + body.toArray().map((n) => n.clone() as Y.XmlElement | Y.XmlText), + ); + out.set("body", copy); + } + return out; +} + +/** The database's JSON with row bodies, for copying (ADR-13: a pasted copy seeds its own map). */ +export function exportDb(m: YItem, bodyJSON: (f: Y.XmlFragment) => unknown[]): DbData { + const db = readDb(m); + const rows = m.get("rows"); + if (rows instanceof Y.Array) { + const bodies = new Map(); + for (const r of rows.toArray() as YItem[]) { + const b = r.get("body"); + if (b instanceof Y.XmlFragment && b.length) bodies.set(String(r.get("id")), b); + } + for (const r of db.rows) { + const b = bodies.get(r.id); + if (b) r.body = bodyJSON(b) as Row["body"]; + } + } + return db; +} + +/** + * Writes a database with row bodies (from exportDb or the server's JSON) + * into the blocks map under id. Bodies are written once the map is part of + * the document, which y-prosemirror needs. + */ +export function seedDb(doc: Y.Doc, id: string, data: DbData, writeBody: (json: unknown[], f: Y.XmlFragment) => void) { + doc.transact(() => { + const m = dbToY(data); + blocksOf(doc).set(id, m); + const rows = m.get("rows") as Y.Array; + const byId = new Map(data.rows.map((r) => [r.id, r])); + for (const yr of rows.toArray()) { + const body = byId.get(String(yr.get("id")))?.body; + if (!body?.length) continue; + const f = new Y.XmlFragment(); + yr.set("body", f); + writeBody(body, f); + } + }, DB_ORIGIN); +} diff --git a/Packages/editor/src/database/view.ts b/Packages/editor/src/database/view.ts new file mode 100644 index 0000000..766fd02 --- /dev/null +++ b/Packages/editor/src/database/view.ts @@ -0,0 +1,1241 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// Draws a database block: its title, view tabs, toolbar and the active view +// (table, kanban or calendar). The header stays put between redraws, so +// panels opened from the toolbar keep their anchor while the rows change. + +import { openBlockMenu, type BlockAction } from "../blockmenu"; +import { editCell, inlineTypes, readOnlyTypes, renderCell, typeIcons, type DbContext } from "./cells"; +import { formatDelimited, fromCSV, matchHeader, parseCell, parseDelimited, toCSV } from "./csv"; +import { closePopover, download, h, icon, iconButton, pickFile, popover, textInput } from "./dom"; +import { fill, typeLabel, viewLabel, type DatabaseLabels } from "./labels"; +import * as p from "./panels"; +import { + cellText, + cellValue, + dateOf, + editableTypes, + filterOps, + groupRows, + isoDay, + monthGrid, + moveToGroup, + titleColumn, + viewRows, + viewTypes, + visibleColumns, + type Column, + type DbData, + type Group, + type Row, + type View, + type ViewType, +} from "./model"; + +export interface ViewHost extends Omit { + /** Opens a row as a page (peek.ts). */ + openRow: (id: string, rows: string[]) => void; + undo: () => void; + redo: () => void; + /** Shows a short message (copied, imported). */ + notify?: (text: string) => void; +} + +const PAGE = 200; + +/** The block's DOM and state; call update() with a new snapshot after every change. */ +export class DatabaseView { + readonly dom = h("div", { class: "dw-db", dataset: { type: "database" }, contentEditable: "false" }); + private db: DbData; + private viewId: string | null = null; + private search = ""; + private editing = 0; + private pending = false; + private limit = PAGE; + private collapsed = new Set(); + /** The selected cell (row id, column id) and the corner of a range, in the table. */ + private sel: { row: string; col: string } | null = null; + private anchor: { row: string; col: string } | null = null; + private picked = new Set(); + private month: { y: number; m: number }; + + private titleEl = h("div", { class: "dw-db__title" }); + private tabs = h("div", { class: "dw-db__tabs", role: "tablist" }); + private tools = h("div", { class: "dw-db__tools" }); + private body = h("div", { class: "dw-db__body" }); + private bulk = h("div", { class: "dw-db__bulk" }); + private searchInput: HTMLInputElement; + private buttons: Record<"filter" | "sort" | "group" | "props" | "more" | "add" | "search", HTMLButtonElement>; + + constructor( + private host: ViewHost, + db: DbData, + ) { + this.db = db; + const now = new Date(); + this.month = { y: now.getFullYear(), m: now.getMonth() }; + const l = host.labels; + this.searchInput = h("input", { class: "dw-db-input dw-db__search", placeholder: l.search, "aria-label": l.search, hidden: true }); + this.searchInput.addEventListener("input", () => { + this.search = this.searchInput.value; + this.limit = PAGE; + this.drawBody(); + }); + this.searchInput.addEventListener("keydown", (e) => { + e.stopPropagation(); + if (e.key === "Escape") { + this.searchInput.value = ""; + this.search = ""; + this.searchInput.hidden = true; + this.drawBody(); + } + }); + this.buttons = { + search: iconButton("search", l.search, () => { + this.searchInput.hidden = !this.searchInput.hidden; + if (!this.searchInput.hidden) this.searchInput.focus(); + }), + filter: iconButton("filter", l.filter, (e) => this.panel(e, "filter"), l.filter), + sort: iconButton("sort", l.sort, (e) => this.panel(e, "sort"), l.sort), + group: iconButton("layers", l.group, (e) => this.panel(e, "group"), l.group), + props: iconButton("sliders", l.properties, (e) => this.panel(e, "props")), + more: iconButton("more", l.more, () => this.moreMenu()), + add: iconButton("plus", l.newRow, () => this.addRow(), l.newRow), + }; + this.buttons.add.classList.add("dw-db__btn--primary"); + const head = h("div", { class: "dw-db__head" }, this.titleEl); + const bar = h("div", { class: "dw-db__bar" }, this.tabs, this.tools); + this.tools.append( + this.searchInput, + this.buttons.search, + this.buttons.filter, + this.buttons.sort, + this.buttons.group, + this.buttons.props, + this.buttons.more, + this.buttons.add, + ); + this.dom.append(head, bar, this.bulk, this.body); + this.draw(); + } + + private get labels(): DatabaseLabels { + return this.host.labels; + } + + private get editable() { + return !!this.host.store; + } + + private get view(): View { + return this.db.views.find((v) => v.id === this.viewId) ?? this.db.views[0] ?? fallbackView; + } + + private ctx(): DbContext { + return { + ...this.host, + db: this.db, + openRow: (id) => this.openRow(id), + setEditing: (on) => { + this.editing = Math.max(0, this.editing + (on ? 1 : -1)); + if (!this.editing && this.pending) { + this.pending = false; + this.draw(); + } + }, + }; + } + + /** A new snapshot (a local or remote change) or new rights. */ + update(db: DbData, host?: Partial) { + this.db = db; + if (host) this.host = { ...this.host, ...host }; + if (this.editing) { + this.pending = true; + return; + } + this.draw(); + } + + destroy() { + closePopover(); + } + + private draw() { + this.drawTitle(); + this.drawTabs(); + this.drawTools(); + this.drawBody(); + } + + private drawTitle() { + const l = this.labels; + const title = this.db.title; + if (this.titleEl.querySelector("input") === document.activeElement) return; + if (!this.editable) { + this.titleEl.replaceChildren(h("span", { class: title ? "" : "is-empty" }, title || l.untitled)); + return; + } + const input = h("input", { class: "dw-db__title-input", placeholder: l.untitled, "aria-label": l.untitled }); + input.value = title; + input.addEventListener("keydown", (e) => { + e.stopPropagation(); + if (e.key === "Enter" || e.key === "Escape") input.blur(); + }); + input.addEventListener("change", () => this.host.store?.setTitle(input.value)); + this.titleEl.replaceChildren(input); + } + + private drawTabs() { + const l = this.labels; + const active = this.view; + this.tabs.replaceChildren( + ...this.db.views.map((v) => { + const tab = h( + "button", + { + type: "button", + class: v.id === active.id ? "dw-db__tab is-active" : "dw-db__tab", + role: "tab", + "aria-selected": String(v.id === active.id), + }, + icon(v.type === "kanban" ? "cards" : v.type === "calendar" ? "calendar" : "table", 14), + h("span", {}, v.name || viewLabel(l, v.type)), + ); + tab.addEventListener("click", () => { + if (v.id === active.id && this.editable) return this.viewMenu(tab, v); + this.viewId = v.id; + this.sel = null; + this.limit = PAGE; + this.draw(); + }); + tab.addEventListener("contextmenu", (e) => { + if (!this.editable) return; + e.preventDefault(); + this.viewMenu(tab, v); + }); + return tab; + }), + ); + if (this.editable) { + const add = iconButton("plus", l.addView, () => + openBlockMenu( + add, + viewTypes.map((t) => ({ + id: t, + label: viewLabel(l, t), + icon: t === "kanban" ? "cards" : t === "calendar" ? "calendar" : "table", + run: () => { + this.showView(this.host.store!.addView(t, viewLabel(l, t))); + }, + })), + l.addView, + ), + ); + this.tabs.append(add); + } + } + + private drawTools() { + const v = this.view; + const b = this.buttons; + const count = (btn: HTMLButtonElement, n: number) => { + btn.classList.toggle("is-on", n > 0); + const span = btn.querySelector("span"); + if (span) span.textContent = n ? `${btn.title} ${n}` : btn.title; + }; + count(b.filter, v.filters.length); + count(b.sort, v.sorts.length); + b.sort.hidden = v.type === "calendar"; + b.group.classList.toggle("is-on", !!v.groupBy && v.type === "table"); + b.group.hidden = v.type === "calendar"; + b.add.hidden = !this.editable; + this.drawBulk(); + } + + private drawBulk() { + const ids = [...this.picked].filter((id) => this.db.rows.some((r) => r.id === id)); + this.picked = new Set(ids); + this.bulk.hidden = !ids.length || !this.editable; + if (this.bulk.hidden) return this.bulk.replaceChildren(); + const l = this.labels; + this.bulk.replaceChildren( + h("span", {}, fill(l.selected, ids.length)), + iconButton("trash", l.deleteRows, () => { + this.host.store?.deleteRows(ids); + this.picked.clear(); + }, l.deleteRows), + iconButton("close", l.close, () => { + this.picked.clear(); + this.draw(); + }), + ); + } + + private panel(e: MouseEvent, kind: "filter" | "sort" | "group" | "props") { + const anchor = e.currentTarget as HTMLElement; + { + popover( + anchor, + (box) => { + const ctx = this.ctx(); + // Panels read the current view each time they redraw themselves. + const view = this.view; + if (kind === "filter") p.filterPanel(ctx, box, view); + else if (kind === "sort") p.sortPanel(ctx, box, view); + else if (kind === "group") p.groupPanel(ctx, box, view); + else { + if (view.type === "calendar") p.datePanel(ctx, box, view); + if (view.type === "kanban") p.groupPanel(ctx, box, view); + p.propertiesPanel(ctx, box, view); + } + }, + { class: "dw-db-pop--panel", label: anchor.title, placement: "bottom-end" }, + ); + } + } + + private viewMenu(anchor: HTMLElement, v: View) { + const l = this.labels; + const store = this.host.store!; + const actions: BlockAction[] = [ + { + id: "rename", + label: l.renameView, + icon: "pencil", + run: () => { + const name = window.prompt(l.viewName, v.name)?.trim(); + if (name) store.updateView(v.id, { name }); + }, + }, + { + id: "layout", + label: l.layout, + icon: "grid", + children: viewTypes.map((t: ViewType) => ({ + id: t, + label: viewLabel(l, t), + icon: t === v.type ? "check" : t === "kanban" ? "cards" : t === "calendar" ? "calendar" : "table", + run: () => this.setLayout(v, t), + })), + }, + { + id: "duplicate", + label: l.duplicateView, + icon: "copy", + run: () => { + this.showView(store.duplicateView(v.id, `${v.name || viewLabel(l, v.type)} 2`)); + }, + }, + ]; + if (this.db.views.length > 1) { + actions.push({ id: "delete", label: l.deleteView, icon: "trash", danger: true, run: () => store.deleteView(v.id) }); + } + openBlockMenu(anchor, actions, l.layout); + } + + private showView(id: string | null) { + if (!id) return; + this.viewId = id; + this.sel = null; + this.limit = PAGE; + this.draw(); + } + + private setLayout(v: View, type: ViewType) { + const patch: Partial = { type }; + const cols = this.db.columns; + if (type === "kanban" && !v.groupBy) patch.groupBy = cols.find((c) => ["select", "multiSelect", "checkbox", "member"].includes(c.type))?.id ?? null; + if (type === "calendar" && !v.dateColumn) patch.dateColumn = cols.find((c) => c.type === "date")?.id ?? null; + if (type === "calendar" && !patch.dateColumn && !v.dateColumn && this.host.store) { + patch.dateColumn = this.host.store.addColumn("date", this.labels.typeDate); + } + this.host.store?.updateView(v.id, patch); + } + + private moreMenu() { + const l = this.labels; + const v = this.view; + const actions: BlockAction[] = [ + { + id: "csv", + label: l.exportCsv, + icon: "download", + run: () => { + const cols = visibleColumns(this.db, v); + const name = (this.db.title || l.untitled).replace(/[\\/:*?"<>|]+/g, " ").trim(); + download(`${name}.csv`, `\uFEFF${toCSV(this.db, cols, viewRows(this.db, v, this.search))}`, "text/csv"); + }, + }, + ]; + if (this.editable) { + actions.push({ id: "import", label: l.importCsv, icon: "upload", run: () => void this.importCsv() }); + actions.push({ id: "view", label: l.layout, icon: "grid", run: () => this.viewMenu(this.buttons.more, v) }); + } + openBlockMenu(this.buttons.more, actions, l.more); + } + + /** Adds a CSV file's rows; columns are matched by name and missing ones added. */ + private async importCsv() { + const store = this.host.store; + const file = await pickFile(".csv,text/csv,.tsv,text/tab-separated-values"); + if (!store || !file) return; + const text = await file.text(); + const sep = file.name.endsWith(".tsv") ? "\t" : ","; + const lines = parseDelimited(text, sep).filter((r) => r.some((f) => f.trim())); + if (lines.length < 2) return; + store.tx(() => { + if (this.db.rows.every((r) => !cellText(r, titleColumn(this.db)))) { + // An empty database takes the file's columns and guessed types. + const parsed = fromCSV(text, sep); + store.deleteRows(this.db.rows.map((r) => r.id)); + const title = titleColumn(this.db); + const [first, ...rest] = parsed.columns; + const ids = new Map(); + if (first) { + store.renameColumn(title.id, first.name); + ids.set(first.id, title.id); + } + for (const c of rest) { + const existing = this.db.columns.find((x) => x.name.toLowerCase() === c.name.toLowerCase() && x.type !== "title"); + if (existing) store.deleteColumn(existing.id); + const id = store.addColumn(c.type, c.name); + if (c.options) store.setOptions(id, c.options); + ids.set(c.id, id); + } + store.addRows(parsed.rows.map((cells) => Object.fromEntries(Object.entries(cells).map(([k, val]) => [ids.get(k) ?? k, val])))); + this.host.notify?.(fill(this.labels.imported, parsed.rows.length)); + return; + } + const { index, missing } = matchHeader(lines[0]!, this.db.columns); + const added = new Map(missing.map((name) => [name, store.addColumn("text", name)])); + const cols = lines[0]!.map((name, i): Column | null => { + const c = index[i]; + if (c) return c; + const id = added.get(name.trim()); + return id ? { id, name, type: "text" } : null; + }); + const options = new Map(this.db.columns.map((c) => [c.id, [...(c.options ?? [])]])); + const rows = lines.slice(1).map((r) => { + const cells: Record = {}; + cols.forEach((c, i) => { + if (!c) return; + const val = parseCell(r[i] ?? "", c, options.get(c.id) ?? []); + if (val !== null) cells[c.id] = val; + }); + return cells; + }); + for (const c of this.db.columns) { + const o = options.get(c.id); + if (o && o.length !== (c.options?.length ?? 0)) store.setOptions(c.id, o); + } + store.addRows(rows); + this.host.notify?.(fill(this.labels.imported, rows.length)); + }); + } + + private addRow(cells: Record = {}, open = false) { + const store = this.host.store; + if (!store) return; + const v = this.view; + // A new row matches the view's simple filters, so it does not vanish. + for (const f of v.filters) { + const col = this.db.columns.find((c) => c.id === f.column); + if (!col || f.column in cells) continue; + if (f.op === "is" && (col.type === "select" || col.type === "text") && f.value) cells[col.id] = f.value; + if (f.op === "contains" && col.type === "multiSelect" && f.value) cells[col.id] = [f.value]; + if (f.op === "checked") cells[col.id] = true; + } + const id = store.addRow(cells); + if (open || v.type !== "table") this.openRow(id); + else { + this.sel = { row: id, col: titleColumn(this.db).id }; + queueMicrotask(() => this.startEdit()); + } + } + + private openRow(id: string) { + const rows = viewRows(this.db, this.view, this.search).map((r) => r.id); + this.host.openRow(id, rows); + } + + private drawBody() { + const v = this.view; + if (v.type === "kanban") this.drawKanban(v); + else if (v.type === "calendar") this.drawCalendar(v); + else this.drawTable(v); + } + + // ---------------------------------------------------------------- table + + private tableRows: Row[] = []; + private tableCols: Column[] = []; + private grid: HTMLElement | null = null; + + private drawTable(v: View) { + const l = this.labels; + const cols = visibleColumns(this.db, v); + const rows = viewRows(this.db, v, this.search); + const group = v.groupBy ? this.db.columns.find((c) => c.id === v.groupBy) : undefined; + const groups: Group[] = group + ? groupRows(rows, group, l.noValue, l.checked, l.unchecked).filter((g) => g.rows.length || g.key !== "") + : [{ key: "", label: "", rows }]; + this.tableCols = cols; + this.tableRows = []; + const editable = this.editable; + const sorted = v.sorts.length > 0; + + const colgroup = h( + "colgroup", + {}, + h("col", { class: "dw-db-t__gutter-col" }), + cols.map((c) => h("col", { style: { width: `${v.widths[c.id] ?? (c.type === "title" ? 240 : 160)}px` } })), + editable ? h("col", { class: "dw-db-t__add-col" }) : null, + ); + const head = h( + "tr", + {}, + h("th", { class: "dw-db-t__gutter", "aria-hidden": "true" }), + cols.map((c, i) => this.headerCell(c, i, colgroup.children[i + 1] as HTMLElement)), + editable + ? h( + "th", + { class: "dw-db-t__add" }, + iconButton("plus", l.addColumn, (e) => this.addColumnMenu(e.currentTarget as HTMLElement)), + ) + : null, + ); + const table = h("table", { class: "dw-db-t" }, colgroup, h("thead", {}, head)); + let shown = 0; + for (const g of groups) { + const tbody = h("tbody", {}); + const key = `${v.id}:${g.key}`; + if (group) { + const open = !this.collapsed.has(key); + const toggle = h( + "button", + { type: "button", class: "dw-db-t__group", "aria-expanded": String(open) }, + icon(open ? "chevron-down" : "chevron-right", 14), + g.key && group.type !== "checkbox" && group.type !== "member" && group.type !== "createdBy" + ? h("span", { class: "dw-db-tag", dataset: { color: g.color ?? "gray" } }, g.label) + : h("span", {}, g.label), + h("span", { class: "dw-db-t__count" }, String(g.rows.length)), + ); + toggle.addEventListener("click", () => { + if (open) this.collapsed.add(key); + else this.collapsed.delete(key); + this.drawBody(); + }); + tbody.append(h("tr", { class: "dw-db-t__group-row" }, h("td", { colSpan: cols.length + 2 }, toggle))); + if (!open) { + table.append(tbody); + continue; + } + } + for (const r of g.rows) { + if (shown >= this.limit) break; + shown++; + this.tableRows.push(r); + tbody.append(this.tableRow(r, cols, editable && !sorted)); + } + if (editable && shown < this.limit) { + const add = h("button", { type: "button", class: "dw-db-t__new" }, icon("plus", 14), h("span", {}, l.newRow)); + add.addEventListener("click", () => { + const cells: Record = {}; + if (group && g.key) cells[group.id] = moveToGroup({ id: "", cells: {}, createdAt: 0, createdBy: null }, group, "", g.key, g.rows.flatMap((x) => asPeople(cellValue(x, group)))); + else if (group?.type === "checkbox") cells[group.id] = g.key === "true"; + this.addRow(cells); + }); + tbody.append(h("tr", { class: "dw-db-t__new-row" }, h("td", { colSpan: cols.length + 2 }, add))); + } + table.append(tbody); + } + const children: Node[] = []; + const wrap = h("div", { class: "dw-db-t__wrap", role: "grid", tabIndex: 0, "aria-label": this.db.title || l.database }, table); + children.push(wrap); + if (!rows.length) children.push(h("p", { class: "dw-db__empty" }, this.db.rows.length ? l.noMatches : l.noRows)); + if (rows.length > shown && shown >= this.limit) { + const more = h("button", { type: "button", class: "dw-db__btn dw-db__more" }, `${l.more} (${rows.length - shown})`); + more.addEventListener("click", () => { + this.limit += PAGE; + this.drawBody(); + }); + children.push(more); + } + this.grid = wrap; + wrap.addEventListener("keydown", (e) => this.onGridKey(e)); + wrap.addEventListener("copy", (e) => this.onCopy(e)); + wrap.addEventListener("paste", (e) => this.onPaste(e)); + const scroll = this.body.querySelector(".dw-db-t__wrap")?.scrollLeft ?? 0; + const hadFocus = this.body.contains(document.activeElement); + this.body.replaceChildren(...children); + wrap.scrollLeft = scroll; + this.markSelection(); + if (hadFocus && this.sel) wrap.focus({ preventScroll: true }); + } + + private headerCell(c: Column, index: number, colEl: HTMLElement): HTMLElement { + const l = this.labels; + const name = h("span", { class: "dw-db-t__name" }, c.name || typeLabel(l, c.type)); + const btn = h( + "button", + { type: "button", class: "dw-db-t__head", "aria-haspopup": "menu", draggable: this.editable }, + icon(typeIcons[c.type], 14), + name, + ); + const th = h("th", { dataset: { col: c.id } }, btn); + btn.addEventListener("click", () => this.columnMenu(btn, c, index)); + if (this.editable) { + btn.addEventListener("dragstart", (e) => { + e.dataTransfer?.setData("application/x-docwell-column", c.id); + if (e.dataTransfer) e.dataTransfer.effectAllowed = "move"; + }); + th.addEventListener("dragover", (e) => { + if (e.dataTransfer?.types.includes("application/x-docwell-column")) { + e.preventDefault(); + th.classList.add("is-drop"); + } + }); + th.addEventListener("dragleave", () => th.classList.remove("is-drop")); + th.addEventListener("drop", (e) => { + th.classList.remove("is-drop"); + const id = e.dataTransfer?.getData("application/x-docwell-column"); + if (!id || id === c.id) return; + e.preventDefault(); + this.host.store?.moveColumn(id, this.db.columns.findIndex((x) => x.id === c.id)); + }); + // Drag the right edge to resize; the width is saved with the view. + const grip = h("span", { class: "dw-db-t__resize", title: l.resize, "aria-hidden": "true" }); + grip.addEventListener("pointerdown", (e) => { + e.preventDefault(); + e.stopPropagation(); + const start = e.clientX; + const from = colEl.getBoundingClientRect().width || 160; + let width = from; + grip.setPointerCapture(e.pointerId); + const move = (ev: PointerEvent) => { + width = Math.max(72, Math.round(from + ev.clientX - start)); + colEl.style.width = `${width}px`; + }; + const up = () => { + grip.removeEventListener("pointermove", move); + grip.removeEventListener("pointerup", up); + const v = this.view; + if (width !== from) this.host.store?.updateView(v.id, { widths: { ...v.widths, [c.id]: width } }); + }; + grip.addEventListener("pointermove", move); + grip.addEventListener("pointerup", up); + }); + th.append(grip); + } + return th; + } + + private columnMenu(anchor: HTMLElement, c: Column, index: number) { + const l = this.labels; + const store = this.host.store; + const v = this.view; + const sortBy = (desc: boolean): BlockAction => ({ + id: desc ? "desc" : "asc", + label: desc ? l.sortDescending : l.sortAscending, + icon: desc ? "arrow-down" : "arrow-up", + run: () => store?.updateView(v.id, { sorts: [{ column: c.id, desc }] }), + }); + if (!store) { + openBlockMenu(anchor, [sortBy(false), sortBy(true)], c.name); + return; + } + const all = this.db.columns; + const at = all.findIndex((x) => x.id === c.id); + const actions: BlockAction[] = [ + { id: "rename", label: l.rename, icon: "pencil", run: () => this.renameColumn(c) }, + ]; + if (c.type !== "title") { + actions.push({ + id: "type", + label: l.type, + icon: typeIcons[c.type], + children: editableTypes.map((t) => ({ + id: t, + label: typeLabel(l, t), + icon: t === c.type ? "check" : typeIcons[t], + run: () => store.changeType(c.id, t), + })), + }); + } + actions.push(sortBy(false), sortBy(true), { + id: "filter", + label: l.filterBy, + icon: "filter", + run: () => { + store.updateView(v.id, { filters: [...v.filters, { column: c.id, op: filterOps(c.type)[0]! }] }); + this.buttons.filter.click(); + }, + }); + if (c.type !== "title") actions.push({ id: "hide", label: l.hide, icon: "close", run: () => store.updateView(v.id, { hidden: [...v.hidden, c.id] }) }); + actions.push( + { id: "left", label: l.insertLeft, icon: "plus", run: () => this.insertColumn(at) }, + { id: "right", label: l.insertRight, icon: "plus", run: () => this.insertColumn(at + 1) }, + ); + if (at > 0) actions.push({ id: "moveLeft", label: l.moveLeft, icon: "arrow-up", run: () => store.moveColumn(c.id, at - 1) }); + if (at < all.length - 1) actions.push({ id: "moveRight", label: l.moveRight, icon: "arrow-down", run: () => store.moveColumn(c.id, at + 1) }); + if (c.type !== "title") { + actions.push( + { id: "duplicate", label: l.duplicate, icon: "copy", run: () => store.duplicateColumn(c.id, `${c.name} 2`) }, + { id: "delete", label: l.deleteColumn, icon: "trash", danger: true, run: () => store.deleteColumn(c.id) }, + ); + } + void index; + openBlockMenu(anchor, actions, c.name || typeLabel(l, c.type)); + } + + private insertColumn(at: number) { + const store = this.host.store; + if (!store) return; + const id = store.addColumn("text", this.labels.typeText, at); + queueMicrotask(() => { + const col = this.db.columns.find((c) => c.id === id); + if (col) this.renameColumn(col); + }); + } + + private addColumnMenu(anchor: HTMLElement) { + const l = this.labels; + openBlockMenu( + anchor, + editableTypes.map((t) => ({ + id: t, + label: typeLabel(l, t), + icon: typeIcons[t], + run: () => { + const id = this.host.store?.addColumn(t, typeLabel(l, t)); + queueMicrotask(() => { + const col = this.db.columns.find((c) => c.id === id); + if (col) this.renameColumn(col); + }); + }, + })), + l.addColumn, + ); + } + + /** Turns a column's header into a name field. */ + private renameColumn(c: Column) { + const th = this.body.querySelector(`th[data-col="${CSS.escape(c.id)}"]`); + const store = this.host.store; + if (!store) return; + if (!th) { + const name = window.prompt(this.labels.columnName, c.name)?.trim(); + if (name) store.renameColumn(c.id, name); + return; + } + const ctx = this.ctx(); + ctx.setEditing(true); + const input = textInput(c.name, { + class: "dw-db-t__name-input", + label: this.labels.columnName, + onCommit: (name) => { + if (name.trim() && name.trim() !== c.name) store.renameColumn(c.id, name.trim()); + ctx.setEditing(false); + this.drawBody(); + }, + onCancel: () => { + ctx.setEditing(false); + this.drawBody(); + }, + }); + th.replaceChildren(input); + input.focus(); + input.select(); + } + + private tableRow(r: Row, cols: Column[], movable: boolean): HTMLElement { + const l = this.labels; + const tr = h("tr", { dataset: { row: r.id }, class: this.picked.has(r.id) ? "is-picked" : "" }); + const gutter = h("td", { class: "dw-db-t__gutter" }); + if (this.editable) { + const check = h("input", { type: "checkbox", class: "dw-db-t__pick", "aria-label": l.selectRow, checked: this.picked.has(r.id) }); + check.addEventListener("change", () => { + if (check.checked) this.picked.add(r.id); + else this.picked.delete(r.id); + tr.classList.toggle("is-picked", check.checked); + this.drawBulk(); + }); + gutter.append(check); + if (movable) { + const grip = h("span", { class: "dw-db-t__grip", draggable: true, title: l.dragRow, "aria-hidden": "true" }, icon("grip", 14)); + grip.addEventListener("dragstart", (e) => { + e.dataTransfer?.setData("application/x-docwell-row", r.id); + if (e.dataTransfer) e.dataTransfer.effectAllowed = "move"; + e.dataTransfer?.setDragImage(tr, 0, 0); + }); + gutter.append(grip); + tr.addEventListener("dragover", (e) => { + if (!e.dataTransfer?.types.includes("application/x-docwell-row")) return; + e.preventDefault(); + const below = e.clientY > tr.getBoundingClientRect().top + tr.offsetHeight / 2; + tr.classList.toggle("is-drop-below", below); + tr.classList.toggle("is-drop-above", !below); + }); + tr.addEventListener("dragleave", () => tr.classList.remove("is-drop-below", "is-drop-above")); + tr.addEventListener("drop", (e) => { + const below = tr.classList.contains("is-drop-below"); + tr.classList.remove("is-drop-below", "is-drop-above"); + const id = e.dataTransfer?.getData("application/x-docwell-row"); + const store = this.host.store; + if (!id || id === r.id || !store) return; + e.preventDefault(); + const from = store.rowIndex(id); + let to = store.rowIndex(r.id) + (below ? 1 : 0); + if (from < to) to--; + store.moveRow(id, to); + }); + } + } + tr.append(gutter); + for (const c of cols) { + const td = h("td", { dataset: { col: c.id }, class: `dw-db-t__cell dw-db-t__cell--${c.type}`, role: "gridcell" }, renderCell(this.ctx(), r, c)); + if (c.type === "title") { + const open = h("button", { type: "button", class: "dw-db-t__open", title: l.openRow }, icon("open", 13), h("span", {}, l.openRow)); + open.addEventListener("click", (e) => { + e.stopPropagation(); + this.openRow(r.id); + }); + td.append(open); + } + td.addEventListener("mousedown", (e) => { + if ((e.target as HTMLElement).closest("input, button, a")) return; + if (e.shiftKey && this.sel) this.anchor = this.anchor ?? this.sel; + else this.anchor = null; + this.sel = { row: r.id, col: c.id }; + if (!e.shiftKey) this.anchor = null; + this.markSelection(); + // Inside the page's contenteditable the browser would leave focus where it was. + e.preventDefault(); + this.grid?.focus({ preventScroll: true }); + }); + td.addEventListener("click", (e) => { + if ((e.target as HTMLElement).closest("input, button, a") || e.shiftKey) return; + if (c.type === "checkbox") this.startEdit(); + }); + td.addEventListener("dblclick", () => this.startEdit()); + tr.append(td); + } + if (this.editable) tr.append(h("td", { class: "dw-db-t__add" })); + tr.addEventListener("contextmenu", (e) => { + if (!this.editable) return; + e.preventDefault(); + this.rowMenu(tr, r); + }); + return tr; + } + + private rowMenu(anchor: HTMLElement, r: Row) { + const l = this.labels; + const store = this.host.store!; + const i = store.rowIndex(r.id); + openBlockMenu( + anchor, + [ + { id: "open", label: l.openRow, icon: "open", run: () => this.openRow(r.id) }, + { id: "above", label: l.insertAbove, icon: "arrow-up", run: () => store.addRow({}, i) }, + { id: "below", label: l.insertBelow, icon: "arrow-down", run: () => store.addRow({}, i + 1) }, + { id: "duplicate", label: l.duplicateRow, icon: "copy", run: () => store.duplicateRow(r.id) }, + { id: "delete", label: l.deleteRow, icon: "trash", danger: true, run: () => store.deleteRows([r.id]) }, + ], + l.openRow, + ); + } + + /** The (row, column) indexes of the selection's rectangle in the drawn table. */ + private range(): { r0: number; r1: number; c0: number; c1: number } | null { + if (!this.sel) return null; + const ri = (id: string) => this.tableRows.findIndex((r) => r.id === id); + const ci = (id: string) => this.tableCols.findIndex((c) => c.id === id); + const a = this.anchor ?? this.sel; + const [ra, rb, ca, cb] = [ri(a.row), ri(this.sel.row), ci(a.col), ci(this.sel.col)]; + if (rb < 0 || cb < 0) return null; + const r0 = ra < 0 ? rb : ra; + const c0 = ca < 0 ? cb : ca; + return { r0: Math.min(r0, rb), r1: Math.max(r0, rb), c0: Math.min(c0, cb), c1: Math.max(c0, cb) }; + } + + private markSelection() { + if (!this.grid) return; + for (const el of this.grid.querySelectorAll(".is-selected, .is-in-range")) el.classList.remove("is-selected", "is-in-range"); + const rg = this.range(); + if (!rg || !this.sel) return; + for (let r = rg.r0; r <= rg.r1; r++) { + for (let c = rg.c0; c <= rg.c1; c++) { + this.cellEl(this.tableRows[r]!.id, this.tableCols[c]!.id)?.classList.add("is-in-range"); + } + } + const el = this.cellEl(this.sel.row, this.sel.col); + el?.classList.add("is-selected"); + el?.scrollIntoView({ block: "nearest", inline: "nearest" }); + } + + private cellEl(row: string, col: string): HTMLElement | null { + return this.grid?.querySelector(`tr[data-row="${CSS.escape(row)}"] td[data-col="${CSS.escape(col)}"]`) ?? null; + } + + private startEdit(initial?: string) { + if (!this.sel || !this.host.store) return; + const r = this.db.rows.find((x) => x.id === this.sel!.row); + const c = this.db.columns.find((x) => x.id === this.sel!.col); + const el = this.cellEl(this.sel.row, this.sel.col); + if (!r || !c || !el) return; + editCell(this.ctx(), el, r, c, { + initial, + onDone: (move) => { + if (move) this.moveSel(move === "down" ? 1 : 0, move === "right" ? 1 : move === "left" ? -1 : 0, false); + this.drawBody(); + this.grid?.focus({ preventScroll: true }); + }, + }); + } + + private moveSel(dr: number, dc: number, extend: boolean) { + const rows = this.tableRows; + const cols = this.tableCols; + if (!rows.length || !cols.length) return; + if (!this.sel) { + this.sel = { row: rows[0]!.id, col: cols[0]!.id }; + return this.markSelection(); + } + if (extend) this.anchor = this.anchor ?? { ...this.sel }; + else this.anchor = null; + const r = Math.max(0, Math.min(rows.length - 1, rows.findIndex((x) => x.id === this.sel!.row) + dr)); + const c = Math.max(0, Math.min(cols.length - 1, cols.findIndex((x) => x.id === this.sel!.col) + dc)); + this.sel = { row: rows[r]!.id, col: cols[c]!.id }; + this.markSelection(); + } + + private onGridKey(e: KeyboardEvent) { + if ((e.target as HTMLElement).closest("input, select, textarea")) return; + const mod = e.ctrlKey || e.metaKey; + if (mod && e.key.toLowerCase() === "z") { + e.preventDefault(); + return e.shiftKey ? this.host.redo() : this.host.undo(); + } + if (mod && e.key.toLowerCase() === "y") { + e.preventDefault(); + return this.host.redo(); + } + if (mod) return; + const arrows: Record = { ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1] }; + const step = arrows[e.key]; + if (step) { + e.preventDefault(); + return this.moveSel(step[0], step[1], e.shiftKey); + } + if (!this.sel) return; + if (e.key === "Tab") { + e.preventDefault(); + return this.moveSel(0, e.shiftKey ? -1 : 1, false); + } + if (e.key === "Escape") { + this.sel = null; + this.anchor = null; + this.markSelection(); + return; + } + if (e.key === "Enter" || e.key === "F2") { + e.preventDefault(); + return this.startEdit(); + } + if (e.key === " ") { + e.preventDefault(); + const c = this.db.columns.find((x) => x.id === this.sel!.col); + if (c?.type === "title") return this.openRow(this.sel.row); + return this.startEdit(); + } + if ((e.key === "Delete" || e.key === "Backspace") && this.host.store) { + e.preventDefault(); + const rg = this.range(); + if (!rg) return; + const changes = []; + for (let r = rg.r0; r <= rg.r1; r++) { + for (let c = rg.c0; c <= rg.c1; c++) { + const col = this.tableCols[c]!; + if (!readOnlyTypes.includes(col.type)) changes.push({ row: this.tableRows[r]!.id, col: col.id, value: null }); + } + } + this.host.store.setCells(changes); + return; + } + if (e.key.length === 1 && this.host.store) { + const c = this.db.columns.find((x) => x.id === this.sel!.col); + if (c && (inlineTypes.includes(c.type) || c.type === "select" || c.type === "multiSelect")) { + e.preventDefault(); + this.startEdit(e.key); + } + } + } + + /** Copies the selected cells as tab-separated text, which spreadsheets paste as cells. */ + private onCopy(e: ClipboardEvent) { + if ((e.target as HTMLElement).closest("input, textarea")) return; + const rg = this.range(); + if (!rg || !e.clipboardData) return; + e.preventDefault(); + const lines: string[][] = []; + for (let r = rg.r0; r <= rg.r1; r++) { + const line: string[] = []; + for (let c = rg.c0; c <= rg.c1; c++) line.push(cellText(this.tableRows[r]!, this.tableCols[c]!)); + lines.push(line); + } + e.clipboardData.setData("text/plain", formatDelimited(lines, "\t")); + this.host.notify?.(fill(this.labels.copyNotice, (rg.r1 - rg.r0 + 1) * (rg.c1 - rg.c0 + 1))); + } + + /** Pastes tab-separated text from a spreadsheet at the selected cell, adding rows as needed. */ + private onPaste(e: ClipboardEvent) { + if ((e.target as HTMLElement).closest("input, textarea")) return; + const store = this.host.store; + const text = e.clipboardData?.getData("text/plain"); + if (!store || !text || !this.sel) return; + e.preventDefault(); + const lines = parseDelimited(text.replace(/\r?\n$/, ""), text.includes("\t") ? "\t" : "\t"); + const r0 = this.tableRows.findIndex((r) => r.id === this.sel!.row); + const c0 = this.tableCols.findIndex((c) => c.id === this.sel!.col); + if (r0 < 0 || c0 < 0) return; + const options = new Map(this.db.columns.map((c) => [c.id, [...(c.options ?? [])]])); + const changes: { row: string; col: string; value: unknown }[] = []; + const extra: Record[] = []; + lines.forEach((line, i) => { + const row = this.tableRows[r0 + i]; + const cells: Record = {}; + line.forEach((field, j) => { + const col = this.tableCols[c0 + j]; + if (!col || readOnlyTypes.includes(col.type)) return; + const value = parseCell(field, col, options.get(col.id) ?? []); + if (row) changes.push({ row: row.id, col: col.id, value }); + else if (value !== null) cells[col.id] = value; + }); + if (!row) extra.push(cells); + }); + store.tx(() => { + for (const c of this.db.columns) { + const o = options.get(c.id); + if (o && o.length !== (c.options?.length ?? 0)) store.setOptions(c.id, o); + } + store.setCells(changes); + if (extra.length) store.addRows(extra); + }); + } + + // ---------------------------------------------------------------- kanban + + private drawKanban(v: View) { + const l = this.labels; + const col = this.db.columns.find((c) => c.id === v.groupBy); + if (!col) { + this.body.replaceChildren(h("p", { class: "dw-db__empty" }, l.noGroupColumn)); + return; + } + const rows = viewRows(this.db, v, this.search); + const groups = groupRows(rows, col, l.noValue, l.checked, l.unchecked); + const shown = visibleColumns(this.db, v).filter((c) => c.type !== "title" && c.id !== col.id); + const title = titleColumn(this.db); + const people = rows.flatMap((r) => asPeople(cellValue(r, col))); + const board = h("div", { class: "dw-db-k" }); + for (const g of groups) { + if (!g.key && !g.rows.length && col.type !== "checkbox" && (col.options?.length ?? 0) > 0) continue; + const list = h("div", { class: "dw-db-k__cards", dataset: { group: g.key } }); + const head = h( + "div", + { class: "dw-db-k__head" }, + g.key && col.type !== "checkbox" && col.type !== "member" && col.type !== "createdBy" + ? h("span", { class: "dw-db-tag", dataset: { color: g.color ?? "gray" } }, g.label) + : h("span", { class: "dw-db-k__label" }, g.label), + h("span", { class: "dw-db-t__count" }, String(g.rows.length)), + ); + for (const r of g.rows.slice(0, this.limit)) { + const card = h( + "div", + { class: "dw-db-k__card", tabIndex: 0, role: "button", draggable: this.editable && !readOnlyTypes.includes(col.type), dataset: { row: r.id } }, + h("div", { class: "dw-db-k__title" }, renderCell(this.ctx(), r, title)), + shown.flatMap((c) => { + if (cellText(r, c) === "" || (c.type === "checkbox" && cellValue(r, c) !== true)) return []; + return [h("div", { class: "dw-db-k__prop", title: c.name }, renderCell(this.ctx(), r, c))]; + }), + ); + card.addEventListener("click", () => this.openRow(r.id)); + card.addEventListener("keydown", (e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + this.openRow(r.id); + } + }); + card.addEventListener("dragstart", (e) => { + e.dataTransfer?.setData("application/x-docwell-card", JSON.stringify({ row: r.id, from: g.key })); + if (e.dataTransfer) e.dataTransfer.effectAllowed = "move"; + card.classList.add("is-dragging"); + }); + card.addEventListener("dragend", () => card.classList.remove("is-dragging")); + list.append(card); + } + if (this.editable) { + const add = h("button", { type: "button", class: "dw-db-t__new" }, icon("plus", 14), h("span", {}, l.newRow)); + add.addEventListener("click", () => { + const blank: Row = { id: "", cells: {}, createdAt: 0, createdBy: null }; + this.addRow(g.key || col.type === "checkbox" ? { [col.id]: moveToGroup(blank, col, "", g.key, people) } : {}, true); + }); + list.append(add); + list.addEventListener("dragover", (e) => { + if (!e.dataTransfer?.types.includes("application/x-docwell-card")) return; + e.preventDefault(); + list.classList.add("is-drop"); + }); + list.addEventListener("dragleave", (e) => { + if (!list.contains(e.relatedTarget as Node)) list.classList.remove("is-drop"); + }); + list.addEventListener("drop", (e) => { + list.classList.remove("is-drop"); + const raw = e.dataTransfer?.getData("application/x-docwell-card"); + const store = this.host.store; + if (!raw || !store) return; + e.preventDefault(); + const { row, from } = JSON.parse(raw) as { row: string; from: string }; + const r = this.db.rows.find((x) => x.id === row); + if (!r) return; + // Dropped onto a card: the row goes before it. + const target = (e.target as HTMLElement).closest(".dw-db-k__card"); + store.tx(() => { + if (from !== g.key) store.setCell(row, col.id, moveToGroup(r, col, from, g.key, people)); + const before = target?.dataset.row; + if (before && before !== row && !v.sorts.length) { + const fromIndex = store.rowIndex(row); + let to = store.rowIndex(before); + if (fromIndex < to) to--; + store.moveRow(row, to); + } + }); + }); + } + board.append(h("section", { class: "dw-db-k__col", "aria-label": g.label }, head, list)); + } + this.body.replaceChildren(board); + } + + // ---------------------------------------------------------------- calendar + + private drawCalendar(v: View) { + const l = this.labels; + const col = this.db.columns.find((c) => c.id === v.dateColumn); + if (!col) { + this.body.replaceChildren(h("p", { class: "dw-db__empty" }, l.noDateColumn)); + return; + } + const movable = this.editable && col.type === "date"; + const { y, m } = this.month; + const days = monthGrid(y, m); + const rows = viewRows(this.db, v, this.search); + const byDay = new Map(); + const undated: Row[] = []; + for (const r of rows) { + const d = dateOf(cellValue(r, col)); + if (!d) undated.push(r); + else byDay.set(d, [...(byDay.get(d) ?? []), r]); + } + const title = titleColumn(this.db); + const today = isoDay(new Date()); + const monthName = new Date(y, m, 1).toLocaleDateString(this.host.locale, { month: "long", year: "numeric" }); + const go = (dm: number) => { + const d = new Date(y, m + dm, 1); + this.month = { y: d.getFullYear(), m: d.getMonth() }; + this.drawBody(); + }; + const nav = h( + "div", + { class: "dw-db-c__nav" }, + h("strong", { class: "dw-db-c__month" }, monthName), + iconButton("chevron-left", l.previousMonth, () => go(-1)), + iconButton("chevron-right", l.nextMonth, () => go(1)), + iconButton("calendar", l.today, () => { + const d = new Date(); + this.month = { y: d.getFullYear(), m: d.getMonth() }; + this.drawBody(); + }, l.today), + ); + const week = days.slice(0, 7).map((d) => { + const [yy, mm, dd] = d.split("-").map(Number); + return h("div", { class: "dw-db-c__wd" }, new Date(yy!, mm! - 1, dd!).toLocaleDateString(this.host.locale, { weekday: "short" })); + }); + const chip = (r: Row) => { + const el = h( + "button", + { type: "button", class: "dw-db-c__chip", draggable: movable, dataset: { row: r.id } }, + cellText(r, title) || l.untitledRow, + ); + el.addEventListener("click", () => this.openRow(r.id)); + el.addEventListener("dragstart", (e) => { + e.dataTransfer?.setData("application/x-docwell-row-date", r.id); + if (e.dataTransfer) e.dataTransfer.effectAllowed = "move"; + }); + return el; + }; + const grid = h("div", { class: "dw-db-c__grid", role: "grid" }, week); + for (const d of days) { + const inMonth = Number(d.slice(5, 7)) === m + 1; + const cell = h( + "div", + { class: `dw-db-c__day${inMonth ? "" : " is-out"}${d === today ? " is-today" : ""}`, role: "gridcell", dataset: { day: d } }, + h("span", { class: "dw-db-c__num" }, String(Number(d.slice(8)))), + (byDay.get(d) ?? []).map(chip), + ); + if (this.editable && col.type === "date") { + const add = h("button", { type: "button", class: "dw-db-c__add", "aria-label": `${l.newRow} ${d}`, title: l.newRow }, icon("plus", 12)); + add.addEventListener("click", () => this.addRow({ [col.id]: d }, true)); + cell.append(add); + } + if (movable) { + cell.addEventListener("dragover", (e) => { + if (!e.dataTransfer?.types.includes("application/x-docwell-row-date")) return; + e.preventDefault(); + cell.classList.add("is-drop"); + }); + cell.addEventListener("dragleave", () => cell.classList.remove("is-drop")); + cell.addEventListener("drop", (e) => { + cell.classList.remove("is-drop"); + const id = e.dataTransfer?.getData("application/x-docwell-row-date"); + if (!id) return; + e.preventDefault(); + this.host.store?.setCell(id, col.id, d); + }); + } + grid.append(cell); + } + const children: Node[] = [nav, grid]; + if (undated.length) { + children.push( + h( + "details", + { class: "dw-db-c__undated" }, + h("summary", {}, fill(l.noDate, undated.length)), + h("div", { class: "dw-db-c__chips" }, undated.slice(0, this.limit).map(chip)), + ), + ); + } + this.body.replaceChildren(h("div", { class: "dw-db-c" }, children)); + } +} + +const fallbackView: View = { + id: "", + name: "", + type: "table", + hidden: [], + filters: [], + filterMode: "and", + sorts: [], + groupBy: null, + dateColumn: null, + widths: {}, +}; + +function asPeople(v: unknown) { + return Array.isArray(v) ? (v as { id: string; name: string }[]).filter((p) => p && typeof p.id === "string") : []; +} + diff --git a/Packages/editor/src/editor.css b/Packages/editor/src/editor.css index 7c3f556..24560a8 100644 --- a/Packages/editor/src/editor.css +++ b/Packages/editor/src/editor.css @@ -1240,3 +1240,930 @@ .dw-prose .dw-synced__body .dw-prose { min-height: 0; } + +/* ---- Databases (database/): table, kanban and calendar views ---- */ +.dw-db-node { + margin: 1em 0; +} +.dw-db { + font-family: var(--font-sans); + font-size: 14px; + color: var(--color-ink); +} +.dw-db__head { + margin-bottom: 4px; +} +.dw-db__title, +.dw-db__title-input { + font-size: 1.25rem; + font-weight: 650; + line-height: 1.3; +} +.dw-db__title .is-empty { + color: var(--color-ink-faint); +} +.dw-db__title-input { + width: 100%; + padding: 2px 0; + border: none; + background: none; + color: inherit; + font-family: inherit; +} +.dw-db__title-input:focus { + outline: none; +} +.dw-db__title-input::placeholder { + color: var(--color-ink-faint); +} +.dw-db__bar { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 4px 12px; + padding-bottom: 4px; + border-bottom: 1px solid var(--color-line); +} +.dw-db__tabs, +.dw-db__tools { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 2px; +} +.dw-db__tab, +.dw-db__btn { + display: inline-flex; + align-items: center; + gap: 6px; + min-height: 28px; + padding: 2px 8px; + border: none; + border-radius: var(--radius-sm); + background: none; + color: var(--color-ink-muted); + font: inherit; + font-size: 13px; + white-space: nowrap; + cursor: pointer; +} +.dw-db__tab:hover, +.dw-db__btn:hover:not(:disabled) { + background: var(--color-surface-hover); + color: var(--color-ink); +} +.dw-db__tab.is-active { + color: var(--color-ink); + font-weight: 600; + box-shadow: inset 0 -2px 0 var(--color-accent); + border-radius: var(--radius-sm) var(--radius-sm) 0 0; +} +.dw-db__btn--icon { + width: 28px; + padding: 0; + justify-content: center; +} +.dw-db__btn.is-on { + color: var(--color-accent); +} +.dw-db__btn:disabled { + opacity: 0.4; + cursor: default; +} +.dw-db__btn[hidden] { + display: none; +} +.dw-db__btn--primary { + background: var(--color-primary); + color: var(--color-on-primary); +} +.dw-db__btn--primary:hover:not(:disabled) { + background: var(--color-primary-hover); + color: var(--color-on-primary); +} +.dw-db__tab:focus-visible, +.dw-db__btn:focus-visible, +.dw-db-t__head:focus-visible, +.dw-db-t__wrap:focus-visible, +.dw-db-k__card:focus-visible, +.dw-db-peek__value:focus-visible { + outline: 2px solid var(--color-focus-ring); + outline-offset: 1px; +} +.dw-db__search { + width: 12rem; + max-width: 50vw; +} +.dw-db__search[hidden] { + display: none; +} +.dw-db__bulk { + display: flex; + align-items: center; + gap: 8px; + padding: 4px 8px; + margin-top: 4px; + border-radius: var(--radius-sm); + background: var(--color-accent-soft); + font-size: 13px; +} +.dw-db__bulk[hidden] { + display: none; +} +.dw-db__empty { + margin: 12px 0; + color: var(--color-ink-faint); + font-size: 13px; +} +.dw-db__more { + margin-top: 4px; +} +.dw-db-input { + width: 100%; + min-height: 30px; + padding: 4px 8px; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-surface); + color: var(--color-ink); + font: inherit; + font-size: 13px; +} +.dw-db-input--small { + width: 9rem; +} +.dw-db-input:focus, +.dw-db-select:focus { + outline: 2px solid var(--color-focus-ring); + outline-offset: -1px; +} +.dw-db-select { + min-height: 30px; + max-width: 12rem; + padding: 2px 6px; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-surface); + color: var(--color-ink); + font: inherit; + font-size: 13px; +} + +/* Tags (select choices), people and files inside cells. */ +.dw-db-tags { + display: inline-flex; + flex-wrap: wrap; + gap: 4px; + min-width: 0; +} +.dw-db-tag { + display: inline-flex; + align-items: center; + gap: 2px; + max-width: 100%; + padding: 0 6px; + border-radius: var(--radius-xs); + background: var(--dw-bg, var(--dw-bg-gray)); + color: var(--color-ink); + font-size: 12.5px; + line-height: 20px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.dw-db-tag__x { + padding: 0 2px; + border: none; + background: none; + color: var(--color-ink-muted); + font: inherit; + cursor: pointer; +} +.dw-db-person, +.dw-db-file { + display: inline-flex; + align-items: center; + gap: 4px; + font-size: 13px; + color: var(--color-ink); + text-decoration: none; + white-space: nowrap; +} +.dw-db-person__dot { + display: inline-grid; + place-items: center; + width: 18px; + height: 18px; + border-radius: 50%; + background: var(--color-accent-soft); + color: var(--color-accent); + font-size: 10px; + font-weight: 700; +} +.dw-db-check { + display: inline-grid; + place-items: center; + width: 16px; + height: 16px; + border: 1.5px solid var(--color-line-strong); + border-radius: 4px; + vertical-align: middle; +} +.dw-db-check.is-on { + border-color: var(--color-accent); + background: var(--color-accent); + color: var(--color-on-primary); +} +.dw-db-progress { + display: inline-flex; + align-items: center; + gap: 8px; + width: 100%; +} +.dw-db-progress__bar { + flex: 1; + height: 6px; + border-radius: 3px; + background: var(--color-surface-sunken); + overflow: hidden; +} +.dw-db-progress__fill { + display: block; + height: 100%; + background: var(--color-accent); +} +.dw-db-progress__num { + min-width: 3ch; + color: var(--color-ink-muted); + font-size: 12px; + font-variant-numeric: tabular-nums; +} +.dw-db-cell__title { + font-weight: 550; +} +.dw-db-cell__title.is-empty { + color: var(--color-ink-faint); + font-weight: 400; +} +.dw-db-cell__number { + display: block; + text-align: right; + font-variant-numeric: tabular-nums; +} +.dw-db-cell__link { + color: var(--color-accent); + text-decoration: underline; + text-underline-offset: 2px; +} + +/* ---- Table view ---- */ +.dw-db-t__wrap { + overflow-x: auto; + outline: none; +} +.dw-prose .dw-db-t, +.dw-db-t { + width: max-content; + min-width: 100%; + margin: 0; + border-collapse: collapse; + table-layout: fixed; +} +.dw-prose .dw-db-t th, +.dw-prose .dw-db-t td, +.dw-db-t th, +.dw-db-t td { + position: relative; + min-width: 0; + padding: 0; + border: none; + border-bottom: 1px solid var(--color-line); + background: none; + text-align: left; + vertical-align: middle; +} +.dw-prose .dw-db-t th + th, +.dw-prose .dw-db-t td.dw-db-t__cell + td.dw-db-t__cell, +.dw-db-t th + th, +.dw-db-t td.dw-db-t__cell + td.dw-db-t__cell { + border-left: 1px solid var(--color-line); +} +.dw-db-t__gutter-col { + width: 48px; +} +.dw-db-t__add-col { + width: 40px; +} +.dw-db-t__gutter { + white-space: nowrap; +} +.dw-db-t__pick, +.dw-db-t__grip { + opacity: 0; + vertical-align: middle; +} +.dw-db-t__grip { + display: inline-grid; + color: var(--color-ink-faint); + cursor: grab; +} +.dw-db-t tr:hover .dw-db-t__pick, +.dw-db-t tr:hover .dw-db-t__grip, +.dw-db-t tr.is-picked .dw-db-t__pick, +.dw-db-t__pick:focus-visible { + opacity: 1; +} +.dw-db-t tr.is-picked td { + background: var(--color-accent-soft); +} +.dw-db-t__head { + display: flex; + align-items: center; + gap: 6px; + width: 100%; + min-height: 34px; + padding: 0 8px; + border: none; + background: none; + color: var(--color-ink-muted); + font: inherit; + font-size: 13px; + font-weight: 500; + text-align: left; + cursor: pointer; +} +.dw-db-t__head:hover { + background: var(--color-surface-hover); +} +.dw-db-t__name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.dw-db-t__name-input { + width: 100%; + min-height: 34px; + padding: 0 8px; + border: none; + background: var(--color-surface); + color: var(--color-ink); + font: inherit; + font-size: 13px; + outline: 2px solid var(--color-focus-ring); + outline-offset: -2px; +} +.dw-db-t__resize { + position: absolute; + top: 0; + right: -3px; + z-index: 1; + width: 6px; + height: 100%; + cursor: col-resize; +} +.dw-db-t__resize:hover { + background: var(--color-accent); +} +.dw-db-t th.is-drop { + box-shadow: inset 3px 0 0 var(--color-accent); +} +.dw-prose .dw-db-t td.dw-db-t__cell, +.dw-db-t__cell { + height: 34px; + padding: 4px 8px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + cursor: default; +} +.dw-db-t__cell.is-in-range { + background: var(--color-selection); +} +.dw-db-t__cell.is-selected { + box-shadow: inset 0 0 0 2px var(--color-focus-ring); +} +.dw-prose .dw-db-t td.dw-db-t__cell.is-editing { + padding: 0; +} +.dw-db-cell__input { + width: 100%; + height: 34px; + padding: 0 8px; + border: none; + background: var(--color-surface); + color: var(--color-ink); + font: inherit; + outline: 2px solid var(--color-focus-ring); + outline-offset: -2px; +} +.dw-db-t__open { + position: absolute; + top: 50%; + right: 6px; + display: none; + align-items: center; + gap: 4px; + padding: 2px 6px; + border: 1px solid var(--color-line); + border-radius: var(--radius-xs); + background: var(--color-surface-raised); + color: var(--color-ink-muted); + font: inherit; + font-size: 12px; + transform: translateY(-50%); + cursor: pointer; +} +.dw-db-t tr:hover .dw-db-t__open, +.dw-db-t__open:focus-visible { + display: inline-flex; +} +.dw-db-t tr.is-drop-above td { + box-shadow: inset 0 2px 0 var(--color-accent); +} +.dw-db-t tr.is-drop-below td { + box-shadow: inset 0 -2px 0 var(--color-accent); +} +.dw-db-t__new, +.dw-db-t__group { + display: inline-flex; + align-items: center; + gap: 6px; + width: 100%; + min-height: 32px; + padding: 0 8px; + border: none; + background: none; + color: var(--color-ink-faint); + font: inherit; + font-size: 13px; + text-align: left; + cursor: pointer; +} +.dw-db-t__new:hover { + background: var(--color-surface-hover); + color: var(--color-ink); +} +.dw-db-t__group { + color: var(--color-ink); + font-weight: 600; + padding-top: 8px; +} +.dw-db-t__count { + color: var(--color-ink-faint); + font-size: 12px; + font-weight: 400; +} +.dw-prose .dw-db-t .dw-db-t__group-row td, +.dw-prose .dw-db-t .dw-db-t__new-row td { + border-bottom-color: transparent; +} + +/* ---- Kanban view ---- */ +.dw-db-k { + display: flex; + gap: 12px; + padding: 12px 0 4px; + overflow-x: auto; +} +.dw-db-k__col { + flex: 0 0 260px; + display: flex; + flex-direction: column; + gap: 8px; +} +.dw-db-k__head { + display: flex; + align-items: center; + gap: 8px; + min-height: 24px; + font-size: 13px; +} +.dw-db-k__label { + font-weight: 600; +} +.dw-db-k__cards { + display: flex; + flex-direction: column; + gap: 6px; + min-height: 48px; + padding: 4px; + border-radius: var(--radius-md); + background: var(--color-surface-sunken); +} +.dw-db-k__cards.is-drop { + outline: 2px dashed var(--color-accent); + outline-offset: -2px; +} +.dw-db-k__card { + display: flex; + flex-direction: column; + gap: 4px; + padding: 8px 10px; + border: 1px solid var(--color-line); + border-radius: var(--radius-sm); + background: var(--color-surface-raised); + box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); + cursor: pointer; +} +.dw-db-k__card:hover { + border-color: var(--color-line-strong); +} +.dw-db-k__card.is-dragging { + opacity: 0.4; +} +.dw-db-k__prop .dw-db-cell__number { + text-align: left; +} +.dw-db-k__prop { + min-width: 0; + overflow: hidden; + color: var(--color-ink-muted); + font-size: 13px; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* ---- Calendar view ---- */ +.dw-db-c { + padding-top: 8px; +} +.dw-db-c__nav { + display: flex; + align-items: center; + gap: 4px; + margin-bottom: 8px; +} +.dw-db-c__month { + margin-right: auto; + font-size: 15px; + text-transform: capitalize; +} +.dw-db-c__grid { + display: grid; + grid-template-columns: repeat(7, minmax(0, 1fr)); + border-top: 1px solid var(--color-line); + border-left: 1px solid var(--color-line); +} +.dw-db-c__wd { + padding: 4px 6px; + border-right: 1px solid var(--color-line); + border-bottom: 1px solid var(--color-line); + color: var(--color-ink-muted); + font-size: 12px; + text-transform: capitalize; +} +.dw-db-c__day { + position: relative; + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; + min-height: 88px; + padding: 4px; + border-right: 1px solid var(--color-line); + border-bottom: 1px solid var(--color-line); +} +.dw-db-c__day.is-out { + background: var(--color-surface-sunken); +} +.dw-db-c__day.is-out .dw-db-c__num { + color: var(--color-ink-faint); +} +.dw-db-c__day.is-drop { + background: var(--color-accent-soft); +} +.dw-db-c__num { + align-self: flex-start; + min-width: 22px; + padding: 0 4px; + border-radius: 11px; + font-size: 12px; + line-height: 22px; + text-align: center; +} +.dw-db-c__day.is-today .dw-db-c__num { + background: var(--color-accent); + color: var(--color-on-primary); + font-weight: 700; +} +.dw-db-c__chip { + display: block; + width: 100%; + padding: 1px 6px; + border: none; + border-radius: var(--radius-xs); + background: var(--color-accent-soft); + color: var(--color-ink); + font: inherit; + font-size: 12px; + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + cursor: pointer; +} +.dw-db-c__add { + position: absolute; + top: 4px; + right: 4px; + display: none; + place-items: center; + width: 20px; + height: 20px; + border: none; + border-radius: var(--radius-xs); + background: var(--color-surface-hover); + color: var(--color-ink-muted); + cursor: pointer; +} +.dw-db-c__day:hover .dw-db-c__add, +.dw-db-c__add:focus-visible { + display: grid; +} +.dw-db-c__undated { + margin-top: 8px; + font-size: 13px; + color: var(--color-ink-muted); +} +.dw-db-c__chips { + display: flex; + flex-wrap: wrap; + gap: 4px; + margin-top: 6px; +} +.dw-db-c__chips .dw-db-c__chip { + width: auto; + max-width: 16rem; +} +@media (max-width: 640px) { + .dw-db-c__day { + min-height: 56px; + } + .dw-db-c__chip { + padding: 0 3px; + font-size: 11px; + } + .dw-db__tools .dw-db__btn span { + display: none; + } +} + +/* ---- Panels and pickers (outside the page, in body) ---- */ +.dw-db-pop { + position: fixed; + z-index: 70; + left: 0; + top: 0; + display: flex; + flex-direction: column; + gap: 6px; + min-width: 14rem; + max-width: calc(100vw - 16px); + max-height: 24rem; + overflow-y: auto; + padding: 8px; + border: 1px solid var(--color-line); + border-radius: var(--radius-md); + background: var(--color-surface-raised); + box-shadow: var(--shadow-menu); + color: var(--color-ink); + font-family: var(--font-sans); + font-size: 13px; +} +.dw-db-pop--panel { + min-width: 20rem; +} +.dw-db-pop--choices { + width: 18rem; +} +.dw-db-pop__row { + display: flex; + align-items: center; + gap: 6px; +} +.dw-db-pop__row--end { + justify-content: flex-end; +} +.dw-db-pop__line { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 4px; +} +.dw-db-pop__label { + color: var(--color-ink-muted); + font-size: 12px; +} +.dw-db-pop__list { + display: flex; + flex-direction: column; + gap: 1px; +} +.dw-db-pop__item { + display: flex; + align-items: center; + gap: 8px; + width: 100%; + min-height: 30px; + padding: 2px 6px; + border: none; + border-radius: var(--radius-sm); + background: none; + color: var(--color-ink); + font: inherit; + text-align: left; + cursor: pointer; +} +.dw-db-pop__item:hover:not(:disabled), +.dw-db-pop__item.is-active { + background: var(--color-surface-hover); +} +.dw-db-pop__item:disabled { + cursor: default; + opacity: 0.7; +} +.dw-db-pop__check { + display: inline-grid; + place-items: center; + width: 16px; + color: var(--color-ink-muted); +} +.dw-db-pop__grow { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.dw-db-pop__more { + margin-left: auto; +} +.dw-db-pop__chosen:empty { + display: none; +} +.dw-db-pop__empty { + margin: 4px 2px; + color: var(--color-ink-faint); +} +.dw-db-pop__add { + align-self: flex-start; +} +.dw-db-switch { + position: relative; + flex-shrink: 0; + width: 28px; + height: 16px; + border-radius: 8px; + background: var(--color-line-strong); +} +.dw-db-switch::after { + content: ""; + position: absolute; + top: 2px; + left: 2px; + width: 12px; + height: 12px; + border-radius: 50%; + background: var(--color-surface); + transition: transform 0.12s; +} +.dw-db-switch.is-on { + background: var(--color-accent); +} +.dw-db-switch.is-on::after { + transform: translateX(12px); +} +.dw-db-range { + flex: 1; + accent-color: var(--color-accent); +} + +/* ---- A row opened as a page ---- */ +.dw-db-peek { + position: fixed; + inset: 0; + z-index: 65; + display: flex; + justify-content: flex-end; + background: rgb(0 0 0 / 0.25); +} +.dw-db-peek__panel { + display: flex; + flex-direction: column; + width: min(720px, 100vw); + height: 100%; + overflow-y: auto; + background: var(--color-surface); + box-shadow: var(--shadow-dialog); + outline: none; + font-family: var(--font-sans); + color: var(--color-ink); +} +.dw-db-peek__panel.is-wide { + width: 100vw; +} +.dw-db-peek__head { + position: sticky; + top: 0; + z-index: 1; + display: flex; + align-items: center; + gap: 4px; + padding: 8px 16px; + border-bottom: 1px solid var(--color-line); + background: var(--color-surface); +} +.dw-db-peek__db { + display: inline-flex; + align-items: center; + gap: 6px; + min-width: 0; + color: var(--color-ink-muted); + font-size: 13px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.dw-db-peek__grow { + flex: 1; +} +.dw-db-peek__props { + display: flex; + flex-direction: column; + gap: 2px; + padding: 24px 48px 12px; + border-bottom: 1px solid var(--color-line); +} +.dw-db-peek__panel.is-wide .dw-db-peek__props, +.dw-db-peek__panel.is-wide .dw-db-peek__body { + box-sizing: border-box; + width: min(900px, 100%); + margin: 0 auto; +} +.dw-db-peek__title { + width: 100%; + margin: 0 0 12px; + padding: 0; + border: none; + background: none; + color: var(--color-ink); + font: inherit; + font-size: 1.75rem; + font-weight: 700; + line-height: 1.25; +} +.dw-db-peek__title:focus { + outline: none; +} +.dw-db-peek__prop { + display: grid; + grid-template-columns: 11rem minmax(0, 1fr); + align-items: center; + min-height: 34px; +} +.dw-db-peek__label { + display: flex; + align-items: center; + gap: 6px; + overflow: hidden; + color: var(--color-ink-muted); + font-size: 13px; + white-space: nowrap; +} +.dw-db-peek__value { + display: flex; + align-items: center; + min-width: 0; + min-height: 30px; + padding: 2px 8px; + border-radius: var(--radius-sm); + cursor: pointer; +} +.dw-db-peek__value:hover { + background: var(--color-surface-hover); +} +.dw-db-peek__value.is-editing { + padding: 0; +} +.dw-db-peek__add { + align-self: flex-start; + margin-top: 4px; +} +.dw-db-peek__body { + padding: 16px 48px 64px; +} +.dw-db-peek__note { + color: var(--color-ink-faint); + font-size: 14px; +} +@media (max-width: 640px) { + .dw-db-peek__props, + .dw-db-peek__body { + padding-left: 16px; + padding-right: 16px; + } + .dw-db-peek__prop { + grid-template-columns: 8rem minmax(0, 1fr); + } +} diff --git a/Packages/editor/src/extensions.ts b/Packages/editor/src/extensions.ts index 1be1671..6db530a 100644 --- a/Packages/editor/src/extensions.ts +++ b/Packages/editor/src/extensions.ts @@ -8,6 +8,8 @@ import StarterKit from "@tiptap/starter-kit"; import { BlockLinks } from "./blocklinks"; import { docwellAlign, docwellTables, docwellTasks, HeadingShortcuts } from "./blocks"; import { Callout } from "./callout"; +import { Database } from "./database"; +import { DB_ORIGIN } from "./database/store"; import { DocwellCodeBlock } from "./codeblock"; import { DocwellHighlight, TextColor } from "./colors"; import { CommentHighlights } from "./comments"; @@ -65,6 +67,8 @@ export interface ExtensionOptions { * without carets, undo or synced pages of its own. */ syncedDoc?: Y.Doc; + /** Edits a database row's body (database/peek.ts): bound to this fragment of doc, without carets. */ + rowBody?: { doc: Y.Doc; fragment: Y.XmlFragment }; /** The Draw.io embed address (default https://embed.diagrams.net). */ drawioUrl?: string; /** Loads Mermaid; without it diagrams show as their text. */ @@ -75,6 +79,8 @@ export interface ExtensionOptions { loadPdf?: PdfLoader; /** Whether code blocks show line numbers unless one was switched on or off itself. */ codeLineNumbers?: boolean; + /** Shows a database row's body read-only (a row in a synced page). */ + rowFragmentReadOnly?: Y.XmlFragment; labels?: EditorLabels; /** Clicking highlighted comment text calls this with the comment id. */ onCommentSelect?: (id: string) => void; @@ -109,7 +115,7 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] { codeBlock: false, link: { openOnClick: false, autolink: true }, // Collaboration brings its own undo history, scoped to the local user. - undoRedo: opts.collab || opts.syncedDoc ? false : undefined, + undoRedo: opts.collab || opts.syncedDoc || opts.rowBody || opts.rowFragmentReadOnly ? false : undefined, }), Placeholder.configure({ placeholder: opts.placeholder ?? "Type '/' for commands…" }), DocwellImage.configure({ host: opts.files }), @@ -162,12 +168,50 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] { LinkCard.configure({ labels }), BlockLinks.configure({ labels, link: opts.blockLink, onCopied: opts.onBlockLinkCopied }), FindReplace, + Database.configure({ + labels, + doc: opts.collab?.provider.doc ?? opts.syncedDoc ?? opts.rowBody?.doc, + readOnlyDoc: !!opts.syncedDoc, + undoScope: !opts.rowBody, + files: opts.files, + people: opts.mentions, + me: () => { + const id = opts.mentions?.me; + return id ? { id, name: opts.collab?.user.name ?? "" } : null; + }, + // A row body is a page of its own: the same blocks, minus carets and synced pages. + rowExtensions: (fragment) => { + const doc = opts.collab?.provider.doc ?? opts.syncedDoc ?? opts.rowBody?.doc; + return docwellExtensions({ + rowBody: fragment && doc && !opts.syncedDoc ? { doc, fragment } : undefined, + files: opts.files, + mentions: opts.mentions, + pages: opts.pages, + links: opts.links, + onNavigate: opts.onNavigate, + drawioUrl: opts.drawioUrl, + loadMermaid: opts.loadMermaid, + loadExcalidraw: opts.loadExcalidraw, + loadPdf: opts.loadPdf, + codeLineNumbers: opts.codeLineNumbers, + labels: opts.labels, + placeholder: labels.database.bodyPlaceholder, + rowFragmentReadOnly: !!fragment && !!opts.syncedDoc ? fragment : undefined, + }); + }, + }), ]; - if (opts.syncedDoc) { + // Database edits (DB_ORIGIN) are undone with the text they were made with. + const yUndoOptions = { trackedOrigins: [DB_ORIGIN] }; + if (opts.rowBody) { + list.push(Collaboration.configure({ document: opts.rowBody.doc, fragment: opts.rowBody.fragment, yUndoOptions })); + } else if (opts.rowFragmentReadOnly) { + list.push(Collaboration.configure({ fragment: opts.rowFragmentReadOnly })); + } else if (opts.syncedDoc) { list.push(Collaboration.configure({ document: opts.syncedDoc })); } else if (opts.collab) { list.push( - Collaboration.configure({ document: opts.collab.provider.doc }), + Collaboration.configure({ document: opts.collab.provider.doc, yUndoOptions }), CollaborationCaret.configure({ provider: opts.collab.provider, user: opts.collab.user, render: renderCaret }), ); } diff --git a/Packages/editor/src/labels.ts b/Packages/editor/src/labels.ts index 5fa9e43..84a1f42 100644 --- a/Packages/editor/src/labels.ts +++ b/Packages/editor/src/labels.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { englishDatabaseLabels, type DatabaseLabels } from "./database/labels"; + /** * The editor's own words (menus, buttons). The editor has no i18n of its own: * hosts pass translated labels, and English is the default. @@ -141,6 +143,8 @@ export interface EditorLabels { /** The button that opens the date's journal page, where the host has journals. */ openJournal?: string; }; + /** The database block (database/labels.ts). */ + database: DatabaseLabels; } export const englishLabels: EditorLabels = { @@ -176,6 +180,7 @@ export const englishLabels: EditorLabels = { 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" }, syncedPage: { label: "Synced page", description: "Show another page here, always up to date" }, + database: { label: "Database", description: "Records in a table, board or calendar" }, newPage: { label: "New page", description: "Make a page and link it here" }, today: { label: "Today", description: "Insert today's date" }, tomorrow: { label: "Tomorrow", description: "Insert tomorrow's date" }, @@ -307,4 +312,5 @@ export const englishLabels: EditorLabels = { edit: "Change date", openJournal: "Open journal", }, + database: englishDatabaseLabels, }; diff --git a/Packages/editor/src/slash.ts b/Packages/editor/src/slash.ts index b14d583..f7d74bf 100644 --- a/Packages/editor/src/slash.ts +++ b/Packages/editor/src/slash.ts @@ -90,6 +90,9 @@ export function slashCommands( block("table", "table", ["grid", "rows", "columns", "spreadsheet"], (e, r) => e.chain().focus().deleteRange(r).insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(), ), + block("database", "database", ["kanban", "board", "calendar", "records", "tracker", "notion"], (e, r) => + e.chain().focus().deleteRange(r).insertDatabase().run(), + ), block("quote", "quote", ["blockquote", ">"], (e, r) => e.chain().focus().deleteRange(r).toggleBlockquote().run()), block("code", "code", ["codeblock", "```", "snippet"], (e, r) => e.chain().focus().deleteRange(r).toggleCodeBlock().run(), diff --git a/Packages/ui/src/icons.ts b/Packages/ui/src/icons.ts index e09aa9e..7aff16b 100644 --- a/Packages/ui/src/icons.ts +++ b/Packages/ui/src/icons.ts @@ -8,6 +8,7 @@ export const iconPaths = { page: ["M6 3h8l4 4v14H6z", "M14 3v4h4", "M9 12h6", "M9 16h6"], "chevron-right": ["M10 6l6 6-6 6"], + "chevron-left": ["M14 6l-6 6 6 6"], "chevron-down": ["M6 10l6 6 6-6"], "chevron-up": ["M6 14l6-6 6 6"], plus: ["M12 5v14", "M5 12h14"], @@ -126,6 +127,8 @@ export const iconPaths = { layers: ["M12 4l8 4-8 4-8-4z", "M4 12l8 4 8-4", "M4 16l8 4 8-4"], journal: ["M6 3h11a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6z", "M9 3v18", "M12 8h3", "M12 12h3"], sliders: ["M5 6h14", "M5 12h14", "M5 18h14", "M9 4v4", "M15 10v4", "M11 16v4"], + sort: ["M7 4v16", "M4 7l3-3 3 3", "M17 20V4", "M14 17l3 3 3-3"], + database: ["M4 5h16v14H4z", "M4 10h16", "M4 15h16", "M10 10v9"], } as const; export type IconName = keyof typeof iconPaths; diff --git a/Server/internal/convert/database.go b/Server/internal/convert/database.go new file mode 100644 index 0000000..f01bc1c --- /dev/null +++ b/Server/internal/convert/database.go @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +package convert + +import ( + "strings" + "time" +) + +// Databases (ADR-13) reach the converters as "database" nodes whose +// attrs.data holds the records, written by yrs from the page's Y.Doc. Every +// export draws one as its title and a table of the first view's visible +// columns, in the rows' own order. + +// expandDatabases replaces database nodes, at any depth, with a title and a table. +func expandDatabases(n Node) Node { + if len(n.Content) == 0 { + return n + } + out := make([]Node, 0, len(n.Content)) + for _, c := range n.Content { + if c.Type == "database" { + out = append(out, databaseNodes(c)...) + } else { + out = append(out, expandDatabases(c)) + } + } + n.Content = out + return n +} + +type dbColumn struct { + id, name, typ string + options map[string]string +} + +func databaseNodes(n Node) []Node { + data, _ := n.Attrs["data"].(map[string]any) + if data == nil { + return nil + } + var cols []dbColumn + for _, raw := range list(data["columns"]) { + c, _ := raw.(map[string]any) + id, _ := c["id"].(string) + if id == "" { + continue + } + col := dbColumn{id: id, typ: str(c["type"]), name: str(c["name"]), options: map[string]string{}} + for _, o := range list(c["options"]) { + if om, ok := o.(map[string]any); ok { + col.options[str(om["id"])] = str(om["name"]) + } + } + cols = append(cols, col) + } + // The first view decides which columns show. + hidden := map[string]bool{} + if views := list(data["views"]); len(views) > 0 { + if v, ok := views[0].(map[string]any); ok { + for _, h := range list(v["hidden"]) { + hidden[str(h)] = true + } + } + } + shown := cols[:0:0] + for _, c := range cols { + if c.typ == "title" || !hidden[c.id] { + shown = append(shown, c) + } + } + if len(shown) == 0 { + return nil + } + + cell := func(typ, text string) Node { + p := Node{Type: "paragraph"} + if text != "" { + p.Content = []Node{{Type: "text", Text: text}} + } + return Node{Type: typ, Content: []Node{p}} + } + head := Node{Type: "tableRow"} + for _, c := range shown { + head.Content = append(head.Content, cell("tableHeader", c.name)) + } + table := Node{Type: "table", Content: []Node{head}} + for _, raw := range list(data["rows"]) { + r, _ := raw.(map[string]any) + if r == nil { + continue + } + row := Node{Type: "tableRow"} + for _, c := range shown { + row.Content = append(row.Content, cell("tableCell", cellText(c, r))) + } + table.Content = append(table.Content, row) + } + var out []Node + if title := str(data["title"]); title != "" { + out = append(out, Node{Type: "paragraph", Content: []Node{{Type: "text", Text: title, Marks: []Mark{{Type: "bold"}}}}}) + } + return append(out, table) +} + +// cellText is a cell as text, like cellText in Packages/editor/src/database/model.ts. +func cellText(c dbColumn, row map[string]any) string { + cells, _ := row["cells"].(map[string]any) + v := cells[c.id] + switch c.typ { + case "createdTime": + if ms, ok := row["createdAt"].(float64); ok && ms > 0 { + return time.UnixMilli(int64(ms)).UTC().Format("2006-01-02") + } + return "" + case "createdBy": + if p, ok := row["createdBy"].(map[string]any); ok { + return str(p["name"]) + } + return "" + case "checkbox": + if v == true { + return "✓" + } + return "" + case "select": + return c.options[str(v)] + case "multiSelect": + var names []string + for _, id := range list(v) { + if name := c.options[str(id)]; name != "" { + names = append(names, name) + } + } + return strings.Join(names, ", ") + case "member", "attachment": + var names []string + for _, x := range list(v) { + if m, ok := x.(map[string]any); ok && str(m["name"]) != "" { + names = append(names, str(m["name"])) + } + } + return strings.Join(names, ", ") + case "progress": + if f, ok := v.(float64); ok { + return formatNumber(f) + "%" + } + return "" + } + switch x := v.(type) { + case string: + return x + case float64: + return formatNumber(x) + } + return "" +} + +func list(v any) []any { + l, _ := v.([]any) + return l +} + +func str(v any) string { + s, _ := v.(string) + return s +} diff --git a/Server/internal/convert/database_test.go b/Server/internal/convert/database_test.go new file mode 100644 index 0000000..4e39ef4 --- /dev/null +++ b/Server/internal/convert/database_test.go @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +package convert + +import ( + "strings" + "testing" +) + +func TestDatabaseExportsAsTable(t *testing.T) { + doc, err := Parse([]byte(`{"type":"doc","content":[{"type":"callout","content":[{"type":"database","attrs":{"id":"d","data":{ + "title":"Tasks", + "columns":[ + {"id":"t","name":"Name","type":"title"}, + {"id":"s","name":"Status","type":"select","options":[{"id":"o","name":"Doing","color":"blue"}]}, + {"id":"m","name":"Tags","type":"multiSelect","options":[{"id":"a","name":"red"},{"id":"b","name":"blue"}]}, + {"id":"c","name":"Done","type":"checkbox"}, + {"id":"h","name":"Secret","type":"text"} + ], + "rows":[ + {"id":"r1","createdAt":1,"cells":{"t":"Write","s":"o","m":["a","b"],"c":true,"h":"x"}}, + {"id":"r2","createdAt":2,"cells":{"t":"Ship"}} + ], + "views":[{"id":"v","type":"table","hidden":["h"]}] + }}}]}]}`)) + if err != nil { + t.Fatal(err) + } + md := Markdown(doc, Options{}) + for _, want := range []string{"**Tasks**", "| Name | Status | Tags | Done |", "| Write | Doing | red, blue | ✓ |", "| Ship |"} { + if !strings.Contains(md, want) { + t.Errorf("markdown lacks %q:\n%s", want, md) + } + } + if strings.Contains(md, "Secret") { + t.Errorf("hidden column exported:\n%s", md) + } + h := HTML(doc, Options{}) + if !strings.Contains(h, "") || !strings.Contains(h, "Doing") { + t.Errorf("html lacks the table:\n%s", h) + } + if _, err := DOCX("T", doc, DOCXOptions{}); err != nil { + t.Fatal(err) + } + if _, err := PDF("T", doc, PDFOptions{}); err != nil { + t.Fatal(err) + } +} diff --git a/Server/internal/convert/docx_export.go b/Server/internal/convert/docx_export.go index ac5ecf2..c89fa38 100644 --- a/Server/internal/convert/docx_export.go +++ b/Server/internal/convert/docx_export.go @@ -26,6 +26,7 @@ type DOCXOptions struct { // highlights, links and images are kept in a form FromDOCX reads back. // Diagrams and embeds become links, formulas their LaTeX. func DOCX(title string, doc Node, o DOCXOptions) ([]byte, error) { + doc = expandDatabases(doc) w := &docxWriter{o: o} if strings.TrimSpace(title) != "" { w.para(paraProps{style: "Title"}, func() { w.text(title, runProps{}) }) diff --git a/Server/internal/convert/export.go b/Server/internal/convert/export.go index f5fb90b..669de82 100644 --- a/Server/internal/convert/export.go +++ b/Server/internal/convert/export.go @@ -45,6 +45,7 @@ var safeURL = regexp.MustCompile(`^(?i)(https?://|mailto:|/|#|\.{0,2}/|[^:/?#]+( // HTML renders the document's body as HTML. func HTML(doc Node, o Options) string { + doc = expandDatabases(doc) var b strings.Builder for _, n := range doc.Content { writeHTML(&b, n, o) @@ -256,6 +257,7 @@ func writeHTMLText(b *strings.Builder, n Node, o Options) { // Markdown renders the document as CommonMark (with ~~strikethrough~~). func Markdown(doc Node, o Options) string { + doc = expandDatabases(doc) w := &mdWriter{o: o} w.blocks(doc.Content, "", "") return strings.TrimRight(w.b.String(), "\n") + "\n" diff --git a/Server/internal/convert/notion.go b/Server/internal/convert/notion.go index 4d5dcd4..edd8f5e 100644 --- a/Server/internal/convert/notion.go +++ b/Server/internal/convert/notion.go @@ -5,7 +5,9 @@ package convert import ( "archive/zip" "bytes" + "crypto/rand" "encoding/csv" + "encoding/hex" "errors" "fmt" "net/url" @@ -254,7 +256,9 @@ func (n *notionReader) resolve(dir, raw string) (string, bool) { return ref, true } -// notionTable turns a database's CSV into a table, its first row the header. +// notionTable turns a database's CSV into a database block (ADR-13): the +// header names the columns, the first column is the title, and the other +// columns get a type guessed from their values. func notionTable(data []byte) (Node, error) { r := csv.NewReader(bytes.NewReader(bytes.TrimPrefix(data, []byte(utf8BOM)))) r.FieldsPerRecord = -1 @@ -263,37 +267,153 @@ func notionTable(data []byte) (Node, error) { if err != nil { return Node{}, err } - cols := 0 - for _, row := range rows { - cols = max(cols, len(row)) - } doc := Node{Type: "doc"} - if cols == 0 { + if len(rows) == 0 || len(rows[0]) == 0 { return doc, nil } - table := Node{Type: "table"} - for i, row := range rows { - tr := Node{Type: "tableRow"} - for c := range cols { - kind := "tableCell" - if i == 0 { - kind = "tableHeader" - } - p := Node{Type: "paragraph"} - if c < len(row) { - if cell := strings.TrimSpace(row[c]); cell != "" { - p.Content = []Node{{Type: "text", Text: cell}} - } - } - attrs := map[string]any{"colspan": float64(1), "rowspan": float64(1), "colwidth": nil} - tr.Content = append(tr.Content, Node{Type: kind, Attrs: attrs, Content: []Node{p}}) + head, body := rows[0], rows[1:] + field := func(row []string, i int) string { + if i < len(row) { + return strings.TrimSpace(row[i]) } - table.Content = append(table.Content, tr) + return "" } - doc.Content = []Node{table} + type column struct { + id, name, typ string + options []map[string]any + byName map[string]string + } + colors := []string{"red", "orange", "yellow", "green", "teal", "blue", "purple", "pink"} + cols := make([]*column, len(head)) + for i, name := range head { + values := make([]string, 0, len(body)) + for _, row := range body { + values = append(values, field(row, i)) + } + typ := "title" + if i > 0 { + typ = guessColumnType(values) + } + if name = strings.TrimSpace(name); name == "" { + name = strconv.Itoa(i + 1) + } + cols[i] = &column{id: shortID(), name: name, typ: typ, byName: map[string]string{}} + } + var outRows []any + for n, row := range body { + cells := map[string]any{} + for i, c := range cols { + v := field(row, i) + if v == "" { + continue + } + switch c.typ { + case "number": + f, _ := strconv.ParseFloat(strings.ReplaceAll(v, ",", "."), 64) + cells[c.id] = f + case "checkbox": + if isYes(v) { + cells[c.id] = true + } + case "date": + cells[c.id] = v[:10] + case "select": + id, ok := c.byName[strings.ToLower(v)] + if !ok { + id = shortID() + c.byName[strings.ToLower(v)] = id + c.options = append(c.options, map[string]any{"id": id, "name": v, "color": colors[len(c.options)%len(colors)]}) + } + cells[c.id] = id + default: + cells[c.id] = v + } + } + outRows = append(outRows, map[string]any{"id": shortID(), "createdAt": float64(n), "cells": cells}) + } + columns := make([]any, len(cols)) + for i, c := range cols { + col := map[string]any{"id": c.id, "name": c.name, "type": c.typ} + if c.typ == "select" { + opts := make([]any, len(c.options)) + for j, o := range c.options { + opts[j] = o + } + col["options"] = opts + } + columns[i] = col + } + view := map[string]any{ + "id": shortID(), "name": "Table", "type": "table", "hidden": []any{}, "filters": []any{}, + "filterMode": "and", "sorts": []any{}, "widths": map[string]any{}, + } + db := map[string]any{"title": "", "columns": columns, "rows": outRows, "views": []any{view}} + doc.Content = []Node{{Type: "database", Attrs: map[string]any{"id": shortID(), "data": db}}} return doc, nil } +var isoDate = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}`) + +func isYes(v string) bool { + switch strings.ToLower(v) { + case "yes", "true", "1", "x", "✓": + return true + } + return false +} + +// guessColumnType is the column type for these values, like guessType in +// Packages/editor/src/database/csv.ts. +func guessColumnType(values []string) string { + var filled []string + for _, v := range values { + if v != "" { + filled = append(filled, v) + } + } + if len(filled) == 0 { + return "text" + } + all := func(ok func(string) bool) bool { + for _, v := range filled { + if !ok(v) { + return false + } + } + return true + } + switch { + case all(func(v string) bool { + _, err := strconv.ParseFloat(strings.ReplaceAll(v, ",", "."), 64) + return err == nil + }): + return "number" + case all(isoDate.MatchString): + return "date" + case all(func(v string) bool { + l := strings.ToLower(v) + return l == "yes" || l == "no" || l == "true" || l == "false" + }): + return "checkbox" + } + distinct := map[string]bool{} + for _, v := range filled { + distinct[strings.ToLower(v)] = true + } + short := all(func(v string) bool { return len([]rune(v)) <= 40 }) + if len(filled) >= 4 && short && float64(len(distinct)) <= max(2, float64(len(filled))/3) { + return "select" + } + return "text" +} + +// shortID is a random id for a database's columns, rows and views. +func shortID() string { + var b [5]byte + _, _ = rand.Read(b[:]) + return hex.EncodeToString(b[:]) +} + // notionAside finds the