PageSourceSearch

https://documents.gov.lk/_next/static/chunks/9bfaa8f5-583cf8cc4b39725f.js

js documents.gov.lk collected 2026-10-02 05:43:11 UTC 185,401 bytes, 12 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3093],{23903:(e,t,o)=>{let n,r,i,s;o.d(t,{AeC:()=>tf,Aou:()=>tm,C0D:()=>ns,D$X:()=>tS,DZE:()=>Y,Dhy:()=>ep,GK3:()=>tr,Ho3:()=>z,J2P:()=>t0,J73:()=>tZ,Jz8:()=>t9,Ovo:()=>nX,PC4:()=>tz,Pt1:()=>ei,QVP:()=>tF,Q_R:()=>on,UnQ:()=>t3,V4G:()=>ec,YLS:()=>oe,YLX:()=>ni,_7C:()=>es,aKi:()=>t8,afH:()=>ed,cK_:()=>eu,cXx:()=>t6,dV$:()=>eY,dcB:()=>en,e$J:()=>X,eg_:()=>nQ,fb2:()=>os,fng:()=>q,hzk:()=>nK,lNy:()=>nY,nL5:()=>or,neB:()=>ot,nrF:()=>Z,p0K:()=>tE,pCv:()=>eo,qmO:()=>K,qqL:()=>el,r1u:()=>t2,rFs:()=>er,rSw:()=>G,tM1:()=>oo,ucK:()=>ti,v63:()=>tQ,xFf:()=>W,xeQ:()=>ea,zTC:()=>t7});var l=o(75456),a=o(99480),d=o(40665),c=o(62450),h=o(81723),u=o(74804),p=o(41162),m=o(25038),f=o(66264),g=o(71510),b=o(11870),k=o(31890),v=o(63238),y=o(93604),w=o(75518),C=o(71482),E=o(33868),S=o(10134),x=o(74272),M=o(31502),T=o(58400),B=o(10856),P=o(53296),L=o(2050),A=o(10958),I=o(69390),H=o(19742),N=o(61628),O=o(15819),V=o(88581),D=Object.defineProperty,U=(e,t,o)=>((e,t,o)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);let _=d.YY.create({name:"uniqueID",priority:1e4,addOptions:()=>({attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>
1{if("u">typeof window&&window.__TEST_OPTIONS){let e=window.__TEST_OPTIONS;return void 0===e.mockID?e.mockID=0:e.mockID++,e.mockID.toString()}return(0,h.A)()},filterTransaction:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{let t={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...t,id:e[this.options.attributeName]}:t}}}}]},addProseMirrorPlugins(){let e=null,t=!1;return[new c.k_({key:new c.hs("uniqueID"),appendTransaction:(e,t,o)=>{let n=e.some(e=>e.docChanged)&&!t.doc.eq(o.doc),r=this.options.filterTransaction&&e.some(e=>{let t,o;return!(null!=(o=(t=this.options).filterTransaction)&&o.call(t,e))});if(!n||r)return;let{tr:i}=o,{types:s,attributeName:l,generateID:a}=this.options,c=(0,d.T7)(t.doc,e),{mapping:h}=c;if((0,d.FF)(c).forEach(({newRange:e})=>{var n;let r=(0,d.Nx)(o.doc,e,e=>s.includes(e.type.name)),c=function(e,t=JSON.stringify){let o={};return e.filter(e=>{let n=t(e);return!Object.prototype.hasOwnProperty.call(o,n)&&(o[n]=!0)})}((n=r.map(({node:e})=>e.attrs[l]).filter(e=>null!==e)).filter((e,t)=>n.indexOf(e)!==t));r.forEach(({node:e,pos:n})=>{let r,s=null==(r=i.doc.nodeAt(n))?void 0:r.attrs[l];if(null===s){let r=t.doc.type.createAndFill().content;if(null===t.doc.content.findDiffStart(r)){let t=JSON.parse(JSON.stringify(o.doc.toJSON()));if(t.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(t.content)===JSON.stringify(r.toJSON()))return void i.setNodeMarkup(n,void 0,{...e.attrs,[l]:"initialBlockId"})}i.setNodeMarkup(n,void 0,{...e.attrs,[l]:a()});return}let{deleted:d}=h.invert().mapResult(n);d&&c.includes(s)&&i.setNodeMarkup(n,void 0,{...e.attrs,[l]:a()})})}),i.steps.length)return i},view(t){let o=o=>{let n;e=null!=(n=t.dom.parentElement)&&n.contains(o.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(o,n)=>{let r;return t=e!==o.dom.parentElement||(null==(r=n.dataTransfer)?void 0:r.effectAllowed)==="copy",e=null,!1},paste:()=>(t=!0,!1)},transformPasted:e=>{if(!t)return e;let{types:o,attributeName:n}=this.options,r=e=>{let t=[];return e.forEach(e=>{if(e.isText)return void t.push(e);if(!o.includes(e.type.name))return void t.push(e.copy(r(e.content)));let i=e.type.create({...e.attrs,[n]:null},r(e.content),e.marks);t.push(i)}),l.FK.from(t)};return t=!1,new l.Ji(r(e.content),e.openStart,e.openEnd)}}})]}});function $(e){return"link"===e.type}function R(e){return"string"!=typeof e&&"link"===e.type}function F(e){return"string"!=typeof e&&"text"===e.type}function z(e){var t,o,n,r,i;return G(e)?{...e}:j(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:(null==(t=e.props)?void 0:t.backgroundColor)??"default",textColor:(null==(o=e.props)?void 0:o.textColor)??"default",textAlignment:(null==(n=e.props)?void 0:n.textAlignment)??"left",colspan:(null==(r=e.props)?void 0:r.colspan)??1,rowspan:(null==(i=e.props)?void 0:i.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function j(e){return null!=e&&"string"!=typeof e&&!Array.isArray(e)&&"tableCell"===e.type}function G(e){return j(e)&&void 0!==e.props&&void 0!==e.content}function W(e){return G(e)?e.props.colspan??1:1}function q(e){return G(e)?e.props.rowspan??1:1}class J extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function K(e,t=!0){let{"data-test":o,...n}=e;if(Object.keys(n).length>0&&t)throw Error("Object must be empty "+JSON.stringify(e))}function Y(e,t="Ctrl"){return"u">typeof navigator&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent))?e.replace("Mod","⌘"):e.replace("Mod",t)}function X(...e){return[...new Set(e.filter(e=>e).join(" ").split(" "))].join(" ")}let Z=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function Q(e,t,o,n){let r=document.createElement("div");for(let[t,n]of(r.className=X("bn-block-content",o.class),r.setAttribute("data-content-type",e),Object.entries(o)))"class"!==t&&r.setAttribute(t,n);let i=document.createElement(t);
1for(let[e,t]of(i.className=X("bn-inline-content",n.class),Object.entries(n)))"class"!==e&&i.setAttribute(e,t);return r.appendChild(i),{dom:r,contentDOM:i}}let ee=(e,t)=>{let o=eK(e,t.pmSchema);"blockContainer"===o.type.name&&(o=o.firstChild);let n=t.pmSchema.nodes[o.type.name].spec.toDOM;if(void 0===n)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let r=n(o);if("object"!=typeof r||!("dom"in r))throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r},et={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},eo=["backgroundColor","textColor"];function en(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function er(e){let t=e.split("/");return t.length&&""!==t[t.length-1]?t[t.length-1]:e}function ei(e){let t={};return Object.entries(e).filter(([e,t])=>!eo.includes(e)).forEach(([e,o])=>{t[e]={default:o.default,keepOnSplit:!0,parseHTML:t=>{let n=t.getAttribute(en(e));if(null===n)return null;if(void 0===o.default&&"boolean"===o.type||void 0!==o.default&&"boolean"==typeof o.default)return"true"===n||"false"!==n&&null;if(void 0===o.default&&"number"===o.type||void 0!==o.default&&"number"==typeof o.default){let e=parseFloat(n);return!Number.isNaN(e)&&Number.isFinite(e)?e:null}return n},renderHTML:t=>t[e]!==o.default?{[en(e)]:t[e]}:{}}}),t}function es(e,t,o,n){if("boolean"==typeof e)throw Error("Cannot find node position as getPos is a boolean, not a function.");let r=e(),i=o.state.doc.resolve(r).node().attrs.id;if(!i)throw Error("Block doesn't have id");let s=t.getBlock(i);if(s.type!==n)throw Error("Block type does not match");return s}function el(e,t,o,n,r=!1,i){let s=document.createElement("div");if(void 0!==i)for(let[e,t]of Object.entries(i))"class"!==e&&s.setAttribute(e,t);for(let[e,r]of(s.className=X("bn-block-content",(null==i?void 0:i.class)||""),s.setAttribute("data-content-type",t),Object.entries(o))){let t=n[e].default;eo.includes(e)||r===t||s.setAttribute(en(e),r)}return r&&s.setAttribute("data-file-block",""),s.appendChild(e.dom),void 0!==e.contentDOM&&(e.contentDOM.className=X("bn-inline-content",e.contentDOM.className)),{...e,dom:s}}function ea(e){return d.bP.create(e)}function ed(e,t){return{config:e,implementation:t}}function ec(e,t,o){return ed({type:e.name,content:"inline*"===e.config.content?"inline":"tableRow+"===e.config.content?"table":"none",propSchema:t},{node:e,requiredExtensions:o,toInternalHTML:ee,toExternalHTML:ee})}function eh(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eu(e,t){e.stopEvent=e=>("mousedown"===e.type&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function ep(e,t){let o=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t&&o.push({tag:"*",getAttrs(e){if("string"==typeof e)return!1;let o=null==t?void 0:t(e);return void 0!==o&&o}}),o}function em(e,t){let o=ea({name:e.type,content:"inline"===e.content?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes:()=>ei(e.propSchema),parseHTML:()=>ep(e,t.parse),renderHTML({HTMLAttributes:t}){let o=document.createElement("div");return el({dom:o,contentDOM:"inline"===e.content?o:void 0},e.type,{},e.propSchema,e.isFileBlock,t)},addNodeView(){return({getPos:o})=>{var n;let r=this.options.editor,i=es(o,r,this.editor,e.type),s=(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},l=el(t.render(i,r),i.type,i.props,e.propSchema,e.isFileBlock,s);return!1===e.isSelectable&&eu(l,this.editor),l}}});if(o.name!==e.type)throw Error("Node name does not match block type. This is a bug in BlockNote.");return ed(e,{node:o,toInternalHTML:(n,r)=>{var i;let s=(null==(i=o.options.domAttributes)?void 0:i.blockContent)||{};return el(t.render(n,r),n.type,n.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(n,r)=>{var i,s;let l=(null==(i=o.options.domAttributes)?void 0:i.blockContent)||{},a=null==(s=t.toExternalHTML)?void 0:s.call(t,n,r);return void 0===a&&(a=t.render(n,r)),el(a,n.type,n.props,e.propSchema,l)}})}function ef(e,t){let o=e.resolve(t);if(o.nodeAfter&&o.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:o.pos,node:o.nodeAfter};let n=o.depth,r=o.node(n);for(;n>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:o.before(n),node:r};n--,r=o.node(n)}let i=[];e.descendants((e,t)=>{e.type.isInGroup("bnBlock")&&i.push(t)}),console.warn(`Position ${t} is not within a blockContainer node.`);let s=e.resolve(i.find(e=>e>=t)||i[i.length-1]);return{posBeforeNode:s.pos,node:s.nodeAfter}}function eg(e,t){if(!e.type.isInGroup("bnBlock"))throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);let o=t+e.nodeSize,n={node:e,beforePos:t,afterPos:o};
1if("blockContainer"===e.type.name){let o,r;if(e.forEach((e,n)=>{if("blockContent"===e.type.spec.group){let r=t+n+1,i=r+e.nodeSize;o={node:e,beforePos:r,afterPos:i}}else if("blockGroup"===e.type.name){let o=t+n+1,i=o+e.nodeSize;r={node:e,beforePos:o,afterPos:i}}}),!o)throw Error(`blockContainer node does not contain a blockContent node in its children: ${e}`);return{isBlockContainer:!0,bnBlock:n,blockContent:o,childContainer:r,blockNoteType:o.node.type.name}}if(!n.node.type.isInGroup("childContainer"))throw Error(`bnBlock node is not in the childContainer group: ${n.node}`);return{isBlockContainer:!1,bnBlock:n,childContainer:n,blockNoteType:n.node.type.name}}function eb(e){return eg(e.node,e.posBeforeNode)}function ek(e){if(!e.nodeAfter)throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return eg(e.nodeAfter,e.pos)}function ev(e){return eb(ef(e.doc,e.selection.anchor))}function ey(e){return eb(ef(e.doc,e.selection.anchor))}function ew(e){return"doc"in e?e.doc.type.schema:e.type.schema}function eC(e){return e.cached.blockNoteEditor}function eE(e){return eC(e).schema}function eS(e){return eE(e).blockSchema}function ex(e){return eE(e).inlineContentSchema}function eM(e){return eE(e).styleSchema}function eT(e){return eC(e).blockCache}function eB(e,t,o){var n,r;let i={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},s=[];e.content.forEach((e,n,r)=>{let l={cells:[]};0===r&&e.content.forEach(e=>{let t=e.attrs.colwidth;null==t&&(t=Array(e.attrs.colspan??1).fill(void 0)),i.columnWidths.push(...t)}),l.cells=e.content.content.map((e,n)=>(s[r]||(s[r]=[]),s[r][n]="tableHeader"===e.type.name,{type:"tableCell",content:e.content.content.map(e=>eP(e,t,o)).reduce((e,t)=>{if(!e.length)return t;let o=e[e.length-1],n=t[0];return n&&F(o)&&F(n)&&JSON.stringify(o.styles)===JSON.stringify(n.styles)?(o.text+=`
2`+n.text,e.push(...t.slice(1))):e.push(...t),e},[]),props:{colspan:e.attrs.colspan,rowspan:e.attrs.rowspan,backgroundColor:e.attrs.backgroundColor,textColor:e.attrs.textColor,textAlignment:e.attrs.textAlignment}})),i.rows.push(l)});for(let e=0;e<s.length;e++)null!=(n=s[e])&&n.every(e=>e)&&(i.headerRows=(i.headerRows??0)+1);for(let e=0;e<(null==(r=s[0])?void 0:r.length);e++)null!=s&&s.every(t=>t[e])&&(i.headerCols=(i.headerCols??0)+1);return i}function eP(e,t,o){let n,r=[];return e.content.forEach(e=>{let i;if("hardBreak"===e.type.name){if(n)if(F(n))n.text+=`
3`;else if($(n))n.content[n.content.length-1].text+=`
4`;else throw Error("unexpected");else n={type:"text",text:`
5`,styles:{}};return}if("link"!==e.type.name&&"text"!==e.type.name)return t[e.type.name]?(n&&(r.push(n),n=void 0),void r.push(function(e,t,o){let n;if("text"===e.type.name||"link"===e.type.name)throw Error("unexpected");let r={},i=t[e.type.name];for(let[t,o]of Object.entries(e.attrs)){if(!i)throw Error("ic node is of an unrecognized type: "+e.type.name);t in i.propSchema&&(r[t]=o)}return n="styled"===i.content?eP(e,t,o):void 0,{type:e.type.name,props:r,content:n}}(e,t,o))):void console.warn("unrecognized inline content type",e.type.name);let s={};for(let t of e.marks)if("link"===t.type.name)i=t;else{let e=o[t.type.name];if(!e){if(t.type.spec.blocknoteIgnore)continue;throw Error(`style ${t.type.name} not found in styleSchema`)}if("boolean"===e.propSchema)s[e.type]=!0;else if("string"===e.propSchema)s[e.type]=t.attrs.stringValue;else throw new J(e.propSchema)}n?F(n)?i?(r.push(n),n={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):JSON.stringify(n.styles)===JSON.stringify(s)?n.text+=e.textContent:(r.push(n),n={type:"text",text:e.textContent,styles:s}):$(n)&&(i?n.href===i.attrs.href?JSON.stringify(n.content[n.content.length-1].styles)===JSON.stringify(s)?n.content[n.content.length-1].text+=e.textContent:n.content.push({type:"text",text:e.textContent,styles:s}):(r.push(n),n={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):(r.push(n),n={type:"text",text:e.textContent,styles:s})):n=i?{type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}:{type:"text",text:e.textContent,styles:s}}),n&&r.push(n),r}function eL(e,t,o=eS(t),n=ex(t),r=eM(t),i=eT(t)){var s;let l;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.n
5ame);let a=null==i?void 0:i.get(e);if(a)return a;let d=eg(e,0),c=d.bnBlock.node.attrs.id;null===c&&(c=_.options.generateID());let h=o[d.blockNoteType];if(!h)throw Error("Block is of an unrecognized type: "+d.blockNoteType);let u={};for(let[t,o]of Object.entries({...e.attrs,...d.isBlockContainer?d.blockContent.node.attrs:{}})){let e=h.propSchema;t in e&&(void 0!==e[t].default||void 0!==o)&&(u[t]=o)}let p=o[d.blockNoteType],m=[];if(null==(s=d.childContainer)||s.node.forEach(e=>{m.push(eL(e,t,o,n,r,i))}),"inline"===p.content){if(!d.isBlockContainer)throw Error("impossible");l=eP(d.blockContent.node,n,r)}else if("table"===p.content){if(!d.isBlockContainer)throw Error("impossible");l=eB(d.blockContent.node,n,r)}else if("none"===p.content)l=void 0;else throw new J(p.content);let f={id:c,type:p.type,props:u,content:l,children:m};return null==i||i.set(e,f),f}function eA(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eI(e,t){return{config:{type:e.name,propSchema:t},implementation:{mark:e}}}function eH(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eN(e){let{height:t,width:o}=eD(e),n=Array(t).fill(!1).map(()=>Array(o).fill(null)),r=(e,r)=>{for(let i=e;i<t;i++)for(let e=r;e<o;e++)if(!n[i][e])return{row:i,col:e};throw Error("Unable to create occupancy grid for table, no more available cells")};for(let t=0;t<e.content.rows.length;t++)for(let o=0;o<e.content.rows[t].cells.length;o++){let i=z(e.content.rows[t].cells[o]),s=q(i),l=W(i),{row:a,col:d}=r(t,o);for(let e=a;e<a+s;e++)for(let r=d;r<d+l;r++){if(n[e][r])throw Error(`Unable to create occupancy grid for table, cell at ${e},${r} is already occupied`);n[e][r]={row:t,col:o,rowspan:s,colspan:l,cell:i}}}return n}function eO(e){let t=new Set;return e.map(e=>({cells:e.map(e=>!t.has(e.row+":"+e.col)&&(t.add(e.row+":"+e.col),e.cell)).filter(e=>!1!==e)}))}function eV(e,t,o=eN(t)){for(let t=0;t<o.length;t++)for(let n=0;n<o[t].length;n++){let r=o[t][n];if(r.row===e.row&&r.col===e.col)return{row:t,col:n,cell:r.cell}}throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function eD(e){let t=e.content.rows.length,o=0;return e.content.rows.forEach(e=>{let t=0;e.cells.forEach(e=>{t+=W(e)}),o=Math.max(o,t)}),{height:t,width:o}}function eU(e,t,o=eN(t)){var n;let r=null==(n=o[e.row])?void 0:n[e.col];if(r)return{row:r.row,col:r.col,cell:r.cell}}function e_(e,t){var o;let n=eN(e);if(t<0||t>=n.length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(o=n[r])?void 0:o[0];if(!e)return[];r+=e.rowspan}let i=Array(n[0].length).fill(!1).map((t,o)=>eU({row:r,col:o},e,n)).filter(e=>void 0!==e);return i.filter((e,t)=>i.findIndex(t=>t.row===e.row&&t.col===e.col)===t)}function e$(e,t){var o;let n=eN(e);if(t<0||t>=n[0].length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(o=n[0])?void 0:o[r];if(!e)return[];r+=e.colspan}let i=Array(n.length).fill(!1).map((t,o)=>eU({row:o,col:r},e,n)).filter(e=>void 0!==e);return i.filter((e,t)=>i.findIndex(t=>t.row===e.row&&t.col===e.col)===t)}function eR(e){return!e||(j(e)?eR(e.content):"string"==typeof e?0===e.length:!!Array.isArray(e)&&e.every(e=>"string"==typeof e?0===e.length:F(e)?0===e.text.length:!!R(e)&&("string"==typeof e.content?0===e.content.length:e.content.every(e=>0===e.text.length))))}function eF(e,t,o){let n=e_(e,o);if(!n.some(e=>q(e.cell)>1))return!0;let r=o,i=o;return n.forEach(e=>{let t=q(e.cell);r=Math.max(r,e.row+t-1),i=Math.min(i,e.row)}),t<o?o===r:o===i}function ez(e,t,o){let n=e$(e,o);if(!n.some(e=>W(e.cell)>1))return!0;let r=o,i=o;return n.forEach(e=>{let t=W(e.cell);r=Math.max(r,e.col+t-1),i=Math.min(i,e.col)}),t<o?o===r:o===i}function ej(e,t,o,n){let r=[];for(let[n,i]of Object.entries(e.styles||{})){let e=o[n];if(!e)throw Error(`style ${n} not found in styleSchema`);if("boolean"===e.propSchema)i&&r.push(t.mark(n));else if("string"===e.propSchema)i&&r.push(t.mark(n,{stringValue:i}));else throw new J(e.propSchema)}return n&&t.nodes[n].spec.code?e.text.length>0?[t.text(e.text,r)]:[]:e.text.split(/(\n)/g).filter(e=>e.length>0).map(e=>e===`
6`?t.nodes.hardBreak.createChecked():t.text(e,r))}function eG(e,t,o,n){let r=[];if("string"==typeof e)return r.push(...ej({text:e,styles:{}},t,o,n)),r;for(let i of e)r.push(...ej(i,t,o,n));return r}function eW(e,t,o,n=eM(t)){let r=[];for(let i of e)"string"==typeof i?r.push(...eG(i,t,n,o)):R(i)?r.push(...function(e,t,o){let n=t.marks.link.create({href:e.href});return eG(e.content,t,o).map(e=>
6{if("text"===e.type.name)return e.mark([...e.marks,n]);if("hardBreak"===e.type.name)return e;throw Error("unexpected node type")})}(i,t,n)):F(i)?r.push(...eG([i],t,n,o)):r.push(eJ(i,t,n));return r}function eq(e,t,o=eM(t)){let n=[],r=Array(e.headerRows??0).fill(!0),i=Array(e.headerCols??0).fill(!0),s=e.columnWidths??[];for(let l=0;l<e.rows.length;l++){let a=e.rows[l],d=[],c=r[l];for(let n=0;n<a.cells.length;n++){let r=a.cells[n],h=i[n],u=void 0,p=null,m=eV({row:l,col:n},{content:e}),f=s[m.col]?[s[m.col]]:null;if(r)if("string"==typeof r)p=t.text(r);else if(j(r)){r.content&&(p=eW(r.content,t,"tableParagraph",o));let e=W(r);e>1&&(f=Array(e).fill(!1).map((e,t)=>s[m.col+t]??void 0))}else p=eW(r,t,"tableParagraph",o);let g=t.nodes[h||c?"tableHeader":"tableCell"].createChecked({...j(r)?r.props:{},colwidth:f},t.nodes.tableParagraph.createChecked(u,p));d.push(g)}let h=t.nodes.tableRow.createChecked({},d);n.push(h)}return n}function eJ(e,t,o){let n,r=e.type;if(void 0===r&&(r="paragraph"),!t.nodes[r])throw Error(`node type ${r} not found in schema`);if(e.content)if("string"==typeof e.content){let i=eW([e.content],t,r,o);n=t.nodes[r].createChecked(e.props,i)}else if(Array.isArray(e.content)){let i=eW(e.content,t,r,o);n=t.nodes[r].createChecked(e.props,i)}else if("tableContent"===e.content.type){let i=eq(e.content,t,o);n=t.nodes[r].createChecked(e.props,i)}else throw new J(e.content.type);else n=t.nodes[r].createChecked(e.props);return n}function eK(e,t,o=eM(t)){let n=e.id;void 0===n&&(n=_.options.generateID());let r=[];if(e.children)for(let n of e.children)r.push(eK(n,t,o));if(!e.type||t.nodes[e.type].isInGroup("blockContent")){let i=eJ(e,t,o),s=r.length>0?t.nodes.blockGroup.createChecked({},r):void 0;return t.nodes.blockContainer.createChecked({id:n,...e.props},s?[i,s]:i)}if(t.nodes[e.type].isInGroup("bnBlock"))return t.nodes[e.type].createChecked({id:n,...e.props},r);throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}function eY(e,t){let o,n;if(t.firstChild.descendants((t,r)=>!o&&(!eX(t)||t.attrs.id!==e||(o=t,n=r+1,!1))),void 0!==o&&void 0!==n)return{node:o,posBeforeNode:n}}function eX(e){return e.type.isInGroup("bnBlock")}function eZ(e,t,o){let n=ew(e),r=o.map(e=>eK(e,n)),i=new Set(t.map(e=>"string"==typeof e?e:e.id)),s=[],l="string"==typeof t[0]?t[0]:t[0].id,a=0;if(e.doc.descendants((t,d)=>{if(0===i.size)return!1;if(!t.type.isInGroup("bnBlock")||!i.has(t.attrs.id))return!0;if(s.push(eL(t,n)),i.delete(t.attrs.id),o.length>0&&t.attrs.id===l){let t=e.doc.nodeSize;e.insert(d,r);let o=e.doc.nodeSize;a+=t-o}let c=e.doc.nodeSize,h=e.doc.resolve(d-a);"blockGroup"===h.node().type.name&&"doc"!==h.node(h.depth-1).type.name&&1===h.node().childCount?e.delete(h.before(),h.after()):e.delete(d-a,d-a+t.nodeSize);let u=e.doc.nodeSize;return a+=c-u,!1}),i.size>0)throw Error("Blocks with the following IDs could not be found in the editor: "+[...i].join(`
7`));return{insertedBlocks:r.map(e=>eL(e,n)),removedBlocks:s}}let eQ=(e,t)=>({tr:o,dispatch:n})=>(n&&e0(o,e,t),!0);function e0(e,t,o,n,r){let i=ek(e.doc.resolve(t)),s=null;"table"===i.blockNoteType&&(s=function(e){let t="selection"in e?e.selection:null;if(!(t instanceof c.U3))return null;let o=e.doc.resolve(t.head),n=-1,r=-1;for(let e=o.depth;e>=0;e--){let t=o.node(e).type.name;if(n<0&&("tableCell"===t||"tableHeader"===t)&&(n=e),"table"===t){r=e;break}}if(n<0||r<0)return null;let i=o.before(n),s=o.before(r),l=e.doc.nodeAt(s);if(!l||"table"!==l.type.name)return null;let a=u.J3.get(l),d=i-(s+1),h=a.map.indexOf(d);if(h<0)return null;let p=Math.floor(h/a.width);return{row:p,col:h%a.width,offset:Math.max(0,t.head-(i+1+1))}}(e));let a=ew(e);if(void 0!==n&&void 0!==r&&n>r)throw Error("Invalid replaceFromPos or replaceToPos");let d=a.nodes[i.blockNoteType],h=a.nodes[o.type||i.blockNoteType],p=h.isInGroup("bnBlock")?h:a.nodes.blockContainer;if(i.isBlockContainer&&h.isInGroup("blockContent")){let t=void 0!==n&&n>i.blockContent.beforePos&&n<i.blockContent.afterPos?n-i.blockContent.beforePos-1:void 0,s=void 0!==r&&r>i.blockContent.beforePos&&r<i.blockContent.afterPos?r-i.blockContent.beforePos-1:void 0;
7e1(o,e,i),function(e,t,o,n,r,i,s){let a=ew(t),d="keep";if(e.content)if("string"==typeof e.content)d=eW([e.content],a,n.name);else if(Array.isArray(e.content))d=eW(e.content,a,n.name);else if("tableContent"===e.content.type)d=eq(e.content,a);else throw new J(e.content.type);else""===o.spec.content||n.spec.content!==o.spec.content&&(d=[]);if("keep"===d)t.setNodeMarkup(r.blockContent.beforePos,n,{...r.blockContent.node.attrs,...e.props});else if(void 0!==i||void 0!==s){t.setNodeMarkup(r.blockContent.beforePos,n,{...r.blockContent.node.attrs,...e.props});let o=r.blockContent.beforePos+1+(i??0),a=r.blockContent.beforePos+1+(s??r.blockContent.node.content.size),c=t.doc.resolve(r.blockContent.beforePos).depth,h=t.doc.resolve(o).depth,u=t.doc.resolve(a).depth;t.replace(o,a,new l.Ji(l.FK.from(d),h-c-1,u-c-1))}else t.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,n.createChecked({...r.blockContent.node.attrs,...e.props},d))}(o,e,d,h,i,t,s)}else if(!i.isBlockContainer&&h.isInGroup("bnBlock"))e1(o,e,i);else{let t=eL(i.bnBlock.node,a);e.replaceWith(i.bnBlock.beforePos,i.bnBlock.afterPos,eK({children:t.children,...o},a));return}
7e.setNodeMarkup(i.bnBlock.beforePos,p,{...i.bnBlock.node.attrs,...o.props}),s&&function(e,t,o){var n;if("table"!==t.blockNoteType)return;let r=-1;if(t.isBlockContainer)r=e.mapping.map(t.blockContent.beforePos);else{let o=e.mapping.map(t.bnBlock.beforePos),i=o+((null==(n=e.doc.nodeAt(o))?void 0:n.nodeSize)||0);e.doc.nodesBetween(o,i,(e,t)=>"table"!==e.type.name||(r=t,!1))}let i=r>=0?e.doc.nodeAt(r):null;if(!i||"table"!==i.type.name)return;let s=u.J3.get(i),l=Math.max(0,Math.min(o.row,s.height-1)),a=Math.max(0,Math.min(o.col,s.width-1)),d=l*s.width+a,h=s.map[d];if(null==h)return;let p=r+1+h+1,m=e.doc.nodeAt(p),f=p+1,g=m?m.content.size:0,b=f+Math.max(0,Math.min(o.offset,g));"selection"in e&&e.setSelection(c.U3.create(e.doc,b))}(e,i,s)}function e1(e,t,o){let n=ew(t);if(void 0!==e.children&&e.children.length>0){let r=e.children.map(e=>eK(e,n));if(o.childContainer)t.step(new a.Ln(o.childContainer.beforePos+1,o.childContainer.afterPos-1,new l.Ji(l.FK.from(r),0,0)));else{if(!o.isBlockContainer)throw Error("impossible");t.insert(o.blockContent.afterPos,n.nodes.blockGroup.createChecked({},r))}}}function e2(e){let t=Array.from(e.classList).filter(e=>!e.startsWith("bn-"))||[];t.length>0?e.className=t.join(" "):e.removeAttribute("class")}function e3(e,t,o,n){let r;if(t)if("string"==typeof t)r=eW([t],e.pmSchema);else if(Array.isArray(t))r=eW(t,e.pmSchema);else if("tableContent"===t.type)r=eq(t,e.pmSchema);else throw new J(t.type);else throw Error("blockContent is required");let i=o.serializeFragment(l.FK.from(r),n);return 1===i.nodeType&&e2(i),i}let e4=(e,t,o,n,r,i,s)=>{for(let l of o)!function(e,t,o,n,r,i,s){var l,a,d,c,h,u,p,m;let f,g=(null==s?void 0:s.document)??document,b=t.pmSchema.nodes.blockContainer,k=o.props;if(!o.props)for(let[e,n]of(k={},Object.entries(t.schema.blockSchema[o.type].propSchema)))void 0!==n.default&&(k[e]=n.default);let v=Array.from((null==(a=null==(l=b.spec)?void 0:l.toDOM)?void 0:a.call(l,b.create({id:o.id,...k}))).dom.attributes),y=t.blockImplementations[o.type].implementation.toExternalHTML({...o,props:k},t),w=g.createDocumentFragment();if(y.dom.classList.contains("bn-block-content")){for(let e of[...v,...Array.from(y.dom.attributes)].filter(e=>e.name.startsWith("data")&&"data-content-type"!==e.name&&"data-file-block"!==e.name&&"data-node-view-wrapper"!==e.name&&"data-node-type"!==e.name&&"data-id"!==e.name&&"data-index"!==e.name&&"data-editable"!==e.name))y.dom.firstChild.setAttribute(e.name,e.value);e2(y.dom.firstChild),w.append(...Array.from(y.dom.childNodes))}else w.append(y.dom);if(y.contentDOM&&o.content){let e=e3(t,o.content,n,s);y.contentDOM.appendChild(e)}if(r.has(o.type)?f="OL":i.has(o.type)&&(f="UL"),f){if((null==(d=e.lastChild)?void 0:d.nodeName)!==f){let t=g.createElement(f);"OL"===f&&null!=k&&k.start&&(null==k?void 0:k.start)!==1&&t.setAttribute("start",k.start+""),e.append(t)}let t=g.createElement("li");t.append(w),e.lastChild.appendChild(t)}else e.append(w);if(o.children&&o.children.length>0){let l=g.createDocumentFragment();if(e4(l,t,o.children,n,r,i,s),(null==(c=e.lastChild)?void 0:c.nodeName)==="UL"||(null==(h=e.lastChild)?void 0:h.nodeName)==="OL")for(;(null==(u=l.firstChild)?void 0:u.nodeName)==="UL"||(null==(p=l.firstChild)?void 0:p.nodeName)==="OL";)e.lastChild.lastChild.appendChild(l.firstChild);t.pmSchema.nodes[o.type].isInGroup("blockContent")?e.append(l):null==(m=y.contentDOM)||m.append(l)}}(e,t,l,n,r,i,s)},e5=(e,t)=>{let o=l.ZF.fromSchema(e);return{exportBlocks:(e,n)=>{let r=((e,t,o,n,r,i)=>{let s=((null==i?void 0:i.document)??document).createDocumentFragment();return e4(s,e,t,o,n,r,i),s})(t,e,o,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),n),i=document.createElement("div");return i.append(r),i.innerHTML},exportInlineContent:(e,n)=>{let r=e3(t,e,o,n),i=document.createElement("div");return i.append(r.cloneNode(!0)),i.innerHTML}}},e9=(e,t,o,n)=>{var r;let i=e.pmSchema.nodes.blockGroup,s=i.spec.toDOM(i.create({})),a=function e(t,o,n,r){let i=((null==r?void 0:r.document)??document).createDocumentFragment(),s=0;for(let a of o){"numberedListItem"===a.type?s++:s=0;let o=function(t,o,n,r,i){var s,a,d,c,h;let u=t.pmSchema.nodes.blockContainer,p=o.props;if(!o.props)for(let[e,n]of(p={},Object.entries(t.schema.blockSchema[o.type].propSchema)))void 0!==n.default&&(p[e]=n.default);let m=t.blockImplementations[o.type].implementation.toInternalHTML({...o,props:p},t);
7if("numberedListItem"===o.type&&m.dom.setAttribute("data-index",r.toString()),m.contentDOM&&o.content){let e=function(e,t,o,n,r){let i;if(t)if("string"==typeof t)i=eW([t],e.pmSchema,n);else if(Array.isArray(t))i=eW(t,e.pmSchema,n);else if("tableContent"===t.type)i=eq(t,e.pmSchema);else throw new J(t.type);else throw Error("blockContent is required");return o.serializeFragment(l.FK.from(i),r)}(t,o.content,n,o.type,i);m.contentDOM.appendChild(e)}if(t.pmSchema.nodes[o.type].isInGroup("bnBlock")){if(o.children&&o.children.length>0){let r=e(t,o.children,n,i);null==(s=m.contentDOM)||s.append(r)}return m.dom}let f=null==(d=null==(a=u.spec)?void 0:a.toDOM)?void 0:d.call(a,u.create({id:o.id,...p}));return null==(c=f.contentDOM)||c.appendChild(m.dom),o.children&&o.children.length>0&&(null==(h=f.contentDOM)||h.appendChild(e9(t,o.children,n,i))),f.dom}(t,a,n,s,r);i.appendChild(o)}return i}(e,t,o,n);return null==(r=s.contentDOM)||r.appendChild(a),s.dom};function e7(e){let t={},o={},n=ew(e);return e.descendants((r,i)=>{if(!eX(r))return!0;let s=function(e,t){if(0===t)return;let o=e.resolve(t);for(let e=o.depth;e>0;e--){let t=o.node(e);if(eX(t))return t.attrs.id}}(e,i),l=s??"__root__";o[l]||(o[l]=[]);let a=eL(r,n);return t[r.attrs.id]={block:a,parentId:s},o[l].push(r.attrs.id),!0}),{byId:t,childrenByParent:o}}function e6(e,t=[]){let o=e.getMeta("paste")?{type:"paste"}:"drop"===e.getMeta("uiEvent")?{type:"drop"}:e.getMeta("history$")?{type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")?e.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"}:{type:"local"},n=(0,d.T7)(e.before,[e,...t]),r=e7(n.before),i=e7(n.doc),s=[],l=new Set;Object.keys(i.byId).filter(e=>!(e in r.byId)).forEach(e=>{s.push({type:"insert",block:i.byId[e].block,source:o,prevBlock:void 0}),l.add(e)}),Object.keys(r.byId).filter(e=>!(e in i.byId)).forEach(e=>{s.push({type:"delete",block:r.byId[e].block,source:o,prevBlock:void 0}),l.add(e)}),Object.keys(i.byId).filter(e=>e in r.byId).forEach(e=>{var t,n;let a=r.byId[e],d=i.byId[e];a.parentId!==d.parentId?(s.push({type:"move",block:d.block,prevBlock:a.block,source:o,prevParent:a.parentId?null==(t=r.byId[a.parentId])?void 0:t.block:void 0,currentParent:d.parentId?null==(n=i.byId[d.parentId])?void 0:n.block:void 0}),l.add(e)):p({...a.block,children:void 0},{...d.block,children:void 0})||(s.push({type:"update",block:d.block,prevBlock:a.block,source:o}),l.add(e))});let a=r.childrenByParent,c=i.childrenByParent,h=new Set([...Object.keys(a),...Object.keys(c)]),u=new Set;return h.forEach(e=>{let t=function(e,t){let o=new Set;if(!e||!t)return o;let n=new Set(e),r=t.filter(e=>n.has(e)),i=e.filter(e=>r.includes(e));if(i.length<=1||r.length<=1)return o;let s={};for(let e=0;e<i.length;e++)s[i[e]]=e;let l=r.map(e=>s[e]),a=l.length,d=[],c=[],h=Array(a).fill(-1),u=(e,t)=>{let o=0,n=e.length;for(;o<n;){let r=o+n>>>1;e[r]<t?o=r+1:n=r}return o};for(let e=0;e<a;e++){let t=l[e],o=u(d,t);o>0&&(h[e]=c[o-1]),o===d.length?(d.push(t),c.push(e)):(d[o]=t,c[o]=e)}let p=new Set,m=c[c.length-1]??-1;for(;-1!==m;)p.add(m),m=h[m];for(let e=0;e<r.length;e++)p.has(e)||o.add(r[e]);return o}(a[e],c[e]);0!==t.size&&t.forEach(t=>{var n,a;let d=r.byId[t],c=i.byId[t];!d||!c||d.parentId!==c.parentId||l.has(t)||(d.parentId??"__root__")!==e||u.has(t)||(u.add(t),s.push({type:"move",block:c.block,prevBlock:d.block,source:o,prevParent:d.parentId?null==(n=r.byId[d.parentId])?void 0:n.block:void 0,currentParent:c.parentId?null==(a=i.byId[c.parentId])?void 0:a.block:void 0}),l.add(t))})}),s}let e8=(e,t)=>{let o=e.querySelector(t);if(!o)return;let n=e.querySelector("figcaption");return{targetElement:o,caption:(null==n?void 0:n.textContent)??void 0}},te=(e,t,o,n,r)=>{let i=document.createElement("div");if(i.className="bn-file-block-content-wrapper",""===e.props.url){let o=((e,t,o,n)=>{let r=document.createElement("div");r.className="bn-add-file-button";let i=document.createElement("div");i.className="bn-add-file-button-icon",n?i.appendChild(n):i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(i);let s=document.createElement("p");s.className="bn-add-file-button-text",s.innerHTML=o||t.dictionary.file_blocks.file.add_button_text,r.appendChild(s);let l=e=>{e.preventDefault()},a=()=>{t.transact(o=>o.setMeta(t.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",l,!0),r.addEventListener("click",a,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",l,!0),r.removeEventListener("click",a,!0)}}})(e,t,n,r);i.appendChild(o.dom);let s=t.onUploadStart(t=>{if(t===e.id){i.removeChild(o.dom);let e=document.createElement("div");e.className="bn-file-loading-preview",e.textContent="Loading...",i.appendChild(e)}});return{dom:i,destroy:()=>{s(),o.destroy()}}}let s={dom:i};if(!1!==e.props.showPreview&&o)i.appendChild(o.dom);else{let t=(e=>{let t=document.createElement("div");t.className="bn-file-name-with-icon";let o=document.createElement("div");o.className="bn-file-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',t.appendChild(o);let n=document.createElement("p");return n.className="bn-file-name",n.textContent=e.props.name,t.appendChild(n),{dom:t}})(e);i.appendChild(t.dom),s.destroy=()=>{var e;null==(e=t.destroy)||e.call(t)}}if(e.props.caption){let t=document.createElement("p");t.className="bn-file-caption",t.textContent=e.props.caption,i.appendChild(t)}return s},tt=(e,t)=>{let o=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=t,o.appendChild(e),o.appendChild(n),{dom:o}},to=(e,t)=>{let o=document.createElement("div"),n=document.createElement("p");return n.textContent=t,o.appendChild(e),o.appendChild(n),{dom:o}},tn=e=>({url:e.src||void 0}),tr={type:"audio",propSchema:{backgroundColor:et.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},ti=e=>{if("AUDIO"===e.tagName)return e.closest("figure")?void 0:tn(e);if("FIGURE"===e.tagName){let t=e8(e,"audio");if(!t)return;let{targetElement:o,caption:n}=t;return{...tn(o),caption:n}}},ts=em(tr,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 
717.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';let n=document.createElement("audio");return n.className="bn-audio",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{n.src=e}):n.src=e.props.url,n.controls=!0,n.contentEditable="false",n.draggable=!1,te(e,t,{dom:n},t.dictionary.file_blocks.audio.add_button_text,o.firstElementChild)},parse:ti,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add audio",{dom:e}}return e.props.showPreview?(t=document.createElement("audio")).src=e.props.url:((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tt(t,e.props.caption):to(t,e.props.caption):{dom:t}}}),tl=Symbol.for("blocknote.shikiParser"),ta=Symbol.for("blocknote.shikiHighlighterPromise"),td=ec(ea({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions:()=>({defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}),addAttributes(){let e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:t=>{let o=t,n=null;(null==o?void 0:o.tagName)==="DIV"&&(null==o?void 0:o.dataset.contentType)==="codeBlock"&&(o=o.children[0]),(null==o?void 0:o.tagName)==="PRE"&&(o=null==o?void 0:o.children[0]);let r=null==o?void 0:o.getAttribute("data-language");if(r)n=r.toLowerCase();else{let e=[...(null==o?void 0:o.className.split(" "))||[]].filter(e=>e.startsWith("language-")).map(e=>e.replace("language-",""));e.length>0&&(n=e[0].toLowerCase())}return n?tc(e.editor.settings.codeBlock,n)??n:null},renderHTML:e=>e.language?{class:`language-${e.language}`,"data-language":e.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var t,o;let n=document.createElement("pre"),{dom:r,contentDOM:i}=Q(this.name,"code",(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},{...(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{},...e});return r.removeChild(i),r.appendChild(n),n.appendChild(i),{dom:r,contentDOM:i}},addNodeView(){let e=this.options;return({editor:t,node:o,getPos:n,HTMLAttributes:r})=>{var i,s;let l=document.createElement("pre"),a=document.createElement("select"),d=document.createElement("div"),{dom:c,contentDOM:h}=Q(this.name,"code",{...(null==(i=this.options.domAttributes)?void 0:i.blockContent)||{},...r},(null==(s=this.options.domAttributes)?void 0:s.inlineContent)||{}),u=e=>{let o=e.target.value;t.commands.command(({tr:e})=>(e.setNodeAttribute(n(),"language",o),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([e,{name:t}])=>{let o=document.createElement("option");o.value=e,o.text=t,a.appendChild(o)}),d.contentEditable="false",a.value=o.attrs.language||e.editor.settings.codeBlock.defaultLanguage,c.removeChild(h),c.appendChild(d),c.appendChild(l),l.appendChild(h),d.appendChild(a),a.addEventListener("change",u),{dom:c,contentDOM:h,update:e=>e.type===this.type,destroy:()=>{a.removeEventListener("change",u)}}}},addProseMirrorPlugins(){let e,t,o=this.options,n=globalThis;return[(0,m.U)({parser:r=>{if(!o.editor.settings.codeBlock.createHighlighter)return[];if(!e)return n[ta]=n[ta]||o.editor.settings.codeBlock.createHighlighter(),n[ta].then(t=>{e=t});let i=tc(o.editor.settings.codeBlock,r.language);return i&&"text"!==i&&"none"!==i&&"plaintext"!==i&&"txt"!==i?e.getLoadedLanguages().includes(i)?(t||(t=n[tl]||(0,f.C)(e),n[tl]=t),t(r)):e.loadLanguage(i):[]},languageExtractor:e=>e.attrs.language,nodeTypes:[this.name]})]},addInputRules(){let e=this.options;return[new d.fV({find:/^```(.*?)\s$/,handler:({state:t,range:o,match:n})=>{let r=t.doc.resolve(o.from),i=n[1].trim(),s={language:tc(e.editor.settings.codeBlock,i)??i};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;t.tr.delete(o.from,o.to).setBlockType(o.from,o.from,this.type,s).setSelection(c.U3.create(t.tr.doc,o.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let{selection:t}=e.state,{$from:o}=t;if(e.isActive(this.name)&&!o.parent.textContent&&(0,d.eE)(t)){let t=
7o.pos-o.parentOffset-2;return e.chain().setNodeSelection(t).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>!!(this.options.indentLineWithTab&&e.isActive(this.name))&&(e.commands.insertContent("  "),!0),Enter:({editor:e})=>{let{$from:t}=e.state.selection;if(!e.isActive(this.name))return!1;let o=t.parentOffset===t.parent.nodeSize-2,n=t.parent.textContent.endsWith(`
8
9`);return o&&n?e.chain().command(({tr:e})=>(e.delete(t.pos-2,t.pos),!0)).exitCode().run():(e.commands.insertContent(`
10`),!0)},"Shift-Enter":({editor:e})=>{let{$from:t}=e.state.selection;return!!e.isActive(this.name)&&(e.chain().insertContentAt(t.pos-t.parentOffset+t.parent.nodeSize,{type:"paragraph"}).run(),!0)}}}}),{language:{default:"text"}});function tc(e,t){var o;return null==(o=Object.entries(e.supportedLanguages).find(([e,{aliases:o}])=>(null==o?void 0:o.includes(t))||e===t))?void 0:o[0]}let th=eI(d.CU.create({name:"backgroundColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:e=>"string"!=typeof e&&!!e.hasAttribute("data-background-color")&&{stringValue:e.getAttribute("data-background-color")}}],renderHTML:({HTMLAttributes:e})=>["span",e,0]}),"string"),tu=eI(d.CU.create({name:"textColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:e=>"string"!=typeof e&&!!e.hasAttribute("data-text-color")&&{stringValue:e.getAttribute("data-text-color")}}],renderHTML:({HTMLAttributes:e})=>["span",e,0]}),"string"),tp=e=>({url:e.src||void 0}),tm={type:"file",propSchema:{backgroundColor:et.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none",isFileBlock:!0},tf=e=>{if("EMBED"===e.tagName)return e.closest("figure")?void 0:tp(e);if("FIGURE"===e.tagName){let t=e8(e,"embed");if(!t)return;let{targetElement:o,caption:n}=t;return{...tp(o),caption:n}}},tg=em(tm,{render:(e,t)=>te(e,t),parse:tf,toExternalHTML:e=>{if(!e.props.url){let e=document.createElement("p");return e.textContent="Add file",{dom:e}}let t=document.createElement("a");return t.href=e.props.url,t.textContent=e.props.name||e.props.url,e.props.caption?to(t,e.props.caption):{dom:t}}}),tb={set:(e,t)=>window.localStorage.setItem(`toggle-${e.id}`,t?"true":"false"),get:e=>"true"===window.localStorage.getItem(`toggle-${e.id}`)},tk=(e,t,o,n=tb)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:o};let r=document.createElement("div"),i=document.createElement("div");i.className="bn-toggle-wrapper";let s=document.createElement("button");s.className="bn-toggle-button",s.type="button",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';let l=e=>e.preventDefault();s.addEventListener("mousedown",l);let a=()=>{var o;"true"===i.getAttribute("data-show-children")?(i.setAttribute("data-show-children","false"),n.set(t.getBlock(e),!1),r.contains(d)&&r.removeChild(d)):(i.setAttribute("data-show-children","true"),n.set(t.getBlock(e),!0),(null==(o=t.getBlock(e))?void 0:o.children.length)!==0||r.contains(d)||r.appendChild(d))};s.addEventListener("click",a),i.appendChild(s),i.appendChild(o);let d=document.createElement("button");d.className="bn-toggle-add-block-button",d.type="button",d.textContent=t.dictionary.toggle_blocks.add_block_button;let c=e=>e.preventDefault();d.addEventListener("mousedown",c);let h=()=>{t.transact(()=>{let o=t.updateBlock(e,{children:[{}]});
10t.setTextCursorPosition(o.children[0].id,"end"),t.focus()})};d.addEventListener("click",h),r.appendChild(i);let u=e.children.length,p=t.onChange(()=>{var o;let s=(null==(o=t.getBlock(e))?void 0:o.children.length)??0;s>u?("false"===i.getAttribute("data-show-children")&&(i.setAttribute("data-show-children","true"),n.set(t.getBlock(e),!0)),r.contains(d)&&r.removeChild(d)):0===s&&s<u&&("true"===i.getAttribute("data-show-children")&&(i.setAttribute("data-show-children","false"),n.set(t.getBlock(e),!1)),r.contains(d)&&r.removeChild(d)),u=s});return n.get(e)?(i.setAttribute("data-show-children","true"),0===e.children.length&&r.appendChild(d)):i.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:e=>e instanceof MutationRecord&&("attributes"===e.type&&e.target===i&&"data-show-children"===e.attributeName||"childList"===e.type&&(e.addedNodes[0]===d||e.removedNodes[0]===d)),destroy:()=>{s.removeEventListener("mousedown",l),s.removeEventListener("click",a),d.removeEventListener("mousedown",c),d.removeEventListener("click",h),null==p||p()}}},tv={...et,level:{default:1,values:[1,2,3,4,5,6]},isToggleable:{default:!1}},ty=ec(ea({name:"heading",content:"inline*",group:"blockContent",addAttributes:()=>ei(tv),addInputRules(){return[...this.options.editor.settings.heading.levels.map(e=>new d.fV({find:RegExp(`^(#{${e}})\\s$`),handler:({state:t,chain:o,range:n})=>{let r=ev(t);r.isBlockContainer&&"inline*"===r.blockContent.node.type.spec.content&&o().command(eQ(r.bnBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:n.from,to:n.to}).run()}}))]},addKeyboardShortcuts(){return Object.fromEntries(this.options.editor.settings.heading.levels.map(e=>[`Mod-Alt-${e}`,()=>{let t=ev(this.editor.state);return!t.isBlockContainer||"inline*"!==t.blockContent.node.type.spec.content||this.editor.commands.command(eQ(t.bnBlock.beforePos,{type:"heading",props:{level:e}}))}]))},parseHTML(){let e=this.options.editor;return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},...e.settings.heading.levels.map(e=>({tag:`h${e}`,attrs:{level:e},node:"heading"}))]},renderHTML({node:e,HTMLAttributes:t}){var o,n;return Q(this.name,`h${e.attrs.level}`,{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:t,getPos:o})=>{var n,r;let{dom:i,contentDOM:s}=Q(this.name,`h${e.attrs.level}`,{...(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},...t},(null==(r=this.options.domAttributes)?void 0:r.inlineContent)||{});i.removeChild(s);let l=this.options.editor,a=tk(es(o,l,this.editor,this.name),l,s);return i.appendChild(a.dom),{dom:i,contentDOM:s,ignoreMutation:a.ignoreMutation,destroy:a.destroy}}}}),tv),tw=(e,t,o,n,r,i)=>{let{dom:s,destroy:l}=te(e,t,o,r,i);s.style.position="relative",e.props.url&&e.props.showPreview&&(e.props.previewWidth?s.style.width=`${e.props.previewWidth}px`:s.style.width="fit-content");let a=document.createElement("div");a.className="bn-resize-handle",a.style.left="4px";let d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let c=document.createElement("div");c.style.position="absolute",c.style.height="100%",c.style.width="100%";let h,u=e.props.previewWidth,p=o=>{var r,i;if(!h){!t.isEditable&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d));return}u=Math.min(Math.max("center"===e.props.textAlignment?"left"===h.handleUsed?h.initialWidth+(h.initialClientX-o.clientX)*2:h.initialWidth+(o.clientX-h.initialClientX)*2:"left"===h.handleUsed?h.initialWidth+h.initialClientX-o.clientX:h.initialWidth+o.clientX-h.initialClientX,64),(null==(i=null==(r=t.domElement)?void 0:r.firstElementChild)?void 0:i.clientWidth)||Number.MAX_VALUE),s.style.width=`${u}px`},m=o=>{(!o.target||!s.contains(o.target)||!t.isEditable)&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d)),h&&(h=void 0,s.contains(c)&&s.removeChild(c),t.updateBlock(e,{props:{previewWidth:u}}))},f=()=>{t.isEditable&&(n.appendChild(a),n.appendChild(d))},g=e=>{e.relatedTarget===a||e.relatedTarget===d||h||t.isEditable&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d))},b=e=>{e.preventDefault(),s.contains(c)||s.appendChild(c),h={handleUsed:"left",initialWidth:s.clientWidth,initialClientX:e.clientX}},k=e=>{e.preventDefault(),s.contains(c)||s.appendChild(c),h={handleUsed:"right",initialWidth:s.clientWidth,initialClientX:e.clientX}};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",m),s.addEventListener("mouseenter",f),s.addEventListener("mouseleave",g),a.addEventListener("mousedown",b),d.addEventListener("mousedown",k),{dom:s,destroy:()=>{null==l||l(),window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",m),s.removeEventListener("mouseenter",f),s.removeEventListener("mouseleave",g),a.removeEventListener("mousedown",b),d.removeEventListener("mousedown",k)}}},tC=e=>{let t=e.src||void 0;return{url:t,previewWidth:e.width||void 0,name:e.alt||void 0}},tE={type:"image",propSchema:{textAlignment:et.textAlignment,backgroundColor:et.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},tS=e=>{if("IMG"===e.tagName)return e.closest("figure")?void 0:tC(e);if("FIGURE"===e.tagName){let t=e8(e,"img");if(!t)return;let{targetElement:o,caption:n}=t;return{...tC(o),caption:n}}},tx=em(tE,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';let n=document.createElement("div");n.className="bn-visual-media-wrapper";let r=document.createElement("img");return r.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{r.src=e}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,n.appendChild(r),tw(e,t,{dom:n},n,t.dictionary.file_blocks.image.add_button_text,o.firstElementChild)},parse:tS,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add image",{dom:e}}return e.props.showPreview?((t=document.createElement("img")).src=e.props.url,t.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(t.width=e.props.previewWidth)):((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tt(t,e.props.caption):to(t,e.props.caption):{dom:t}}}),tM=(e,t,o)=>({state:n,dispatch:r})=>{let i=eb(ef(n.doc,e));if(!i.isBlockContainer)throw Error(`BlockContainer expected when calling splitBlock, position ${e}`);let s=[{type:i.bnBlock.node.type,attrs:o?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:t?i.blockContent.node.type:n.schema.nodes.paragraph,attrs:o?{...i.blockContent.node.attrs}:{}}];return r&&n.tr.split(e,2,s),!0},tT=e=>{let{blockInfo:t,selectionEmpty:o}=e.transact(e=>({blockInfo:ey(e),selectionEmpty:e.selection.anchor===e.selection.head}));if(!t.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=t;
10return("toggleListItem"===r.node.type.name||"bulletListItem"===r.node.type.name||"numberedListItem"===r.node.type.name||"checkListItem"===r.node.type.name)&&!!o&&e._tiptapEditor.commands.first(({state:e,chain:t,commands:o})=>[()=>o.command(()=>0===r.node.childCount&&o.command(eQ(n.beforePos,{type:"paragraph",props:{}}))),()=>o.command(()=>r.node.childCount>0&&(t().deleteSelection().command(tM(e.selection.from,!0)).run(),!0))])},tB={...et},tP=ec(ea({name:"toggleListItem",content:"inline*",group:"blockContent",priority:90,addKeyboardShortcuts(){return{Enter:()=>tT(this.options.editor),"Mod-Shift-6":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"toggleListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"}]},renderHTML({HTMLAttributes:e}){var t,o;return Q(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})},addNodeView(){return({HTMLAttributes:e,getPos:t})=>{var o,n;let{dom:r,contentDOM:i}=Q(this.name,"p",{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{}),s=this.options.editor,l=tk(es(t,s,this.editor,this.name),s,i);return r.appendChild(l.dom),{dom:r,contentDOM:i,ignoreMutation:l.ignoreMutation,destroy:l.destroy}}}}),tB);function tL(e,t,o){var n,r,i;let s=l.S4.fromSchema(t),a=document.createElement("div");for(let t of(a.setAttribute("data-node-type","blockGroup"),Array.from(e.childNodes)))a.appendChild(t.cloneNode(!0));let d=s.parse(a,{topNode:t.nodes.blockGroup.create()});(null==(r=null==(n=d.firstChild)?void 0:n.firstChild)?void 0:r.type.name)==="checkListItem"&&(d=d.copy(d.content.cut(d.firstChild.firstChild.nodeSize+2)));let c=null==(i=d.firstChild)?void 0:i.firstChild;if(!(null!=c&&c.isTextblock))return l.FK.from(d);let h=t.nodes[o].create({},c.content),u=d.content.cut(c.nodeSize+2);if(u.size>0){let e=d.copy(u);return h.content.addToEnd(e)}return h.content}let tA={...et},tI=ec(ea({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules:()=>[new d.fV({find:RegExp("^[-+*]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ev(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&"heading"!==n.blockNoteType&&t().command(eQ(n.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>tT(this.options.editor),"Mod-Shift-8":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;return null!==o&&("UL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="UL")&&{}},getContent:(e,t)=>tL(e,t,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return Q(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tA),tH={...et,checked:{default:!1}},tN=ec(ea({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes:()=>ei(tH),addInputRules:()=>[new d.fV({find:RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ev(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(eQ(n.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:o.from,to:o.to})}}),new d.fV({find:RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ev(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(eQ(n.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>
10tT(this.options.editor),"Mod-Shift-9":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>!("string"==typeof e||e.closest("[data-content-type]")||e.closest("li"))&&"checkbox"===e.type&&{checked:e.checked},node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;if(null===o)return!1;if("UL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="UL"){let t=e.querySelector("input[type=checkbox]")||null;return null!==t&&{checked:t.checked}}return!1},getContent:(e,t)=>tL(e,t,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:t}){var o,n;let r=document.createElement("input");r.type="checkbox",r.checked=e.attrs.checked,e.attrs.checked&&r.setAttribute("checked","");let{dom:i,contentDOM:s}=Q(this.name,"p",{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{});return i.insertBefore(r,s),{dom:i,contentDOM:s}},addNodeView(){return({node:e,getPos:t,editor:o,HTMLAttributes:n})=>{var r,i;let s=document.createElement("div"),l=document.createElement("div");l.contentEditable="false";let a=document.createElement("input");a.type="checkbox",a.checked=e.attrs.checked,e.attrs.checked&&a.setAttribute("checked","");let d=()=>{if(!o.isEditable){a.checked=!a.checked;return}if("boolean"!=typeof t){let e=ef(o.state.doc,t());if("blockContainer"!==e.node.type.name)throw Error(`Expected blockContainer node, got ${e.node.type.name}`);this.editor.commands.command(eQ(e.posBeforeNode,{type:"checkListItem",props:{checked:a.checked}}))}};a.addEventListener("change",d);let{dom:c,contentDOM:h}=Q(this.name,"p",{...(null==(r=this.options.domAttributes)?void 0:r.blockContent)||{},...n},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{});if("boolean"!=typeof t){let e="label-"+this.editor.state.doc.resolve(t()).node().attrs.id;a.setAttribute("aria-labelledby",e),h.id=e}return c.removeChild(h),c.appendChild(s),s.appendChild(l),s.appendChild(h),l.appendChild(a),{dom:c,contentDOM:h,destroy:()=>{a.removeEventListener("change",d)}}}}}),tH),tO=new c.hs("numbered-list-indexing"),tV={...et,start:{default:void 0,type:"number"}},tD=ec(ea({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes:()=>({...ei(tV),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}),addInputRules:()=>[new d.fV({find:RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:t,range:o,match:n})=>{let r=ev(e);if(!r.isBlockContainer||"inline*"!==r.blockContent.node.type.spec.content||"numberedListItem"===r.blockNoteType||"heading"===r.blockNoteType)return;let i=parseInt(n[1]);t().command(eQ(r.bnBlock.beforePos,{type:"numberedListItem",props:1===i&&{}||{start:i}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>tT(this.options.editor),"Mod-Shift-7":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins:()=>[new c.k_({key:tO,appendTransaction:(e,t,o)=>{let n=o.tr;n.setMeta("numberedListIndexing",!0);let r=!1;return o.doc.descendants((e,t)=>{var o;if("blockContainer"===e.type.name&&"numberedListItem"===e.firstChild.type.name){let i=`${e.firstChild.attrs.start||1}`,s=eb({posBeforeNode:t,node:e});if(!s.isBlockContainer)throw Error("impossible");let l=n.doc.resolve(s.bnBlock.beforePos).nodeBefore;if(l){let e=eb({posBeforeNode:s.bnBlock.beforePos-l.nodeSize,node:l});if("numberedListItem"===e.blockNoteType){if(!e.isBlockContainer)throw Error("impossible");i=(parseInt(e.blockContent.node.attrs.index)+1).toString()}}let a=s.blockContent.node,d=a.attrs.index,c=(null==(o=null==l?void 0:l.firstChild)?void 0:o.type.name)!=="numberedListItem";if(d!==i||a.attrs.start&&!c){r=!0;let{start:e,...t}=a.attrs;n.setNodeMarkup(s.blockContent.beforePos,void 0,{...t,index:i,..."number"==typeof e&&c&&{start:e}}
10)}}}),r?n:null}})],parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;if(null===o)return!1;if("OL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="OL"){let t=parseInt(o.getAttribute("start")||"1")||1;return e.previousSibling||1===t?{}:{start:t}}return!1},getContent:(e,t)=>tL(e,t,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return Q(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tV),tU={...et},t_=ec(ea({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var t;return"string"!=typeof e&&!!(null!=(t=e.textContent)&&t.trim())&&{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var t,o;return Q(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tU),t$={...et},tR=ec(ea({name:"quote",content:"inline*",group:"blockContent",addInputRules:()=>[new d.fV({find:RegExp("^>\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ev(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(eQ(n.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{let e=ev(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(eQ(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote",getContent:(e,t)=>{let o=e.cloneNode(!0);return function(e){let t=e.querySelectorAll("p");if(t.length>1){let e=t[0];for(let o=1;o<t.length;o++){let n=t[o];e.innerHTML+="<br>"+n.innerHTML,n.remove()}}}(o),l.S4.fromSchema(t).parse(o,{topNode:t.nodes.paragraph.create()}).content}}]},renderHTML({HTMLAttributes:e}){var t,o;return Q(this.name,"blockquote",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),t$),tF=120,tz=31,tj=d.YY.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[(0,u.AL)({cellMinWidth:35,defaultCellMinWidth:tF,View:null}),(0,u.LF)()],addKeyboardShortcuts(){return{Enter:()=>!!this.editor.state.selection.empty&&"tableParagraph"===this.editor.state.selection.$head.parent.type.name&&(this.editor.commands.insertContent({type:"hardBreak"}),!0),Backspace:()=>{let e=this.editor.state.selection,t=e.empty,o=0===e.$head.parentOffset,n="tableParagraph"===e.$head.node().type.name;return t&&o&&n},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>(0,u.D8)(1)(e,t,o)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>(0,u.D8)(-1)(e,t,o))}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:(0,d.gk)((0,d.iI)(e,"tableRole",t))}}}),tG={textColor:et.textColor},tW=ea({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){var o,n,r;let i=Q(this.name,"table",{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{}),s=document.createElement("colgroup");for(let t of e.children[0].children)if(t.attrs.colwidth)for(let e of t.attrs.colwidth){let t=document.createElement("col");e&&(t.style=`width: ${e}px`),s.appendChild(t)}else s.appendChild(document.createElement("col"));return null==(r=i.dom.firstChild)||r.appendChild(s),i},addNodeView(){return({node:e,HTMLAttributes:t})=>{var o;class n extends u.Qg{constructor(e,t,o){super(e,t),this.node=e,this.cellMinWidth=t,this.blockContentHTMLAttributes=o;let n=document.createElement("div");for(let[e,t]of(n.className=X("bn-block-content",o.class),n.setAttribute("data-content-type","table"),Object.entries(o)))"class"!==e&&n.setAttribute(e,t);let r=this.dom,i=document.createElement("div");i.className="tableWrapper-inner",i.appendChild(r.firstChild),r.appendChild(i),n.appendChild(r);let s=document.createElement("div");s.className="table-widgets-container",s.style.position="relative",r.appendChild(s),this.dom=n}ignoreMutation(e){return!e.target.closest(".tableWrapper-inner")||super.ignoreMutation(e)}}return new n(e,tF,{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t})}}}
10),tq=ea({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML:()=>[{tag:"p",getAttrs:e=>{if("string"==typeof e||!e.textContent||!e.closest("[data-content-type]"))return!1;let t=e.parentElement;return null!==t&&("TD"===t.tagName||"TH"===t.tagName)&&{}},node:"tableParagraph"}],renderHTML:({HTMLAttributes:e})=>["p",e,0]}),tJ=d.bP.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",(0,d.KV)(this.options.HTMLAttributes,e),0]}});function tK(e,t){let o=l.S4.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),n=[];return o.content.descendants(e=>{if(e.isInline)return n.push(e),!1}),l.FK.fromArray(n)}let tY=ec(tW,tG,[tj,tq,C.A.extend({content:"tableContent+",parseHTML:()=>[{tag:"th",getContent:(e,t)=>tK(e,t)}]}),w.n.extend({content:"tableContent+",parseHTML:()=>[{tag:"td",getContent:(e,t)=>tK(e,t)}]}),tJ]),tX=e=>({url:e.src||void 0,previewWidth:e.width||void 0}),tZ={type:"video",propSchema:{textAlignment:et.textAlignment,backgroundColor:et.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},tQ=e=>{if("VIDEO"===e.tagName)return e.closest("figure")?void 0:tX(e);if("FIGURE"===e.tagName){let t=e8(e,"video");if(!t)return;let{targetElement:o,caption:n}=t;return{...tX(o),caption:n}}},t0={paragraph:t_,heading:ty,quote:tR,codeBlock:td,toggleListItem:tP,bulletListItem:tI,numberedListItem:tD,checkListItem:tN,table:tY,file:tg,image:tx,video:em(tZ,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>';let n=document.createElement("div");n.className="bn-visual-media-wrapper";let r=document.createElement("video");return r.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{r.src=e}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,n.appendChild(r),tw(e,t,{dom:n},n,t.dictionary.file_blocks.video.add_button_text,o.firstElementChild)},parse:tQ,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add video",{dom:e}}return e.props.showPreview?((t=document.createElement("video")).src=e.props.url,e.props.previewWidth&&(t.width=e.props.previewWidth)):((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tt(t,e.props.caption):to(t,e.props.caption):{dom:t}}}),audio:ts},t1=eh(t0),t2={bold:eI(g.Ay,"boolean"),italic:eI(k.Ay,"boolean"),underline:eI(y.A,"boolean"),strike:eI(v.Ay,"boolean"),code:eI(b.Ay,"boolean"),textColor:tu,backgroundColor:th},t3=(eH(t2),{text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}}),t4=eA(t3);function t5(e,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===t1[e]}function t9(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock||!1}function t7(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock&&"showPreview"in t.schema.blockSchema[e.type].propSchema||!1}function t6(e,t){return t.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function t8(e,t,o){return t in o.schema.blockSchema&&e in o.schema.blockSchema[t].propSchema&&o.schema.blockSchema[t].propSchema[e]===et[e]}function oe(e,t,o){return t8(e,t.type,o)}function ot(e){return e instanceof u.rn}function oo(e,t){let o,n=e.getTextCursorPosition().block;if(void 0===n.content)throw Error("Slash Menu open in a block that doesn't contain content.");return Array.isArray(n.content)&&(1===n.content.length&&F(n.content[0])&&"text"===n.content[0].type&&"/"===n.content[0].text||0===n.content.length)?(o=e.updateBlock(n,t),e.setTextCursorPosition(o)):(o=e.insertBlocks([t],n,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),function(e){let t=e.getTextCursorPosition().block,o=e.schema.blockSchema[t.type].content;for(;"none"===o;){if(void 0===(t=e.getTextCursorPosition().nextBlock))return;o=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}}(e),o}function on(e){let t=[];return t5("heading",e)&&t.push({onItemClick:()=>{oo(e,{type:"heading",props:{level:1}})},badge:Y("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{oo(e,{type:"heading",props:{level:2}})},badge:Y("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{oo(e,{type:"heading",props:{level:3}})},badge:Y("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),t5("quote",e)&&t.push({onItemClick:()=>{oo(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),t5("toggleListItem",e)&&t.push({onItemClick:()=>{oo(e,{type:"toggleListItem"})}
10,badge:Y("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),t5("numberedListItem",e)&&t.push({onItemClick:()=>{oo(e,{type:"numberedListItem"})},badge:Y("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),t5("bulletListItem",e)&&t.push({onItemClick:()=>{oo(e,{type:"bulletListItem"})},badge:Y("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),t5("checkListItem",e)&&t.push({onItemClick:()=>{oo(e,{type:"checkListItem"})},badge:Y("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),t5("paragraph",e)&&t.push({onItemClick:()=>{oo(e,{type:"paragraph"})},badge:Y("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),t5("codeBlock",e)&&t.push({onItemClick:()=>{oo(e,{type:"codeBlock"})},badge:Y("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),t5("table",e)&&t.push({onItemClick:()=>{oo(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),t5("image",e)&&t.push({onItemClick:()=>
10{let t=oo(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),t5("video",e)&&t.push({onItemClick:()=>{let t=oo(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),t5("audio",e)&&t.push({onItemClick:()=>{let t=oo(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),t5("file",e)&&t.push({onItemClick:()=>{let t=oo(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),t5("heading",e)&&(t.push({onItemClick:()=>{oo(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{oo(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{oo(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),e.settings.heading.levels.filter(e=>e>3).forEach(o=>{t.push({onItemClick:()=>{oo(e,{type:"heading",props:{level:o}})},key:`heading_${o}`,...e.dictionary.slash_menu[`heading_${o}`]})})),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function or(e,t){return e.filter(({title:e,aliases:o})=>e.toLowerCase().includes(t.toLowerCase())||o&&0!==o.filter(e=>e.toLowerCase().includes(t.toLowerCase())).length)}function oi(e){return e&&Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}class os{constructor(e){U(this,"blockSpecs"),U(this,"inlineContentSpecs"),U(this,"styleSpecs"),U(this,"blockSchema"),U(this,"inlineContentSchema"),U(this,"styleSchema"),U(this,"BlockNoteEditor","only for types"),U(this,"Block","only for types"),U(this,"PartialBlock","only for types"),this.blockSpecs=oi(null==e?void 0:e.blockSpecs)||t0,this.inlineContentSpecs=oi(null==e?void 0:e.inlineContentSpecs)||t3,this.styleSpecs=oi(null==e?void 0:e.styleSpecs)||t2,this.blockSchema=eh(this.blockSpecs),this.inlineContentSchema=eA(this.inlineContentSpecs),this.styleSchema=eH(this.styleSpecs)}static create(e){return new os(e)}}let ol=em({type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},{render:()=>{let e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},parse:e=>{if("DIV"===e.tagName&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},toExternalHTML:()=>{let e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}}});function oa(e,t,o){e.transact(n=>{var r;let i=(null==(r=e.getSelection())?void 0:r.blocks)||[e.getTextCursorPosition().block],s=e.transact(e=>{let t=ef(e.doc,e.selection.anchor);if(e.selection instanceof u.rn)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:e.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:e.selection.$headCell.pos-t.posBeforeNode};if(e.selection instanceof c.nh)return{type:"node",anchorBlockId:t.node.attrs.id};{let o=ef(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-o.posBeforeNode}}});e.removeBlocks(i),e.insertBlocks(function e(t){return t.map(t=>"columnList"===t.type?t.children.map(t=>e(t.children)).flat():{...t,children:e(t.children)}).flat()}(i),t,o),function(e,t){var o,n;let r,i=null==(o=eY(t.anchorBlockId,e.doc))?void 0:o.posBeforeNode;if(void 0===i)throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);if("cell"===t.type)r=u.rn.create(e.doc,i+t.anchorCellOffset,i+t.headCellOffset);else if("node"===t.type)r=c.nh.create(e.doc,i+1);else{let o=null==(n=eY(t.headBlockId,e.doc))?void 0:n.posBeforeNode;if(void 0===o)throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);r=c.U3.create(e.doc,i+t.anchorOffset,o+t.headOffset)}e.setSelection(r)}(n,s)})}function od(e){return!e||"columnList"!==e.type}function oc(e){return e.transact(t=>(function(e,t,o){let{$from:n,$to:r}=e.selection,i=n.blockRange(r,e=>e.childCount>
100&&("blockGroup"===e.type.name||"column"===e.type.name));if(!i)return!1;let s=i.startIndex;if(0===s)return!1;let d=i.parent.child(s-1);if(d.type!==t)return!1;let c=d.lastChild&&d.lastChild.type===o,h=l.FK.from(c?t.create():null),u=new l.Ji(l.FK.from(t.create(null,l.FK.from(o.create(null,h)))),c?3:1,0),p=i.start,m=i.end;return e.step(new a.Wg(p-(c?3:1),m,p,m,u,1,!0)).scrollIntoView(),!0})(t,e.pmSchema.nodes.blockContainer,e.pmSchema.nodes.blockGroup))}async function oh(){if(n)return n;let e=await Promise.all([Promise.all([o.e(7499),o.e(1324),o.e(341)]).then(o.bind(o,50341)),Promise.all([o.e(7499),o.e(6765)]).then(o.bind(o,26765)),Promise.all([o.e(1324),o.e(6737)]).then(o.bind(o,26737)),Promise.all([o.e(7499),o.e(9253)]).then(o.bind(o,29253)),Promise.all([o.e(7032),o.e(6581),o.e(8449)]).then(o.bind(o,8449)),Promise.all([o.e(7032),o.e(4608),o.e(7347)]).then(o.bind(o,27347)),Promise.all([o.e(7032),o.e(4608),o.e(3527)]).then(o.bind(o,83527)),o.e(7380).then(o.bind(o,77380)),Promise.all([o.e(7032),o.e(4127)]).then(o.bind(o,54127)),Promise.all([o.e(7032),o.e(6581),o.e(2224)]).then(o.bind(o,62224))]);return n={rehypeParse:e[0],rehypeStringify:e[1],unified:e[2],hastUtilFromDom:e[3],rehypeRemark:e[4],remarkGfm:e[5],remarkStringify:e[6],remarkParse:e[7],remarkRehype:e[8],rehypeFormat:e[9]}}function ou(){let e=t=>{let o=t.children.length;for(let n=0;n<o;n++){let r=t.children[n];if("element"===r.type&&(e(r),"u"===r.tagName))if(r.children.length>0){t.children.splice(n,1,...r.children);let e=r.children.length-1;o+=e,n+=e}else t.children.splice(n,1),o--,n--}};return e}function op(){let e=n;if(!e)throw Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");let t=o=>{var n;if(o.children&&"length"in o.children&&o.children.length)for(let r=o.children.length-1;r>=0;r--){let i=o.children[r],s=r+1<o.children.length?o.children[r+1]:void 0;"element"===i.type&&"input"===i.tagName&&(null==(n=i.properties)?void 0:n.type)==="checkbox"&&(null==s?void 0:s.type)==="element"&&"p"===s.tagName?(s.tagName="span",s.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):t(i)}};return t}function om(e){let t=n;if(!t)throw Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return t.unified.unified().use(t.rehypeParse.default,{fragment:!0}).use(ou).use(op).use(t.rehypeRemark.default).use(t.remarkGfm.default).use(t.remarkStringify.default,{handlers:{text:e=>e.value}}).processSync(e).value}async function of(e,t,o,n){return await oh(),om(e5(t,o).exportBlocks(e,n))}os.create({blockSpecs:{pageBreak:ol}});let og=null;function ob(e){if("string"==typeof e){let t=(og||(og=document.implementation.createHTMLDocument("title"))).createElement("div");t.innerHTML=e,e=t}return e.querySelectorAll("li > ul, li > ol").forEach(e=>{let t=Array.prototype.indexOf.call(e.parentElement.childNodes,e),o=e.parentElement,n=Array.from(o.childNodes).slice(t+1);e.remove(),n.forEach(e=>{e.remove()}),o.insertAdjacentElement("afterend",e),n.reverse().forEach(t=>{if(3===t.nodeType&&!/\S/.test(t.nodeValue||""))return;let o=document.createElement("li");o.append(t),e.insertAdjacentElement("afterend",o)}),0===o.childNodes.length&&o.remove()}),e.querySelectorAll("li + ul, li + ol").forEach(e=>{var t,o;let n=e.previousElementSibling,r=document.createElement("div");n.insertAdjacentElement("afterend",r),r.append(n);let i=document.createElement("div");for(i.setAttribute("data-node-type","blockGroup"),r.append(i);(null==(t=r.nextElementSibling)?void 0:t.nodeName)==="UL"||(null==(o=r.nextElementSibling)?void 0:o.nodeName)==="OL";)i.append(r.nextElementSibling)}),e}async function ok(e,t){let o=ob(e),n=l.S4.fromSchema(t).parse(o,{topNode:t.nodes.blockGroup.create()}),r=[];for(let e=0;e<n.childCount;e++)r.push(eL(n.child(e),t));return r}function ov(e,t){let o=t.value?t.value:"",n={};t.lang&&(n["data-language"]=t.lang);let r={type:"element",tagName:"code",properties:n,children:[{type:"text",value:o}]};return t.meta&&(r.data={meta:t.meta}),e.patch(t,r),r={type:"element",tagName:"pre",properties:{},children:[r=e.applyData(t,r)]},e.patch(t,r),r}async function oy(e){let t=await oh();return t.unified.unified().use(t.remarkParse.default).use(t.remarkGfm.default).use(t.remarkRehype.default,{handlers:{...t.remarkRehype.defaultHandlers,code:ov}}).use(t.rehypeStringify.default).processSync(e).value}async function ow(e,t){return ok(await oy(e),t)}let oC=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function oE(e,t,o,n="after"){return Array.isArray(t.content)&&0===t.content.length?e.updateBlock(t,o).id:e.insertBlocks([o],t,n)[0].id}async function oS(e,t){var o;if(!t.uploadFile)return void console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");let n="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(null===n)return;let r=null;for(let e of oC)if(n.types.includes(e)){r=e;break}if("Files"!==r)return;let i=n.items;if(!i)return;e.preventDefault();let s=Object.values(t.schema.blockSchema).filter(e=>e.isFileBlock);for(let n=0;n<i.length;n++){let r="file";for(let e of s)for(let t of e.fileBlockAccept||[]){let o=t.startsWith("."),s=i[n].getAsFile();if(s&&(!o&&s.type&&function(e,t){let o=e.split("/"),n=t.split("/");if(2!==o.length)throw Error(`The string ${e} is not a valid MIME type.`);if(2!==n.length)throw Error(`The string ${t} is not a valid MIME type.`);return"*"===o[1]||"*"===n[1]?o[0]===n[0]:("*"===o[0]||"*"===n[0]||o[0]===n[0])&&o[1]===n[1]}(i[n].type,t)||o&&function(e,t){if(!e.startsWith(".")||!t.startsWith("."))throw Error("The strings provided are not valid file extensions.");return e===t}("."+s.name.split(".").pop(),t))){r=e.type;break}}let l=i[n].getAsFile();if(l){let n,i={type:r,props:{name:l.name}};if("paste"===e.type){let e=t.getTextCursorPosition().block;n=oE(t,e,i)}else{if("drop"!==e.type)return;let r={left:e.clientX,top:e.clientY},s=null==(o=t.prosemirrorView)?void 0:o.posAtCoords(r);if(!s)return;n=t.transact(e=>{var o;let n=ef(e.doc,s.pos),l=null==(o=t.prosemirrorView)?void 0:o.dom.querySelector(`[data-id="${n.node.attrs.id}"]`),a=null==l?void 0:l.getBoundingClientRect();return oE(t,t.getBlock(n.node.attrs.id),i,a&&(a.top+a.bottom)/2>r.top?"before":"after")})}let s=await t.uploadFile(l,n),a="string"==typeof s?{props:{url:s}}:{...s};t.updateBlock(n,a)}}}let ox=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,oM=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,oT=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,oB=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,oP=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,oL=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,oA=/\n{2} {0,3}-{2,48}\n{2}/,oI=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,oH=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,oN=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,oO=/^\s*\|(.+\|)+\s*$/m,oV=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,oD=/^\s*\|(.+\|)+\s*$/m;async function oU(e,t){let{schema:o}=t.state;if(!e.clipboardData)return!1;let n=e.clipboardData.getData("text/plain");if(!n)return!1;if(!o.nodes.codeBlock)return t.pasteText(n),!0;let r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=null==i?void 0:i.mode;return!!s&&(t.pasteHTML(`<pre><code class="language-${s}">${n.replace(/\r\n?/g,`
11`)}</code></pre>`),!0)}function o_(e){let t=[];return e.descendants(e=>{var o,n;let r=ew(e);
11return"blockContainer"===e.type.name&&(null==(o=e.firstChild)?void 0:o.type.name)==="blockGroup"||("columnList"===e.type.name&&1===e.childCount?(null==(n=e.firstChild)||n.forEach(e=>{t.push(eL(e,r))}),!1):!e.type.isInGroup("bnBlock")||(t.push(eL(e,r)),!1))}),t}function o$(e,t){"node"in e.state.selection&&"blockContent"===e.state.selection.node.type.spec.group&&t.transact(t=>t.setSelection(new c.nh(t.doc.resolve(e.state.selection.from-1))));let o=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,n=e.state.selection.content().content,r=function(e,t,o){var n;let r,i=!1,s=e.state.selection instanceof u.rn;if(!s){let o=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,n=[];for(let e=0;e<o.childCount;e++)n.push(o.child(e));(i=void 0===n.find(e=>e.type.isInGroup("bnBlock")||"blockGroup"===e.type.name||"blockContent"===e.type.spec.group))&&(t=o)}let l=e5(e.state.schema,o);if(s){(null==(n=t.firstChild)?void 0:n.type.name)==="table"&&(t=t.firstChild.content);let e=eB(t,o.schema.inlineContentSchema,o.schema.styleSchema);r=`<table>${l.exportInlineContent(e,{})}</table>`}else if(i){let e=eP(t,o.schema.inlineContentSchema,o.schema.styleSchema);r=l.exportInlineContent(e,{})}else{let e=o_(t);r=l.exportBlocks(e,{})}return r}(e,n,t),i=om(r);return{clipboardHTML:o,externalHTML:r,markdown:i}}let oR=()=>{let e=window.getSelection();if(!e||e.isCollapsed)return!0;let t=e.focusNode;for(;t;){if(t instanceof HTMLElement&&"false"===t.getAttribute("contenteditable"))return!0;t=t.parentElement}return!1},oF=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();let{clipboardHTML:n,externalHTML:r,markdown:i}=o$(t,e);o.clipboardData.setData("blocknote/html",n),o.clipboardData.setData("text/html",r),o.clipboardData.setData("text/plain",i)},oz=d.YY.create({name:"blockBackgroundColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:et.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):et.backgroundColor.default,renderHTML:e=>e.backgroundColor===et.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]});class oj{constructor(){U(this,"callbacks",{})}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),()=>this.off(e,t)}emit(e,...t){let o=this.callbacks[e];o&&o.forEach(e=>e.apply(this,t))}off(e,t){let o=this.callbacks[e];o&&(t?this.callbacks[e]=o.filter(e=>e!==t):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}}class oG extends oj{constructor(...e){super(),U(this,"plugins",[])}static key(){throw Error("You must implement the key method in your extension")}addProsemirrorPlugin(e){this.plugins.push(e)}get priority(){}}class oW extends oG{constructor(){super(),U(this,"beforeChangeCallbacks",[]),this.addProsemirrorPlugin(new c.k_({filterTransaction:e=>{let t;return this.beforeChangeCallbacks.reduce((o,n)=>!1===o?o:!1!==n({getChanges:()=>t||(t=e6(e)),tr:e}),!0)}}))}static key(){return"blockChange"}subscribe(e){return this.beforeChangeCallbacks.push(e),()=>{this.beforeChangeCallbacks=this.beforeChangeCallbacks.filter(t=>t!==e)}}}let oq=class e extends oG{constructor(t){super(),U(this,"provider"),U(this,"recentlyUpdatedCursors"),U(this,"renderCursor",(t,o)=>{let n=this.recentlyUpdatedCursors.get(o);if(!n){let r=(this.collaboration.renderCursor??e.defaultCursorRender)(t);"always"!==this.collaboration.showCursorLabels&&(r.addEventListener("mouseenter",()=>{let e=this.recentlyUpdatedCursors.get(o);e.element.setAttribute("data-active",""),e.hideTimeout&&(clearTimeout(e.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:e.element,hideTimeout:void 0}))}),r.addEventListener("mouseleave",()=>{let e=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute("data-active")},2e3)})})),n={element:r,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,n)}return n.element}),U(this,"updateUser",e=>{this.provider.awareness.setLocalStateField("user",e)}),this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),"always"!==t.showCursorLabels&&this.provider.awareness.on("change",({updated:e})=>{for(let t of e){let e=this.recentlyUpdatedCursors.get(t);e&&(e.element.setAttribute("data-active",""),e.hideTimeout&&clearTimeout(e.hideTimeout),this.recentlyUpdatedCursors.set(t,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin((0,T.Tr)(this.provider.awareness,{selectionBuilder:T.v0,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}static isDarkColor(e){let t="#"===e.charAt(0)?e.substring(1,7):e,o=parseInt(t.substring(0,2),16),n=[o/255,parseInt(t.substring(2,4),16)/255,parseInt(t.substring(4,6),16)/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return .2126*n[0]+.7152*n[1]+.0722*n[2]<=.179}};U(oq,"defaultCursorRender",e=>{let t=document.createElement("span");t.classList.add("bn-collaboration-cursor__base");let o=document.createElement("span");o.setAttribute("contentedEditable","false"),o.classList.add("bn-collaboration-cursor__caret"),o.setAttribute("style",`background-color: ${e.color}; color: ${oq.isDarkColor(e.color)?"white":"black"}`);let n=document.createElement("span");return n.classList.add("bn-collaboration-cursor__label"),n.setAttribute("style",`background-color: ${e.color}; color: ${oq.isDarkColor(e.color)?"white":"black"}`),n.insertBefore(document.createTextNode(e.name),null),o.insertBefore(n,null),t.insertBefore(document.createTextNode("⁠"),null),t.insertBefore(o,null),t.insertBefore(document.createTextNode("⁠"),null),t});class oJ extends oG{static key(){return"ySyncPlugin"}constructor(e){super(),this.addProsemirrorPlugin((0,B.YZ)(e))}get priority(){return 1001}}class oK extends oG{static key(){return"yUndoPlugin"}constructor({editor:e}){super(),this.addProsemirrorPlugin((0,P.$J)({trackedOrigins:[e]}))}get priority(){return 1e3}}let oY=d.CU.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes:()=>({orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}),renderHTML:({HTMLAttributes:e})=>["span",(0,d.KV)(e,{class:"bn-thread-mark"})],parseHTML:()=>[{tag:"span.bn-thread-mark"}],extendMarkSchema:e=>"comment"===e.name?{blocknoteIgnore:!0}:{}});class oX extends oj{constructor(e){super(),U(this,"userCache",new Map),U(this,"loadingUsers",new Set),this.resolveUsers=e}async loadUsers(e){let t=e.filter(e=>!this.userCache.has(e)&&!this.loadingUsers.has(e));if(0!==t.length){for(let e of t)this.loadingUsers.add(e);try{for(let e of(await this.resolveUsers(t)))this.userCache.set(e.id,e);
11this.emit("update",this.userCache)}finally{for(let e of t)this.loadingUsers.delete(e)}}}getUser(e){return this.userCache.get(e)}subscribe(e){return this.on("update",e)}}let oZ=new c.hs("blocknote-comments");class oQ extends oG{constructor(e,t,o){if(super(),U(this,"userStore"),U(this,"pendingComment",!1),U(this,"selectedThreadId"),U(this,"threadPositions",new Map),U(this,"updateMarksFromThreads",e=>{this.editor.transact(t=>{t.doc.descendants((o,n)=>{o.marks.forEach(r=>{if(r.type.name===this.markType){let i=r.type,s=r.attrs.threadId,l=e.get(s),a=!!(!l||l.resolved||l.deletedAt);if(a!==r.attrs.orphan){let e=Math.max(n,0),l=Math.min(n+o.nodeSize,t.doc.content.size-1,t.doc.content.size-1);t.removeMark(e,l,r),t.addMark(e,l,i.create({...r.attrs,orphan:a})),a&&this.selectedThreadId===s&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})}),this.editor=e,this.threadStore=t,this.markType=o,!e.resolveUsers)throw Error("resolveUsers is required for comments");this.userStore=new oX(e.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),e.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),e.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});let n=this;this.addProsemirrorPlugin(new c.k_({key:oZ,state:{init:()=>({decorations:I.zF.empty}),apply(e,t){let o=e.getMeta(oZ);if(!e.docChanged&&!o)return t;let r=e.docChanged?function(e,t){let o=new Map;return e.descendants((e,n)=>{e.marks.forEach(r=>{if(r.type.name===t){let t=r.attrs.threadId;if(!t)return;let i=n+e.nodeSize,s=o.get(t)??{from:1/0,to:0};o.set(t,{from:Math.min(n,s.from),to:Math.max(i,s.to)})}})}),o}(e.doc,n.markType):n.threadPositions;(r.size>0||n.threadPositions.size>0)&&(n.threadPositions=r,n.emitStateUpdate());let i=[];if(n.selectedThreadId){let e=r.get(n.selectedThreadId);e&&i.push(I.NZ.inline(e.from,e.to,{class:"bn-thread-mark-selected"}))}return{decorations:I.zF.create(e.doc,i)}}},props:{decorations(e){var t;return(null==(t=oZ.getState(e))?void 0:t.decorations)??I.zF.empty},handleClick:(e,t,r)=>{if(0!==r.button)return;let i=e.state.doc.nodeAt(t);if(!i)return void n.selectThread(void 0);let s=i.marks.find(e=>e.type.name===o&&!0!==e.attrs.orphan),l=null==s?void 0:s.attrs.threadId;n.selectThread(l,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(e){return this.on("update",e)}selectThread(e,t=!0){var o,n;if(this.selectedThreadId!==e&&(this.selectedThreadId=e,this.emitStateUpdate(),this.editor.transact(e=>e.setMeta(oZ,{name:"SET_SELECTED_THREAD_ID"})),e&&t)){let t=this.threadPositions.get(e);if(!t)return;null==(n=null==(o=this.editor.prosemirrorView)?void 0:o.domAtPos(t.from).node)||n.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(e){let t=await this.threadStore.createThread(e);if(this.threadStore.addThreadToDocument){let e=this.editor.prosemirrorView,o=e.state.selection,n=L.pJ.getState(e.state),r={prosemirror:{head:o.head,anchor:o.anchor},yjs:n?(0,B.Zr)(n.binding,e.state):void 0};await this.threadStore.addThreadToDocument({threadId:t.id,selection:r})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:t.id})}}class o0{constructor(e,t,o,n){U(this,"state"),U(this,"emitUpdate"),U(this,"mouseDownHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"dragstartHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"scrollHandler",()=>{var e;if(null!=(e=this.state)&&e.show){let e=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!e)return;this.state.referencePos=e.getBoundingClientRect(),this.emitUpdate()}}),U(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized file panel");n(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(e,t){var o,n;let r=this.pluginKey.getState(e.state),i=this.pluginKey.getState(t);if(!(null!=(o=this.state)&&o.show)&&null!=r&&r.block&&this.editor.isEditable){let e=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${r.block.id}"]`);if(!e)return;this.state={show:!0,referencePos:e.getBoundingClientRect(),block:r.block},this.emitUpdate();return}let s=(null==r?void 0:r.block)&&!(null!=i&&i.block),l=!(null!=r&&r.block)&&(null==i?void 0:i.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),l&&null!=(n=this.state)&&n.show&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}let o1=new c.hs("FilePanelPlugin");class o2 extends oG{constructor(e){super(),U(this,"view"),U(this,"closeMenu",()=>{var e;return null==(e=this.view)?void 0:e.closeMenu()}),this.addProsemirrorPlugin(new c.k_({key:o1,view:t=>(this.view=new o0(e,o1,t,e=>
11{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>{var o;return"Escape"===t.key&&!!this.shown&&(null==(o=this.view)||o.closeMenu(),!0)}},state:{init:()=>({block:void 0}),apply:(e,t)=>e.getMeta(o1)||(!e.getMeta(L.pJ)&&(e.selectionSet||e.docChanged)?{block:void 0}:t)}}))}static key(){return"filePanel"}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}onUpdate(e){return this.on("update",e)}}class o3{constructor(e,t,o){U(this,"state"),U(this,"emitUpdate"),U(this,"preventHide",!1),U(this,"preventShow",!1),U(this,"shouldShow",({view:e,state:t,from:o,to:n})=>{let{doc:r,selection:i}=t,{empty:s}=i,l=!r.textBetween(o,n).length&&(0,d.eE)(t.selection);if(i.$from.parent.type.spec.code||(0,d.BQ)(i)&&i.node.type.spec.code||s||l)return!1;let a=document.activeElement;return!(!this.isElementWithinEditorWrapper(a)&&e.editable)}),U(this,"blurHandler",e=>{var t;if(this.preventHide){this.preventHide=!1;return}let o=this.pmView.dom.parentElement;e&&e.relatedTarget&&(o===e.relatedTarget||o.contains(e.relatedTarget)||e.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"isElementWithinEditorWrapper",e=>{if(!e)return!1;let t=this.pmView.dom.parentElement;return!!t&&t.contains(e)}),U(this,"viewMousedownHandler",e=>{this.isElementWithinEditorWrapper(e.target)&&0!==e.button||(this.preventShow=!0)}),U(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))}),U(this,"dragHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"scrollHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())}),U(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(e,t){var o,n,r;let{state:i,composing:s}=e,{doc:l,selection:a}=i,d=t&&t.doc.eq(l)&&t.selection.eq(a);if(s||d)return;let{ranges:h}=a,u=Math.min(...h.map(e=>e.$from.pos)),p=Math.max(...h.map(e=>e.$to.pos)),m=this.shouldShow({view:e,state:i,from:u,to:p}),f=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(m||this.preventHide)&&!f){let t=this.getSelectionBoundingBox();if(0===t.height&&0===t.width)return void queueMicrotask(()=>{let t={show:!0,referencePos:this.getSelectionBoundingBox()};this.state=t,this.emitUpdate(),e.dispatch(e.state.tr.setSelection(c.U3.create(e.state.doc,e.state.selection.from+1,e.state.selection.to))),e.dispatch(e.state.tr.setSelection(c.U3.create(e.state.doc,e.state.selection.from-1,e.state.selection.to)))});let r={show:!0,referencePos:this.getSelectionBoundingBox()};return void((r.show!==(null==(o=this.state)?void 0:o.show)||r.referencePos.toJSON()!==(null==(n=this.state)?void 0:n.referencePos.toJSON()))&&(this.state=r,this.emitUpdate()))}if(null!=(r=this.state)&&r.show&&!this.preventHide&&(!m||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){let{state:e}=this.pmView,{selection:t}=e,{ranges:o}=t,n=Math.min(...o.map(e=>e.$from.pos)),r=Math.max(...o.map(e=>e.$to.pos));if((0,d.BQ)(t)){let e=this.pmView.nodeDOM(n);if(e)return e.getBoundingClientRect()}return(0,d.MG)(this.pmView,n,r)}}
11let o4=new c.hs("FormattingToolbarPlugin");class o5 extends oG{constructor(e){super(),U(this,"view"),U(this,"closeMenu",()=>this.view.closeMenu()),this.addProsemirrorPlugin(new c.k_({key:o4,view:t=>(this.view=new o3(e,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}}))}static key(){return"formattingToolbar"}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}onUpdate(e){return this.on("update",e)}}let o9=d.bP.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,d.KV)(this.options.HTMLAttributes,e)]},renderText:()=>`
12`}),o7=(e,t)=>{let o=e.resolve(t);if(o.depth<=1)return;let n=o.posAtIndex(o.index(o.depth-1),o.depth-1);return ek(e.resolve(n))},o6=(e,t)=>{let o=e.resolve(t),n=o.index();if(0===n)return;let r=o.posAtIndex(n-1);return ek(e.resolve(r))},o8=(e,t)=>{for(;t.childContainer;){let o=t.childContainer.node,n=e.resolve(t.childContainer.beforePos+1).posAtIndex(o.childCount-1);t=ek(e.resolve(n))}return t},ne=e=>({state:t,dispatch:o})=>{let n=ek(t.doc.resolve(e)),r=o6(t.doc,n.bnBlock.beforePos);if(!r)return!1;let i=o8(t.doc,r);return!!((e,t)=>e.isBlockContainer&&"inline*"===e.blockContent.node.type.spec.content&&e.blockContent.node.childCount>0&&t.isBlockContainer&&"inline*"===t.blockContent.node.type.spec.content)(i,n)&&((e,t,o,n)=>{if(!n.isBlockContainer)throw Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but next block is not a block container`);if(n.childContainer){let o=e.doc.resolve(n.childContainer.beforePos+1),r=e.doc.resolve(n.childContainer.afterPos-1),i=o.blockRange(r);if(t){let t=e.doc.resolve(n.bnBlock.beforePos);e.tr.lift(i,t.depth)}}if(t){if(!o.isBlockContainer)throw Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(o.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0})(t,o,i,n)},nt=d.YY.create({priority:50,addKeyboardShortcuts(){let e=(e=!1)=>this.editor.commands.first(({commands:t,tr:o})=>[()=>t.command(({state:e})=>{let o=ev(e);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,{depth:i}=e.doc.resolve(n.beforePos),s=0===e.selection.$anchor.parentOffset,l=e.selection.anchor===e.selection.head,a=0===r.node.childCount;return!!s&&!!l&&!!a&&i>1&&t.liftListItem("blockContainer")}),()=>t.command(({state:t})=>{let n=ev(t),r=this.options.editor.schema.blockSchema[n.blockNoteType].hardBreakShortcut??"shift+enter";if("none"===r)return!1;if("shift+enter"===r&&e||"enter"===r){let e=o.storedMarks||o.selection.$head.marks().filter(e=>this.editor.extensionManager.splittableMarks.includes(e.type.name));return o.insert(o.selection.head,o.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e),!0}return!1}),()=>t.command(({state:e,dispatch:t})=>{let o=ev(e);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,i=0===e.selection.$anchor.parentOffset,s=e.selection.anchor===e.selection.head,l=0===r.node.childCount;if(i&&s&&l){let o=n.afterPos;if(t){let t=e.schema.nodes.blockContainer.createAndFill();e.tr.insert(o,t).scrollIntoView(),e.tr.setSelection(new c.U3(e.doc.resolve(o+2)))}return!0}return!1}),()=>t.command(({state:e,chain:t})=>{let o=ev(e);if(!o.isBlockContainer)return!1;let{blockContent:n}=o,r=0===e.selection.$anchor.parentOffset;return 0!==n.node.childCount&&(t().deleteSelection().command(tM(e.selection.from,r,r)).run(),!0)})]);return{Backspace:()=>this.editor.commands.first(({chain:e,commands:t})=>[()=>t.deleteSelection(),()=>t.undoInputRule(),()=>t.command(({state:e})=>{let o=ev(e);if(!o.isBlockContainer)return!1;let n=e.selection.from===o.blockContent.beforePos+1,r="paragraph"===o.blockContent.node.type.name;return!!n&&!r&&t.command(eQ(o.bnBlock.beforePos,{type:"paragraph",props:{}}))}),()=>t.command(({state:e})=>{let o=ev(e);if(!o.isBlockContainer)return!1;let{blockContent:n}=o;return e.selection.from===n.beforePos+1&&t.liftListItem("blockContainer")}),()=>t.command(({state:t})=>{let o=ev(t);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,i=t.selection.from===r.beforePos+1,s=t.selection.empty,l=n.beforePos;return!!i&&!!s&&e().command(ne(l)).scrollIntoView().run()}),()=>t.command(({state:e,dispatch:t})=>{let o=ev(e);
12if(!o.isBlockContainer||e.selection.from!==o.blockContent.beforePos+1||o6(e.doc,o.bnBlock.beforePos))return!1;let n=o7(e.doc,o.bnBlock.beforePos);if((null==n?void 0:n.blockNoteType)!=="column")return!1;let r=o7(e.doc,n.bnBlock.beforePos);if((null==r?void 0:r.blockNoteType)!=="columnList")throw Error("parent of column is not a column list");let i=1===n.childContainer.node.childCount,s=i&&2===r.childContainer.node.childCount,l=r.childContainer.node.firstChild===n.bnBlock.node;if(t){let t=e.doc.slice(o.bnBlock.beforePos,o.bnBlock.afterPos,!1);if(s)if(l){e.tr.step(new a.Wg(r.bnBlock.beforePos,r.bnBlock.afterPos,n.bnBlock.afterPos+1,r.bnBlock.afterPos-2,t,t.size,!1));let o=e.tr.doc.resolve(n.bnBlock.beforePos);e.tr.setSelection(c.U3.between(o,o))}else{e.tr.step(new a.Wg(r.bnBlock.beforePos,r.bnBlock.afterPos,r.bnBlock.beforePos+2,n.bnBlock.beforePos-1,t,0,!1));let o=e.tr.doc.resolve(e.tr.mapping.map(n.bnBlock.beforePos-1));e.tr.setSelection(c.U3.between(o,o))}else if(i)if(l){e.tr.delete(n.bnBlock.beforePos,n.bnBlock.afterPos),e.tr.insert(r.bnBlock.beforePos,t.content);let o=e.tr.doc.resolve(r.bnBlock.beforePos);e.tr.setSelection(c.U3.between(o,o))}else e.tr.delete(n.bnBlock.beforePos-1,n.bnBlock.beforePos+1);else{e.tr.delete(o.bnBlock.beforePos,o.bnBlock.afterPos),l?e.tr.insert(r.bnBlock.beforePos-1,t.content):e.tr.insert(n.bnBlock.beforePos-1,t.content);let i=e.tr.doc.resolve(n.bnBlock.beforePos-1);e.tr.setSelection(c.U3.between(i,i))}}return!0}),()=>t.command(({state:t})=>{let o=ev(t);if(!o.isBlockContainer)return!1;if(0===o.blockContent.node.childCount&&"inline*"===o.blockContent.node.type.spec.content){let n=o6(t.doc,o.bnBlock.beforePos);if(!n||!n.isBlockContainer)return!1;let r=e();if("tableRow+"===n.blockContent.node.type.spec.content){let e=o.bnBlock.beforePos-1-1-1-1-1;r=r.setTextSelection(e)}else if(""===n.blockContent.node.type.spec.content){let e=n.blockContent.afterPos-n.blockContent.node.nodeSize;r=r.setNodeSelection(e)}else{let e=n.blockContent.afterPos-n.blockContent.node.nodeSize;r=r.setTextSelection(e)}return r.deleteRange({from:o.bnBlock.beforePos,to:o.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let o=ev(t);if(!o.isBlockContainer)throw Error("todo");let n=t.selection.from===o.blockContent.beforePos+1,r=t.selection.empty,i=o6(t.doc,o.bnBlock.beforePos);if(i&&n&&r){let n=o8(t.doc,i);if(!n.isBlockContainer)throw Error("todo");if(""===n.blockContent.node.type.spec.content||"inline*"===n.blockContent.node.type.spec.content&&0===n.blockContent.node.childCount)return e().cut({from:o.bnBlock.beforePos,to:o.bnBlock.afterPos},n.bnBlock.afterPos).deleteRange({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.command(({state:t})=>{let o=ev(t);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r,childContainer:i}=o,{depth:s}=t.doc.resolve(n.beforePos),l=n.afterPos===t.doc.nodeSize-3,a=t.selection.from===r.afterPos-1,d=t.selection.empty;if(!l&&a&&d&&void 0===i){let o=s,r=n.afterPos+1,i=t.doc.resolve(r).depth;for(;i<o;)o=i,r+=2,i=t.doc.resolve(r).depth;return e.command(ne(r-1))}return!1})]),Enter:()=>e(),"Shift-Enter":()=>e(!0),Tab:()=>{var e,t,o;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(o=this.options.editor.filePanel)||!o.shown))&&oc(this.options.editor)},"Shift-Tab":()=>{var e,t,o;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(o=this.options.editor.filePanel)||!o.shown))&&(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class no{constructor(e,t,o){U(this,"state"),U(this,"emitUpdate"),U(this,"menuUpdateTimer"),U(this,"startMenuUpdateTimer"),U(this,"stopMenuUpd
12ateTimer"),U(this,"mouseHoveredLinkMark"),U(this,"mouseHoveredLinkMarkRange"),U(this,"keyboardHoveredLinkMark"),U(this,"keyboardHoveredLinkMarkRange"),U(this,"linkMark"),U(this,"linkMarkRange"),U(this,"mouseOverHandler",e=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),e.target instanceof HTMLAnchorElement&&"A"===e.target.nodeName){let t=e.target,o=this.pmView.posAtDOM(t,0)+1,n=this.pmView.state.doc.resolve(o);for(let e of n.marks())if(e.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=e,this.mouseHoveredLinkMarkRange=(0,d.ve)(n,e.type,e.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1}),U(this,"clickHandler",e=>{var t;let o=this.pmView.dom.parentElement;this.linkMark&&e&&e.target&&!(o===e.target||o.contains(e.target))&&null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"scrollHandler",()=>{var e;void 0!==this.linkMark&&null!=(e=this.state)&&e.show&&(this.state.referencePos=(0,d.MG)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())}),U(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(e,t){var o;this.editor.transact(o=>{let n=ew(o);o.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),o.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,n.mark("link",{href:e}))}),this.pmView.focus(),null!=(o=this.state)&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var e;this.editor.transact(e=>e.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}update(e,t,o=!1){var n;let{state:r}=e;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;let i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){for(let e of this.pmView.state.selection.$from.marks())if(e.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=e,this.keyboardHoveredLinkMarkRange=(0,d.ve)(this.pmView.state.selection.$from,e.type,e.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:(0,d.MG)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if(null!=(n=this.state)&&n.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}let nn=new c.hs("LinkToolbarPlugin");class nr extends oG{constructor(e){super(),U(this,"view"),U(this,"editLink",(e,t)=>{this.view.editLink(e,t)}),U(this,"deleteLink",()=>{this.view.deleteLink()}),U(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()}),U(this,"stopHideTimer",()=>
12{this.view.stopMenuUpdateTimer()}),U(this,"closeMenu",()=>this.view.closeMenu()),this.addProsemirrorPlugin(new c.k_({key:nn,view:t=>(this.view=new no(e,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}}))}static key(){return"linkToolbar"}onUpdate(e){return this.on("update",e)}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}}let ni=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],ns="https",nl=new c.hs("node-selection-keyboard");class na extends oG{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new c.k_({key:nl,props:{handleKeyDown:(e,t)=>{if("node"in e.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(1===t.key.length)return t.preventDefault(),!0;if("Enter"===t.key&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){let t=e.state.tr;return e.dispatch(t.insert(e.state.tr.selection.$to.after(),e.state.schema.nodes.paragraph.createChecked()).setSelection(new c.U3(t.doc.resolve(e.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}let nd=new c.hs("blocknote-placeholder");class nc extends oG{static key(){return"placeholder"}constructor(e,t){super(),this.addProsemirrorPlugin(new c.k_({key:nd,view:o=>{var n,r;let i=`placeholder-selector-${(0,h.A)()}`;o.dom.classList.add(i);let s=document.createElement("style"),l=e._tiptapEditor.options.injectNonce;l&&s.setAttribute("nonce",l),(null==(n=e.prosemirrorView)?void 0:n.root)instanceof ShadowRoot?e.prosemirrorView.root.append(s):null==(r=e.prosemirrorView)||r.root.head.appendChild(s);let a=s.sheet,d=(e="")=>`.${i} .bn-block-content${e} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{let{default:e,emptyDocument:o,...n}=t;for(let[e,t]of Object.entries(n)){let o=`[data-content-type="${e}"]`;a.insertRule(`${d(o)} { content: ${JSON.stringify(t)}; }`)}a.insertRule(`${d("[data-is-only-empty-block]")} { content: ${JSON.stringify(o)}; }`),a.insertRule(`${d("[data-is-empty-and-focused]")} { content: ${JSON.stringify(e)}; }`)}catch(e){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",e)}return{destroy:()=>{var t,o;(null==(t=e.prosemirrorView)?void 0:t.root)instanceof ShadowRoot?e.prosemirrorView.root.removeChild(s):null==(o=e.prosemirrorView)||o.root.head.removeChild(s)}}},props:{decorations:t=>{let{doc:o,selection:n}=t;if(!e.isEditable||!n.empty||n.$from.parent.type.spec.code)return;let r=[];6===t.doc.content.size&&r.push(I.NZ.node(2,4,{"data-is-only-empty-block":"true"}));let i=n.$anchor,s=i.parent;if(0===s.content.size){let e=i.before();r.push(I.NZ.node(e,e+s.nodeSize,{"data-is-empty-and-focused":"true"}))}return I.zF.create(o,r)}}}))}}let nh=new c.hs("previous-blocks"),nu={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class np extends oG{static key(){return"previousBlockType"}constructor(){let e;super(),this.addProsemirrorPlugin(new c.k_({key:nh,view(t){return{update:async(t,o)=>{var n;(null==(n=this.key)?void 0:n.getState(t.state).updatedBlocks.size)>0&&(e=setTimeout(()=>{t.dispatch(t.state.tr.setMeta(nh,{clearUpdate:!0}))},0))},destroy:()=>{e&&clearTimeout(e)}}},state:{init:()=>({prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}),apply(e,t,o,n){if(t.currentTransactionOldBlockAttrs={},t.updatedBlocks.clear(),!e.docChanged||o.doc.eq(n.doc))return t;let r={},i=new Map((0,d.xe)(o.doc,e=>e.attrs.id).map(e=>[e.node.attrs.id,e]));for(let s of(0,d.xe)(n.doc,e=>e.attrs.id)){let l=i.get(s.node.attrs.id),a=null==l?void 0:l.node.firstChild,d=s.node.firstChild;if(l&&a&&d){let i={index:d.attrs.index,level:d.attrs.level,type:d.type.name,depth:n.doc.resolve(s.pos).depth},c={index:a.attrs.index,level:a.attrs.level,type:a.type.name,depth:o.doc.resolve(l.pos).depth};r[s.node.attrs.id]=c,e.getMeta("numberedListIndexing")&&(s.node.attrs.id in t.prevTransactionOldBlockAttrs&&(c=t.prevTransactionOldBlockAttrs[s.node.attrs.id]),"numberedListItem"===i.type&&(c.index=i.index)),t.currentTransactionOldBlockAttrs[s.node.attrs.id]=c,JSON.stringify(c)!==JSON.stringify(i)&&(c["depth-change"]=c.depth-i.depth,t.updatedBlocks.add(s.node.attrs.id))}}return t.prevTransactionOldBlockAttrs=r,t}},props:{decorations(e){let t=this.getState(e);if(0===t.updatedBlocks.size)return;let o=[];return e.doc.descendants((e,n)=>{if(!e.attrs.id||!t.updatedBlocks.has(e.attrs.id))return;let r=t.currentTransactionOldBlockAttrs[e.attrs.id],i={};for(let[e,t]of Object.entries(r))i["data-prev-"+nu[e]]=t||"none";let s=I.NZ.node(n,n+e.nodeSize,{...i});o.push(s)}),I.zF.create(e.doc,o)}}}))}}let nm=new c.hs("blocknote-show-selection");class nf extends oG{constructor(e){super(),U(this,"enabled",!1),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nm,props:{decorations:e=>{let{doc:t,selection:o}=e;if(!this.enabled)return I.zF.empty;let n=I.NZ.inline(o.from,o.to,{"data-show-selection":"true"});return I.zF.create(t,[n])}}}))}static key(){return"showSelection"}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.editor.transact(e=>e.setMeta(nm,{})))}getEnabled(){return this.enabled}}function ng(e,t){for(var o,n;e&&e.parentElement&&e.parentElement!==t.dom&&(null==(o=e.getAttribute)?void 0:o.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if((null==(n=e.getAttribute)?void 0:n.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class nb extends c.LN{constructor(e,t){super(e,t),U(this,"nodes");let o=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,t.pos,(e,t,n)=>{if(null!==n&&n.eq(o))return this.nodes.push(e),!1})}static create(e,t,o=t){return new nb(e.resolve(t),e.resolve(o))}content(){return new l.Ji(l.FK.from(this.nodes),0,0)}eq(e){if(!(e instanceof nb)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let t=0;t<this.nodes.length;t++)if(!this.nodes[t].eq(e.nodes[t]))return!1;return!0}map(e,t){let o=t.mapResult(this.from),n=t.mapResult(this.to);return n.deleted?c.LN.near(e.resolve(o.pos)):o.deleted?c.LN.near(e.resolve(n.pos)):new nb(e.resolve(o.pos),e.resolve(n.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}function nk(e,t,o=t){t===o&&(o+=e.state.doc.resolve(t+1).node().nodeSize);let n=e.domAtPos(t).node.cloneNode(!0),i=e.domAtPos(t).node,s=(e,t)=>Array.prototype.indexOf.call(e.children,t),l=s(i,e.domAtPos(t+1).node.parentElement),a=s(i,e.domAtPos(o-1).node.parentElement);for(let e=i.childElementCount-1;e>=0;e--)(e>a||e<l)&&n.removeChild(n.children[e]);nv(e.root);let d=(r=n).getElementsByTagName("iframe");for(let e=0;e<d.length;e++){let t=d[e],o=t.parentElement;o&&o.removeChild(t)}let c=e.dom.className.split(" ").filter(e=>"ProseMirror"!==e&&"bn-root"!==e&&"bn-editor"!==e).join(" ");r.className=r.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(r):e.root.body.appendChild(r)}function nv(e){void 0!==r&&(e instanceof ShadowRoot?e.removeChild(r):e.body.removeChild(r),r=void 0)}function ny(e,t,o=!0){for(let n of e.root.elementsFromPoint(t.left,t.top))if(e.dom.contains(n))return o&&n.closest("[data-node-type=columnList]")?ny(e,{left:t.left+50,top:t.top},!1):ng(n,e)}c.LN.jsonID("multiple-node",nb);class nw{constructor(e,t,o){U(this,"state"),U(this,"emitUpdate"),U(this,"mousePos"),U(this,"hoveredBlock"),U(this,"menuFrozen",!1),U(this,"isDragOrigin",!1),U(this,"updateState",e=>{this.state=e,this.emitUpdate(this.state)}),U(this,"updateStateFromMousePos",()=>{var e,t,o,n,r;
12if(this.menuFrozen||!this.mousePos)return;let i=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((null==i?void 0:i.element)!==this.pmView.dom||i.distance>250){null!=(e=this.state)&&e.show&&(this.state.show=!1,this.updateState(this.state));return}let s=function(e,t){if(!t.dom.firstChild)return;let o=t.dom.firstChild.getBoundingClientRect(),n=ny(t,{left:Math.min(Math.max(o.left+10,e.x),o.right-10),top:e.y});if(n)return ny(t,{left:n.node.getBoundingClientRect().right-10,top:e.y},!1)}(this.mousePos,this.pmView);if(!s||!this.editor.isEditable){null!=(t=this.state)&&t.show&&(this.state.show=!1,this.updateState(this.state));return}if(!(null!=(o=this.state)&&o.show&&null!=(n=this.hoveredBlock)&&n.hasAttribute("data-id")&&(null==(r=this.hoveredBlock)?void 0:r.getAttribute("data-id"))===s.id)&&(this.hoveredBlock=s.node,this.editor.isEditable)){let e=s.node.getBoundingClientRect(),t=s.node.closest("[data-node-type=column]");this.state={show:!0,referencePos:new DOMRect(t?t.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,e.y,e.width,e.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateState(this.state)}}),U(this,"onDragStart",e=>{var t;let o=null==(t=e.dataTransfer)?void 0:t.getData("blocknote/html");if(!o||this.pmView.dragging)return;let n=document.createElement("div");n.innerHTML=o;let r=l.S4.fromSchema(this.pmView.state.schema).parse(n,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new l.Ji(r.content,0,0),move:!0}}),U(this,"findClosestEditorElement",e=>{let t=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(0===t.length)return null;let o=t[0],n=Number.MAX_VALUE;return t.forEach(t=>{let r=t.querySelector(".bn-block-group").getBoundingClientRect(),i=Math.sqrt(Math.pow(e.clientX<r.left?r.left-e.clientX:e.clientX>r.right?e.clientX-r.right:0,2)+Math.pow(e.clientY<r.top?r.top-e.clientY:e.clientY>r.bottom?e.clientY-r.bottom:0,2));i<n&&(n=i,o=t)}),{element:o,distance:n}}),U(this,"onDragOver",e=>{if(e.synthetic)return;let t=this.getDragEventContext(e);if(!t||!t.isDropPoint)return void this.closeDropCursor();t.isDropPoint&&!t.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(e)}),U(this,"closeDropCursor",()=>{let e=new Event("dragleave",{bubbles:!1});e.synthetic=!0,this.pmView.dom.dispatchEvent(e)}),U(this,"getDragEventContext",e=>{var t;let o=!(null!=(t=e.dataTransfer)&&t.types.includes("blocknote/html"))&&!!this.pmView.dragging,n=!!this.isDragOrigin,r=o||n,i=this.findClosestEditorElement(e);if(!i||i.distance>250)return;let s=i.element===this.pmView.dom,l=s&&0===i.distance;if(!(!s&&!r))return{isDropPoint:s,isDropWithinEditorBounds:l,isDragOrigin:r}}),U(this,"onDrop",e=>{if(e.synthetic)return;let t=this.getDragEventContext(e);if(!t)return void this.closeDropCursor();let{isDropPoint:o,isDropWithinEditorBounds:n,isDragOrigin:r}=t;if(!n&&o&&this.dispatchSyntheticEvent(e),o){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(c.U3.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}if(r)return void setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0)}),U(this,"onDragEnd",e=>{e.synthetic||(this.pmView.dragging=null)}),U(this,"onKeyDown",e=>{var t;null!=(t=this.state)&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))}),U(this,"onMouseMove",e=>{var t;if(this.menuFrozen)return;this.mousePos={x:e.clientX,y:e.clientY};let o=this.pmView.dom.getBoundingClientRect(),n=this.mousePos.x>o.left&&this.mousePos.x<o.right&&this.mousePos.y>o.top&&this.mousePos.y<o.bottom,r=this.pmView.dom.parentElement;if(n&&e&&e.target&&!(r===e.target||r.contains(e.target))){null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()}),U(this,"onScroll",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state)),this.updateStateFromMousePos()}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized side menu");o(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),oh(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),t.root.addEventListener("scroll",this.onScroll,!0)}dispatchSyntheticEvent(e){let t=new Event(e.type,e),o=this.pmView.dom.firstChild.getBoundingClientRect();t.clientX=e.clientX,t.clientY=e.clientY,t.clientX=Math.min(Math.max(e.clientX,o.left),o.left+o.width),t.clientY=Math.min(Math.max(e.clientY,o.top),o.top+o.height),t.dataTransfer=e.dataTransfer,t.preventDefault=()=>e.preventDefault(),t.synthetic=!0,this.pmView.dom.dispatchEvent(t)}update(e,t){var o;!t.doc.eq(this.pmView.state.doc)&&null!=(o=this.state)&&o.show&&this.updateStateFromMousePos()}destroy(){var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}let nC=new c.hs("SideMenuPlugin");class nE extends oG{constructor(e){super(),U(this,"view"),U(this,"blockDragStart",(e,t)=>{this.view&&(this.view.isDragOrigin=!0),function(e,t,o){if(!e.dataTransfer)return;let n=o.prosemirrorView;if(!n)return;let i=eY(t.id,n.state.doc);if(!i)throw Error(`Block with ID ${t.id} not found`);let s=i.posBeforeNode;if(null!=s){let t=n.state.selection,i=n.state.doc,{from:l,to:a}=function(e,t){let o,n,r="blockContent"===t.resolve(e.from).node().type.spec.group,i="blockContent"===t.resolve(e.to).node().type.spec.group,s=Math.min(e.$anchor.depth,e.$head.depth);if(r&&i){let r=e.$from.start(s-1),i=e.$to.end(s-1);o=t.resolve(r-1).pos,n=t.resolve(i+1).pos}else o=e.from,n=e.to;return{from:o,to:n}}(t,i),d=l<=s&&s<a,h=t.$anchor.node()!==t.$head.node()||t instanceof nb;d&&h?(n.dispatch(n.state.tr.setSelection(nb.create(i,l,a))),nk(n,l,a)):(n.dispatch(n.state.tr.setSelection(c.nh.create(n.state.doc,s))),nk(n,s));let u=n.state.selection.content(),p=o.pmSchema,m=n.serializeForClipboard(u).dom.innerHTML,f=e5(p,o),g=o_(u.content),b=f.exportBlocks(g,{}),k=om(b);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",b),e.dataTransfer.setData("text/plain",k),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(r,0,0)}}(e,t,this.editor)}),U(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&nv(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)}),U(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)}),U(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)}),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nC,view:t=>(this.view=new nw(e,t,e=>
12{this.emit("update",e)}),this.view)}))}static key(){return"sideMenu"}onUpdate(e){return this.on("update",e)}}let nS=new Map,nx=(0,d.KP)(e=>"blockContainer"===e.type.name);class nM{constructor(e,t){var o,n;U(this,"state"),U(this,"emitUpdate"),U(this,"rootEl"),U(this,"pluginState"),U(this,"handleScroll",()=>{var e,t;if(null!=(e=this.state)&&e.show){let e=null==(t=this.rootEl)?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!e)return;this.state.referencePos=e.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}}),U(this,"closeMenu",()=>{this.editor.transact(e=>e.setMeta(nT,null))}),U(this,"clearQuery",()=>{void 0!==this.pluginState&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(e=>e.selection.from)}).run()}),this.editor=e,this.pluginState=void 0,this.emitUpdate=e=>{var o;if(!this.state)throw Error("Attempting to update uninitialized suggestions menu");t(e,{...this.state,ignoreQueryLength:null==(o=this.pluginState)?void 0:o.ignoreQueryLength})},this.rootEl=null==(o=this.editor.prosemirrorView)?void 0:o.root,null==(n=this.rootEl)||n.addEventListener("scroll",this.handleScroll,!0)}update(e,t){var o;let n=nT.getState(t),r=nT.getState(e.state),i=void 0!==n&&void 0===r;if((void 0!==n||void 0===r)&&(void 0===n||void 0===r)&&!i)return;if(this.pluginState=i?n:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}let s=null==(o=this.rootEl)?void 0:o.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&s&&(this.state={show:!0,referencePos:s.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var e;null==(e=this.rootEl)||e.removeEventListener("scroll",this.handleScroll,!0)}}let nT=new c.hs("SuggestionMenuPlugin");class nB extends oG{constructor(e){super(),U(this,"view"),U(this,"triggerCharacters",[]),U(this,"addTriggerCharacter",e=>{this.triggerCharacters.push(e)}),U(this,"removeTriggerCharacter",e=>{this.triggerCharacters=this.triggerCharacters.filter(t=>t!==e)}),U(this,"closeMenu",()=>this.view.closeMenu()),U(this,"clearQuery",()=>this.view.clearQuery());let t=this.triggerCharacters;this.addProsemirrorPlugin(new c.k_({key:nT,view:()=>(this.view=new nM(e,(e,t)=>{this.emit(`update ${e}`,t)}),this.view),state:{init(){},apply:(t,o,n,r)=>{if(void 0!==t.getMeta("orderedListIndexing")||t.selection.$from.parent.type.spec.code)return o;let i=t.getMeta(nT);if("object"==typeof i&&null!==i){o&&this.closeMenu();let t=function(e,t,o="left"){let n=L.pJ.getState(e._tiptapEditor.state);if(!n){let n=function(e){if(nS.has(e))return nS.get(e);let t=new a.X9;return e._tiptapEditor.on("transaction",({transaction:e})=>{t.appendMapping(e.mapping)}),e._tiptapEditor.on("destroy",()=>{nS.delete(e)}),nS.set(e,t),t}(e),r=n.maps.length;return()=>n.slice(r).map(t,"left"===o?-1:1)}let r=(0,A.Bw)(t+ +("right"===o),n.binding.type,n.binding.mapping);return()=>{let t=L.pJ.getState(e._tiptapEditor.state),n=(0,A.bL)(t.doc,t.binding.type,r,t.binding.mapping);if(null===n)throw Error("Position not found, cannot track positions");return n+("right"===o?-1:0)}}(e,r.selection.from-i.triggerCharacter.length);return{triggerCharacter:i.triggerCharacter,deleteTriggerCharacter:!1!==i.deleteTriggerCharacter,queryStartPos:()=>t()+i.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(0xffffffff*Math.random())}`,ignoreQueryLength:null==i?void 0:i.ignoreQueryLength}}if(void 0===o)return o;if(r.selection.from!==r.selection.to||null===i||t.getMeta("focus")||t.getMeta("blur")||t.getMeta("pointer")||void 0!==o.triggerCharacter&&r.selection.from<o.queryStartPos()||!r.selection.$from.sameParent(r.doc.resolve(o.queryStartPos())))return;let s={...o};return s.query=r.doc.textBetween(o.queryStartPos(),r.selection.from),s}},props:{handleTextInput(e,o,n,r){if(o===n){let n=e.state.doc;for(let i of t){let t=i.length>1?n.textBetween(o-i.length,o)+r:r;if(i===t)return e.dispatch(e.state.tr.insertText(r)),e.dispatch(e.state.tr.setMeta(nT,{triggerCharacter:t}).scrollIntoView()),!0}}return!1},decorations(e){let t=this.getState(e);if(void 0===t)return null;if(!t.deleteTriggerCharacter){let o=nx(e.selection);if(o)return I.zF.create(e.doc,[I.NZ.node(o.pos,o.pos+o.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}return I.zF.create(e.doc,[I.NZ.inline(t.queryStartPos()-t.triggerCharacter.length,t.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(e,t){return this.triggerCharacters.includes(e)||this.addTriggerCharacter(e),this.on(`update ${e}`,t)}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}}let nP=d.CU.create({name:"insertion",inclusive:!1,excludes:"deleti
12on modification insertion",addAttributes:()=>({id:{default:null,validate:"number"}}),extendMarkSchema:e=>"insertion"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>["ins",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0],parseDOM:[{tag:"ins",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10)}}]}}),nL=d.CU.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes:()=>({id:{default:null,validate:"number"}}),extendMarkSchema:e=>"deletion"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>["del",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0],parseDOM:[{tag:"del",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10)}}]}}),nA=d.CU.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes:()=>({id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}),extendMarkSchema:e=>"modification"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>[t?"span":"div",{"data-type":"modification","data-id":String(e.attrs.id),"data-mod-type":e.attrs.type,"data-mod-prev-val":JSON.stringify(e.attrs.previousValue),"data-mod-new-val":JSON.stringify(e.attrs.newValue)},0],parseDOM:[{tag:"span[data-type='modification']",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal,newValue:e.dataset.modNewVal}},{tag:"div[data-type='modification']",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal}}]}});function nI(e){i||((i=document.createElement("div")).innerHTML="_",i.style.opacity="0",i.style.height="1px",
12i.style.width="1px",e instanceof Document?e.body.appendChild(i):e.appendChild(i))}function nH(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}class nN{constructor(e,t,o){U(this,"state"),U(this,"emitUpdate"),U(this,"tableId"),U(this,"tablePos"),U(this,"tableElement"),U(this,"menuFrozen",!1),U(this,"mouseState","up"),U(this,"prevWasEditable",null),U(this,"viewMousedownHandler",()=>{this.mouseState="down"}),U(this,"mouseUpHandler",e=>{this.mouseState="up",this.mouseMoveHandler(e)}),U(this,"mouseMoveHandler",e=>{var t,o,n,r,i,s,l;let a;if(this.menuFrozen||"selecting"===this.mouseState||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let d=function(e){let t=e;for(;t&&"TD"!==t.nodeName&&"TH"!==t.nodeName&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;let e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return"TD"===t.nodeName||"TH"===t.nodeName?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}(e.target);if((null==d?void 0:d.type)==="cell"&&"down"===this.mouseState&&!(null!=(t=this.state)&&t.draggingState)){this.mouseState="selecting",null!=(o=this.state)&&o.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!d||!this.editor.isEditable){null!=(n=this.state)&&n.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!d.tbodyNode)return;let c=d.tbodyNode.getBoundingClientRect(),h=ng(d.domNode,this.pmView);if(!h)return;this.tableElement=h.node;let u=this.editor.transact(e=>eY(h.id,e.doc));if(!u)throw Error(`Block with ID ${h.id} not found`);let p=eL(u.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(function(e,t,o){return t.type===e&&t.type in o.schema.blockSchema&&t5(t.type,o)}("table",p,this.editor)&&(this.tablePos=u.posBeforeNode+1,a=p),!a)return;this.tableId=h.id;let m=null==(r=d.domNode.closest(".tableWrapper"))?void 0:r.querySelector(".table-widgets-container");if((null==d?void 0:d.type)==="wrapper"){let t=e.clientY>=c.bottom-1&&e.clientY<c.bottom+20,o=e.clientX>=c.right-1&&e.clientX<c.right+20,n=e.clientX>c.right||e.clientY>c.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:o,referencePosTable:c,block:a,widgetContainer:m,colIndex:n||null==(i=this.state)?void 0:i.colIndex,rowIndex:n||null==(s=this.state)?void 0:s.rowIndex,referencePosCell:n||null==(l=this.state)?void 0:l.referencePosCell}}else{let e=nH(d.domNode),t=nH(d.domNode.parentElement),o=d.domNo
12de.getBoundingClientRect();if(void 0!==this.state&&this.state.show&&this.tableId===h.id&&this.state.rowIndex===t&&this.state.colIndex===e)return;this.state={show:!0,showAddOrRemoveColumnsButton:e===a.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:t===a.content.rows.length-1,referencePosTable:c,block:a,draggingState:void 0,referencePosCell:o,colIndex:e,rowIndex:t,widgetContainer:m}}return this.emitUpdate(),!1}),U(this,"dragOverHandler",e=>{var t;if((null==(t=this.state)?void 0:t.draggingState)===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect="move",function(e,t){let o=t.querySelectorAll(e);for(let e=0;e<o.length;e++)o[e].style.visibility="hidden"}(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);let o={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},n=this.pmView.root.elementsFromPoint(o.left,o.top).filter(e=>"TD"===e.tagName||"TH"===e.tagName);if(0===n.length)return;let r=n[0],i=!1,s=nH(r.parentElement),l=nH(r),a="row"===this.state.draggingState.draggedCellOrientation?this.state.rowIndex:this.state.colIndex,d=("row"===this.state.draggingState.draggedCellOrientation?s:l)!==a;(this.state.rowIndex!==s||this.state.colIndex!==l)&&(this.state.rowIndex=s,this.state.colIndex=l,this.state.referencePosCell=r.getBoundingClientRect(),i=!0);let c="row"===this.state.draggingState.draggedCellOrientation?o.top:o.left;this.state.draggingState.mousePos!==c&&(this.state.draggingState.mousePos=c,i=!0),i&&this.emitUpdate(),d&&this.editor.transact(e=>e.setMeta(nO,!0))}),U(this,"dropHandler",e=>{if(this.mouseState="up",void 0===this.state||void 0===this.state.draggingState)return!1;if(void 0===this.state.rowIndex||void 0===this.state.colIndex)throw Error("Attempted to drop table row or column, but no table block was hovered prior.");e.preventDefault();let{draggingState:t,colIndex:o,rowIndex:n}=this.state,r=this.state.block.content.columnWidths;if("row"===t.draggedCellOrientation){if(!eF(this.state.block,t.originalIndex,n))return!1;let e=function(e,t,o,n=eN(e)){let{row:r}=eV({row:t,col:0},e,n),{row:i}=eV({row:o,col:0},e,n),[s]=n.splice(r,1);return n.splice(i,0,s),eO(n)}(this.state.block,t.originalIndex,n);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:e}})}else{if(!ez(this.state.block,t.originalIndex,o))return!1;let e=function(e,t,o,n=eN(e)){let{col:r}=eV({row:0,col:t},e,n),{col:i}=eV({row:0,col:o},e,n);return n.forEach(e=>{let[t]=e.splice(r,1);e.splice(i,0,t)}),eO(n)}(this.state.block,t.originalIndex,o),[n]=r.splice(t.originalIndex,1);r.splice(o,0,n),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:r,rows:e}})}return this.editor.setTextCursorPosition(this.state.block.id),!0}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var e;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||"table"!==this.state.block.type||!(null!=(e=this.tableElement)&&e.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}let{height:t,width:o}=eD(this.state.block);void 0!==this.state.rowIndex&&void 0!==this.state.colIndex&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=o&&(this.state.colIndex=o-1));let n=this.tableElement.querySelector("tbody");if(!n)throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(void 0!==this.state.rowIndex&&void 0!==this.state.colIndex){let e=n.children[this.state.rowIndex].children[this.state.colIndex];e?this.state.referencePosCell=e.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=n.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}let nO=new c.hs("TableHandlesPlugin");class nV extends oG{constructor(e){super(),U(this,"view"),U(this,"colDragStart",e=>{if(void 0===this.view.state||void 0===this.view.state.colIndex)throw Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:e.clientX},this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nO,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");nI(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="move"}),U(this,"rowDragStart",e=>{if(void 0===this.view.state||void 0===this.view.state.rowIndex)throw Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:e.clientY},this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nO,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");nI(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="copyMove"}),U(this,"dragEnd",()=>{if(void 0===this.view.state)throw Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nO,null)),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");!function(e){i&&(e instanceof Document?e.body.removeChild(i):e.removeChild(i),i=void 0)}(this.editor.prosemirrorView.root)}),U(this,"freezeHandles",()=>{this.view.menuFrozen=!0}),U(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1}),U(this,"getCellsAtRowHandle",(e,t)=>e_(e,t)),U(this,"getCellsAtColumnHandle",(e,t)=>e$(e,t)),U(this,"setCellSelection",(e,t,o=t)=>{let n=this.view;if(!n)throw Error("Table handles view not initialized");let r=e.doc.resolve(n.tablePos+1),i=e.doc.resolve(r.posAtIndex(t.row)+1),s=e.doc.resolve(i.posAtIndex(t.col)),l=e.doc.resolve(r.posAtIndex(o.row)+1),a=e.doc.resolve(l.posAtIndex(o.col)),d=e.tr;return d.setSelection(new u.rn(s,a)),e.apply(d)}),U(this,"addRowOrColumn",(e,t)=>{this.editor.exec((o,n)=>{let r=this.setCellSelection(o,"row"===t.orientation?{row:e,col:0}:{row:0,col:e});return"row"===t.orientation?"above"===t.side?(0,u.JD)(r,n):(0,u.gC)(r,n):"left"===t.side?(0,u.RC)(r,n):(0,u.GU)(r,n)})}),U(this,"removeRowOrColumn",(e,t)=>"row"===t?this.editor.exec((t,o)=>{let n=this.setCellSelection(t,{row:e,col:0});return(0,u.aR)(n,o)}):this.editor.exec((t,o)=>{let n=this.setCellSelection(t,{row:0,col:e});return(0,u.gR)(n,o)})),U(this,"mergeCells",e=>this.editor.exec((t,o)=>{let n=e?this.setCellSelection(t,e.relativeStartCell,e.relativeEndCell):t;return(0,u.w7)(n,o)})),U(this,"splitCell",e=>this.editor.exec((t,o)=>{let n=e?this.setCellSelection(t,e):t;return(0,u.L0)(n,o)})),U(this,"getCellSelection",()=>this.editor.transact(e=>{let t=e.selection,o=t.$from,n=t.$to;if(ot(t)){let{ranges:e}=t;
12e.forEach(e=>{o=e.$from.min(o??e.$from),n=e.$to.max(n??e.$to)})}else if(o=e.doc.resolve(t.$from.pos-t.$from.parentOffset-1),n=e.doc.resolve(t.$to.pos-t.$to.parentOffset-1),0===o.pos||0===n.pos)return;let r=e.doc.resolve(o.pos-o.parentOffset-1),i=e.doc.resolve(n.pos-n.parentOffset-1),s=e.doc.resolve(r.pos-r.parentOffset-1),l=o.index(r.depth),a=r.index(s.depth),d=n.index(i.depth),c=i.index(s.depth),h=[];for(let e=a;e<=c;e++)for(let t=l;t<=d;t++)h.push({row:e,col:t});return{from:{row:a,col:l},to:{row:c,col:d},cells:h}})),U(this,"getMergeDirection",e=>this.editor.transact(t=>{let o=ot(t.selection)?t.selection:void 0;if(!o||!e||o.ranges.length<=1)return;let n=this.getCellSelection();if(n)return!function(e,t,o){let n=eV(e,o),r=eV(t,o);return n.col===r.col}(n.from,n.to,e)?"horizontal":"vertical"})),U(this,"cropEmptyRowsOrColumns",(e,t)=>(function(e,t,o=eN(e)){if("columns"===t){let e=0;for(let t=o[0].length-1;t>=0&&o.every(e=>eR(e[t].cell)&&1===e[t].colspan);t--)e++;for(let t=o.length-1;t>=0;t--){let n=Math.max(o[t].length-e,1);o[t]=o[t].slice(0,n)}return eO(o)}let n=0;for(let e=o.length-1;e>=0&&o[e].every(e=>eR(e.cell)&&1===e.rowspan);e--)n++;let r=Math.min(n,o.length-1);return o.splice(o.length-r,r),eO(o)})(e,t)),U(this,"addRowsOrColumns",(e,t,o)=>(function(e,t,o,n=eN(e)){let{width:r,height:i}=eD(e);if("columns"===t)n.forEach((e,t)=>{if(o>=0)for(let n=0;n<o;n++)e.push({row:t,col:Math.max(...e.map(e=>e.col))+1,rowspan:1,colspan:1,cell:z("")});else e.splice(r+o,-1*o)});else if(o>0)for(let e=0;e<o;e++){let t=Array(r).fill(null).map((t,o)=>({row:i+e,col:o,rowspan:1,colspan:1,cell:z("")}));n.push(t)}else o<0&&n.splice(i+o,-1*o);return eO(n)})(e,t,o)),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nO,view:t=>(this.view=new nN(e,t,e=>{this.emit("update",e)}),this.view),props:{decorations:e=>{if(void 0===this.view||void 0===this.view.state||void 0===this.view.state.draggingState||void 0===this.view.tablePos)return;let t="row"===this.view.state.draggingState.draggedCellOrientation?this.view.state.rowIndex:this.view.state.colIndex;if(void 0===t)return;let o=[],{block:n,draggingState:r}=this.view.state,{originalIndex:i,draggedCellOrientation:s}=r;if(t===i||!n||"row"===s&&!eF(n,i,t)||"col"===s&&!ez(n,i,t))return I.zF.create(e.doc,o);let l=e.doc.resolve(this.view.tablePos+1);return"row"===this.view.state.draggingState.draggedCellOrientation?e_(this.view.state.block,t).forEach(({row:n,col:r})=>{let s=e.doc.resolve(l.posAtIndex(n)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);o.push(I.NZ.widget(c,()=>{let e=document.createElement("div");return e.className="bn-table-drop-cursor",e.style.left="0",e.style.right="0",t>i?e.style.bottom="-2px":e.style.top="-3px",e.style.height="4px",e}))}):e$(this.view.state.block,t).forEach(({row:n,col:r})=>{let s=e.doc.resolve(l.posAtIndex(n)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);o.push(I.NZ.widget(c,()=>{let e=document.createElement("div");return e.className="bn-table-drop-cursor",e.style.top="0",e.style.bottom="0",t>i?e.style.right="-2px":e.style.left="-3px",e.style.width="4px",e}))}),I.zF.create(e.doc,o)}}}))}static key(){return"tableHandles"}onUpdate(e){return this.on("update",e)}}let nD=d.YY.create({name:"textAlignment",addGlobalAttributes:()=>[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>"left"===e.textAlignment?{}:{"data-text-alignment":e.textAlignment}}}}]}),nU=d.YY.create({name:"blockTextColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:et.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):et.textColor.default,renderHTML:e=>e.textColor===et.textColor.default?{}:{"data-text-color":e.textColor}}}}]}),n_=d.YY.create({name:"trailingNode",addProseMirrorPlugins(){let e=new c.hs(this.name);return[new c.k_({key:e,appendTransaction:(t,o,n)=>{let{doc:r,tr:i,schema:s}=n,l=e.getState(n),a=r.content.size-2,d=s.nodes.blockContainer,c=s.nodes.paragraph;if(l)return i.insert(a,d.create(void 0,c.create()))},state:{init:(e,t)=>
12{},apply:(e,t)=>{if(!e.docChanged)return t;let o=e.doc.lastChild;if(!o||"blockGroup"!==o.type.name)throw Error("Expected blockGroup");if(!(o=o.lastChild)||"blockContainer"!==o.type.name)return!0;let n=o.firstChild;if(!n)throw Error("Expected blockContent");return o.nodeSize>4||"inline*"!==n.type.spec.content}}})]}}),n$={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},nR=d.bP.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if("string"==typeof e)return!1;let t={};for(let[o,n]of Object.entries(n$))e.getAttribute(n)&&(t[o]=e.getAttribute(n));return t}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var t;let o=document.createElement("div");for(let[t,n]of(o.className="bn-block-outer",o.setAttribute("data-node-type","blockOuter"),Object.entries(e)))"class"!==t&&o.setAttribute(t,n);let n={...(null==(t=this.options.domAttributes)?void 0:t.block)||{},...e},r=document.createElement("div");for(let[e,t]of(r.className=X("bn-block",n.class),r.setAttribute("data-node-type",this.name),Object.entries(n)))"class"!==e&&r.setAttribute(e,t);return o.appendChild(r),{dom:o,contentDOM:r}}}),nF=d.bP.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML:()=>[{tag:"div",getAttrs:e=>"string"!=typeof e&&"blockGroup"===e.getAttribute("data-node-type")&&null}],renderHTML({HTMLAttributes:e}){var t;let o={...(null==(t=this.options.domAttributes)?void 0:t.blockGroup)||{},...e},n=document.createElement("div");for(let[e,t]of(n.className=X("bn-block-group",o.class),n.setAttribute("data-node-type","blockGroup"),Object.entries(o)))"class"!==e&&n.setAttribute(e,t);return{dom:n,contentDOM:n}}}),nz=d.bP.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class nj extends oG{constructor({editor:e,collaboration:t}){super(e),U(this,"editor"),U(this,"collaboration"),U(this,"forkedState"),this.editor=e,this.collaboration=t}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(e,t){let o=e.doc;if(null===e._item){let n=Array.from(o.share.keys()).find(t=>o.share.get(t)===e);if(null==n)throw Error("type does not exist in other ydoc");return t.get(n,e.constructor)}{let o=e._item,n=t.store.clients.get(o.id.client)??[],r=H.A$(n,o.id.clock);return n[r].content.type}}get isForkedFromRemote(){return void 0!==this.forkedState}fork(){var e;if(this.isForkedFromRemote)return;let t=null==(e=this.collaboration)?void 0:e.fragment;if(!t)throw Error("No fragment to fork from");let o=new H.JA;H.QE(o,H.PR(t.doc));let n=this.findTypeInOtherYdoc(t,o);this.forkedState={undoStack:L.Mj.getState(this.editor.prosemirrorState).undoManager.undoStack,originalFragment:t,forkedFragment:n},this.editor._tiptapEditor.unregisterPlugin([L.S6,L.Mj,L.pJ]),this.editor._tiptapEditor.registerPlugin(new oJ(n).plugins[0]),this.editor._tiptapEditor.registerPlugin(new oK({editor:this.editor}).plugins[0]),this.emit("forked",!0)}merge({keepChanges:e}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(L.pJ),this.editor._tiptapEditor.unregisterPlugin(L.Mj);let{originalFragment:t,forkedFragment:o,undoStack:n}=this.forkedState;if(this.editor.extensions.ySyncPlugin=new oJ(t),this.editor.extensions.yCursorPlugin=new oq(this.collaboration),this.editor.extensions.yUndoPlugin=new oK({editor:this.editor}),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.ySyncPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yCursorPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yUndoPlugin.plugins[0]),L.Mj.getState(this.editor.prosemirrorState).undoManager.undoStack=n,e){let e=H.PR(o.doc,H.FX(t.doc));H.QE(t.doc,e,this.editor)}this.forkedState=void 0,this.emit("forked",!1)}}let nG=!1;function nW(e,t){let o=l.FK.from(e.content);if(!function(e,t){var o,n;let r=1===e.childCount,i=(null==(o=e.firstChild)?void 0:o.type.spec.content)==="inline*",s=(null==(n=e.firstChild)?void 0:n.type.spec.content)==="tableRow+";if(r){if(i)return!1;if(s){let e=ev(t.state);if(e.isBlockContainer)return"tableRow+"!==e.blockContent.node.type.spec.content}}return!0}(o=function(e,t){let o=[];for(let n=0;n<e.childCount;n++)if("tableRow"===e.child(n).type.name)if(o.length>0&&"table"===o[o.length-1].type.name){let t=o[o.length-1],r=t.copy(t.content.addToEnd(e.child(n)));o[o.length-1]=r}else{let r=t.nodes.table.createChecked(void 0,e.child(n));o.push(r)}else o.push(e.child(n));return l.FK.from(o)}(o,t.state.schema),t))return new l.Ji(o,e.openStart,e.openEnd);for(let e=0;e<o.childCount;e++)if("blockContent"===o.child(e).type.spec.group){let n=[o.child(e)];if(e+1<o.childCount&&"blockGroup"===o.child(e+1).type.name){let t=o.child(e+1).child(0).child(0);("bulletListItem"===t.type.name||"numberedListItem"===t.type.name||"checkListItem"===t.type.name)&&(n.push(o.child(e+1)),o=function(e,t){let o=[];return e.forEach((e,n,r)=>{r!==t&&o.push(e)}),l.FK.from(o)}(o,e+1))}let r=t.state.schema.nodes.blockContainer.createChecked(void 0,n);o=o.replaceChild(e,r)}return new l.Ji(o,e.openStart,e.openEnd)}let nq=class extends d.KE{constructor(e,t){let o,n;super({...e,content:void 0}),U(this,"_state"),U(this,"mount",(e,t,o)=>{t?(this.options.element=t,this.createViewAlternative(e,o)):(this.destroy(),this.isInitialized=!1)});
12let r=this.schema,i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...e)=>{if(o)return o;let t=JSON.parse(JSON.stringify(i.apply(r.nodes.doc,e).toJSON()));return t.content[0].content[0].attrs.id="initialBlockId",o=l.bP.fromJSON(r,t)};try{let o=null==e?void 0:e.content.map(e=>eK(e,this.schema,t).toJSON());n=(0,d.ui)({type:"doc",content:[{type:"blockGroup",content:o}]},this.schema,this.options.parseOptions)}catch(t){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",t),Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(e.content))}this._state=c.$t.create({doc:n,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(e){if(!this.view){this._state=this.state.apply(e),this.emit("transaction",{editor:this,transaction:e});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return void this.dispatchTransaction(e);let{state:t,transactions:o}=this.state.applyTransaction(e),n=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});let r=e.getMeta("focus"),i=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!e.docChanged||e.getMeta("preventUpdate")||(this.emit("update",{editor:this,transaction:e}),this.emit("v3-update",{editor:this,transaction:e,appendedTransactions:o.slice(1)}))}forceEnablePlugins(){if(this.view)throw Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(e,t){this.contentComponent=t;let o={};this.extensionManager.extensions.forEach(t=>{"mark"===t.type&&t.config.addMarkView&&(o[t.name]=t.config.addMarkView(e))}),this.view=new I.Lz({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:o,nodeViews:this.extensionManager.nodeViews});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.commands.focus(this.options.autofocus||"true"===this.options.element.getAttribute("data-bn-autofocus"),{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};U(nq,"create",(e,t)=>{var o,n;let r=null==(o=null==globalThis?void 0:globalThis.window)?void 0:o.setTimeout;"u">typeof(null==(n=null==globalThis?void 0:globalThis.window)?void 0:n.setTimeout)&&(globalThis.window.setTimeout=()=>0);try{return new nq(e,t)}finally{r&&(globalThis.window.setTimeout=r)}}),nq.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};let nJ={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class nK extends oj{constructor(e){var t,o,n,r,i,s,l,a,h,u,p,m,f,g,b,k;if(super(),U(this,"pmSchema"),U(this,"extensions",{}),U(this,"headless",!1),U(this,"_tiptapEditor"),U(this,"elementRenderer",null),U(this,"blockCache",new WeakMap),U(this,"dictionary"),U(this,"schema"),U(this,"blockImplementations"),U(this,"inlineContentImplementations"),U(this,"styleImplementations"),U(this,"formattingToolbar"),U(this,"linkToolbar"),U(this,"sideMenu"),U(this,"suggestionMenus"),U(this,"filePanel"),U(this,"tableHandles"),U(this,"comments"),U(this,"showSelectionPlugin"),U(this,"forkYDocPlugin"),U(this,"uploadFile"),U(this,"onUploadStartCallbacks",[]),U(this,"onUploadEndCallbacks",[]),U(this,"resolveFileUrl"),U(this,"resolveUsers"),U(this,"settings"),U(this,"activeTransaction",null),U(this,"mount",(e,t)=>{this._tiptapEditor.mount(this,e,t)}),this.options=e,e.onEditorContentChange)throw Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(e.onTextCursorPositionChange)throw Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(e.onEditorReady)throw Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");
12if(e.editable)throw Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=e.dictionary||V.e,this.settings={tables:{splitCells:(null==(t=null==e?void 0:e.tables)?void 0:t.splitCells)??!1,cellBackgroundColor:(null==(o=null==e?void 0:e.tables)?void 0:o.cellBackgroundColor)??!1,cellTextColor:(null==(n=null==e?void 0:e.tables)?void 0:n.cellTextColor)??!1,headers:(null==(r=null==e?void 0:e.tables)?void 0:r.headers)??!1},codeBlock:{indentLineWithTab:(null==(i=null==e?void 0:e.codeBlock)?void 0:i.indentLineWithTab)??!0,defaultLanguage:(null==(s=null==e?void 0:e.codeBlock)?void 0:s.defaultLanguage)??"text",supportedLanguages:(null==(l=null==e?void 0:e.codeBlock)?void 0:l.supportedLanguages)??{},createHighlighter:(null==(a=null==e?void 0:e.codeBlock)?void 0:a.createHighlighter)??void 0},heading:{levels:(null==(h=null==e?void 0:e.heading)?void 0:h.levels)??[1,2,3]}};let v={defaultStyles:!0,schema:e.schema||os.create(),_headless:!1,...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(v.comments&&!v.resolveUsers)throw Error("resolveUsers is required when using comments");for(let e of(this.resolveUsers=v.resolveUsers,this.schema=v.schema,this.blockImplementations=v.schema.blockSpecs,this.inlineContentImplementations=v.schema.inlineContentSpecs,this.styleImplementations=v.schema.styleSpecs,this.extensions=(e=>{var t;let o={};for(let t of(e=>{let t=[d.XO.ClipboardTextSerializer,d.XO.Commands,d.XO.Editable,d.XO.FocusEvents,d.XO.Tabindex,E.v,d.YY.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),_.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),o9,M.E,nP,nL,nA,x.N_.extend({inclusive:!1}).configure({defaultProtocol:ns,protocols:nG?[]:ni}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),nU,oz,nD,d.YY.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>!e.editor.suggestionMenus.shown&&this.editor.commands.blur()}}}),nz,nR.configure({editor:e.editor,domAttributes:e.domAttributes}),nt.configure({editor:e.editor,tabBehavior:e.tabBehavior}),nF.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(e=>"link"!==e.config&&"text"!==e.config).map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(t=>t.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),(e=>d.YY.create({name:"copyToClipboard",addProseMirrorPlugins:()=>(oh(),[new c.k_({props:{handleDOMEvents:{copy:(t,o)=>(oR()||oF(e,t,o),!0),cut:(t,o)=>(oR()||(oF(e,t,o),t.editable&&t.dispatch(t.state.tr.deleteSelection())),!0),dragstart(t,o){if(!("node"in t.state.selection)||"blockContent"!==t.state.selection.node.type.spec.group)return;e.transact(e=>e.setSelection(new c.nh(e.doc.resolve(t.state.selection.from-1)))),o.preventDefault(),o.dataTransfer.clearData();let{clipboardHTML:n,externalHTML:r,markdown:i}=o$(t,e);return o.dataTransfer.setData("blocknote/html",n),o.dataTransfer.setData("text/html",r),o.dataTransfer.setData("text/plain",i),!0}}}})])}))(e.editor),((e,t)=>d.YY.create({name:"pasteFromClipboard",addProseMirrorPlugins:()=>[new c.k_({props:{handleDOMEvents:{paste(o,n){if(n.preventDefault(),e.isEditable)return t({event:n,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:t=!0,plainTextAsMarkdown:o=!0}={})=>(function({event:e,editor:t,prioritizeMarkdownOverHTML:o,plainTextAsMarkdown:n}){var r;let i;if(t.transact(e=>e.selection.$from.parent.type.spec.code&&e.selection.$to.parent.type.spec.code)){let o=null==(r=e.clipboardData)?void 0:r.getData("text/plain");if(o)return t.pasteText(o),!0}for(let t of oC)if(e.clipboardData.types.includes(t)){i=t;break}if(!i)return!0;if("vscode-editor-data"===i)return oU(e,t.prosemirrorView),!0;if("Files"===i)return oS(e,t),!0;let s=e.clipboardData.getData(i);if("blocknote/html"===i)return t.pasteHTML(s,!0),!0;if("text/markdown"===i)return t.pasteMarkdown(s),!0;if(o){let o=e.clipboardData.getData("text/plain");if(ox.test(o)||oM.test(o)||oT.test(o)||oB.test(o)||oP.test(o)||oL.test(o)||oA.test(o)||oI.test(o)||oH.test(o)||oN.test(o)||oO.test(o)||oV.test(o)||oD.test(o))return t.pasteMarkdown(o),!0}return"text/html"===i?t.pasteHTML(s):n?t.pasteMarkdown(s):t.pasteText(s),!0})({event:n,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o})})}}}})]}))(e.editor,e.pasteHandler||(e=>e.defaultPasteHandler())),(e=>d.YY.create({name:"dropFile",addProseMirrorPlugins:()=>[new c.k_({props:{handleDOMEvents:{drop(t,o){if(!e.isEditable)return;let n=null;for(let e of oC)if(o.dataTransfer.types.includes(e)){n=e;break}return null===n||"Files"===n&&(oS(o,e),!0)}}}})]}))(e.editor),...void 0===e.trailingBlock||e.trailingBlock?[n_]:[],...e.comments?[oY]:[]];return nG=!0,e.collaboration||t.push(S.B),t})(e))o[t.name]=t;for(let n of(e.collaboration&&(o.ySyncPlugin=new oJ(e.collaboration.fragment),o.yUndoPlugin=new oK({editor:e.editor}),null!=(t=e.collaboration.provider)&&t.awareness&&(o.yCursorPlugin=new oq(e.collaboration)),o.forkYDocPlugin=new nj({editor:e.editor,collaboration:e.collaboration}
12)),o.formattingToolbar=new o5(e.editor),o.linkToolbar=new nr(e.editor),o.sideMenu=new nE(e.editor),o.suggestionMenus=new nB(e.editor),o.filePanel=new o2(e.editor),o.placeholder=new nc(e.editor,e.placeholders),(e.animations??!0)&&(o.animations=new np),e.tableHandles&&(o.tableHandles=new nV(e.editor)),o.nodeSelectionKeyboard=new na,o.blockChange=new oW,o.showSelection=new nf(e.editor),e.comments&&(o.comments=new oQ(e.editor,e.comments.threadStore,oY.name)),e.disableExtensions||[]))delete o[n];return o})({editor:this,domAttributes:v.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:v.collaboration,trailingBlock:v.trailingBlock,disableExtensions:v.disableExtensions,setIdAttribute:v.setIdAttribute,animations:v.animations??!0,tableHandles:t5("table",this),dropCursor:this.options.dropCursor??O.A,placeholders:v.placeholders,tabBehavior:v.tabBehavior,comments:v.comments,pasteHandler:v.pasteHandler}),((null==(u=v._tiptapOptions)?void 0:u.extensions)||[]).forEach(e=>{this.extensions[e.name]=e}),v.extensions||[])){"function"==typeof e&&(e=e(this));let t=e.constructor.key();if(!t)throw Error(`Extension ${e.constructor.name} does not have a key method`);if(this.extensions[t])throw Error(`Extension ${e.constructor.name} already exists with key ${t}`);this.extensions[t]=e}if(Object.entries(v._extensions||{}).forEach(([e,t])=>{let o="function"==typeof t?t(this):t;if(!("plugin"in o)){this.extensions[e]=o;return}this.extensions[e]=new class extends oG{static key(){return e}constructor(){super(),this.addProsemirrorPlugin(o.plugin)}get priority(){return o.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,v.uploadFile){let e=v.uploadFile;this.uploadFile=async(t,o)=>{this.onUploadStartCallbacks.forEach(e=>e.apply(this,[o]));try{return await e(t,o)}finally{this.onUploadEndCallbacks.forEach(e=>e.apply(this,[o]))}}}this.resolveFileUrl=v.resolveFileUrl,this.headless=v._headless;let y="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;y&&v.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");let w=v.initialContent||(y?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:_.options.generateID()}]);if(!Array.isArray(w)||0===w.length)throw Error("initialContent must be a non-empty array of blocks, received: "+w);let C=[...Object.entries(this.extensions).map(([e,t])=>t instanceof d.YY||t instanceof d.bP||t instanceof d.CU?t:t instanceof oG&&!t.plugins.length?void 0:d.YY.create({name:e,priority:t.priority,addProseMirrorPlugins:()=>t.plugins}))].filter(e=>void 0!==e),T={...nJ,...v._tiptapOptions,content:w,extensions:C,editorProps:{...null==(p=v._tiptapOptions)?void 0:p.editorProps,attributes:{tabIndex:"0",...null==(f=null==(m=v._tiptapOptions)?void 0:m.editorProps)?void 0:f.attributes,...null==(g=v.domAttributes)?void 0:g.editor,class:X("bn-editor",v.defaultStyles?"bn-default-styles":"",(null==(k=null==(b=v.domAttributes)?void 0:b.editor)?void 0:k.class)||"")},transformPasted:nW}};this.headless?this.pmSchema=(0,d._w)(T.extensions):(this._tiptapEditor=nq.create(T,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(e={}){return new nK(e)}exec(e){if(this.activeTransaction)throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");return e(this._tiptapEditor.state,e=>this._tiptapEditor.dispatch(e),this._tiptapEditor.view)}canExec(e){if(this.activeTransaction)throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");return e(this._tiptapEditor.state,void 0,this._tiptapEditor.view)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;let t=e(this.activeTransaction),o=this.activeTransaction;return this.activeTransaction=null,o&&(o.docChanged||o.selectionSet||o.scrolledIntoView||o.storedMarksSet||!o.isGeneric)&&this._tiptapEditor.dispatch(o),t}finally{this.activeTransaction=null}}extension(e,t=e.key()){let o=this.extensions[t];if(!o)throw Error(`Extension ${t} not found`);return o}get prosemirrorState(){if(this.activeTransaction)throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var e;return null==(e=this.prosemirrorView)?void 0:e.dom}isFocused(){var e;return(null==(e=this.prosemirrorView)?void 0:e.hasFocus())||!1}focus(){var e;null==(e=this.prosemirrorView)||e.focus()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{let t=this.onUploadStartCallbacks.indexOf(e);t>-1&&this.onUploadStartCallbacks.splice(t,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{let t=this.onUploadEndCallbacks.indexOf(e);t>-1&&this.onUploadEndCallbacks.splice(t,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(e=>(function(e,t,o=eS(t),n=ex(t),r=eM(t),i=eT(t)){let s=[];return e.firstChild.descendants(e=>(s.push(eL(e,t,o,n,r,i)),!1)),s})(e.doc,this.pmSchema))}getBlock(e){return this.transact(t=>(function(e,t){let o="string"==typeof t?t:t.id,n=ew(e),r=eY(o,e);if(r)return eL(r.node,n)})(t.doc,e))}getPrevBlock(e){return this.transact(t=>(function(e,t){let o=eY("string"==typeof t?t:t.id,e),n=ew(e);if(!o)return;let r=e.resolve(o.posBeforeNode).nodeBefore;if(r)return eL(r,n)})(t.doc,e))}getNextBlock(e){return this.transact(t=>(function(e,t){let o=eY("string"==typeof t?t:t.id,e),n=ew(e);if(!o)return;let r=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(r)return eL(r,n)})(t.doc,e))}getParentBlock(e){return this.transact(t=>(function(e,t){let o="string"==typeof t?t:t.id,n=ew(e),r=eY(o,e);if(!r)return;let i=e.resolve(r.posBeforeNode),s=i.node(),l=i.node(-1),a="doc"!==l.type.n
12ame?"blockGroup"===s.type.name?l:s:void 0;if(a)return eL(a,n)})(t.doc,e))}forEachBlock(e,t=!1){let o=this.document.slice();t&&o.reverse(),!function o(n){for(let r of n)if(!1===e(r)||!o(t?r.children.slice().reverse():r.children))return!1;return!0}(o)}onEditorContentChange(e){this._tiptapEditor.on("update",e)}onEditorSelectionChange(e){this._tiptapEditor.on("selectionUpdate",e)}getTextCursorPosition(){return this.transact(e=>(function(e){let t,{bnBlock:o}=ey(e),n=ew(e.doc),r=e.doc.resolve(o.beforePos),i=r.nodeBefore,s=e.doc.resolve(o.afterPos).nodeAfter;return r.depth>1&&((t=r.node()).type.isInGroup("bnBlock")||(t=r.node(r.depth-1))),{block:eL(o.node,n),prevBlock:null===i?void 0:eL(i,n),nextBlock:null===s?void 0:eL(s,n),parentBlock:void 0===t?void 0:eL(t,n)}})(e))}setTextCursorPosition(e,t="start"){return this.transact(o=>(function e(t,o,n="start"){let r="string"==typeof o?o:o.id,i=eE(ew(t.doc)),s=eY(r,t.doc);if(!s)throw Error(`Block with ID ${r} not found`);let l=eb(s),a=i.blockSchema[l.blockNoteType].content;if(l.isBlockContainer){let e=l.blockContent;if("none"===a)return void t.setSelection(c.nh.create(t.doc,e.beforePos));if("inline"===a)"start"===n?t.setSelection(c.U3.create(t.doc,e.beforePos+1)):t.setSelection(c.U3.create(t.doc,e.afterPos-1));else if("table"===a)"start"===n?t.setSelection(c.U3.create(t.doc,e.beforePos+4)):t.setSelection(c.U3.create(t.doc,e.afterPos-4));else throw new J(a)}else e(t,("start"===n?l.childContainer.node.firstChild:l.childContainer.node.lastChild).attrs.id,n)})(o,e,t))}getSelection(){return this.transact(e=>(function(e){let t=ew(e);if(e.selection.empty||"node"in e.selection)return;let o=e.doc.resolve(ef(e.doc,e.selection.from).posBeforeNode),n=e.doc.resolve(ef(e.doc,e.selection.to).posBeforeNode),r=(n,r)=>{let i=o.posAtIndex(n,r),s=e.doc.resolve(i).nodeAfter;if(!s)throw Error(`Error getting selection - node not found at position ${i}`);return eL(s,t)},i=[],s=o.sharedDepth(n.pos),l=o.index(s),a=n.index(s);if(o.depth>s){i.push(eL(o.nodeAfter,t));for(let e=o.depth;e>s;e--)if(o.node(e).type.isInGroup("childContainer")){let t=o.index(e)+1,n=o.node(e).childCount;for(let o=t;o<n;o++)i.push(r(o,e))}}else i.push(r(l,s));for(let e=l+1;e<=a;e++)i.push(r(e,s));if(0===i.length)throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:i}})(e))}getSelectionCutBlocks(){return this.transact(e=>(function(e){let t=ew(e),o=e.selection.$from,n=e.selection.$to;for(;n.parentOffset>=n.parent.nodeSize-2&&n.depth>0;)n=e.doc.resolve(n.pos+1);for(;0===n.parentOffset&&n.depth>0;)n=e.doc.resolve(n.pos-1);for(;0===o.parentOffset&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);let r=function(e,t,o=eS(t),n=ex(t),r=eM(t),i=eT(t)){if(0===e.content.childCount)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(1!==e.content.childCount)throw Error("slice must be a single block, did you forget includeParents=true?");return function e(s,l,a){let d,c;if("blockGroup"!==s.type.name)throw Error("unexpected");let h=[];return s.forEach((u,p,m)=>{if("blockContainer"!==u.type.name)throw Error("unexpected");if(0===u.childCount)return;if(0===u.childCount||u.childCount>2)throw Error("unexpected, blockContainer.childCount: "+u.childCount);let f=0===m,g=m===s.childCount-1;if("blockGroup"===u.firstChild.type.name){if(!f)throw Error("unexpected");let t=e(u.firstChild,Math.max(0,l-1),g?Math.max(0,a-1):0);d=t.blockCutAtStart,g&&(c=t.blockCutAtEnd),h.push(...t.blocks);return}let b=eL(u,t,o,n,r,i),k=u.childCount>1?u.child(1):void 0,v=[];if(k){let t=e(k,0,g?Math.max(0,a-1):0);v=t.blocks,g&&(c=t.blockCutAtEnd)}g&&!k&&a>1&&(c=b.id),f&&l>1&&(d=b.id),h.push({...b,children:v})}),{blocks:h,blockCutAtStart:d,blockCutAtEnd:c}}(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}(e.doc.slice(o.pos,n.pos,!0),t);return{_meta:{startPos:o.pos,endPos:n.pos},...r}})(e))}setSelection(e,t){return this.transact(o=>(function(e,t,o){let n,r,i="string"==typeof t?t:t.id,s="string"==typeof o?o:o.id,l=eE(ew(e));if(i===s)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);let a=eY(i,e.doc);if(!a)throw Error(`Block with ID ${i} not found`);let d=eY(s,e.doc);if(!d)throw Error(`Block with ID ${s} not found`);let h=eb(a),p=eb(d),m=l.blockSchema[h.blockNoteType],f=l.blockSchema[p.blockNoteType];
12if(!h.isBlockContainer||"none"===m.content)throw Error(`Attempting to set selection anchor in block without content (id ${i})`);if(!p.isBlockContainer||"none"===f.content)throw Error(`Attempting to set selection anchor in block without content (id ${s})`);if("table"===m.content){let e=u.J3.get(h.blockContent.node);n=h.blockContent.beforePos+e.positionAt(0,0,h.blockContent.node)+1+2}else n=h.blockContent.beforePos+1;if("table"===f.content){let t=u.J3.get(p.blockContent.node),o=p.blockContent.beforePos+t.positionAt(t.height-1,t.width-1,p.blockContent.node)+1,n=e.doc.resolve(o).nodeAfter.nodeSize;r=o+n-2}else r=p.blockContent.afterPos-1;e.setSelection(c.U3.create(e.doc,n,r))})(o,e,t))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw Error("no editor, but also not headless?");return!1}return void 0===this._tiptapEditor.isEditable||this._tiptapEditor.isEditable}set isEditable(e){if(!this._tiptapEditor){if(!this.headless)throw Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==e&&this._tiptapEditor.setEditable(e)}insertBlocks(e,t,o="before"){return this.transact(n=>(function(e,t,o,n="before"){let r="string"==typeof o?o:o.id,i=ew(e),s=t.map(e=>eK(e,i)),d=eY(r,e.doc);if(!d)throw Error(`Block with ID ${r} not found`);let c=d.posBeforeNode;return"after"===n&&(c+=d.node.nodeSize),e.step(new a.Ln(c,c,new l.Ji(l.FK.from(s),0,0))),s.map(e=>eL(e,i))})(n,e,t,o))}updateBlock(e,t){return this.transact(o=>(function(e,t,o,n,r){let i="string"==typeof t?t:t.id,s=eY(i,e.doc);if(!s)throw Error(`Block with ID ${i} not found`);return e0(e,s.posBeforeNode,o,void 0,void 0),eL(e.doc.resolve(s.posBeforeNode+1).node(),ew(e))})(o,e,t))}removeBlocks(e){return this.transact(t=>eZ(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.transact(o=>eZ(o,e,t))}undo(){return this.options.collaboration?this.exec(P.Eb):this.exec(N.tN)}redo(){return this.options.collaboration?this.exec(P.eD):this.exec(N.ZS)}insertInlineContent(e,{updateSelection:t=!1}={}){let o=eW(e,this.pmSchema);this.transact(e=>{!function(e,t,o,n={updateSelection:!0}
12){let{from:r,to:i}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},s=!0,l=!0,a="";if(o.forEach(e=>{e.check(),s&&e.isText&&0===e.marks.length?a+=e.text:s=!1,l=!!l&&e.isBlock}),r===i&&l){let{parent:t}=e.doc.resolve(r);!t.isTextblock||t.type.spec.code||t.childCount||(r-=1,i+=1)}s?e.insertText(a,r,i):e.replaceWith(r,i,o),n.updateSelection&&(0,d.Ms)(e,e.steps.length-1,-1)}(e,{from:e.selection.from,to:e.selection.to},o,{updateSelection:t})})}getActiveStyles(){return this.transact(e=>{let t={};for(let o of e.selection.$to.marks()){let e=this.schema.styleSchema[o.type.name];if(!e){"link"===o.type.name||o.type.spec.blocknoteIgnore||console.warn("mark not found in styleschema",o.type.name);continue}"boolean"===e.propSchema?t[e.type]=!0:t[e.type]=o.attrs.stringValue}return t})}addStyles(e){for(let[t,o]of Object.entries(e)){let e=this.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if("boolean"===e.propSchema)this._tiptapEditor.commands.setMark(t);else if("string"===e.propSchema)this._tiptapEditor.commands.setMark(t,{stringValue:o});else throw new J(e.propSchema)}}removeStyles(e){for(let t of Object.keys(e))this._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(let[t,o]of Object.entries(e)){let e=this.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if("boolean"===e.propSchema)this._tiptapEditor.commands.toggleMark(t);else if("string"===e.propSchema)this._tiptapEditor.commands.toggleMark(t,{stringValue:o});else throw new J(e.propSchema)}}getSelectedText(){return this.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(e,t){if(""===e)return;let o=this.pmSchema.mark("link",{href:e});this.transact(e=>{let{from:n,to:r}=e.selection;t?e.insertText(t,n,r).addMark(n,n+t.length,o):e.setSelection(c.U3.create(e.doc,r)).addMark(n,r,o)})}canNestBlock(){return this.transact(e=>{let{bnBlock:t}=ey(e);return null!==e.doc.resolve(t.beforePos).nodeBefore})}nestBlock(){oc(this)}canUnnestBlock(){return this.transact(e=>{let{bnBlock:t}=ey(e);return e.doc.resolve(t.beforePos).depth>1})}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}moveBlocksUp(){var e;return e=this,void e.transact(()=>{let t=e.getSelection(),o=(null==t?void 0:t.blocks[0])||e.getTextCursorPosition().block,n=function e(t,o,n){let r,i;if(o?o.children.length>0?(r=o.children[o.children.length-1],i="after"):(r=o,i="before"):n&&(r=n,i="before"),!r||!i)return;let s=t.getParentBlock(r);return od(s)?{referenceBlock:r,placement:i}:e(t,"after"===i?r:t.getPrevBlock(r),s)}(e,e.getPrevBlock(o),e.getParentBlock(o));n&&oa(e,n.referenceBlock,n.placement)})}moveBlocksDown(){var e;return e=this,void e.transact(()=>{let t=e.getSelection(),o=(null==t?void 0:t.blocks[(null==t?void 0:t.blocks.length)-1])||e.getTextCursorPosition().block,n=function e(t,o,n){let r,i;if(o?o.children.length>0?(r=o.children[0],i="before"):(r=o,i="after"):n&&(r=n,i="after"),!r||!i)return;let s=t.getParentBlock(r);return od(s)?{referenceBlock:r,placement:i}:e(t,"before"===i?r:t.getNextBlock(r),s)}(e,e.getNextBlock(o),e.getParentBlock(o));n&&oa(e,n.referenceBlock,n.placement)})}async blocksToHTMLLossy(e=this.document){return e5(this.pmSchema,this).exportBlocks(e,{})}async blocksToFullHTML(e){return((e,t)=>{let o=l.ZF.fromSchema(e);return{serializeBlocks:(e,n)=>e9(t,e,o,n).outerHTML}})(this.pmSchema,this).serializeBlocks(e,{})}async tryParseHTMLToBlocks(e){return ok(e,this.pmSchema)}async blocksToMarkdownLossy(e=this.document){return of(e,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(e){return ow(e,this.pmSchema)}updateCollaborationUserInfo(e){if(!this.options.collaboration)throw Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(e)}onBeforeChange(e){return this.headless?()=>{}:this.extensions.blockChange.subscribe(t=>e(this,t))}onChange(e){if(this.headless)return;let t=({transaction:t,appendedTransactions:o})=>{e(this,{getChanges:()=>e6(t,o)})};return this._tiptapEditor.on("v3-update",t),()=>{this._tiptapEditor.off("v3-update",t)}}onSelectionChange(e,t){if(this.headless)return;let o=o=>{o.transaction.getMeta(L.pJ)&&!t||e(this)};return this._tiptapEditor.on("selectionUpdate",o),()=>{this._tiptapEditor.off("selectionUpdate",o)}}onCreate(e){return this.on("create",e),()=>{this.off("create",e)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;let{selection:e}=this.prosemirrorState,{ranges:t}=e,o=Math.min(...t.map(e=>e.$from.pos)),n=Math.max(...t.map(e=>e.$to.pos));if((0,d.BQ)(e)){let e=this.prosemirrorView.nodeDOM(o);if(e)return e.getBoundingClientRect()}return(0,d.MG)(this.prosemirrorView,o,n)}get isEmpty(){let e=this.document;return 0===e.length||1===e.length&&"paragraph"===e[0].type&&0===e[0].content.length}openSuggestionMenu(e,t){this.prosemirrorView&&(this.focus(),this.transact(o=>{null!=t&&t.deleteTriggerCharacter&&o.insertText(e),o.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:e,deleteTriggerCharacter:(null==t?void 0:t.deleteTriggerCharacter)||!1,ignoreQueryLength:(null==t?void 0:t.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(e){this.showSelectionPlugin.setEnabled(e)}convertHtmlToBlockNoteHtml(e){return ob(e.trim()).innerHTML}pasteHTML(e,t=!1){var o;let n=e;t||(n=this.convertHtmlToBlockNoteHtml(e)),n&&(null==(o=this.prosemirrorView)||o.pasteHTML(n))}pasteText(e){var t;return null==(t=this.prosemirrorView)?void 0:t.pasteText(e)}async pasteMarkdown(e){return this.pasteHTML(await oy(e))}}let nY={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},nX={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};async function nZ(){return s||(s=(async()=>{let[e,t]=await Promise.all([o.e(7326).then(o.bind(o,64791)),o.e(8733).then(o.t.bind(o,41243,17))]),n="default"in e?e.default:e,r="default"in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})())}async function nQ(e,t){var o;if(!((o="text")in e.schema.inlineContentSchema&&e.schema.inlineContentSchema[o]===t4[o]))return[];let{emojiData:n,emojiMart:r}=await nZ();return(""===t.trim()?Object.values(n.emojis):await r.SearchIndex.search(t)).map(t=>({id:t.skins[0].native,onItemClick:()=>e.insertInlineContent(t.skins[0].native+" ")}))}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.