@fileverse-dev/ddoc 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(et,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],b):(et=typeof globalThis<"u"?globalThis:et||self,b(et.dpage={},et.React,et.ReactDOM))})(this,function(et,b,vt){"use strict";var xT=Object.defineProperty;var kT=(et,b,vt)=>b in et?xT(et,b,{enumerable:!0,configurable:!0,writable:!0,value:vt}):et[b]=vt;var bn=(et,b,vt)=>(kT(et,typeof b!="symbol"?b+"":b,vt),vt);function Kc(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const q=Kc(b),gg=Kc(vt);function Jc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ul={exports:{}},mo={};/**
1
+ (function(et,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],b):(et=typeof globalThis<"u"?globalThis:et||self,b(et.ddoc={},et.React,et.ReactDOM))})(this,function(et,b,vt){"use strict";var xT=Object.defineProperty;var kT=(et,b,vt)=>b in et?xT(et,b,{enumerable:!0,configurable:!0,writable:!0,value:vt}):et[b]=vt;var bn=(et,b,vt)=>(kT(et,typeof b!="symbol"?b+"":b,vt),vt);function Kc(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const q=Kc(b),gg=Kc(vt);function Jc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ul={exports:{}},mo={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -27,7 +27,7 @@ Check the top-level render call using <`+j+">.")}return L}}function ho(x,L){{if(
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,_c,xr,bT,xr),hg[xr+_c]=!0}}return x===r?pT(Ee):hT(Ee),Ee}}function mT(x,L,j){return pg(x,L,j,!0)}function gT(x,L,j){return pg(x,L,j,!1)}var yT=gT,vT=mT;go.Fragment=r,go.jsx=yT,go.jsxs=vT}()),go}process.env.NODE_ENV==="production"?ul.exports=yg():ul.exports=vg();var w=ul.exports;const bg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA9fSURBVHgB7Z0LmFRlGcf/75nZ2ZnZXZA7BOyFS7BiKYhAGZYpGSlqaKWCyZNWmima5VOWPZh000zxbiZikFgaPeI1NUsMVFxBBQQV2AVWQK7K7s7MzuW8vd8Zgb3NMrs75zZ7fs9z5lzmzMyZ73++9/u+9/u+9xBcDlcjiECoH5IoRZLLAd8x0LgShKFg9JZTjpKlWPZ9sk/Gh0i2WD4B1Mv2Plnvl+VDeeMdOb4Omr4R9bwN0dgOGo8EXAzBZfDfRagJ4WMB7Rwwj5cjlSLKQPknBcglLMIS9kgSrZGdV5Di57Et+gadjBhchCsE5trQEDRq35Cc+RXZO0kuOwx7iMjvrwTTCyjkv9Dg6DY4HMcKbJheKr4Y0M+XnDpOLjUEJ8HcCKIqua4HENOWUmXdXjgQRwnMVWJm+wcnIUU/kMQ7W8xkEO4gJtf6FHz6bVQW+x8chCMEZpZytSZ4oZSrl8juRFn8cC+vSbLei/KGh0hV5mzGVoH5A4SRCM+SzcskKY5BPkFYK8sd2B1ZJDXxCGzCNoG5JjxVRL1eNifBJZW9TqBy8Gr5d7+g8sgzsAHLE5bfLToWQf4VdJyJ7kNclmclteeI0KthIZYJzLv7lqAucpX84uWyOwDdERZnioa7kAjOo5H7DsACLBGYt4bHS469Tf7gifBQqb4cpH2fyurXwWQ0mIjUjjWuDl2JlDQhPHEPo9JC15ertOE55mpgWg7mdf2KEa6/X37iPHhkQvnDF6IxPJtG76mDCZgisNSQx0r2fUS+/tPwyAJ6H4HkNBrc+C5yTM4FFrMjzR56Qjb7wiN7mOqg0dlUXv8ickhO7T9vDp0rqxfgidtxiEvA+lLeHJ6GHJIzgXlT0QzxHy+SKy2CR2cpEpu6lGuCM5hzY127LLC6EK4uvlLqyyIuCuHRdVhbgOrQD5EDunyXGDlX4wVwdweBMyF9BpXHHkYX6JLARnkhJgUeZtEoJnImDYs+hk7SaYG5tvjLSKSWemWu2XCDvJxKFdFX0Qk6JTBXB0YDBdLvyT3gYQV7Rakpnemo6HAly+g0YP8TnriW0kfayY8Y3sEO0iGBlW8Z9ZF5cjeNgIfF8KdRVP+njvquO2SijY4D0C3wasw2wrOlPL4927OzFpjfLx4DPy+XrZ7wsJNd8OF0Ko1UZXNyVtmdN6AEfv0+T1xH0F/1rfMGqQtlQXb2PBC+Sl69/lynoPqTCyJXZ3PqEU10uusPasCY64fZ3L0wiWQKtlA5Qto5X/AhZ6jhP0SnUUXDW+2ddmSBq8OPyyovBsgVHR1BJApbOPNUHx6/P+eu+qVUETmrvRParQ1zTeFUsfdT821Q66xzfQgUWPOnNmxiLFtpmtk4kzcWTqURjRmH5GYU2BiUHvfNzfmsPQdwy88D6H2UNQI/+nTKTIEBn+96rsJLmQbXZ87ByfBMeR0LF7L/I0Ysnvn9HbsZjXGYxqD+lpq8SeirZodE7m7rzTYFNjqbq3GFvLrSOJ/5vUa8vV5vdfxg+Ttpesy0oYyfGkBY868Q/DmsTx0BpdFlotl9RGhlKtrOwTVFF0k3vmvnCtXVMw7UAz2KCYEm9Zq+Zg5HkPtpz36W34T1qHldxuS92IKWb2Uw0Xwp8oAl9wUw6ThThx0fYnMt47On2Tj5n7SLJRcvklycbHq4lcC8tWQyUqmJyAOChYSisDWlTLFdMQcOwlIWbyv5nNivl5sebp2D9eRst0z2u3tRAq+/3XoK7pbt6fXcOxIYaFKFp6QI+P1PAwg5ZxSaX7S7TNaZBeaqkr7g5OlwCf99RTeaIZl49iXzmie9ehLm/ohFYAdlBqbpKvQFVRwOFNM8B/fSp0nudUvYhENcfqEfJ3/emmrrgTrG968zsY3VNQpB4e80bTI1F1jji+FCJo314ZyvWiPwrr2MAme7fs6XpbXAvClYKqvxcCDbP2TUfNC6rK3dkT62dTtjxSodZnFcJSEccolLgHG8CjtFQ6K1avdwDvZpM+VNRw5c//29Sdy+IHPAuZ//wTyTWRgAViwJYtwY1/h8Qkho35D1rWrnsMBMU2B/UJh26duLMGSgdQm9fpN5VsFUWAWMayIwv69yrj7B6c2jqy/247rLrSkAG8R1P+HsKDZtcfZN3yaEk1TIR/omUmk3D4XG2xge0CP3hNPxPA+aaJ8yz/az5NkUrv1d6/J05670+tb5Scx/NAmzePDmQkw+wRrXpgWcI8uqtMCMzzvBOqs2Znsmcc8+lgWmYddoD1NgnKBWfiM+JDkrytzUL/lw83XWNTZnXRNH1RqXVqgywaiUzoegH4NCAxF31oz8o3oAY0ZaZyqL8rH2QeiP7aF+fiNSOqwdlvNeNWPx0tZl6ap16Vy0ZoOOG+aZF2h9uni9PjMqb8raTASUtlIGayOsbv++X61jzm2ZBVz7HstinsDDS6k7CKwiBZT7kZLy16YKVtkQwvnTrJvm9MS/U1j3Xp6Vte0h2qrUrYRNjCzT8NtrrSsdtn+oi8DoPmhcqclL9wwM2h0gDNXEb9kbHvkJo7fUNKgXPPITpl6qKpnVNEQPF0JcpAS2boi2h9X4lcD5+rwED5gcENzDfjQ44Nk+mdi7n1G7k9VcqTZRx9W4LDVlxKNNWJpJsGnOe/v8aXESo0+JoWJyFDOuiiPVwgGli6azb4hj1JdjGPHFGO58yLx+YheTVCa6Hg5DiXftbxNGzkyKbqpj4rllze/DF1ekcIeIGokxPpZ+5J/dFEfNNi8nt6BeBOaP4DBUra+xsblYeosc3Ngo5zWpHqqzNa890BzGfimDycQxEp1DCXfzdYFDAh53tIZTTmxeHzz1Cz6cNcV36PwrLipA6afsbxDE5Mb7x9NJPPZ0ylheW21j54aGfX5RWT0Ddxwcxg8v8uOkiRrqG4BjK8mYKdgUNV558e0BvLWeEZDto0c6o0GgipXzrnTM1Jadfrn935Hq6FlwIJ8d3b5oSvSJxzmrGa+mtZw71QetxaWPO8aG8kPnDaq70PSnb3UnBvQh/OWPhVaGcMgMaWulwz+1pdXt5hBU/20kSkYZa+RTQrNtY9VkrTZVABS/RWMI4on0olBlr+PQ9I1+BGkL4lCX6bg5c+dLWfbmO3xYzE9e2jLKSuDePYFlfw8agVDMZv/HjHFnHA7Z4MAGWhx+bPUjHt0NhHfKgaFwGEMHaVi2MnsHxhA5f0A/68rkbTvaltUhtYK92BHdqaVng9MGOJBrL+2Yrb3gLD98FpU2R/Ug7HszhNTmcLNl64oQfE4of5nW0ngk0smhc1axh61G1aIvnZGdyGPHaPjetywMTkUwbiaNmi/klEo98Qq1+mRuEh6TQuRncCC3Xh8wotI9mGFOkkrQ44/R8Nd5hejdK/epq6LT3nRv4pATpSEKJBLpdrijSfHzapUWeGXkLUwIR0Rkx43xDxYC828KYPppPtz2YBJVa1L4+ED6+KhhmhGfY+Z0v2nRblIi8N+edGR/THtEsC36htowBFbzSLkay2Tzq3AoZ5ziMxaFikMZKEibRLNR5emPv1uAwS0mnqsbqrjIqWMleCWdnI6006SA4+dEascK3JSgheZROSy+eYYP48a4aGwE0wsHNw8LnMSj0hL+tZjpELop6zfqGNQvva3K2pTrLLNBI1hfeHDnkMA0MlrLNeFV6MbPZrj6xtadBI6vTLWEUEXDY1sP7jZvg+hYLCd0W4GHlRIK/K17rRzqyW2bFD3QdLe5wBR5ABy+RUTuls8BvvvGQpx2kovHIbJUrOJas6fBNvs3hleL6Z/wcCtPUWXd3qYHWruJUql7xCadizx+fN1PfpfAzfcfdpx8sCNfxnLp81oeaS3igdgr6BN+DXlc2dq5i40lz3iNhsVebnmwlcDKQc3V9Gcx6Hkr8NxrCjBlcmu/dcUQN0/y0O9t62jbZri8YSGqw9c4LfpOrigbTJhwbB5N6iCsRVnsobbealNg9fQO3gx1R9wBE7s3392s4w/3Wzdg/d3qvBw3zeKkupMyzFDJXJEqiMxHKnyBESTNJFSH+U9+49jg2m5hNUI9F6Lt52JlFpiGIso1qbnibn8aOWbUcM0YFmsXw8vyxDwzEtBSv6DBOyKZTulWD6fMOzQspbL2H0555FvZT9fL64fwcBbq8bJx3HCk044oMA1teFu+7C54OI27aGRk1ZFOyq4w2hWZJ8Z8OTycwnLsCs7L5sSsm0C8KXyC3A5PQj1D3sNG6GMk6UQaWZ/VjJSsq5M0PPK6yPxreNiJOA30X2YrrqJj7YXy6J3Q+RF42MVCPCQadIAOe6l4HYoRDlXJR0fBwzoYG6XcPZ4m7TvQkY91yg3JNeGx8oNq3G0feJgP0QE0JibSqHiHZ6B0yqVD5ZHVIvMZsjTAw2Qkjf2pr3dGXEWnfXZUEX1VcvEsqFF8HubBdAENib2ITtIlpywNiz4GnVz5QEsXkBTTPJOGRZaiC3TZ607DG/4qt9ls44I8cofGP0JZw8PoIjnp62WW79lcdIFc1CJ4dJVGybnfofKui6vIaWc+bwlPk3byYvnaInh0hgbJLbOMoi9H5Hy0Bm8qOkVy8hLZ7AGPjrBHUm+aUXnNIaYMx+HqwGiw7wkxNSPgkQX0HojPSzc/c4spQxuoQtps8agKrvYgvMpX+5AUaY2h8WaIqzBt7AqNRh3KI5dIfr5G2ssdcq91Cxi7jdbHguhMGr2nDiZhyUBg3lI8Brp+H7rxzMVm6FiBAsym0ojpsVEsG+nNu/uWoC5ylfzi5bLbPZ/VpIbZaLgLieA8GrnPEqtm+VD+Tzoq5sjmVDgw+JqJiEeKfkkVDW/BQmybqyFCf02EvlE2x9p5HSajXECvyHquVKKegQ3YmrBchTD6hGdKMlyRd9NkGGvFHN+Dgp4L2hu3bDaOyDk8R5LiouC3pVJ/qexOhHuRDgJILxs9oOZ3qSlAsBnHmUbeHJwsQs+WKztddoNwAyz+Y42WQE/dg32xV9UMTTgEx5Z9XFvSB3piGlLaJZKA450XVoKjknyr5LoeBvefTxU1MTgQV1RueFOwFKRdKK7PU8XzM8G2iHwEFQ1wmfSBP4dC/VEaEq2Fw3Fd7ZX/I2Z7aOh4+GiKXP7n5MhnJNH7yj/JbZNLTewi7JTfWC89PFXinFiCVZE3VVRAuAjXN08k6QswKDRQqjel0LUR0PQxSNHRUm0bkH42stZLzlJPWFVT+pv+36RUhhpA+n45rJ48s80QU02mJr1G5N2K4QN2EznT9GbL/wFLC+Kh6JIF9QAAAABJRU5ErkJggg==",wg=({metaData:n,setMetaData:e})=>w.jsxs("div",{className:"flex items-center gap-4",children:[w.jsx("img",{src:bg,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),w.jsx("input",{className:"custom-input w-[50%] mx-2 focus:outline-none",type:"text",placeholder:"Untitled",defaultValue:n.plugin.title||"",onChange:t=>e({...n,plugin:{...n.plugin,title:t.target.value}})})]});function Ie(n){this.content=n}Ie.prototype={constructor:Ie,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new Ie(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ie(t)},addToStart:function(n,e){return new Ie([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ie(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new Ie(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ie.from(n),n.size?new Ie(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ie.from(n),n.size?new Ie(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ie.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ie.from=function(n){if(n instanceof Ie)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ie(e)};function Yc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)t++;return t}if(o.content.size||i.content.size){let s=Yc(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Xc(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let c=Xc(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class M{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new M(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new M(r,o)}cutByIndex(e,t){return e==t?M.empty:e==0&&t==this.content.length?this:new M(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new M(o,i)}addToStart(e){return new M([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new M(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Yc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Xc(this,e,t,r)}findIndex(e,t=-1){if(e==0)return li(0,e);if(e==this.size)return li(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||t>0?li(r+1,s):li(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return M.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new M(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return M.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new M(t||e,r)}static from(e){if(!e)return M.empty;if(e instanceof M)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new M([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}M.empty=new M([],0);const dl={index:0,offset:0};function li(n,e){return dl.index=n,dl.offset=e,dl}function ai(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ai(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ai(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let de=class Wc{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ai(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Wc.none;if(e instanceof Wc)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};de.none=[];class ci extends Error{}class B{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=eu(this.content,e+this.openStart,t);return r&&new B(r,this.openStart,this.openEnd)}removeBetween(e,t){return new B(Qc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return B.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(M.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new B(e,r,o)}}B.empty=new B(M.empty,0,0);function Qc(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Qc(i.content,e-o-1,t-o-1)))}function eu(n,e,t,r){let{index:o,offset:i}=n.findIndex(e),s=n.maybeChild(o);if(i==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=eu(s.content,e-i-1,t);return l&&n.replaceChild(o,s.copy(l))}function xg(n,e,t){if(t.openStart>n.depth)throw new ci("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ci("Inconsistent open depths");return tu(n,e,t,0)}function tu(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=tu(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Kn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=kg(t,n);return Kn(i,ru(n,s,l,e,r))}else return Kn(i,ui(n,e,r))}function nu(n,e){if(!e.type.compatibleContent(n.type))throw new ci("Cannot join "+e.type.name+" onto "+n.type.name)}function fl(n,e,t){let r=n.node(t);return nu(r,e.node(t)),r}function Un(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function yo(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Un(n.nodeAfter,r),i++));for(let l=i;l<s;l++)Un(o.child(l),r);e&&e.depth==t&&e.textOffset&&Un(e.nodeBefore,r)}function Kn(n,e){return n.type.checkContent(e),n.copy(e)}function ru(n,e,t,r,o){let i=n.depth>o&&fl(n,e,o+1),s=r.depth>o&&fl(t,r,o+1),l=[];return yo(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(nu(i,s),Un(Kn(i,ru(n,e,t,r,o+1)),l)):(i&&Un(Kn(i,ui(n,e,o+1)),l),yo(e,t,o,l),s&&Un(Kn(s,ui(t,r,o+1)),l)),yo(r,null,o,l),new M(l)}function ui(n,e,t){let r=[];if(yo(null,n,t,r),n.depth>t){let o=fl(n,e,t+1);Un(Kn(o,ui(n,e,t+1)),r)}return yo(e,null,t,r),new M(r)}function kg(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(M.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class vo{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return de.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new di(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new vo(t,r,i)}static resolveCached(e,t){for(let o=0;o<hl.length;o++){let i=hl[o];if(i.pos==t&&i.doc==e)return i}let r=hl[pl]=vo.resolve(e,t);return pl=(pl+1)%Cg,r}}let hl=[],pl=0,Cg=12;class di{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Sg=Object.create(null);let Jn=class qc{constructor(e,t,r,o=de.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||M.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ai(this.attrs,t||e.defaultAttrs||Sg)&&de.sameSet(this.marks,r||de.none)}copy(e=null){return e==this.content?this:new qc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qc(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return B.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new B(c,o.depth-s,i.depth-s)}replace(e,t,r){return xg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return vo.resolveCached(this,e)}resolveNoCache(e){return vo.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ou(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=M.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=de.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!de.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=M.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Jn.prototype.text=void 0;class fi extends Jn{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ou(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new fi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new fi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ou(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Zn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Eg(e,t);if(r.next==null)return Zn.empty;let o=iu(r);r.next&&r.err("Unexpected trailing text");let i=Lg(Dg(o));return Pg(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return M.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
30
+ <%s key={someKey} {...props} />`,_c,xr,bT,xr),hg[xr+_c]=!0}}return x===r?pT(Ee):hT(Ee),Ee}}function mT(x,L,j){return pg(x,L,j,!0)}function gT(x,L,j){return pg(x,L,j,!1)}var yT=gT,vT=mT;go.Fragment=r,go.jsx=yT,go.jsxs=vT}()),go}process.env.NODE_ENV==="production"?ul.exports=yg():ul.exports=vg();var w=ul.exports;const bg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA9fSURBVHgB7Z0LmFRlGcf/75nZ2ZnZXZA7BOyFS7BiKYhAGZYpGSlqaKWCyZNWmima5VOWPZh000zxbiZikFgaPeI1NUsMVFxBBQQV2AVWQK7K7s7MzuW8vd8Zgb3NMrs75zZ7fs9z5lzmzMyZ73++9/u+9/u+9xBcDlcjiECoH5IoRZLLAd8x0LgShKFg9JZTjpKlWPZ9sk/Gh0i2WD4B1Mv2Plnvl+VDeeMdOb4Omr4R9bwN0dgOGo8EXAzBZfDfRagJ4WMB7Rwwj5cjlSLKQPknBcglLMIS9kgSrZGdV5Di57Et+gadjBhchCsE5trQEDRq35Cc+RXZO0kuOwx7iMjvrwTTCyjkv9Dg6DY4HMcKbJheKr4Y0M+XnDpOLjUEJ8HcCKIqua4HENOWUmXdXjgQRwnMVWJm+wcnIUU/kMQ7W8xkEO4gJtf6FHz6bVQW+x8chCMEZpZytSZ4oZSrl8juRFn8cC+vSbLei/KGh0hV5mzGVoH5A4SRCM+SzcskKY5BPkFYK8sd2B1ZJDXxCGzCNoG5JjxVRL1eNifBJZW9TqBy8Gr5d7+g8sgzsAHLE5bfLToWQf4VdJyJ7kNclmclteeI0KthIZYJzLv7lqAucpX84uWyOwDdERZnioa7kAjOo5H7DsACLBGYt4bHS469Tf7gifBQqb4cpH2fyurXwWQ0mIjUjjWuDl2JlDQhPHEPo9JC15ertOE55mpgWg7mdf2KEa6/X37iPHhkQvnDF6IxPJtG76mDCZgisNSQx0r2fUS+/tPwyAJ6H4HkNBrc+C5yTM4FFrMjzR56Qjb7wiN7mOqg0dlUXv8ickhO7T9vDp0rqxfgidtxiEvA+lLeHJ6GHJIzgXlT0QzxHy+SKy2CR2cpEpu6lGuCM5hzY127LLC6EK4uvlLqyyIuCuHRdVhbgOrQD5EDunyXGDlX4wVwdweBMyF9BpXHHkYX6JLARnkhJgUeZtEoJnImDYs+hk7SaYG5tvjLSKSWemWu2XCDvJxKFdFX0Qk6JTBXB0YDBdLvyT3gYQV7Rakpnemo6HAly+g0YP8TnriW0kfayY8Y3sEO0iGBlW8Z9ZF5cjeNgIfF8KdRVP+njvquO2SijY4D0C3wasw2wrOlPL4927OzFpjfLx4DPy+XrZ7wsJNd8OF0Ko1UZXNyVtmdN6AEfv0+T1xH0F/1rfMGqQtlQXb2PBC+Sl69/lynoPqTCyJXZ3PqEU10uusPasCY64fZ3L0wiWQKtlA5Qto5X/AhZ6jhP0SnUUXDW+2ddmSBq8OPyyovBsgVHR1BJApbOPNUHx6/P+eu+qVUETmrvRParQ1zTeFUsfdT821Q66xzfQgUWPOnNmxiLFtpmtk4kzcWTqURjRmH5GYU2BiUHvfNzfmsPQdwy88D6H2UNQI/+nTKTIEBn+96rsJLmQbXZ87ByfBMeR0LF7L/I0Ysnvn9HbsZjXGYxqD+lpq8SeirZodE7m7rzTYFNjqbq3GFvLrSOJ/5vUa8vV5vdfxg+Ttpesy0oYyfGkBY868Q/DmsTx0BpdFlotl9RGhlKtrOwTVFF0k3vmvnCtXVMw7UAz2KCYEm9Zq+Zg5HkPtpz36W34T1qHldxuS92IKWb2Uw0Xwp8oAl9wUw6ThThx0fYnMt47On2Tj5n7SLJRcvklycbHq4lcC8tWQyUqmJyAOChYSisDWlTLFdMQcOwlIWbyv5nNivl5sebp2D9eRst0z2u3tRAq+/3XoK7pbt6fXcOxIYaFKFp6QI+P1PAwg5ZxSaX7S7TNaZBeaqkr7g5OlwCf99RTeaIZl49iXzmie9ehLm/ohFYAdlBqbpKvQFVRwOFNM8B/fSp0nudUvYhENcfqEfJ3/emmrrgTrG968zsY3VNQpB4e80bTI1F1jji+FCJo314ZyvWiPwrr2MAme7fs6XpbXAvClYKqvxcCDbP2TUfNC6rK3dkT62dTtjxSodZnFcJSEccolLgHG8CjtFQ6K1avdwDvZpM+VNRw5c//29Sdy+IHPAuZ//wTyTWRgAViwJYtwY1/h8Qkho35D1rWrnsMBMU2B/UJh26duLMGSgdQm9fpN5VsFUWAWMayIwv69yrj7B6c2jqy/247rLrSkAG8R1P+HsKDZtcfZN3yaEk1TIR/omUmk3D4XG2xge0CP3hNPxPA+aaJ8yz/az5NkUrv1d6/J05670+tb5Scx/NAmzePDmQkw+wRrXpgWcI8uqtMCMzzvBOqs2Znsmcc8+lgWmYddoD1NgnKBWfiM+JDkrytzUL/lw83XWNTZnXRNH1RqXVqgywaiUzoegH4NCAxF31oz8o3oAY0ZaZyqL8rH2QeiP7aF+fiNSOqwdlvNeNWPx0tZl6ap16Vy0ZoOOG+aZF2h9uni9PjMqb8raTASUtlIGayOsbv++X61jzm2ZBVz7HstinsDDS6k7CKwiBZT7kZLy16YKVtkQwvnTrJvm9MS/U1j3Xp6Vte0h2qrUrYRNjCzT8NtrrSsdtn+oi8DoPmhcqclL9wwM2h0gDNXEb9kbHvkJo7fUNKgXPPITpl6qKpnVNEQPF0JcpAS2boi2h9X4lcD5+rwED5gcENzDfjQ44Nk+mdi7n1G7k9VcqTZRx9W4LDVlxKNNWJpJsGnOe/v8aXESo0+JoWJyFDOuiiPVwgGli6azb4hj1JdjGPHFGO58yLx+YheTVCa6Hg5DiXftbxNGzkyKbqpj4rllze/DF1ekcIeIGokxPpZ+5J/dFEfNNi8nt6BeBOaP4DBUra+xsblYeosc3Ngo5zWpHqqzNa890BzGfimDycQxEp1DCXfzdYFDAh53tIZTTmxeHzz1Cz6cNcV36PwrLipA6afsbxDE5Mb7x9NJPPZ0ylheW21j54aGfX5RWT0Ddxwcxg8v8uOkiRrqG4BjK8mYKdgUNV558e0BvLWeEZDto0c6o0GgipXzrnTM1Jadfrn935Hq6FlwIJ8d3b5oSvSJxzmrGa+mtZw71QetxaWPO8aG8kPnDaq70PSnb3UnBvQh/OWPhVaGcMgMaWulwz+1pdXt5hBU/20kSkYZa+RTQrNtY9VkrTZVABS/RWMI4on0olBlr+PQ9I1+BGkL4lCX6bg5c+dLWfbmO3xYzE9e2jLKSuDePYFlfw8agVDMZv/HjHFnHA7Z4MAGWhx+bPUjHt0NhHfKgaFwGEMHaVi2MnsHxhA5f0A/68rkbTvaltUhtYK92BHdqaVng9MGOJBrL+2Yrb3gLD98FpU2R/Ug7HszhNTmcLNl64oQfE4of5nW0ngk0smhc1axh61G1aIvnZGdyGPHaPjetywMTkUwbiaNmi/klEo98Qq1+mRuEh6TQuRncCC3Xh8wotI9mGFOkkrQ44/R8Nd5hejdK/epq6LT3nRv4pATpSEKJBLpdrijSfHzapUWeGXkLUwIR0Rkx43xDxYC828KYPppPtz2YBJVa1L4+ED6+KhhmhGfY+Z0v2nRblIi8N+edGR/THtEsC36htowBFbzSLkay2Tzq3AoZ5ziMxaFikMZKEibRLNR5emPv1uAwS0mnqsbqrjIqWMleCWdnI6006SA4+dEascK3JSgheZROSy+eYYP48a4aGwE0wsHNw8LnMSj0hL+tZjpELop6zfqGNQvva3K2pTrLLNBI1hfeHDnkMA0MlrLNeFV6MbPZrj6xtadBI6vTLWEUEXDY1sP7jZvg+hYLCd0W4GHlRIK/K17rRzqyW2bFD3QdLe5wBR5ABy+RUTuls8BvvvGQpx2kovHIbJUrOJas6fBNvs3hleL6Z/wcCtPUWXd3qYHWruJUql7xCadizx+fN1PfpfAzfcfdpx8sCNfxnLp81oeaS3igdgr6BN+DXlc2dq5i40lz3iNhsVebnmwlcDKQc3V9Gcx6Hkr8NxrCjBlcmu/dcUQN0/y0O9t62jbZri8YSGqw9c4LfpOrigbTJhwbB5N6iCsRVnsobbealNg9fQO3gx1R9wBE7s3392s4w/3Wzdg/d3qvBw3zeKkupMyzFDJXJEqiMxHKnyBESTNJFSH+U9+49jg2m5hNUI9F6Lt52JlFpiGIso1qbnibn8aOWbUcM0YFmsXw8vyxDwzEtBSv6DBOyKZTulWD6fMOzQspbL2H0555FvZT9fL64fwcBbq8bJx3HCk044oMA1teFu+7C54OI27aGRk1ZFOyq4w2hWZJ8Z8OTycwnLsCs7L5sSsm0C8KXyC3A5PQj1D3sNG6GMk6UQaWZ/VjJSsq5M0PPK6yPxreNiJOA30X2YrrqJj7YXy6J3Q+RF42MVCPCQadIAOe6l4HYoRDlXJR0fBwzoYG6XcPZ4m7TvQkY91yg3JNeGx8oNq3G0feJgP0QE0JibSqHiHZ6B0yqVD5ZHVIvMZsjTAw2Qkjf2pr3dGXEWnfXZUEX1VcvEsqFF8HubBdAENib2ITtIlpywNiz4GnVz5QEsXkBTTPJOGRZaiC3TZ607DG/4qt9ls44I8cofGP0JZw8PoIjnp62WW79lcdIFc1CJ4dJVGybnfofKui6vIaWc+bwlPk3byYvnaInh0hgbJLbOMoi9H5Hy0Bm8qOkVy8hLZ7AGPjrBHUm+aUXnNIaYMx+HqwGiw7wkxNSPgkQX0HojPSzc/c4spQxuoQtps8agKrvYgvMpX+5AUaY2h8WaIqzBt7AqNRh3KI5dIfr5G2ssdcq91Cxi7jdbHguhMGr2nDiZhyUBg3lI8Brp+H7rxzMVm6FiBAsym0ojpsVEsG+nNu/uWoC5ylfzi5bLbPZ/VpIbZaLgLieA8GrnPEqtm+VD+Tzoq5sjmVDgw+JqJiEeKfkkVDW/BQmybqyFCf02EvlE2x9p5HSajXECvyHquVKKegQ3YmrBchTD6hGdKMlyRd9NkGGvFHN+Dgp4L2hu3bDaOyDk8R5LiouC3pVJ/qexOhHuRDgJILxs9oOZ3qSlAsBnHmUbeHJwsQs+WKztddoNwAyz+Y42WQE/dg32xV9UMTTgEx5Z9XFvSB3piGlLaJZKA450XVoKjknyr5LoeBvefTxU1MTgQV1RueFOwFKRdKK7PU8XzM8G2iHwEFQ1wmfSBP4dC/VEaEq2Fw3Fd7ZX/I2Z7aOh4+GiKXP7n5MhnJNH7yj/JbZNLTewi7JTfWC89PFXinFiCVZE3VVRAuAjXN08k6QswKDRQqjel0LUR0PQxSNHRUm0bkH42stZLzlJPWFVT+pv+36RUhhpA+n45rJ48s80QU02mJr1G5N2K4QN2EznT9GbL/wFLC+Kh6JIF9QAAAABJRU5ErkJggg==",wg=({metaData:n,setMetaData:e,isPreviewMode:t})=>w.jsxs("div",{className:"flex items-center gap-4",children:[w.jsx("img",{src:bg,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),w.jsx("input",{className:"custom-input mx-2 focus:outline-none",disabled:t,type:"text",placeholder:"Untitled",defaultValue:n.plugin.title||"",onChange:r=>e({...n,plugin:{...n.plugin,title:r.target.value}})})]});function Ie(n){this.content=n}Ie.prototype={constructor:Ie,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new Ie(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ie(t)},addToStart:function(n,e){return new Ie([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ie(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new Ie(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ie.from(n),n.size?new Ie(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ie.from(n),n.size?new Ie(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ie.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ie.from=function(n){if(n instanceof Ie)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ie(e)};function Yc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)t++;return t}if(o.content.size||i.content.size){let s=Yc(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Xc(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let c=Xc(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class M{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new M(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new M(r,o)}cutByIndex(e,t){return e==t?M.empty:e==0&&t==this.content.length?this:new M(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new M(o,i)}addToStart(e){return new M([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new M(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Yc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Xc(this,e,t,r)}findIndex(e,t=-1){if(e==0)return li(0,e);if(e==this.size)return li(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||t>0?li(r+1,s):li(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return M.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new M(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return M.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new M(t||e,r)}static from(e){if(!e)return M.empty;if(e instanceof M)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new M([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}M.empty=new M([],0);const dl={index:0,offset:0};function li(n,e){return dl.index=n,dl.offset=e,dl}function ai(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ai(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ai(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let de=class Wc{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ai(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Wc.none;if(e instanceof Wc)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};de.none=[];class ci extends Error{}class B{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=eu(this.content,e+this.openStart,t);return r&&new B(r,this.openStart,this.openEnd)}removeBetween(e,t){return new B(Qc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return B.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(M.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new B(e,r,o)}}B.empty=new B(M.empty,0,0);function Qc(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Qc(i.content,e-o-1,t-o-1)))}function eu(n,e,t,r){let{index:o,offset:i}=n.findIndex(e),s=n.maybeChild(o);if(i==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=eu(s.content,e-i-1,t);return l&&n.replaceChild(o,s.copy(l))}function xg(n,e,t){if(t.openStart>n.depth)throw new ci("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ci("Inconsistent open depths");return tu(n,e,t,0)}function tu(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=tu(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Kn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=kg(t,n);return Kn(i,ru(n,s,l,e,r))}else return Kn(i,ui(n,e,r))}function nu(n,e){if(!e.type.compatibleContent(n.type))throw new ci("Cannot join "+e.type.name+" onto "+n.type.name)}function fl(n,e,t){let r=n.node(t);return nu(r,e.node(t)),r}function Un(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function yo(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Un(n.nodeAfter,r),i++));for(let l=i;l<s;l++)Un(o.child(l),r);e&&e.depth==t&&e.textOffset&&Un(e.nodeBefore,r)}function Kn(n,e){return n.type.checkContent(e),n.copy(e)}function ru(n,e,t,r,o){let i=n.depth>o&&fl(n,e,o+1),s=r.depth>o&&fl(t,r,o+1),l=[];return yo(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(nu(i,s),Un(Kn(i,ru(n,e,t,r,o+1)),l)):(i&&Un(Kn(i,ui(n,e,o+1)),l),yo(e,t,o,l),s&&Un(Kn(s,ui(t,r,o+1)),l)),yo(r,null,o,l),new M(l)}function ui(n,e,t){let r=[];if(yo(null,n,t,r),n.depth>t){let o=fl(n,e,t+1);Un(Kn(o,ui(n,e,t+1)),r)}return yo(e,null,t,r),new M(r)}function kg(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(M.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class vo{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return de.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new di(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new vo(t,r,i)}static resolveCached(e,t){for(let o=0;o<hl.length;o++){let i=hl[o];if(i.pos==t&&i.doc==e)return i}let r=hl[pl]=vo.resolve(e,t);return pl=(pl+1)%Cg,r}}let hl=[],pl=0,Cg=12;class di{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Sg=Object.create(null);let Jn=class qc{constructor(e,t,r,o=de.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||M.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ai(this.attrs,t||e.defaultAttrs||Sg)&&de.sameSet(this.marks,r||de.none)}copy(e=null){return e==this.content?this:new qc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qc(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return B.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new B(c,o.depth-s,i.depth-s)}replace(e,t,r){return xg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return vo.resolveCached(this,e)}resolveNoCache(e){return vo.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ou(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=M.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=de.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!de.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=M.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Jn.prototype.text=void 0;class fi extends Jn{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ou(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new fi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new fi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ou(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Zn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Eg(e,t);if(r.next==null)return Zn.empty;let o=iu(r);r.next&&r.err("Unexpected trailing text");let i=Lg(Dg(o));return Pg(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return M.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
31
31
  `)}}Zn.empty=new Zn(!0);class Eg{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function iu(n){let e=[];do e.push(Ag(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ag(n){let e=[];do e.push(Tg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Tg(n){let e=Ng(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Mg(n,e);else break;return e}function su(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Mg(n,e){let t=su(n),r=t;return n.eat(",")&&(n.next!="}"?r=su(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Og(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.groups.indexOf(e)>-1&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Ng(n){if(n.eat("(")){let e=iu(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Og(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Dg(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function lu(n,e){return e-n}function au(n,e){let t=[];return r(e),t.sort(lu);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Lg(n){let e=Object.create(null);return t(au(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);au(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Zn(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(lu);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function Pg(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function cu(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function uu(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let i=n[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function du(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new Rg(n[t]);return e}let fu=class mg{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=du(r.attrs),this.defaultAttrs=cu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Zn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:uu(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Jn(this,this.computeAttrs(e),M.from(t),de.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Jn(this,this.computeAttrs(e),t,de.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(M.empty,!0);return i?new Jn(this,e,t.append(i),de.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:de.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new mg(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Rg{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class hi{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=du(o.attrs),this.excluded=null;let i=cu(this.attrs);this.instance=i?new de(this,i):null}create(e=null){return!e&&this.instance?this.instance:new de(this,uu(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new hi(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class Ig{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Ie.from(e.nodes),t.marks=Ie.from(e.marks||{}),this.nodes=fu.compile(this.spec.nodes,this),this.marks=hi.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Zn.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?hu(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:hu(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof fu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new fi(r,r.defaultAttrs,e,de.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Jn.fromJSON(this,e)}markFromJSON(e){return de.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function hu(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Fg(n){return n.tag!=null}function $g(n){return n.style!=null}class kr{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{Fg(r)?this.tags.push(r):$g(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new yu(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new yu(this,t,!0);return r.addAll(e,t.from,t.to),B.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(jg(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=vu(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=vu(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kr(e,kr.schemaRules(e)))}}const pu={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Bg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mu={ol:!0,ul:!0},pi=1,mi=2,bo=4;function gu(n,e,t){return e!=null?(e?pi:0)|(e==="full"?mi:0):n&&n.whitespace=="pre"?pi|mi:t&~bo}class gi{constructor(e,t,r,o,i,s,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=l,this.content=[],this.activeMarks=de.none,this.stashMarks=[],this.match=s||(l&bo?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&pi)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let o=r[t];(this.type?this.type.allowsMarkType(o.type):zg(o.type,e))&&!o.isInSet(this.activeMarks)&&(this.activeMarks=o.addToSet(this.activeMarks),this.pendingMarks=o.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!pu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class yu{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let o=t.topNode,i,s=gu(null,t.preserveWhitespace,0)|(r?bo:0);o?i=new gi(o.type,o.attrs,de.none,de.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new gi(null,null,de.none,de.none,!0,null,s):i=new gi(e.schema.topNodeType,null,de.none,de.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,t){let r=e.style;if(!r||!r.length)return t();let o=this.readStyles(e.style);if(!o)return;let[i,s]=o,l=this.top;for(let a=0;a<s.length;a++)this.removePendingMark(s[a],l);for(let a=0;a<i.length;a++)this.addPendingMark(i[a]);t();for(let a=0;a<i.length;a++)this.removePendingMark(i[a],l);for(let a=0;a<s.length;a++)this.addPendingMark(s[a])}addTextNode(e){let t=e.nodeValue,r=this.top;if(r.options&mi||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&pi)r.options&mi?t=t.replace(/\r\n?/g,`
32
32
  `):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let o=r.content[r.content.length-1],i=e.previousSibling;(!o||i&&i.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),o;mu.hasOwnProperty(r)&&this.parser.normalizeLists&&Hg(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,t));if(i?i.ignore:Bg.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let s,l=this.top,a=this.needsBlock;if(pu.hasOwnProperty(r))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),s=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}i&&i.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
33
33
  `))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=de.none,r=de.none;for(let o=0,i=e.length;o<i;o++){let s=e.item(o);for(let l=void 0;;){let a=this.parser.matchStyle(s,e.getPropertyValue(s),this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let o,i,s;t.node?(i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):o=this.enter(i,t.attrs||null,t.preserveWhitespace)):(s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,t,r){let o=t||0;for(let i=t?e.childNodes[t]:e.firstChild,s=r==null?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i);this.findAtPoint(e,o)}findPlace(e){let t,r;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,r=i,!s.length)||i.solid)break}if(!t)return!1;this.sync(r);for(let o=0;o<t.length;o++)this.enterInner(t[o],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let o=0;o<e.marks.length;o++)(!t.type||t.type.allowsMarkType(e.marks[o].type))&&(r=e.marks[o].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let o=this.findPlace(e.create(t));return o&&this.enterInner(e,t,!0,r),o}enterInner(e,t=null,r=!1,o){this.closeExtra();let i=this.top;i.applyPending(e),i.match=i.match&&i.match.matchType(e);let s=gu(e,o,i.options);i.options&bo&&i.content.length==0&&(s|=bo),this.nodes.push(new gi(e,t,i.activeMarks,i.pendingMarks,r,null,s)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=Vg(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let s=o.popFromStashMark(e);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==t)break}}}function Hg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&mu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function jg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function vu(n){let e={};for(let t in n)e[t]=n[t];return e}function zg(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}function Vg(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class Ft{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ml(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Ft.renderSpec(ml(t),this.nodes[e.type.name](e));if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Ft.renderSpec(ml(r),o(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],i=o.indexOf(" ");i>0&&(r=o.slice(0,i),o=o.slice(i+1));let s,l=r?e.createElementNS(r,o):e.createElement(o),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<t.length;u++){let d=t[u];if(d===0){if(u<t.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=Ft.renderSpec(e,d,r);if(l.appendChild(f),h){if(s)throw new RangeError("Multiple content holes");s=h}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ft(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=bu(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return bu(e.marks)}}function bu(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ml(n){return n.document||window.document}const wu=65535,xu=Math.pow(2,16);function _g(n,e){return n+e*xu}function ku(n){return n&wu}function Wg(n){return(n-(n&wu))/xu}const Cu=1,Su=2,yi=4,Eu=8;class gl{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Eu)>0}get deletedBefore(){return(this.delInfo&(Cu|yi))>0}get deletedAfter(){return(this.delInfo&(Su|yi))>0}get deletedAcross(){return(this.delInfo&yi)>0}}class at{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&at.empty)return at.empty}recover(e){let t=0,r=ku(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Wg(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+o+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:_g(l/3,e-a),m=e==a?Su:e==d?Cu:yi;return(t<0?e!=a:e!=d)&&(m|=Eu),new gl(h,m,p)}o+=u-c}return r?e+o:new gl(e+o,0,null)}touches(e,t){let r=0,o=ku(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new at(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?at.empty:new at(e<0?[0,-e,0]:[0,0,e])}}at.empty=new at([]);class Cr{constructor(e=[],t,r=0,o=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=o}slice(e=0,t=this.maps.length){return new Cr(this.maps,this.mirror,e,t)}copy(){return new Cr(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Cr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this.maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new gl(e,o,null)}}const yl=Object.create(null);class je{getMap(){return at.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yl)throw new RangeError("Duplicate use of step JSON ID "+e);return yl[e]=t,t.prototype.jsonID=e,t}}class ke{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ke(e,null)}static fail(e){return new ke(null,e)}static fromReplace(e,t,r,o){try{return ke.ok(e.replace(t,r,o))}catch(i){if(i instanceof ci)return ke.fail(i.message);throw i}}}function vl(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(vl(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return M.fromArray(r)}class wn extends je{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new B(vl(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return ke.fromReplace(e,this.from,this.to,i)}invert(){return new $t(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new wn(t.pos,r.pos,this.mark)}merge(e){return e instanceof wn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wn(t.from,t.to,e.markFromJSON(t.mark))}}je.jsonID("addMark",wn);class $t extends je{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new B(vl(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return ke.fromReplace(e,this.from,this.to,r)}invert(){return new wn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new $t(t.pos,r.pos,this.mark)}merge(e){return e instanceof $t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new $t(t.from,t.to,e.markFromJSON(t.mark))}}je.jsonID("removeMark",$t);class xn extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ke.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ke.fromReplace(e,this.pos,this.pos+1,new B(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new xn(this.pos,t.marks[o]);return new xn(this.pos,this.mark)}}return new Sr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xn(t.pos,e.markFromJSON(t.mark))}}je.jsonID("addNodeMark",xn);class Sr extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ke.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ke.fromReplace(e,this.pos,this.pos+1,new B(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Sr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Sr(t.pos,e.markFromJSON(t.mark))}}je.jsonID("removeNodeMark",Sr);class Oe extends je{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&bl(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new at([this.from,this.to-this.from,this.slice.size])}invert(e){return new Oe(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Oe(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Oe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?B.empty:new B(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Oe(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?B.empty:new B(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Oe(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Oe(t.from,t.to,B.fromJSON(e,t.slice),!!t.structure)}}je.jsonID("replace",Oe);class Ne extends je{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(bl(e,this.from,this.gapFrom)||bl(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ke.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ke.fromReplace(e,this.from,this.to,r):ke.fail("Content does not fit in gap")}getMap(){return new at([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ne(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos?null:new Ne(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ne(t.from,t.to,t.gapFrom,t.gapTo,B.fromJSON(e,t.slice),t.insert,!!t.structure)}}je.jsonID("replaceAround",Ne);function bl(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function qg(n,e,t,r){let o=[],i=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(s&&s.to==f&&s.mark.eq(d[m])?s.to=h:o.push(s=new $t(f,h,d[m])));l&&l.to==f?l.to=h:i.push(l=new wn(f,h,r))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Ug(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof hi){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new $t(s.from,s.to,s.style)))}function Au(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new Oe(l,u,B.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new $t(l,u,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new B(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new Oe(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(M.empty,!0);n.replace(l,l,new B(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function Kg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Er(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),i=n.$from.index(r),s=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(i,s,t))return r;if(r==0||o.type.spec.isolating||!Kg(o,i,s))break}return null}function Jg(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=M.empty,d=0;for(let p=i,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=M.from(r.node(p).copy(u)),d++):a--;let f=M.empty,h=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=M.from(o.node(p).copy(f)),h++):c++;n.step(new Ne(a,c,s,l,new B(u.append(f),d,h),u.size-d,!0))}function wl(n,e,t=null,r=n){let o=Zg(n,e),i=o&&Gg(r,e);return i?o.map(Tu).concat({type:e,attrs:t}).concat(i.map(Tu)):null}function Tu(n){return{type:n,attrs:null}}function Zg(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function Gg(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Yg(n,e,t){let r=M.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new Ne(o,i,o,i,new B(r,0,0),t.length,!0))}function Xg(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,o)&&t0(n.doc,n.mapping.slice(i).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&e0(n,s,l,i),Au(n,n.mapping.slice(i).map(l,1),r,void 0,a===null);let c=n.mapping.slice(i),u=c.map(l,1),d=c.map(l+s.nodeSize,1);return n.step(new Ne(u,d,u+1,d-1,new B(M.from(r.create(o,null,s.marks)),0,0),1,!0)),a===!0&&Qg(n,s,l,i),!1}})}function Qg(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function e0(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
@@ -353,4 +353,4 @@ img.ProseMirror-separator {
353
353
  .block-interactivity-`.concat(n,` {pointer-events: none;}
354
354
  .allow-interactivity-`).concat(n,` {pointer-events: all;}
355
355
  `)},XS=0,oo=[];function QS(n){var e=q.useRef([]),t=q.useRef([0,0]),r=q.useRef(),o=q.useState(XS++)[0],i=q.useState(function(){return um()})[0],s=q.useRef(n);q.useEffect(function(){s.current=n},[n]),q.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(o));var m=wS([n.lockRef.current],(n.shards||[]).map(ym),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[n.inert,n.lockRef.current,n.shards]);var l=q.useCallback(function(m,g){if("touches"in m&&m.touches.length===2)return!s.current.allowPinchZoom;var y=Xs(m),k=t.current,C="deltaX"in m?m.deltaX:k[0]-y[0],v="deltaY"in m?m.deltaY:k[1]-y[1],E,S=m.target,O=Math.abs(C)>Math.abs(v)?"h":"v";if("touches"in m&&O==="h"&&S.type==="range")return!1;var D=hm(O,S);if(!D)return!0;if(D?E=O:(E=O==="v"?"h":"v",D=hm(O,S)),!D)return!1;if(!r.current&&"changedTouches"in m&&(C||v)&&(r.current=E),!E)return!0;var A=r.current||E;return ZS(A,g,m,A==="h"?C:v,!0)},[]),a=q.useCallback(function(m){var g=m;if(!(!oo.length||oo[oo.length-1]!==i)){var y="deltaY"in g?gm(g):Xs(g),k=e.current.filter(function(E){return E.name===g.type&&E.target===g.target&&GS(E.delta,y)})[0];if(k&&k.should){g.cancelable&&g.preventDefault();return}if(!k){var C=(s.current.shards||[]).map(ym).filter(Boolean).filter(function(E){return E.contains(g.target)}),v=C.length>0?l(g,C[0]):!s.current.noIsolation;v&&g.cancelable&&g.preventDefault()}}},[]),c=q.useCallback(function(m,g,y,k){var C={name:m,delta:g,target:y,should:k};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(v){return v!==C})},1)},[]),u=q.useCallback(function(m){t.current=Xs(m),r.current=void 0},[]),d=q.useCallback(function(m){c(m.type,gm(m),m.target,l(m,n.lockRef.current))},[]),f=q.useCallback(function(m){c(m.type,Xs(m),m.target,l(m,n.lockRef.current))},[]);q.useEffect(function(){return oo.push(i),n.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,ro),document.addEventListener("touchmove",a,ro),document.addEventListener("touchstart",u,ro),function(){oo=oo.filter(function(m){return m!==i}),document.removeEventListener("wheel",a,ro),document.removeEventListener("touchmove",a,ro),document.removeEventListener("touchstart",u,ro)}},[]);var h=n.removeScrollBar,p=n.inert;return q.createElement(q.Fragment,null,p?q.createElement(i,{styles:YS(o)}):null,h?q.createElement(VS,{gapMode:"margin"}):null)}const eE=OS(cm,QS);var vm=q.forwardRef(function(n,e){return q.createElement(Gs,Yt({},n,{ref:e,sideCar:eE}))});vm.classNames=Gs.classNames;const bm="Popover",[wm,FT]=Cp(bm,[Qp]),Tc=Qp(),[tE,io]=wm(bm),nE=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=n,l=Tc(e),a=b.useRef(null),[c,u]=b.useState(!1),[d=!1,f]=pS({prop:r,defaultProp:o,onChange:i});return b.createElement(cS,l,b.createElement(tE,{scope:e,contentId:Yk(),triggerRef:a,open:d,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:s},t))},rE="PopoverTrigger",oE=b.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,o=io(rE,t),i=Tc(t),s=hr(e,o.triggerRef),l=b.createElement(pr.button,Ae({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":km(o.open)},r,{ref:s,onClick:Hn(n.onClick,o.onOpenToggle)}));return o.hasCustomAnchor?l:b.createElement(uS,Ae({asChild:!0},i),l)}),iE="PopoverPortal",[$T,sE]=wm(iE,{forceMount:void 0}),ni="PopoverContent",lE=b.forwardRef((n,e)=>{const t=sE(ni,n.__scopePopover),{forceMount:r=t.forceMount,...o}=n,i=io(ni,n.__scopePopover);return b.createElement(om,{present:r||i.open},i.modal?b.createElement(aE,Ae({},o,{ref:e})):b.createElement(cE,Ae({},o,{ref:e})))}),aE=b.forwardRef((n,e)=>{const t=io(ni,n.__scopePopover),r=b.useRef(null),o=hr(e,r),i=b.useRef(!1);return b.useEffect(()=>{const s=r.current;if(s)return bS(s)},[]),b.createElement(vm,{as:sc,allowPinchZoom:!0},b.createElement(xm,Ae({},n,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hn(n.onCloseAutoFocus,s=>{var l;s.preventDefault(),i.current||(l=t.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Hn(n.onPointerDownOutside,s=>{const l=s.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Hn(n.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})))}),cE=b.forwardRef((n,e)=>{const t=io(ni,n.__scopePopover),r=b.useRef(!1),o=b.useRef(!1);return b.createElement(xm,Ae({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s;if((s=n.onCloseAutoFocus)===null||s===void 0||s.call(n,i),!i.defaultPrevented){var l;r.current||(l=t.triggerRef.current)===null||l===void 0||l.focus(),i.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:i=>{var s,l;(s=n.onInteractOutside)===null||s===void 0||s.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((l=t.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}}))}),xm=b.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=n,f=io(ni,t),h=Tc(t);return zk(),b.createElement(Vk,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i},b.createElement(Bk,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},b.createElement(dS,Ae({"data-state":km(f.open),role:"dialog",id:f.contentId},h,d,{ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),uE="PopoverClose",dE=b.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,o=io(uE,t);return b.createElement(pr.button,Ae({type:"button"},r,{ref:e,onClick:Hn(n.onClick,()=>o.onOpenChange(!1))}))});function km(n){return n?"open":"closed"}const fE=nE,hE=oE,pE=lE,Qs=dE,Mc=b.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...o},i)=>{const s=fe(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return w.jsx("div",{className:s,...o,ref:i,children:n})});Mc.displayName="Surface";const el=({children:n,isActive:e,onClick:t,disabled:r,className:o})=>{const i=fe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",o);return w.jsx("button",{className:i,disabled:r,onClick:t,children:n})},mE=(n,e,t)=>{const r=b.useCallback(()=>{const l=n.chain();l.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[n,t,e==null?void 0:e.type.name]),o=b.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:l}=n.state.selection,a=l.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=b.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),s=b.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:o,copyNodeToClipboard:i,deleteNode:s}},tl=b.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:o="primary",className:i,activeClassname:s,...l},a)=>{const c=fe("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded-md disabled:opacity-50 whitespace-nowrap",o==="primary"&&fe("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",n&&fe("bg-neutral-900 dark:bg-neutral-300",s)),o==="secondary"&&fe("text-neutral-900 dark:text-white",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",n&&"bg-neutral-200 dark:bg-neutral-800"),o==="tertiary"&&fe("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",n&&fe("bg-neutral-200 dark:bg-neutral-800",s)),o==="ghost"&&fe("bg-transparent border-transparent text-neutral-500",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",n&&fe("bg-black/10 text-neutral-800 ",s)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return w.jsx("button",{ref:a,disabled:r,className:c,...l,children:t})});tl.displayName="Button";const Cm=({content:n,children:e})=>{const[t,r]=b.useState(!1);return w.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&w.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},Sm=b.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...o},i)=>{const s=fe("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&w.jsx(Mc,{className:s,...o,ref:i,children:e}):null});Sm.displayName="Toolbar";const Em=b.forwardRef(({horizontal:n,className:e,...t},r)=>{const o=fe("bg-neutral-200",n?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return w.jsx("div",{className:o,ref:r,...t})});Em.displayName="Toolbar.Divider";const Am=b.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:o,activeClassname:i,...s},l)=>{const a=fe("gap-1 min-w-[2rem] px-2 w-auto",r),c=w.jsx(tl,{activeClassname:i,className:a,variant:t,buttonSize:e,ref:l,...s,children:n});return o?w.jsx(Cm,{content:o,children:c}):c});Am.displayName="ToolbarButton";const ri={Wrapper:Sm,Divider:Em,Button:Am},gE=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[o,i]=b.useState(!1),s=mE(t,n,e()),l=$s(),a=["https://twitter.com","https://x.com"],c=b.useMemo(()=>{const{content:A}=n.content;return A[0].type.name==="table"},[n.content]),u=b.useMemo(()=>{var P;const{content:A}=n.content;return(P=A[0].content.content[0])==null?void 0:P.text},[n.content]),d=b.useMemo(()=>{var P;const{content:A}=n.content;return(P=A[0].content.content[1])==null?void 0:P.text},[n.content]),f=b.useMemo(()=>{const{content:A}=n.content;return A[0].content.content.find(P=>{var H;return(H=P==null?void 0:P.text)==null?void 0:H.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let A=u;if(u.includes("<iframe"))A=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const R=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);R&&R.length>0&&(A=`https://www.youtube.com/embed/${R[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const R=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);R&&R.length>0&&(A=`https://player.vimeo.com/video/${R[1]}`);break}default:return}const P=640,H=360,N=e(),$=N+n.nodeSize;A&&(t==null||t.chain().focus(N).deleteRange({from:N===0?N:N+1,to:$}).setIframe({src:A,width:P,height:H}).run())},p=A=>{const P=A.match(/\/status\/([0-9]*)/);return P&&P.length>0?P[1]:null},m=()=>{if(!u)return;let A=u;const P=a.some(R=>u.includes(R)),H=p(u);P&&H?A=H:f&&(A=p(f.text));const N=e(),$=N+n.nodeSize;A&&(t==null||t.chain().focus(N).deleteRange({from:N===2?N:N+1,to:$}).setTweetEmbed({tweetId:A}).run())},g=()=>{const A=e()+n.nodeSize;t.commands.insertContentAt(A,{type:"dBlock",content:[{type:"paragraph"}]})},y=()=>{const A=e();t.commands.insertContentAt(A,{type:"dBlock",content:[{type:"paragraph"}]})},k=()=>{r()},C=A=>{A.altKey?E():v()},v=()=>{g()},E=()=>{y()},S=A=>{A.altKey&&k()},D=xp(()=>{if(a.some(A=>u.includes(A))||f!=null&&f.text){m();return}else{h();return}},1e3);return b.useEffect(()=>{u&&D()},[u]),w.jsxs(Ko,{as:"div",className:fe("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[w.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[w.jsx(Cm,{content:w.jsxs("div",{className:"flex flex-col w-40",children:[w.jsx("div",{className:"text-xs",children:"Click to add below"}),w.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:w.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:C,children:w.jsx(Gx,{size:18})})}),w.jsxs(fE,{open:o,onOpenChange:i,children:[w.jsx(hE,{asChild:!0,children:w.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:S,children:w.jsx(Wx,{size:18})})}),w.jsx(pE,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:w.jsxs(Mc,{className:"p-2 flex flex-col min-w-[16rem]",children:[w.jsx(Qs,{children:w.jsxs(el,{onClick:s.resetTextFormatting,children:[w.jsx(Yx,{size:18}),"Clear formatting"]})}),w.jsx(Qs,{children:w.jsxs(el,{onClick:s.copyNodeToClipboard,children:[w.jsx(jx,{size:18}),"Copy to clipboard"]})}),w.jsx(Qs,{children:w.jsxs(el,{onClick:s.duplicateNode,children:[w.jsx(Vx,{size:18}),"Duplicate"]})}),w.jsx(ri.Divider,{horizontal:!0}),w.jsx(Qs,{children:w.jsxs(el,{onClick:s.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[w.jsx(ek,{size:18}),"Delete"]})})]})})]})]}),w.jsx(yh,{className:fe("node-view-content w-full",{"is-table min-w-auto":c})})]})},yE=pe.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",ee(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,o=n!==void 0||n!==null?r:n;return t().insertContentAt(o,{type:this.name,content:[{type:"paragraph"}]}).focus(o+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:o}=e.selection;let i=e.tr;const s=[];if(e.doc.nodesBetween(r,o,a=>{if(a.type.name===this.name){const c=e.schema.nodes.listItem.create(null,a.content);c&&s.push(c)}}),s.length===0)return!1;const l=e.schema.nodes[n].create(null,s);return l?(i=i.replaceRangeWith(r,o,l),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:o}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,o,(s,l)=>{if(s.type.name===n){const a=e.schema.nodes[this.name].create(null,s.content);i=i.insert(l,a)}}),t(i),!0}}},addNodeView(){return cr(gE)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:o}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let s=-1,l="";o.descendants((u,d)=>{if(s!==-1)return!1;if(u.type.name===this.name)return;const[f,h]=[d,d+u.nodeSize];return f<=t&&r<=h&&(s=h,l=u.type.name),!1});const a=(c=o.slice(t,s))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?n.chain().insertContentAt({from:t,to:s},`
356
- `).focus(s+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:s},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let Oc,Nc;if(typeof WeakMap<"u"){let n=new WeakMap;Oc=e=>n.get(e),Nc=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;Oc=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Nc=(r,o)=>(t==e&&(t=0),n[t++]=r,n[t++]=o)}class so{constructor(e,t,r,o){this.left=e,this.top=t,this.right=r,this.bottom=o}}class we{constructor(e,t,r,o){this.width=e,this.height=t,this.map=r,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let o=t%this.width,i=t/this.width|0,s=o+1,l=i+1;for(let a=1;s<this.width&&this.map[t+a]==r;a++)s++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new so(o,i,s,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:o,right:i,top:s,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?o==0:i==this.width)?null:this.map[s*this.width+(r<0?o-1:i)]:(r<0?s==0:l==this.height)?null:this.map[o+this.width*(r<0?s-1:l)]}rectBetween(e,t){let{left:r,right:o,top:i,bottom:s}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new so(Math.min(r,l),Math.min(i,c),Math.max(o,a),Math.max(s,u))}cellsInRect(e){let t=[],r={};for(let o=e.top;o<e.bottom;o++)for(let i=e.left;i<e.right;i++){let s=o*this.width+i,l=this.map[s];r[l]||(r[l]=!0,(i!=e.left||!i||this.map[s-1]!=l)&&(o!=e.top||!o||this.map[s-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let o=0,i=0;;o++){let s=i+r.child(o).nodeSize;if(o==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<i;)l++;return l==a?s-1:this.map[l]}i=s}}static get(e){return Oc(e)||Nc(e,vE(e))}}function vE(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=bE(n),t=n.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:k}=m.attrs;for(let C=0;C<y;C++){if(C+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-C});break}let v=o+C*e;for(let E=0;E<g;E++){r[v+E]==0?r[v+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-E});let S=k&&k[E];if(S){let O=(v+E)%e*2,D=s[O];D==null||D!=S&&s[O+1]==1?(s[O]=S,s[O+1]=1):D==S&&s[O+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let l=new we(e,t,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&wE(l,s,n),l}function bE(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let o=n.child(r),i=0;if(t)for(let s=0;s<r;s++){let l=n.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function wE(n,e,t){n.problems||(n.problems=[]);for(let r=0,o={};r<n.map.length;r++){let i=n.map[r];if(o[i])continue;o[i]=!0;let s=t.nodeAt(i),l=null;for(let a=0;a<s.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!s.attrs.colwidth||s.attrs.colwidth[a]!=u)&&((l||(l=xE(s.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function xE(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ve(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const Wn=new Ce("selectingCells");function lo(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function kE(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Pt(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function nl(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:lo(e.$head)||CE(e.$head)}function CE(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Dc(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function SE(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Lc(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Tm(n,e,t){let r=n.start(-1),i=we.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function Pe(n,e,t){let r={};for(let o in n)r[o]=n[o];return r[e]=t,r}function gr(n,e,t=1){let r=Pe(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Mm(n,e,t=1){let r=Pe(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function EE(n,e,t){let r=Ve(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}class ne extends J{constructor(e,t=e){let r=e.node(-1),o=we.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);let c=a.map(u=>{let d=r.nodeAt(u),f=u+i+1;return new El(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Dc(r)&&Dc(o)&&Lc(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ne.rowSelection(r,o):i&&this.isColSelection()?ne.colSelection(r,o):new ne(r,o)}return K.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=we.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){let f=t.map[u];if(!i[f]){i[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;m>0&&(y=gr(y,0,m)),g>0&&(y=gr(y,y.colspan-g,g)),h.left<o.left?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y=Pe(p.attrs,"rowspan",Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top));h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}}s.push(e.child(a).copy(M.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new B(M.from(l),1,1)}replace(e,t=B.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?B.empty:t)}let i=J.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new B(M.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=we.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=we.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.top<=s.top?(i.top>0&&(e=l.resolve(o+r.map[i.left])),s.bottom<r.height&&(t=l.resolve(o+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(t=l.resolve(o+r.map[s.left])),i.bottom<r.height&&(e=l.resolve(o+r.map[r.width*(r.height-1)+i.right-1]))),new ne(e,t)}isRowSelection(){let e=we.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),o=e.colCount(this.$headCell.pos-t);if(Math.min(r,o)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof ne&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=we.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.left<=s.left?(i.left>0&&(e=l.resolve(o+r.map[i.top*r.width])),s.right<r.width&&(t=l.resolve(o+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(t=l.resolve(o+r.map[s.top*r.width])),i.right<r.width&&(e=l.resolve(o+r.map[r.width*(i.top+1)-1]))),new ne(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ne(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ne(e.resolve(t),e.resolve(r))}getBookmark(){return new Pc(this.$anchorCell.pos,this.$headCell.pos)}}ne.prototype.visible=!1,J.jsonID("cell",ne);class Pc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pc(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Lc(t,r)?new ne(t,r):J.near(r,1)}}function AE(n){if(!(n.selection instanceof ne))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push($e.node(r,r+t.nodeSize,{class:"selectedCell"}))}),me.create(n.doc,e)}function TE({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function ME({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function OE(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof W&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=ne.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=ne.rowSelection(l,l)}else if(!t){let l=we.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ne.create(o,a+1,c)}}else r instanceof K&&TE(r)?i=K.create(o,r.from):r instanceof K&&ME(r)&&(i=K.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function NE(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let o=e.firstChild,i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Rc(Ve(s).row,new B(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?Rc(Ve(s).row,new B(e,t,r)).content:e);else return null;return DE(s,l)}function DE(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(M.empty),t[o]<r){let i=Ve(n).cell.createAndFill(),s=[];for(let l=t[o];l<r;l++)s.push(i);e[o]=e[o].append(M.from(s))}return{height:e.length,width:r,rows:e}}function Rc(n,e){let t=n.createAndFill();return new Cl(t).replace(0,t.content.size,e).doc}function LE({width:n,height:e,rows:t},r,o){if(n!=r){let i=[],s=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(gr(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(M.from(c))}t=s,n=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create(Pe(d.attrs,"rowspan",Math.max(1,o-d.attrs.rowspan)),d.content)),a.push(d)}i.push(M.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function PE(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=Ve(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,M.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),h)}return!!(c||u)}function Om(n,e,t,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,Pe(f.attrs,"rowspan",s-h)),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),f.type.createAndFill(Pe(f.attrs,"rowspan",h+f.attrs.rowspan-s))),c+=f.attrs.colspan-1}}return a}function Nm(n,e,t,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,gr(f.attrs,s-h,f.attrs.colspan-(s-h))),n.insert(p+f.nodeSize,f.type.createAndFill(gr(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Dm(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc,s=we.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr,f=0;function h(){i=t?d.doc.nodeAt(t-1):d.doc,s=we.get(i),f=d.mapping.maps.length}PE(d,s,i,t,c,u,f)&&h(),Om(d,s,i,t,a,c,l,f)&&h(),Om(d,s,i,t,a,c,u,f)&&h(),Nm(d,s,i,t,l,u,a,f)&&h(),Nm(d,s,i,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new B(o.rows[p-l],0,0))}h(),d.setSelection(new ne(d.doc.resolve(t+s.positionAt(l,a,i)),d.doc.resolve(t+s.positionAt(u-1,c-1,i)))),e(d)}const RE=ea({ArrowLeft:ol("horiz",-1),ArrowRight:ol("horiz",1),ArrowUp:ol("vert",-1),ArrowDown:ol("vert",1),"Shift-ArrowLeft":il("horiz",-1),"Shift-ArrowRight":il("horiz",1),"Shift-ArrowUp":il("vert",-1),"Shift-ArrowDown":il("vert",1),Backspace:sl,"Mod-Backspace":sl,Delete:sl,"Mod-Delete":sl});function rl(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ol(n,e){return(t,r,o)=>{let i=t.selection;if(i instanceof ne)return rl(t,r,J.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=Lm(o,n,e);if(s==null)return!1;if(n=="horiz")return rl(t,r,J.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=Tm(l,n,e),c;return a?c=J.near(a,1):e<0?c=J.near(t.doc.resolve(l.before(-1)),-1):c=J.near(t.doc.resolve(l.after(-1)),1),rl(t,r,c)}}}function il(n,e){return(t,r,o)=>{let i=t.selection;if(!(i instanceof ne)){let l=Lm(o,n,e);if(l==null)return!1;i=new ne(t.doc.resolve(l))}let s=Tm(i.$headCell,n,e);return s?rl(t,r,new ne(i.$anchorCell,s)):!1}}function sl(n,e){let t=n.selection;if(!(t instanceof ne))return!1;if(e){let r=n.tr,o=Ve(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new B(o,0,0))}),r.docChanged&&e(r)}return!0}function IE(n,e){let t=n.state.doc,r=lo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ne(r))),!0):!1}function FE(n,e,t){if(!Pt(n.state))return!1;let r=NE(t),o=n.state.selection;if(o instanceof ne){r||(r={width:1,height:1,rows:[M.from(Rc(Ve(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=we.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=LE(r,l.right-l.left,l.bottom-l.top),Dm(n.state,n.dispatch,s,l,r),!0}else if(r){let i=nl(n.state),s=i.start(-1);return Dm(n.state,n.dispatch,s,we.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function $E(n,e){if(e.ctrlKey||e.metaKey)return;let t=Pm(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof ne)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=lo(n.state.selection.$anchor))!=null&&Ic(n,e).pos!=r.pos)o(r,e),e.preventDefault();else if(!t)return;function o(l,a){let c=Ic(n,a),u=Wn.getState(n.state)==null;if(!c||!Lc(l,c))if(u)c=l;else return;let d=new ne(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Wn,l.pos),n.dispatch(f)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",s),Wn.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Wn,-1))}function s(l){let a=Wn.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Pm(n,l.target)!=t&&(c=Ic(n,e),!c))return i();c&&o(c,l)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",s)}function Lm(n,e,t){if(!(n.state.selection instanceof K))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Pm(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Ic(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?lo(n.state.doc.resolve(t.pos)):null}const BE=new Ce("fix-tables");function Rm(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?Rm(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Im(n,e){let t,r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=HE(n,o,i,t))};return e?e.doc!=n.doc&&Rm(e.doc,n.doc,0,r):n.doc.descendants(r),t}function HE(n,e,t,r){let o=we.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)i[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,gr(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pe(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pe(u.attrs,"colwidth",c.colwidth))}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++)p.push(Ve(n.schema)[h].createAndFill());let m=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(BE,{fixTables:!0})}function Xt(n){let e=n.selection,t=nl(n),r=t.node(-1),o=t.start(-1),i=we.get(r),s;return e instanceof ne?s=i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s=i.findCell(t.pos-o),s.tableStart=o,s.map=i,s.table=r,s}function Fm(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;EE(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Mm(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Ve(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function jE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e(Fm(n.tr,t,t.left))}return!0}function zE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e(Fm(n.tr,t,t.right))}return!0}function VE(n,{map:e,table:t,tableStart:r},o){let i=n.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=t.nodeAt(a);if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,gr(c.attrs,o-e.colCount(a)));else{let u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}s+=c.attrs.rowspan}}function _E(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;VE(r,t,o),o!=t.left;o--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=we.get(t.table);e(r)}return!0}function WE(n,e,t){let r=Ve(e.type.schema).header_cell;for(let o=0;o<n.width;o++)if(e.nodeAt(n.map[o+t*n.width]).type!=r)return!1;return!0}function $m(n,{map:e,tableStart:t,table:r},o){let i=t;for(let a=0;a<o;a++)i+=r.child(a).nodeSize;let s=[],l=o>0?-1:0;WE(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let a=0,c=e.width*o;a<e.width;a++,c++)if(o>0&&o<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,Pe(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Ve(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;s.push(u.createAndFill())}return n.insert(i,Ve(r.type.schema).row.create(null,s)),n}function qE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e($m(n.tr,t,t.top))}return!0}function UE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e($m(n.tr,t,t.bottom))}return!0}function KE(n,{map:e,table:t,tableStart:r},o){let i=0;for(let a=0;a<o;a++)i+=t.child(a).nodeSize;let s=i+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(i+r,s+r);for(let a=0,c=o*e.width;a<e.width;a++,c++){let u=e.map[c];if(o>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,Pe(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(o<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(Pe(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(o+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function JE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;KE(r,t,o),o!=t.top;o--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=we.get(t.table);e(r)}return!0}function Bm(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function ZE({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,s=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[s]==t[s+n])return!0;o++,s++}return!1}function Hm(n,e){let t=n.selection;if(!(t instanceof ne)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xt(n),{map:o}=r;if(ZE(o,r))return!1;if(e){let i=n.tr,s={},l=M.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!s[f])if(s[f]=!0,a==null)a=f,c=h;else{Bm(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(a+r.tableStart,null,Pe(Mm(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=Bm(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new ne(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function jm(n,e){const t=Ve(n.schema);return GE(({node:r})=>t[r.type.spec.tableRole])(n,e)}function GE(n){return(e,t)=>{let r=e.selection,o,i;if(r instanceof ne){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(o=kE(r.$from),!o)return!1;i=lo(r.$from).pos}if(o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let s=o.attrs,l=[],a=s.colwidth;s.rowspan>1&&(s=Pe(s,"rowspan",1)),s.colspan>1&&(s=Pe(s,"colspan",1));let c=Xt(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?Pe(s,"colwidth",a&&a[f]?[a[f]]:null):s);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=o.nodeSize);for(let p=c.left,m=0;p<c.right;p++,m++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:o,row:f,col:p}).createAndFill(l[m]))}u.setNodeMarkup(i,n({node:o,row:c.top,col:c.left}),l[0]),r instanceof ne&&u.setSelection(new ne(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function YE(n,e){return function(t,r){if(!Pt(t))return!1;let o=nl(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof ne?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,Pe(s.attrs,n,e))}):i.setNodeMarkup(o.pos,null,Pe(o.nodeAfter.attrs,n,e)),r(i)}return!0}}function XE(n){return function(e,t){if(!Pt(e))return!1;if(t){let r=Ve(e.schema),o=Xt(e),i=e.tr,s=o.map.cellsInRect(n=="column"?new so(o.left,0,o.right,o.map.height):n=="row"?new so(0,o.top,o.map.width,o.bottom):o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);t(i)}return!0}}function zm(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function oi(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?XE(n):function(t,r){if(!Pt(t))return!1;if(r){let o=Ve(t.schema),i=Xt(t),s=t.tr,l=zm("row",i,o),a=zm("column",i,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new so(0,u,1,i.map.height):n=="row"?new so(u,0,i.map.width,1):i,f=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(h=>{const p=h+i.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}oi("row",{useDeprecatedLogic:!0}),oi("column",{useDeprecatedLogic:!0});let QE=oi("cell",{useDeprecatedLogic:!0});function eA(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return o-1-i.lastChild.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}}function Vm(n){return function(e,t){if(!Pt(e))return!1;let r=eA(nl(e),n);if(r!=null){if(t){let o=e.doc.resolve(r);t(e.tr.setSelection(K.between(o,SE(o))).scrollIntoView())}return!0}}}function tA(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let nA=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fc(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Fc(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Fc(n,e,t,r,o,i){let s=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let m=o==d?i:h&&h[p],g=m?m+"px":"";s+=m||r,m||(l=!1),a?(a.style.width!=g&&(a.style.width=g),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=g}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}const At=new Ce("tableColumnResizing");function rA({handleWidth:n=5,cellMinWidth:e=25,View:t=nA,lastColumnResizable:r=!0}={}){return new ge({key:At,state:{init(i,s){return this.spec.props.nodeViews[Ve(s.schema).table.name]=(l,a)=>new t(l,e,a),new ii(-1,!1)},apply(i,s){return s.apply(i)}},props:{attributes(i){return At.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,s){oA(i,s,n,e,r)},mouseleave(i){iA(i)},mousedown(i,s){sA(i,s,e)}},decorations(i){let s=At.getState(i);if(s.activeHandle>-1)return fA(i,s.activeHandle)},nodeViews:{}}})}class ii{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(At);if(r&&r.setHandle!=null)return new ii(r.setHandle,null);if(r&&r.setDragging!==void 0)return new ii(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);Dc(e.doc.resolve(o))||(o=null),t=new ii(o,t.dragging)}return t}}function oA(n,e,t,r,o){let i=At.getState(n.state);if(!i.dragging){let s=aA(e.target),l=-1;if(s){let{left:a,right:c}=s.getBoundingClientRect();e.clientX-a<=t?l=_m(n,e,"left"):c-e.clientX<=t&&(l=_m(n,e,"right"))}if(l!=i.activeHandle){if(!o&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=we.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}qm(n,l)}}}function iA(n){let e=At.getState(n.state);e.activeHandle>-1&&!e.dragging&&qm(n,-1)}function sA(n,e,t){let r=At.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let o=n.state.doc.nodeAt(r.activeHandle),i=lA(n,r.activeHandle,o.attrs);n.dispatch(n.state.tr.setMeta(At,{setDragging:{startX:e.clientX,startWidth:i}}));function s(a){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",l);let c=At.getState(n.state);c.dragging&&(cA(n,c.activeHandle,Wm(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(At,{setDragging:null})))}function l(a){if(!a.which)return s(a);let c=At.getState(n.state),u=Wm(c.dragging,a,t);uA(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",s),window.addEventListener("mousemove",l),e.preventDefault(),!0}function lA(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function aA(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function _m(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:o}=r,i=lo(n.state.doc.resolve(o));if(!i)return-1;if(t=="right")return i.pos;let s=we.get(i.node(-1)),l=i.start(-1),a=s.map.indexOf(i.pos-l);return a%s.width==0?-1:l+s.map[a-1]}function Wm(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function qm(n,e){n.dispatch(n.state.tr.setMeta(At,{setHandle:e}))}function cA(n,e,t){let r=n.state.doc.resolve(e),o=r.node(-1),i=we.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],{attrs:f}=o.nodeAt(d),h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():dA(f.colspan);p[h]=t,a.setNodeMarkup(s+d,null,Pe(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function uA(n,e,t,r){let o=n.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=we.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=n.domAtPos(o.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;Fc(i,a.firstChild,a,r,l,t)}function dA(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function fA(n,e){let t=[],r=n.doc.resolve(e),o=r.node(-1),i=we.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan;for(let a=0;a<i.height;a++){let c=l+a*i.width-1;if((l==i.width||i.map[c]!=i.map[c+1])&&(a==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],d=s+u+o.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push($e.widget(d,f))}}return me.create(n.doc,t)}function hA({allowTableNodeSelection:n=!1}={}){return new ge({key:Wn,state:{init(){return null},apply(e,t){let r=e.getMeta(Wn);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:AE,handleDOMEvents:{mousedown:$E},createSelectionBetween(e){if(Wn.getState(e.state)!=null)return e.state.selection},handleTripleClick:IE,handleKeyDown:RE,handlePaste:FE},appendTransaction(e,t,r){return OE(r,Im(r,t),n)}})}function Um(n,e,t,r,o,i){var u;let s=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m+=1,f+=1){const g=o===f?i:p&&p[m],y=g?`${g}px`:"";s+=g||r,g||(l=!1),a?(a.style.width!==y&&(a.style.width=y),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${s}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${s}px`)}class pA{constructor(e,t){bn(this,"node");bn(this,"cellMinWidth");bn(this,"dom");bn(this,"table");bn(this,"colgroup");bn(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Um(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Um(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Km(n,e){return n.createAndFill()}function mA(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function gA(n,e,t,r,o){const i=mA(n),s=[],l=[];for(let c=0;c<t;c+=1){const u=Km(i.cell);if(u&&l.push(u),r){const d=Km(i.header_cell);d&&s.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function yA(n){return n instanceof ne}const ll=({editor:n})=>{const{selection:e}=n.state;if(!yA(e))return!1;let t=0;const r=ua(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},vA=pe.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:pA,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(s=>{s?t+=s:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const s=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*s}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",ee(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const{selection:s}=r,l=gA(i.schema,n,e,t);if(o){const a=r.selection.anchor+1;r.replaceRangeWith(s.from-1,s.to,l).scrollIntoView().setSelection(K.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>jE(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>zE(n,e),deleteColumn:()=>({state:n,dispatch:e})=>_E(n,e),addRowBefore:()=>({state:n,dispatch:e})=>qE(n,e),addRowAfter:()=>({state:n,dispatch:e})=>UE(n,e),deleteRow:()=>({state:n,dispatch:e})=>JE(n,e),deleteTable:()=>({state:n,dispatch:e})=>tA(n,e),mergeCells:()=>({state:n,dispatch:e})=>Hm(n,e),splitCell:()=>({state:n,dispatch:e})=>jm(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>oi("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>oi("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>QE(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Hm(n,e)?!0:jm(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>YE(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Vm(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Vm(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Im(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ne.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ll,"Mod-Backspace":ll,Delete:ll,"Mod-Delete":ll}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[rA({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],hA({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:X(V(n,"tableRole",e))}}});function Jm(n,e){if(n==null)return{};var t={},r=Object.keys(n),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(t[o]=n[o]);return t}var Zm=typeof window<"u"&&typeof document<"u";function $c(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Gm(){return Zm&&document.createElement("div")}function bA(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function Ym(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!Ym(n[t],e[t]))return!1}else return!1;return!0}else return!1}function wA(n){var e=[];return n.forEach(function(t){e.find(function(r){return Ym(t,r)})||e.push(t)}),e}function xA(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:wA([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Bc=Zm?b.useLayoutEffect:b.useEffect;function kA(n){var e=b.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Xm(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var CA={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function o(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Xm(t,"add",e.props.className)}function i(){r()&&Xm(t,"remove",e.props.className)}return{onCreate:o,onBeforeUpdate:i,onAfterUpdate:o}}};function SA(n){function e(t){var r=t.children,o=t.content,i=t.visible,s=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=Jm(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,m=s!==void 0,g=b.useState(!1),y=g[0],k=g[1],C=b.useState({}),v=C[0],E=C[1],S=b.useState(),O=S[0],D=S[1],A=kA(function(){return{container:Gm(),renders:1}}),P=Object.assign({ignoreAttributes:f},h,{content:A.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(R){P[R]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+R+"` prop in","controlled mode (`visible` prop)"].join(" "))}),P.trigger="manual",P.hideOnClick=!1),m&&(u=!0);var H=P,N=P.plugins||[];l&&(H=Object.assign({},P,{plugins:m&&s.data!=null?[].concat(N,[{fn:function(){return{onTrigger:function(U,z){var G=s.data.children.find(function(se){var le=se.instance;return le.reference===z.currentTarget});U.state.$$activeSingletonInstance=G.instance,D(G.content)}}}}]):N,render:function(){return{popper:A.container}}}));var $=[a].concat(r?[r.type]:[]);return Bc(function(){var R=a;a&&a.hasOwnProperty("current")&&(R=a.current);var I=n(R||A.ref||Gm(),Object.assign({},H,{plugins:[CA].concat(P.plugins||[])}));return A.instance=I,u&&I.disable(),i&&I.show(),m&&s.hook({instance:I,content:o,props:H,setSingletonContent:D}),k(!0),function(){I.destroy(),s==null||s.cleanup(I)}},$),Bc(function(){var R;if(A.renders===1){A.renders++;return}var I=A.instance;I.setProps(xA(I.props,H)),(R=I.popperInstance)==null||R.forceUpdate(),u?I.disable():I.enable(),p&&(i?I.show():I.hide()),m&&s.hook({instance:I,content:o,props:H,setSingletonContent:D})}),Bc(function(){var R;if(l){var I=A.instance;I.setProps({popperOptions:Object.assign({},I.props.popperOptions,{modifiers:[].concat((((R=I.props.popperOptions)==null?void 0:R.modifiers)||[]).filter(function(U){var z=U.name;return z!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(z){var G,se=z.state,le=(G=se.modifiersData)==null?void 0:G.hide;(v.placement!==se.placement||v.referenceHidden!==(le==null?void 0:le.isReferenceHidden)||v.escaped!==(le==null?void 0:le.hasPopperEscaped))&&E({placement:se.placement,referenceHidden:le==null?void 0:le.isReferenceHidden,escaped:le==null?void 0:le.hasPopperEscaped}),se.attributes.popper={}}}])})})}},[v.placement,v.referenceHidden,v.escaped].concat($)),b.createElement(b.Fragment,null,r?b.cloneElement(r,{ref:function(I){A.ref=I,$c(r.ref,I)}}):null,y&&vt.createPortal(l?l(bA(v),O,A.instance):o,A.container))}return e}var EA=function(n,e){return b.forwardRef(function(r,o){var i=r.children,s=Jm(r,["children"]);return b.createElement(n,Object.assign({},e,s),i?b.cloneElement(i,{ref:function(a){$c(o,a),$c(i.ref,a)}}):null)})},AA=EA(SA(ar));const TA=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Qm=({node:n,getPos:e,selected:t,editor:r})=>{const[o,i]=b.useState(!1),s=$s(),l=b.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;i(f<=u&&d<=h)};b.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return w.jsxs(Ko,{className:"group",children:[w.jsx(yh,{as:"span"}),(o||t)&&w.jsx(AA,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:w.jsx("article",{className:"dropdown",contentEditable:!1,children:w.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:TA.map(u=>w.jsx("li",{children:w.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[w.jsx("span",{children:u.icon}),w.jsx("span",{children:u.name})]})},u.name))})}),children:w.jsx("label",{tabIndex:0,className:fe("trigger-button",{hidden:s}),contentEditable:!1,children:w.jsx(_x,{fontSize:"small"})})})]})},MA=pe.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return cr(Qm,{as:"td",className:"relative"})}}),OA=pe.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return cr(Qm,{as:"th",className:"relative"})}}),eg=n=>(n.stopPropagation(),n.preventDefault(),n),NA=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},tg=function(n){return!n||n===document.body?document.body:NA(n)?n:tg(n.parentNode)},Hc=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([o,i])=>r.setAttribute(o,i)),t&&Object.entries(t).forEach(([o,i])=>r.addEventListener(o,i)),r},DA=pe.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),o=tg(n.options.element);let i=!1;const s={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const y=r(),k=n.state.doc.resolve(y),C=new W(k);n.view.dispatch(n.state.tr.setSelection(C))}},l=()=>{i=!0},a=()=>{i=!1},c=Hc("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:y=>{y&&eg(y),s.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=Hc("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:y=>{y&&eg(y),s.deleteRow()}}),d=()=>{m(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Hc("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const m=()=>{setTimeout(()=>{const y=h.getBoundingClientRect(),k=JSON.stringify(y);p!==k&&(c.style.top=`${y.top+document.documentElement.scrollTop}px`,c.style.left=`${y.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${y.height+1}px`,p=k)})};return setTimeout(()=>{m()},100),n.on("selectionUpdate",m),n.on("update",m),o==null||o.addEventListener("scroll",m),document.addEventListener("scroll",m),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",m),n.off("update",m),o==null||o.removeEventListener("scroll",m),document.removeEventListener("scroll",m)}}}}}),LA=[vA.configure({resizable:!0}),MA,OA,DA],PA=xh.extend({content:"(dBlock|columns)+"});function ng({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const RA=ve.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ce(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new ge({key:n,appendTransaction:(t,r,o)=>{const{doc:i,tr:s,schema:l}=o,a=n.getState(o),c=i.content.size,u=l.nodes[this.options.node];if(a)return s.insert(c,u.create())},state:{init:(t,r)=>{const o=r.tr.doc.lastChild;return!ng({node:o,types:e})},apply:(t,r)=>{var i,s,l;if(!t.docChanged)return r;const o=(l=(s=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:s.content)==null?void 0:l[0];return!ng({node:o,types:e})}}})]}}),IA=({node:n,editor:e,getPos:t})=>{const[r,o]=b.useState(""),i=$s(),s=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return w.jsx(ip,{});case"iframe":return w.jsx(sp,{});default:return w.jsx(Qx,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const C=r.match(/src="([^"]*)"/);C&&C.length>0&&(p=C[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://www.youtube.com/embed/${C[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://player.vimeo.com/video/${C[1]}`);break}default:{alert("Please enter a valid url");return}}const m=640,g=360,y=t(),k=y+n.nodeSize;p&&(e==null||e.chain().focus(y).deleteRange({from:y,to:k}).setIframe({src:p,width:m,height:g}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const m=s.some(v=>r.includes(v)),g=r.match(/\/status\/([0-9]*)/),y=g&&g.length>0;if(m&&y)p=g[1];else{alert("invalid url");return}const k=t(),C=k+n.nodeSize;p&&(e==null||e.chain().focus(k).deleteRange({from:k,to:C}).setTweetEmbed({tweetId:p}).run())},f=xp(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);b.useEffect(()=>{r&&f()},[r]),b.useEffect(()=>{e==null||e.chain().focus()},[]);const h=b.useRef(null);return b.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),w.jsx(Ko,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&w.jsxs("div",{className:"relative w-full",children:[w.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),w.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>o(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},FA=pe.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return cr(IA)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",ee(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),$A=[tx,Qw.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),nx.configure({types:["heading","paragraph"]}),dk,Ex.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),Ax.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),Ox.configure({multicolor:!0}),uk,Px.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),ex,gk,Nx.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),Lx.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),kh.configure({width:3,color:"#d1d5db"}),Ch,yE,RA,PA,...LA,Tk.configure({uploadFn:ok}),mk,bk,Ck,FA.extend({addInputRules(){return[rg(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),rg(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),pk],rg=(n,e,t)=>new Ro({find:n,handler:({state:r,range:o,commands:i})=>{const s={data:e},{tr:l}=r,a=o.from,c=o.to;l.insert(a-1,t.create(s)).delete(l.mapping.map(a),l.mapping.map(c)),i.focus(c-1)}}),og="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M272-200v-560h221q65%200%20120%2040t55%20111q0%2051-23%2078.5T602-491q25%2011%2055.5%2041t30.5%2090q0%2089-65%20124.5T501-200H272Zm121-112h104q48%200%2058.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33%200%2048-17t15-38q0-24-17-39t-44-15h-95v109Z'/%3e%3c/svg%3e",ig="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z'/%3e%3c/svg%3e",sg="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-120v-80h560v80H200Zm280-160q-101%200-157-63t-56-167v-330h103v336q0%2056%2028%2091t82%2035q54%200%2082-35t28-91v-336h103v330q0%20104-56%20167t-157%2063Z'/%3e%3c/svg%3e",lg="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2584'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2584)'%3e%3cpath%20d='M8%2018L2%2012L8%206L9.425%207.425L4.825%2012.025L9.4%2016.6L8%2018ZM16%2018L14.575%2016.575L19.175%2011.975L14.6%207.4L16%206L22%2012L16%2018Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",ag="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M486-160q-76%200-135-45t-85-123l88-38q14%2048%2048.5%2079t85.5%2031q42%200%2076-20t34-64q0-18-7-33t-19-27h112q5%2014%207.5%2028.5T694-340q0%2086-61.5%20133T486-160ZM80-480v-80h800v80H80Zm402-326q66%200%20115.5%2032.5T674-674l-88%2039q-9-29-33.5-52T484-710q-41%200-68%2018.5T386-640h-96q2-69%2054.5-117.5T482-806Z'/%3e%3c/svg%3e",cg="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2557'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2557)'%3e%3cpath%20d='M11%2017H7C5.61667%2017%204.4375%2016.5125%203.4625%2015.5375C2.4875%2014.5625%202%2013.3833%202%2012C2%2010.6167%202.4875%209.4375%203.4625%208.4625C4.4375%207.4875%205.61667%207%207%207H11V9H7C6.16667%209%205.45833%209.29167%204.875%209.875C4.29167%2010.4583%204%2011.1667%204%2012C4%2012.8333%204.29167%2013.5417%204.875%2014.125C5.45833%2014.7083%206.16667%2015%207%2015H11V17ZM8%2013V11H16V13H8ZM13%2017V15H17C17.8333%2015%2018.5417%2014.7083%2019.125%2014.125C19.7083%2013.5417%2020%2012.8333%2020%2012C20%2011.1667%2019.7083%2010.4583%2019.125%209.875C18.5417%209.29167%2017.8333%209%2017%209H13V7H17C18.3833%207%2019.5625%207.4875%2020.5375%208.4625C21.5125%209.4375%2022%2010.6167%2022%2012C22%2013.3833%2021.5125%2014.5625%2020.5375%2015.5375C19.5625%2016.5125%2018.3833%2017%2017%2017H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",BA=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:op,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:Qh,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:ep,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:tp,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:np,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:rc,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:rc,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:rp,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:Yh,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],o=r.filter(i=>i.isActive()).pop()??{name:"Multiple"};return w.jsxs("div",{className:"relative h-full",children:[w.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[w.jsx("span",{children:o==null?void 0:o.name}),w.jsx(nc,{className:"h-4 w-4"})]}),e&&w.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((i,s)=>w.jsxs("button",{onClick:()=>{i.command(),t(!1)},className:fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":i.isActive()}),children:[w.jsxs("div",{className:"flex items-center space-x-2",children:[w.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:w.jsx(i.icon,{className:"h-3 w-3"})}),w.jsx("span",{children:i.name})]}),o.name===i.name&&w.jsx(Ls,{className:"h-4 w-4"})]},s))})]})},HA=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],o=r.find(({color:i})=>n.isActive("textStyle",{color:i}));return w.jsxs("div",{className:"",children:[w.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[w.jsx("span",{style:{color:(o==null?void 0:o.color)||"#000000"},children:"A"}),w.jsx(nc,{className:"h-4 w-4 "})]}),e&&w.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:i,color:s},l)=>w.jsxs("button",{onClick:()=>{n.chain().focus().setColor(s).run(),t(!1)},className:fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:s})}),children:[w.jsxs("div",{className:"flex items-center space-x-2",children:[w.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:s},children:"A"}),w.jsx("span",{children:i})]}),n.isActive("textStyle",{color:s})&&w.jsx(Ls,{className:"h-4 w-4"})]},l))})]})};var oe=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(oe||{});function jA(n){const[e,t]=b.useState(n),r=b.useRef(null),o=i=>{r&&r.current&&!r.current.contains(i.target)&&t(0)};return b.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const zA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_446'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_446)'%3e%3cpath%20d='M5.55%2019L2%2015.45L3.4%2014.05L5.525%2016.175L9.775%2011.925L11.175%2013.35L5.55%2019ZM5.55%2011L2%207.45005L3.4%206.05005L5.525%208.17505L9.775%203.92505L11.175%205.35005L5.55%2011ZM13%2017V15H22V17H13ZM13%209.00005V7.00005H22V9.00005H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",VA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2594'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2594)'%3e%3cpath%20d='M3.9751%2017L7.7251%207H9.5251L13.2751%2017H11.5501L10.6501%2014.45H6.6001L5.7001%2017H3.9751ZM7.1251%2013H10.1251L8.6751%208.85H8.5751L7.1251%2013ZM16.3501%2017.275C15.5334%2017.275%2014.8918%2017.0625%2014.4251%2016.6375C13.9584%2016.2125%2013.7251%2015.6333%2013.7251%2014.9C13.7251%2014.2%2013.9959%2013.6292%2014.5376%2013.1875C15.0793%2012.7458%2015.7751%2012.525%2016.6251%2012.525C17.0084%2012.525%2017.3626%2012.5542%2017.6876%2012.6125C18.0126%2012.6708%2018.2918%2012.7667%2018.5251%2012.9V12.55C18.5251%2012.1%2018.3709%2011.7417%2018.0626%2011.475C17.7543%2011.2083%2017.3334%2011.075%2016.8001%2011.075C16.4501%2011.075%2016.1209%2011.15%2015.8126%2011.3C15.5043%2011.45%2015.2418%2011.6667%2015.0251%2011.95L13.9501%2011.15C14.2668%2010.7%2014.6668%2010.3583%2015.1501%2010.125C15.6334%209.89167%2016.1918%209.775%2016.8251%209.775C17.8584%209.775%2018.6501%2010.0208%2019.2001%2010.5125C19.7501%2011.0042%2020.0251%2011.7167%2020.0251%2012.65V17.05H18.5501V16.2H18.4751C18.2584%2016.5333%2017.9668%2016.7958%2017.6001%2016.9875C17.2334%2017.1792%2016.8168%2017.275%2016.3501%2017.275ZM16.6001%2016.025C17.1334%2016.025%2017.5876%2015.8375%2017.9626%2015.4625C18.3376%2015.0875%2018.5251%2014.6333%2018.5251%2014.1C18.2918%2013.9667%2018.0251%2013.8667%2017.7251%2013.8C17.4251%2013.7333%2017.1501%2013.7%2016.9001%2013.7C16.3668%2013.7%2015.9584%2013.8042%2015.6751%2014.0125C15.3918%2014.2208%2015.2501%2014.5167%2015.2501%2014.9C15.2501%2015.2333%2015.3751%2015.5042%2015.6251%2015.7125C15.8751%2015.9208%2016.2001%2016.025%2016.6001%2016.025Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",ug="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2572'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2572)'%3e%3cpath%20d='M9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9ZM5%2020C4.45%2020%203.97917%2019.8042%203.5875%2019.4125C3.19583%2019.0208%203%2018.55%203%2018C3%2017.45%203.19583%2016.9792%203.5875%2016.5875C3.97917%2016.1958%204.45%2016%205%2016C5.55%2016%206.02083%2016.1958%206.4125%2016.5875C6.80417%2016.9792%207%2017.45%207%2018C7%2018.55%206.80417%2019.0208%206.4125%2019.4125C6.02083%2019.8042%205.55%2020%205%2020ZM5%2014C4.45%2014%203.97917%2013.8042%203.5875%2013.4125C3.19583%2013.0208%203%2012.55%203%2012C3%2011.45%203.19583%2010.9792%203.5875%2010.5875C3.97917%2010.1958%204.45%2010%205%2010C5.55%2010%206.02083%2010.1958%206.4125%2010.5875C6.80417%2010.9792%207%2011.45%207%2012C7%2012.55%206.80417%2013.0208%206.4125%2013.4125C6.02083%2013.8042%205.55%2014%205%2014ZM5%208C4.45%208%203.97917%207.80417%203.5875%207.4125C3.19583%207.02083%203%206.55%203%206C3%205.45%203.19583%204.97917%203.5875%204.5875C3.97917%204.19583%204.45%204%205%204C5.55%204%206.02083%204.19583%206.4125%204.5875C6.80417%204.97917%207%205.45%207%206C7%206.55%206.80417%207.02083%206.4125%207.4125C6.02083%207.80417%205.55%208%205%208Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",_A="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_458'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_458)'%3e%3cpath%20d='M3%2022V20.5H5.5V19.75H4V18.25H5.5V17.5H3V16H6C6.28333%2016%206.52083%2016.0958%206.7125%2016.2875C6.90417%2016.4792%207%2016.7167%207%2017V18C7%2018.2833%206.90417%2018.5208%206.7125%2018.7125C6.52083%2018.9042%206.28333%2019%206%2019C6.28333%2019%206.52083%2019.0958%206.7125%2019.2875C6.90417%2019.4792%207%2019.7167%207%2020V21C7%2021.2833%206.90417%2021.5208%206.7125%2021.7125C6.52083%2021.9042%206.28333%2022%206%2022H3ZM3%2015V12.25C3%2011.9667%203.09583%2011.7292%203.2875%2011.5375C3.47917%2011.3458%203.71667%2011.25%204%2011.25H5.5V10.5H3V9H6C6.28333%209%206.52083%209.09583%206.7125%209.2875C6.90417%209.47917%207%209.71667%207%2010V11.75C7%2012.0333%206.90417%2012.2708%206.7125%2012.4625C6.52083%2012.6542%206.28333%2012.75%206%2012.75H4.5V13.5H7V15H3ZM4.5%208V3.5H3V2H6V8H4.5ZM9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",WA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2560'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2560)'%3e%3cpath%20d='M5%2019V17H19V19H5ZM6.9%2015L11%204H13L17.1%2015H15.2L14.25%2012.2H9.8L8.8%2015H6.9ZM10.35%2010.6H13.65L12.05%206.05H11.95L10.35%2010.6Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",qA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='m228-240%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T458-480L320-240h-92Zm360%200%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T818-480L680-240h-92ZM320-500q25%200%2042.5-17.5T380-560q0-25-17.5-42.5T320-620q-25%200-42.5%2017.5T260-560q0%2025%2017.5%2042.5T320-500Zm360%200q25%200%2042.5-17.5T740-560q0-25-17.5-42.5T680-620q-25%200-42.5%2017.5T620-560q0%2025%2017.5%2042.5T680-500Zm0-60Zm-360%200Z'/%3e%3c/svg%3e",UA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-280v-400h80v160h160v-160h80v400h-80v-160H280v160h-80Zm480%200v-320h-80v-80h160v400h-80Z'/%3e%3c/svg%3e",KA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-160q0-33%2023.5-56.5T600-520h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v80q0%2033-23.5%2056.5T760-440H600v80h240v80H520Z'/%3e%3c/svg%3e",JA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-80h240v-80H600v-80h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v240q0%2033-23.5%2056.5T760-280H520Z'/%3e%3c/svg%3e",ZA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M680-360q-17%200-28.5-11.5T640-400v-160q0-17%2011.5-28.5T680-600h120q17%200%2028.5%2011.5T840-560v40h-60v-20h-80v120h80v-20h60v40q0%2017-11.5%2028.5T800-360H680Zm-300%200v-240h160q17%200%2028.5%2011.5T580-560v40q0%2017-11.5%2028.5T540-480q17%200%2028.5%2011.5T580-440v40q0%2017-11.5%2028.5T540-360H380Zm60-150h80v-30h-80v30Zm0%2090h80v-30h-80v30Zm-320%2060v-200q0-17%2011.5-28.5T160-600h120q17%200%2028.5%2011.5T320-560v200h-60v-60h-80v60h-60Zm60-120h80v-60h-80v60Z'/%3e%3c/svg%3e",GA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M544-400%20440-504%20240-304l104%20104%20200-200Zm-47-161%20104%20104%20199-199-104-104-199%20199Zm-84-28%20216%20216-229%20229q-24%2024-56%2024t-56-24l-2-2-26%2026H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0%200%20227-227q24-24%2056-24t56%2024l104%20104q24%2024%2024%2056t-24%2056L629-373%20413-589Z'/%3e%3c/svg%3e",YA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%205v14H5V5h14m0-2H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2zm-4.86%208.86l-3%203.87L9%2013.14L6%2017h12l-3.86-5.14z'/%3e%3c/svg%3e",dg=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=jA(oe.NONE);return{toolbar:[{icon:VA,title:"Font",onClick:()=>r(oe.FONT_FAMILY),isActive:t===oe.FONT_FAMILY},{icon:WA,title:"Text Color",onClick:()=>r(oe.TEXT_COLOR),isActive:t===oe.TEXT_COLOR},{icon:GA,title:"Highlight",onClick:()=>r(oe.HIGHLIGHT),isActive:t===oe.HIGHLIGHT},null,{icon:og,title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:ig,title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:sg,title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:ag,title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:ug,title:"List",onClick:()=>r(oe.LIST),isActive:t===oe.LIST},{icon:oc,title:"Alignment",onClick:()=>r(oe.ALIGNMENT),isActive:t===oe.ALIGNMENT},{icon:qA,title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:YA,title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const i=document.createElement("input");i.type="file",i.accept="image/*",i.onchange=async()=>{var s;if((s=i.files)!=null&&s.length){const l=i.files[0],a=n.view.state.selection.from;lp(l,n.view,a)}},i.click()},isActive:!1},{icon:cg,title:"Link",onClick:()=>r(oe.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:lg,title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},XA=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return w.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[w.jsx(Gh,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(oe.NONE)}}),r.map(o=>w.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:o.color}).run(),e(oe.NONE)},className:`w-6 ${o.code} drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:w.jsx(Ls,{size:14,className:`${n.isActive("highlight",{color:o.color})?"visible":"invisible"}`})},o.color))]})},QA=({elementRef:n,editor:e,setToolVisibility:t})=>{const r=[{title:"Trebuchet MS",command:o=>{o.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",command:o=>{o.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",command:o=>{o.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",command:o=>{o.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",command:o=>{o.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",command:o=>{o.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",command:o=>{o.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",command:o=>{o.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",command:o=>{o.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",command:o=>{o.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",command:o=>{o.chain().focus().setFontFamily("cursive").run()}}];return w.jsx("div",{ref:n,className:fe("z-50 h-auto absolute top-[50px] left-[20%] max-h-[330px] w-48 overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:r.map(o=>w.jsx("button",{onClick:()=>{o.command(e),t(oe.NONE)},style:{fontFamily:o.title},className:`flex w-full ${e.isActive("textStyle",{fontFamily:o.title})?"bg-red-500":""} items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100`,children:w.jsx("p",{className:"font-medium",children:o.title})},o.title))})},eT=({elementRef:n,editor:e,setToolVisibility:t})=>w.jsxs("div",{ref:n,className:fe("z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"left"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:oc,alt:"align left"})}),w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"center"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:pp,alt:"align center"})}),w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"right"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:mp,alt:"align right"})})]}),tT=({elementRef:n,editor:e,setToolVisibility:t})=>w.jsxs("div",{ref:n,className:fe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:ug,alt:"bullet list"})})}),w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:_A,alt:"numbered list"})})}),w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:zA,alt:"checklist"})})})]}),fg=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:o})=>{const[i,s]=b.useState(e.getAttributes("link").href),l=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let a=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(a="https://"+i);try{a.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:a}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:a}).run(),t(oe.NONE),r&&o&&o(!1)};return w.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white p-2 shadow-md transition-all",children:[w.jsx("input",{onChange:a=>s(a.target.value),className:"border-2 focus:border-black px-2 py-1.5 rounded w-full font-medium text-sm",placeholder:"Add link here",value:i}),w.jsx("div",{className:"h-full flex items-center",children:w.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},nT=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return w.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[w.jsx(Gh,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(oe.NONE)}}),r.map(o=>w.jsx("div",{onClick:()=>{n.chain().focus().setColor(o.color).run(),e(oe.NONE)},className:`w-6 ${o.code} drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:w.jsx(Ls,{size:14,className:`${n.isActive("textStyle",{color:o.color})?"visible":"invisible"}`})},o.color))]})},rT=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:ZA,command:o=>o.chain().focus().toggleNode("paragraph","paragraph").run()},{title:"Heading 1",description:"Big",icon:UA,command:o=>{o.chain().focus().toggleHeading({level:1}).run()}},{title:"Heading 2",description:"Medium",icon:KA,command:o=>{o.chain().focus().toggleHeading({level:2}).run()}},{title:"Heading 3",description:"Small",icon:JA,command:o=>{o.chain().focus().toggleHeading({level:3}).run()}}];return w.jsx("section",{ref:t,className:fe(" absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(o=>w.jsxs("button",{onClick:()=>{o.command(n),e(oe.NONE)},className:"flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100",children:[w.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-stone-200 bg-white",children:w.jsx("img",{src:o.icon,alt:o.title})}),w.jsxs("div",{children:[w.jsx("p",{className:"font-medium",children:o.title}),w.jsxs("p",{className:"text-xs text-stone-500",children:[" ",o.description," "]})]})]},o.title))})},oT=n=>{const e=[{name:"bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:og},{name:"italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:ig},{name:"underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:sg},{name:"strike",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:ag},{name:"codeBlock",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:lg},{name:"link",isActive:()=>n.editor.isActive("link"),command:()=>a(!l),icon:cg}],t={...n,shouldShow:({state:d,editor:f})=>{const{selection:h}=d,{empty:p}=h;return!(f.isActive("image")||p||Cf(h))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{o(!1),s(!1),a(!1)}}},[r,o]=b.useState(!1),[i,s]=b.useState(!1),[l,a]=b.useState(!1),{toolRef:c,setToolVisibility:u}=dg({editor:n.editor});return w.jsxs(ph,{...t,className:"flex gap-1 overflow-hidden rounded border border-stone-200 bg-white shadow-xl",children:[w.jsx(BA,{editor:n.editor,isOpen:r,setIsOpen:()=>{o(!r),s(!1)}}),e.map((d,f)=>w.jsx("button",{onClick:d.command,className:" py-2 text-stone-600 hover:bg-stone-100 active:bg-stone-200",children:w.jsx("img",{src:d.icon,className:fe(" p-1 rounded-lg h-6 w-6",{"bg-yellow-300":d.isActive()})})},f)),w.jsx(HA,{editor:n.editor,isOpen:i,setIsOpen:()=>{s(!i),o(!1)}}),l&&w.jsx(fg,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a})]})},iT={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}};function sT(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var lT=sT;const aT=Jc(lT),cT=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,o=document.querySelectorAll(".has-focus"),i=o.length,l=o[i-1];if(l&&l.getAttribute("data-type")&&l.getAttribute("data-type")===e||l&&l.classList&&l.classList.contains(e))return l;const a=t.domAtPos(r).node;let c=a;for(c.tagName||(c=a.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},uT=({editor:n,appendTo:e})=>{const t=b.useCallback(()=>{const l=cT(n,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=b.useCallback(()=>n.isActive("columns"),[n]),o=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignLeft).run()},[n]),i=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignRight).run()},[n]),s=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignCenter).run()},[n]);return w.jsx(ph,{editor:n,pluginKey:`columnsMenu-${aT()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[q2],sticky:"popper"},children:w.jsxs(ri.Wrapper,{children:[w.jsx(ri.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:fr.AlignLeft}),onClick:o,children:w.jsx(Jx,{size:20})}),w.jsx(ri.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:fr.AlignCenter}),onClick:s,children:w.jsx(Xh,{size:20})}),w.jsx(ri.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:fr.AlignRight}),onClick:i,children:w.jsx(Zx,{size:20})})]})})},dT=({editor:n})=>{const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:o}=dg({editor:n});return w.jsxs("div",{className:"w-fit bg-transparent px-4 items-center rounded-lg h-16 flex gap-1 justify-center",children:[w.jsxs("button",{className:"hover:bg-[#f2f2f2] border gap-2 rounded-lg w-28 h-8 p-1 flex justify-center items-center",onClick:()=>r(oe.HEADING),children:[w.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),w.jsx(nc,{className:"h-4 w-4"})]}),o.map((i,s)=>i?w.jsx("div",{className:"tooltip tooltip-bottom","data-tip":i.title,children:w.jsx("span",{onClick:()=>i.onClick(),className:fe("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",i.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof i.icon=="string"?w.jsx("img",{src:i.icon,className:"w-4"}):i.icon})},i.title):w.jsx("div",{className:" w-[1px] h-[50%] bg-[#777777]"},s)),t===oe.HEADING&&w.jsx(rT,{setVisibility:r,editor:n,elementRef:e}),t===oe.TEXT_COLOR&&w.jsx(nT,{setVisibility:r,editor:n,elementRef:e}),t===oe.HIGHLIGHT&&w.jsx(XA,{setVisibility:r,editor:n,elementRef:e}),t===oe.FONT_FAMILY&&w.jsx(QA,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.ALIGNMENT&&w.jsx(eT,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.LIST&&w.jsx(tT,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.LINK&&w.jsx(fg,{setToolVisibility:r,editor:n,elementRef:e})]})},fT=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r})=>{const[o,i]=b.useState({cover:{image:null,emoji:null,name:null},plugin:{title:null}}),s=Q2({extensions:[...$A],editorProps:iT,autofocus:"start"}),l=b.useRef(null),a=c=>{var u;(u=l.current)!=null&&u.contains(c.target)||s==null||s.chain().focus().run()};return b.useEffect(()=>{s==null||s.chain().focus()},[]),b.useEffect(()=>{s==null||s.setEditable(!n)},[n]),b.useEffect(()=>{t&&s&&(s==null||s.commands.setContent(t))},[t,s]),s?w.jsx("div",{"data-cy":"single-webpage",className:"h-screen w-screen bg-[#f9fbfd]",children:w.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:w.jsxs("div",{className:"w-full h-screen",children:[w.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:w.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[w.jsx("div",{className:"grow",children:w.jsx(wg,{metaData:o,setMetaData:i})}),!n&&w.jsx("div",{className:"grow relative",children:w.jsx(dT,{editor:s})}),w.jsx("div",{children:w.jsx(tl,{onClick:()=>r(n),children:n?"Edit":"Preview"})}),e&&w.jsx("div",{onClick:()=>e({metaData:o,editorJSONData:s.getJSON()}),className:"cursor-pointer",children:w.jsx(tl,{children:"Publish"})})]})}),w.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:w.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:w.jsx("div",{className:"p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-[70%] max-w-[856px]",children:w.jsxs("div",{ref:l,className:"w-full pt-4 h-full",children:[!n&&w.jsxs("div",{children:[w.jsx(oT,{editor:s}),w.jsx(uT,{editor:s,appendTo:l})]}),w.jsx(vk,{isPreviewMode:n,children:w.jsx(Y2,{editor:s})})]})})})})]})})}):w.jsxs("div",{className:" w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[w.jsx(wp,{}),w.jsx("p",{children:"Loading Editor..."})]})};et.DdocEditor=fT,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})});
356
+ `).focus(s+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:s},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let Oc,Nc;if(typeof WeakMap<"u"){let n=new WeakMap;Oc=e=>n.get(e),Nc=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;Oc=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Nc=(r,o)=>(t==e&&(t=0),n[t++]=r,n[t++]=o)}class so{constructor(e,t,r,o){this.left=e,this.top=t,this.right=r,this.bottom=o}}class we{constructor(e,t,r,o){this.width=e,this.height=t,this.map=r,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let o=t%this.width,i=t/this.width|0,s=o+1,l=i+1;for(let a=1;s<this.width&&this.map[t+a]==r;a++)s++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new so(o,i,s,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:o,right:i,top:s,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?o==0:i==this.width)?null:this.map[s*this.width+(r<0?o-1:i)]:(r<0?s==0:l==this.height)?null:this.map[o+this.width*(r<0?s-1:l)]}rectBetween(e,t){let{left:r,right:o,top:i,bottom:s}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new so(Math.min(r,l),Math.min(i,c),Math.max(o,a),Math.max(s,u))}cellsInRect(e){let t=[],r={};for(let o=e.top;o<e.bottom;o++)for(let i=e.left;i<e.right;i++){let s=o*this.width+i,l=this.map[s];r[l]||(r[l]=!0,(i!=e.left||!i||this.map[s-1]!=l)&&(o!=e.top||!o||this.map[s-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let o=0,i=0;;o++){let s=i+r.child(o).nodeSize;if(o==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<i;)l++;return l==a?s-1:this.map[l]}i=s}}static get(e){return Oc(e)||Nc(e,vE(e))}}function vE(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=bE(n),t=n.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:k}=m.attrs;for(let C=0;C<y;C++){if(C+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-C});break}let v=o+C*e;for(let E=0;E<g;E++){r[v+E]==0?r[v+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-E});let S=k&&k[E];if(S){let O=(v+E)%e*2,D=s[O];D==null||D!=S&&s[O+1]==1?(s[O]=S,s[O+1]=1):D==S&&s[O+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let l=new we(e,t,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&wE(l,s,n),l}function bE(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let o=n.child(r),i=0;if(t)for(let s=0;s<r;s++){let l=n.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function wE(n,e,t){n.problems||(n.problems=[]);for(let r=0,o={};r<n.map.length;r++){let i=n.map[r];if(o[i])continue;o[i]=!0;let s=t.nodeAt(i),l=null;for(let a=0;a<s.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!s.attrs.colwidth||s.attrs.colwidth[a]!=u)&&((l||(l=xE(s.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function xE(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ve(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const Wn=new Ce("selectingCells");function lo(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function kE(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Pt(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function nl(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:lo(e.$head)||CE(e.$head)}function CE(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Dc(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function SE(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Lc(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Tm(n,e,t){let r=n.start(-1),i=we.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function Pe(n,e,t){let r={};for(let o in n)r[o]=n[o];return r[e]=t,r}function gr(n,e,t=1){let r=Pe(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Mm(n,e,t=1){let r=Pe(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function EE(n,e,t){let r=Ve(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}class ne extends J{constructor(e,t=e){let r=e.node(-1),o=we.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);let c=a.map(u=>{let d=r.nodeAt(u),f=u+i+1;return new El(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Dc(r)&&Dc(o)&&Lc(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ne.rowSelection(r,o):i&&this.isColSelection()?ne.colSelection(r,o):new ne(r,o)}return K.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=we.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){let f=t.map[u];if(!i[f]){i[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;m>0&&(y=gr(y,0,m)),g>0&&(y=gr(y,y.colspan-g,g)),h.left<o.left?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y=Pe(p.attrs,"rowspan",Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top));h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}}s.push(e.child(a).copy(M.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new B(M.from(l),1,1)}replace(e,t=B.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?B.empty:t)}let i=J.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new B(M.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=we.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=we.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.top<=s.top?(i.top>0&&(e=l.resolve(o+r.map[i.left])),s.bottom<r.height&&(t=l.resolve(o+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(t=l.resolve(o+r.map[s.left])),i.bottom<r.height&&(e=l.resolve(o+r.map[r.width*(r.height-1)+i.right-1]))),new ne(e,t)}isRowSelection(){let e=we.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),o=e.colCount(this.$headCell.pos-t);if(Math.min(r,o)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof ne&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=we.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.left<=s.left?(i.left>0&&(e=l.resolve(o+r.map[i.top*r.width])),s.right<r.width&&(t=l.resolve(o+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(t=l.resolve(o+r.map[s.top*r.width])),i.right<r.width&&(e=l.resolve(o+r.map[r.width*(i.top+1)-1]))),new ne(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ne(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ne(e.resolve(t),e.resolve(r))}getBookmark(){return new Pc(this.$anchorCell.pos,this.$headCell.pos)}}ne.prototype.visible=!1,J.jsonID("cell",ne);class Pc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pc(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Lc(t,r)?new ne(t,r):J.near(r,1)}}function AE(n){if(!(n.selection instanceof ne))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push($e.node(r,r+t.nodeSize,{class:"selectedCell"}))}),me.create(n.doc,e)}function TE({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function ME({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function OE(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof W&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=ne.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=ne.rowSelection(l,l)}else if(!t){let l=we.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ne.create(o,a+1,c)}}else r instanceof K&&TE(r)?i=K.create(o,r.from):r instanceof K&&ME(r)&&(i=K.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function NE(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let o=e.firstChild,i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Rc(Ve(s).row,new B(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?Rc(Ve(s).row,new B(e,t,r)).content:e);else return null;return DE(s,l)}function DE(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(M.empty),t[o]<r){let i=Ve(n).cell.createAndFill(),s=[];for(let l=t[o];l<r;l++)s.push(i);e[o]=e[o].append(M.from(s))}return{height:e.length,width:r,rows:e}}function Rc(n,e){let t=n.createAndFill();return new Cl(t).replace(0,t.content.size,e).doc}function LE({width:n,height:e,rows:t},r,o){if(n!=r){let i=[],s=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(gr(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(M.from(c))}t=s,n=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create(Pe(d.attrs,"rowspan",Math.max(1,o-d.attrs.rowspan)),d.content)),a.push(d)}i.push(M.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function PE(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=Ve(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,M.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),h)}return!!(c||u)}function Om(n,e,t,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,Pe(f.attrs,"rowspan",s-h)),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),f.type.createAndFill(Pe(f.attrs,"rowspan",h+f.attrs.rowspan-s))),c+=f.attrs.colspan-1}}return a}function Nm(n,e,t,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,gr(f.attrs,s-h,f.attrs.colspan-(s-h))),n.insert(p+f.nodeSize,f.type.createAndFill(gr(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Dm(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc,s=we.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr,f=0;function h(){i=t?d.doc.nodeAt(t-1):d.doc,s=we.get(i),f=d.mapping.maps.length}PE(d,s,i,t,c,u,f)&&h(),Om(d,s,i,t,a,c,l,f)&&h(),Om(d,s,i,t,a,c,u,f)&&h(),Nm(d,s,i,t,l,u,a,f)&&h(),Nm(d,s,i,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new B(o.rows[p-l],0,0))}h(),d.setSelection(new ne(d.doc.resolve(t+s.positionAt(l,a,i)),d.doc.resolve(t+s.positionAt(u-1,c-1,i)))),e(d)}const RE=ea({ArrowLeft:ol("horiz",-1),ArrowRight:ol("horiz",1),ArrowUp:ol("vert",-1),ArrowDown:ol("vert",1),"Shift-ArrowLeft":il("horiz",-1),"Shift-ArrowRight":il("horiz",1),"Shift-ArrowUp":il("vert",-1),"Shift-ArrowDown":il("vert",1),Backspace:sl,"Mod-Backspace":sl,Delete:sl,"Mod-Delete":sl});function rl(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ol(n,e){return(t,r,o)=>{let i=t.selection;if(i instanceof ne)return rl(t,r,J.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=Lm(o,n,e);if(s==null)return!1;if(n=="horiz")return rl(t,r,J.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=Tm(l,n,e),c;return a?c=J.near(a,1):e<0?c=J.near(t.doc.resolve(l.before(-1)),-1):c=J.near(t.doc.resolve(l.after(-1)),1),rl(t,r,c)}}}function il(n,e){return(t,r,o)=>{let i=t.selection;if(!(i instanceof ne)){let l=Lm(o,n,e);if(l==null)return!1;i=new ne(t.doc.resolve(l))}let s=Tm(i.$headCell,n,e);return s?rl(t,r,new ne(i.$anchorCell,s)):!1}}function sl(n,e){let t=n.selection;if(!(t instanceof ne))return!1;if(e){let r=n.tr,o=Ve(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new B(o,0,0))}),r.docChanged&&e(r)}return!0}function IE(n,e){let t=n.state.doc,r=lo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ne(r))),!0):!1}function FE(n,e,t){if(!Pt(n.state))return!1;let r=NE(t),o=n.state.selection;if(o instanceof ne){r||(r={width:1,height:1,rows:[M.from(Rc(Ve(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=we.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=LE(r,l.right-l.left,l.bottom-l.top),Dm(n.state,n.dispatch,s,l,r),!0}else if(r){let i=nl(n.state),s=i.start(-1);return Dm(n.state,n.dispatch,s,we.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function $E(n,e){if(e.ctrlKey||e.metaKey)return;let t=Pm(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof ne)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=lo(n.state.selection.$anchor))!=null&&Ic(n,e).pos!=r.pos)o(r,e),e.preventDefault();else if(!t)return;function o(l,a){let c=Ic(n,a),u=Wn.getState(n.state)==null;if(!c||!Lc(l,c))if(u)c=l;else return;let d=new ne(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Wn,l.pos),n.dispatch(f)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",s),Wn.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Wn,-1))}function s(l){let a=Wn.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Pm(n,l.target)!=t&&(c=Ic(n,e),!c))return i();c&&o(c,l)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",s)}function Lm(n,e,t){if(!(n.state.selection instanceof K))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Pm(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Ic(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?lo(n.state.doc.resolve(t.pos)):null}const BE=new Ce("fix-tables");function Rm(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?Rm(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Im(n,e){let t,r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=HE(n,o,i,t))};return e?e.doc!=n.doc&&Rm(e.doc,n.doc,0,r):n.doc.descendants(r),t}function HE(n,e,t,r){let o=we.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)i[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,gr(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pe(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pe(u.attrs,"colwidth",c.colwidth))}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++)p.push(Ve(n.schema)[h].createAndFill());let m=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(BE,{fixTables:!0})}function Xt(n){let e=n.selection,t=nl(n),r=t.node(-1),o=t.start(-1),i=we.get(r),s;return e instanceof ne?s=i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s=i.findCell(t.pos-o),s.tableStart=o,s.map=i,s.table=r,s}function Fm(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;EE(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Mm(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Ve(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function jE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e(Fm(n.tr,t,t.left))}return!0}function zE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e(Fm(n.tr,t,t.right))}return!0}function VE(n,{map:e,table:t,tableStart:r},o){let i=n.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=t.nodeAt(a);if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,gr(c.attrs,o-e.colCount(a)));else{let u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}s+=c.attrs.rowspan}}function _E(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;VE(r,t,o),o!=t.left;o--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=we.get(t.table);e(r)}return!0}function WE(n,e,t){let r=Ve(e.type.schema).header_cell;for(let o=0;o<n.width;o++)if(e.nodeAt(n.map[o+t*n.width]).type!=r)return!1;return!0}function $m(n,{map:e,tableStart:t,table:r},o){let i=t;for(let a=0;a<o;a++)i+=r.child(a).nodeSize;let s=[],l=o>0?-1:0;WE(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let a=0,c=e.width*o;a<e.width;a++,c++)if(o>0&&o<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,Pe(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Ve(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;s.push(u.createAndFill())}return n.insert(i,Ve(r.type.schema).row.create(null,s)),n}function qE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e($m(n.tr,t,t.top))}return!0}function UE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n);e($m(n.tr,t,t.bottom))}return!0}function KE(n,{map:e,table:t,tableStart:r},o){let i=0;for(let a=0;a<o;a++)i+=t.child(a).nodeSize;let s=i+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(i+r,s+r);for(let a=0,c=o*e.width;a<e.width;a++,c++){let u=e.map[c];if(o>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,Pe(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(o<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(Pe(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(o+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function JE(n,e){if(!Pt(n))return!1;if(e){let t=Xt(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;KE(r,t,o),o!=t.top;o--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=we.get(t.table);e(r)}return!0}function Bm(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function ZE({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,s=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[s]==t[s+n])return!0;o++,s++}return!1}function Hm(n,e){let t=n.selection;if(!(t instanceof ne)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xt(n),{map:o}=r;if(ZE(o,r))return!1;if(e){let i=n.tr,s={},l=M.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!s[f])if(s[f]=!0,a==null)a=f,c=h;else{Bm(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(a+r.tableStart,null,Pe(Mm(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=Bm(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new ne(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function jm(n,e){const t=Ve(n.schema);return GE(({node:r})=>t[r.type.spec.tableRole])(n,e)}function GE(n){return(e,t)=>{let r=e.selection,o,i;if(r instanceof ne){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(o=kE(r.$from),!o)return!1;i=lo(r.$from).pos}if(o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let s=o.attrs,l=[],a=s.colwidth;s.rowspan>1&&(s=Pe(s,"rowspan",1)),s.colspan>1&&(s=Pe(s,"colspan",1));let c=Xt(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?Pe(s,"colwidth",a&&a[f]?[a[f]]:null):s);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=o.nodeSize);for(let p=c.left,m=0;p<c.right;p++,m++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:o,row:f,col:p}).createAndFill(l[m]))}u.setNodeMarkup(i,n({node:o,row:c.top,col:c.left}),l[0]),r instanceof ne&&u.setSelection(new ne(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function YE(n,e){return function(t,r){if(!Pt(t))return!1;let o=nl(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof ne?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,Pe(s.attrs,n,e))}):i.setNodeMarkup(o.pos,null,Pe(o.nodeAfter.attrs,n,e)),r(i)}return!0}}function XE(n){return function(e,t){if(!Pt(e))return!1;if(t){let r=Ve(e.schema),o=Xt(e),i=e.tr,s=o.map.cellsInRect(n=="column"?new so(o.left,0,o.right,o.map.height):n=="row"?new so(0,o.top,o.map.width,o.bottom):o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);t(i)}return!0}}function zm(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function oi(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?XE(n):function(t,r){if(!Pt(t))return!1;if(r){let o=Ve(t.schema),i=Xt(t),s=t.tr,l=zm("row",i,o),a=zm("column",i,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new so(0,u,1,i.map.height):n=="row"?new so(u,0,i.map.width,1):i,f=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(h=>{const p=h+i.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}oi("row",{useDeprecatedLogic:!0}),oi("column",{useDeprecatedLogic:!0});let QE=oi("cell",{useDeprecatedLogic:!0});function eA(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return o-1-i.lastChild.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}}function Vm(n){return function(e,t){if(!Pt(e))return!1;let r=eA(nl(e),n);if(r!=null){if(t){let o=e.doc.resolve(r);t(e.tr.setSelection(K.between(o,SE(o))).scrollIntoView())}return!0}}}function tA(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let nA=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fc(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Fc(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Fc(n,e,t,r,o,i){let s=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let m=o==d?i:h&&h[p],g=m?m+"px":"";s+=m||r,m||(l=!1),a?(a.style.width!=g&&(a.style.width=g),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=g}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}const At=new Ce("tableColumnResizing");function rA({handleWidth:n=5,cellMinWidth:e=25,View:t=nA,lastColumnResizable:r=!0}={}){return new ge({key:At,state:{init(i,s){return this.spec.props.nodeViews[Ve(s.schema).table.name]=(l,a)=>new t(l,e,a),new ii(-1,!1)},apply(i,s){return s.apply(i)}},props:{attributes(i){return At.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,s){oA(i,s,n,e,r)},mouseleave(i){iA(i)},mousedown(i,s){sA(i,s,e)}},decorations(i){let s=At.getState(i);if(s.activeHandle>-1)return fA(i,s.activeHandle)},nodeViews:{}}})}class ii{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(At);if(r&&r.setHandle!=null)return new ii(r.setHandle,null);if(r&&r.setDragging!==void 0)return new ii(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);Dc(e.doc.resolve(o))||(o=null),t=new ii(o,t.dragging)}return t}}function oA(n,e,t,r,o){let i=At.getState(n.state);if(!i.dragging){let s=aA(e.target),l=-1;if(s){let{left:a,right:c}=s.getBoundingClientRect();e.clientX-a<=t?l=_m(n,e,"left"):c-e.clientX<=t&&(l=_m(n,e,"right"))}if(l!=i.activeHandle){if(!o&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=we.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}qm(n,l)}}}function iA(n){let e=At.getState(n.state);e.activeHandle>-1&&!e.dragging&&qm(n,-1)}function sA(n,e,t){let r=At.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let o=n.state.doc.nodeAt(r.activeHandle),i=lA(n,r.activeHandle,o.attrs);n.dispatch(n.state.tr.setMeta(At,{setDragging:{startX:e.clientX,startWidth:i}}));function s(a){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",l);let c=At.getState(n.state);c.dragging&&(cA(n,c.activeHandle,Wm(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(At,{setDragging:null})))}function l(a){if(!a.which)return s(a);let c=At.getState(n.state),u=Wm(c.dragging,a,t);uA(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",s),window.addEventListener("mousemove",l),e.preventDefault(),!0}function lA(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function aA(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function _m(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:o}=r,i=lo(n.state.doc.resolve(o));if(!i)return-1;if(t=="right")return i.pos;let s=we.get(i.node(-1)),l=i.start(-1),a=s.map.indexOf(i.pos-l);return a%s.width==0?-1:l+s.map[a-1]}function Wm(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function qm(n,e){n.dispatch(n.state.tr.setMeta(At,{setHandle:e}))}function cA(n,e,t){let r=n.state.doc.resolve(e),o=r.node(-1),i=we.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],{attrs:f}=o.nodeAt(d),h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():dA(f.colspan);p[h]=t,a.setNodeMarkup(s+d,null,Pe(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function uA(n,e,t,r){let o=n.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=we.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=n.domAtPos(o.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;Fc(i,a.firstChild,a,r,l,t)}function dA(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function fA(n,e){let t=[],r=n.doc.resolve(e),o=r.node(-1),i=we.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan;for(let a=0;a<i.height;a++){let c=l+a*i.width-1;if((l==i.width||i.map[c]!=i.map[c+1])&&(a==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],d=s+u+o.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push($e.widget(d,f))}}return me.create(n.doc,t)}function hA({allowTableNodeSelection:n=!1}={}){return new ge({key:Wn,state:{init(){return null},apply(e,t){let r=e.getMeta(Wn);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:AE,handleDOMEvents:{mousedown:$E},createSelectionBetween(e){if(Wn.getState(e.state)!=null)return e.state.selection},handleTripleClick:IE,handleKeyDown:RE,handlePaste:FE},appendTransaction(e,t,r){return OE(r,Im(r,t),n)}})}function Um(n,e,t,r,o,i){var u;let s=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m+=1,f+=1){const g=o===f?i:p&&p[m],y=g?`${g}px`:"";s+=g||r,g||(l=!1),a?(a.style.width!==y&&(a.style.width=y),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${s}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${s}px`)}class pA{constructor(e,t){bn(this,"node");bn(this,"cellMinWidth");bn(this,"dom");bn(this,"table");bn(this,"colgroup");bn(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Um(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Um(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Km(n,e){return n.createAndFill()}function mA(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function gA(n,e,t,r,o){const i=mA(n),s=[],l=[];for(let c=0;c<t;c+=1){const u=Km(i.cell);if(u&&l.push(u),r){const d=Km(i.header_cell);d&&s.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function yA(n){return n instanceof ne}const ll=({editor:n})=>{const{selection:e}=n.state;if(!yA(e))return!1;let t=0;const r=ua(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},vA=pe.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:pA,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(s=>{s?t+=s:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const s=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*s}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",ee(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const{selection:s}=r,l=gA(i.schema,n,e,t);if(o){const a=r.selection.anchor+1;r.replaceRangeWith(s.from-1,s.to,l).scrollIntoView().setSelection(K.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>jE(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>zE(n,e),deleteColumn:()=>({state:n,dispatch:e})=>_E(n,e),addRowBefore:()=>({state:n,dispatch:e})=>qE(n,e),addRowAfter:()=>({state:n,dispatch:e})=>UE(n,e),deleteRow:()=>({state:n,dispatch:e})=>JE(n,e),deleteTable:()=>({state:n,dispatch:e})=>tA(n,e),mergeCells:()=>({state:n,dispatch:e})=>Hm(n,e),splitCell:()=>({state:n,dispatch:e})=>jm(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>oi("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>oi("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>QE(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Hm(n,e)?!0:jm(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>YE(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Vm(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Vm(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Im(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ne.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ll,"Mod-Backspace":ll,Delete:ll,"Mod-Delete":ll}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[rA({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],hA({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:X(V(n,"tableRole",e))}}});function Jm(n,e){if(n==null)return{};var t={},r=Object.keys(n),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(t[o]=n[o]);return t}var Zm=typeof window<"u"&&typeof document<"u";function $c(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Gm(){return Zm&&document.createElement("div")}function bA(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function Ym(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!Ym(n[t],e[t]))return!1}else return!1;return!0}else return!1}function wA(n){var e=[];return n.forEach(function(t){e.find(function(r){return Ym(t,r)})||e.push(t)}),e}function xA(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:wA([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Bc=Zm?b.useLayoutEffect:b.useEffect;function kA(n){var e=b.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Xm(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var CA={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function o(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Xm(t,"add",e.props.className)}function i(){r()&&Xm(t,"remove",e.props.className)}return{onCreate:o,onBeforeUpdate:i,onAfterUpdate:o}}};function SA(n){function e(t){var r=t.children,o=t.content,i=t.visible,s=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=Jm(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,m=s!==void 0,g=b.useState(!1),y=g[0],k=g[1],C=b.useState({}),v=C[0],E=C[1],S=b.useState(),O=S[0],D=S[1],A=kA(function(){return{container:Gm(),renders:1}}),P=Object.assign({ignoreAttributes:f},h,{content:A.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(R){P[R]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+R+"` prop in","controlled mode (`visible` prop)"].join(" "))}),P.trigger="manual",P.hideOnClick=!1),m&&(u=!0);var H=P,N=P.plugins||[];l&&(H=Object.assign({},P,{plugins:m&&s.data!=null?[].concat(N,[{fn:function(){return{onTrigger:function(U,z){var G=s.data.children.find(function(se){var le=se.instance;return le.reference===z.currentTarget});U.state.$$activeSingletonInstance=G.instance,D(G.content)}}}}]):N,render:function(){return{popper:A.container}}}));var $=[a].concat(r?[r.type]:[]);return Bc(function(){var R=a;a&&a.hasOwnProperty("current")&&(R=a.current);var I=n(R||A.ref||Gm(),Object.assign({},H,{plugins:[CA].concat(P.plugins||[])}));return A.instance=I,u&&I.disable(),i&&I.show(),m&&s.hook({instance:I,content:o,props:H,setSingletonContent:D}),k(!0),function(){I.destroy(),s==null||s.cleanup(I)}},$),Bc(function(){var R;if(A.renders===1){A.renders++;return}var I=A.instance;I.setProps(xA(I.props,H)),(R=I.popperInstance)==null||R.forceUpdate(),u?I.disable():I.enable(),p&&(i?I.show():I.hide()),m&&s.hook({instance:I,content:o,props:H,setSingletonContent:D})}),Bc(function(){var R;if(l){var I=A.instance;I.setProps({popperOptions:Object.assign({},I.props.popperOptions,{modifiers:[].concat((((R=I.props.popperOptions)==null?void 0:R.modifiers)||[]).filter(function(U){var z=U.name;return z!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(z){var G,se=z.state,le=(G=se.modifiersData)==null?void 0:G.hide;(v.placement!==se.placement||v.referenceHidden!==(le==null?void 0:le.isReferenceHidden)||v.escaped!==(le==null?void 0:le.hasPopperEscaped))&&E({placement:se.placement,referenceHidden:le==null?void 0:le.isReferenceHidden,escaped:le==null?void 0:le.hasPopperEscaped}),se.attributes.popper={}}}])})})}},[v.placement,v.referenceHidden,v.escaped].concat($)),b.createElement(b.Fragment,null,r?b.cloneElement(r,{ref:function(I){A.ref=I,$c(r.ref,I)}}):null,y&&vt.createPortal(l?l(bA(v),O,A.instance):o,A.container))}return e}var EA=function(n,e){return b.forwardRef(function(r,o){var i=r.children,s=Jm(r,["children"]);return b.createElement(n,Object.assign({},e,s),i?b.cloneElement(i,{ref:function(a){$c(o,a),$c(i.ref,a)}}):null)})},AA=EA(SA(ar));const TA=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:w.jsx("svg",{viewBox:"0 0 24 24",children:w.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Qm=({node:n,getPos:e,selected:t,editor:r})=>{const[o,i]=b.useState(!1),s=$s(),l=b.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;i(f<=u&&d<=h)};b.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return w.jsxs(Ko,{className:"group",children:[w.jsx(yh,{as:"span"}),(o||t)&&w.jsx(AA,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:w.jsx("article",{className:"dropdown",contentEditable:!1,children:w.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:TA.map(u=>w.jsx("li",{children:w.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[w.jsx("span",{children:u.icon}),w.jsx("span",{children:u.name})]})},u.name))})}),children:w.jsx("label",{tabIndex:0,className:fe("trigger-button",{hidden:s}),contentEditable:!1,children:w.jsx(_x,{fontSize:"small"})})})]})},MA=pe.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return cr(Qm,{as:"td",className:"relative"})}}),OA=pe.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return cr(Qm,{as:"th",className:"relative"})}}),eg=n=>(n.stopPropagation(),n.preventDefault(),n),NA=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},tg=function(n){return!n||n===document.body?document.body:NA(n)?n:tg(n.parentNode)},Hc=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([o,i])=>r.setAttribute(o,i)),t&&Object.entries(t).forEach(([o,i])=>r.addEventListener(o,i)),r},DA=pe.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",ee(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),o=tg(n.options.element);let i=!1;const s={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const y=r(),k=n.state.doc.resolve(y),C=new W(k);n.view.dispatch(n.state.tr.setSelection(C))}},l=()=>{i=!0},a=()=>{i=!1},c=Hc("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:y=>{y&&eg(y),s.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=Hc("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:y=>{y&&eg(y),s.deleteRow()}}),d=()=>{m(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Hc("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const m=()=>{setTimeout(()=>{const y=h.getBoundingClientRect(),k=JSON.stringify(y);p!==k&&(c.style.top=`${y.top+document.documentElement.scrollTop}px`,c.style.left=`${y.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${y.height+1}px`,p=k)})};return setTimeout(()=>{m()},100),n.on("selectionUpdate",m),n.on("update",m),o==null||o.addEventListener("scroll",m),document.addEventListener("scroll",m),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",m),n.off("update",m),o==null||o.removeEventListener("scroll",m),document.removeEventListener("scroll",m)}}}}}),LA=[vA.configure({resizable:!0}),MA,OA,DA],PA=xh.extend({content:"(dBlock|columns)+"});function ng({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const RA=ve.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ce(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new ge({key:n,appendTransaction:(t,r,o)=>{const{doc:i,tr:s,schema:l}=o,a=n.getState(o),c=i.content.size,u=l.nodes[this.options.node];if(a)return s.insert(c,u.create())},state:{init:(t,r)=>{const o=r.tr.doc.lastChild;return!ng({node:o,types:e})},apply:(t,r)=>{var i,s,l;if(!t.docChanged)return r;const o=(l=(s=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:s.content)==null?void 0:l[0];return!ng({node:o,types:e})}}})]}}),IA=({node:n,editor:e,getPos:t})=>{const[r,o]=b.useState(""),i=$s(),s=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return w.jsx(ip,{});case"iframe":return w.jsx(sp,{});default:return w.jsx(Qx,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const C=r.match(/src="([^"]*)"/);C&&C.length>0&&(p=C[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://www.youtube.com/embed/${C[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://player.vimeo.com/video/${C[1]}`);break}default:{alert("Please enter a valid url");return}}const m=640,g=360,y=t(),k=y+n.nodeSize;p&&(e==null||e.chain().focus(y).deleteRange({from:y,to:k}).setIframe({src:p,width:m,height:g}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const m=s.some(v=>r.includes(v)),g=r.match(/\/status\/([0-9]*)/),y=g&&g.length>0;if(m&&y)p=g[1];else{alert("invalid url");return}const k=t(),C=k+n.nodeSize;p&&(e==null||e.chain().focus(k).deleteRange({from:k,to:C}).setTweetEmbed({tweetId:p}).run())},f=xp(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);b.useEffect(()=>{r&&f()},[r]),b.useEffect(()=>{e==null||e.chain().focus()},[]);const h=b.useRef(null);return b.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),w.jsx(Ko,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&w.jsxs("div",{className:"relative w-full",children:[w.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),w.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>o(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},FA=pe.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return cr(IA)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",ee(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),$A=[tx,Qw.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),nx.configure({types:["heading","paragraph"]}),dk,Ex.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),Ax.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),Ox.configure({multicolor:!0}),uk,Px.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),ex,gk,Nx.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),Lx.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),kh.configure({width:3,color:"#d1d5db"}),Ch,yE,RA,PA,...LA,Tk.configure({uploadFn:ok}),mk,bk,Ck,FA.extend({addInputRules(){return[rg(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),rg(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),pk],rg=(n,e,t)=>new Ro({find:n,handler:({state:r,range:o,commands:i})=>{const s={data:e},{tr:l}=r,a=o.from,c=o.to;l.insert(a-1,t.create(s)).delete(l.mapping.map(a),l.mapping.map(c)),i.focus(c-1)}}),og="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M272-200v-560h221q65%200%20120%2040t55%20111q0%2051-23%2078.5T602-491q25%2011%2055.5%2041t30.5%2090q0%2089-65%20124.5T501-200H272Zm121-112h104q48%200%2058.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33%200%2048-17t15-38q0-24-17-39t-44-15h-95v109Z'/%3e%3c/svg%3e",ig="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z'/%3e%3c/svg%3e",sg="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-120v-80h560v80H200Zm280-160q-101%200-157-63t-56-167v-330h103v336q0%2056%2028%2091t82%2035q54%200%2082-35t28-91v-336h103v330q0%20104-56%20167t-157%2063Z'/%3e%3c/svg%3e",lg="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2584'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2584)'%3e%3cpath%20d='M8%2018L2%2012L8%206L9.425%207.425L4.825%2012.025L9.4%2016.6L8%2018ZM16%2018L14.575%2016.575L19.175%2011.975L14.6%207.4L16%206L22%2012L16%2018Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",ag="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M486-160q-76%200-135-45t-85-123l88-38q14%2048%2048.5%2079t85.5%2031q42%200%2076-20t34-64q0-18-7-33t-19-27h112q5%2014%207.5%2028.5T694-340q0%2086-61.5%20133T486-160ZM80-480v-80h800v80H80Zm402-326q66%200%20115.5%2032.5T674-674l-88%2039q-9-29-33.5-52T484-710q-41%200-68%2018.5T386-640h-96q2-69%2054.5-117.5T482-806Z'/%3e%3c/svg%3e",cg="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2557'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2557)'%3e%3cpath%20d='M11%2017H7C5.61667%2017%204.4375%2016.5125%203.4625%2015.5375C2.4875%2014.5625%202%2013.3833%202%2012C2%2010.6167%202.4875%209.4375%203.4625%208.4625C4.4375%207.4875%205.61667%207%207%207H11V9H7C6.16667%209%205.45833%209.29167%204.875%209.875C4.29167%2010.4583%204%2011.1667%204%2012C4%2012.8333%204.29167%2013.5417%204.875%2014.125C5.45833%2014.7083%206.16667%2015%207%2015H11V17ZM8%2013V11H16V13H8ZM13%2017V15H17C17.8333%2015%2018.5417%2014.7083%2019.125%2014.125C19.7083%2013.5417%2020%2012.8333%2020%2012C20%2011.1667%2019.7083%2010.4583%2019.125%209.875C18.5417%209.29167%2017.8333%209%2017%209H13V7H17C18.3833%207%2019.5625%207.4875%2020.5375%208.4625C21.5125%209.4375%2022%2010.6167%2022%2012C22%2013.3833%2021.5125%2014.5625%2020.5375%2015.5375C19.5625%2016.5125%2018.3833%2017%2017%2017H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",BA=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:op,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:Qh,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:ep,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:tp,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:np,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:rc,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:rc,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:rp,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:Yh,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],o=r.filter(i=>i.isActive()).pop()??{name:"Multiple"};return w.jsxs("div",{className:"relative h-full",children:[w.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[w.jsx("span",{children:o==null?void 0:o.name}),w.jsx(nc,{className:"h-4 w-4"})]}),e&&w.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((i,s)=>w.jsxs("button",{onClick:()=>{i.command(),t(!1)},className:fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":i.isActive()}),children:[w.jsxs("div",{className:"flex items-center space-x-2",children:[w.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:w.jsx(i.icon,{className:"h-3 w-3"})}),w.jsx("span",{children:i.name})]}),o.name===i.name&&w.jsx(Ls,{className:"h-4 w-4"})]},s))})]})},HA=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],o=r.find(({color:i})=>n.isActive("textStyle",{color:i}));return w.jsxs("div",{className:"",children:[w.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[w.jsx("span",{style:{color:(o==null?void 0:o.color)||"#000000"},children:"A"}),w.jsx(nc,{className:"h-4 w-4 "})]}),e&&w.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:i,color:s},l)=>w.jsxs("button",{onClick:()=>{n.chain().focus().setColor(s).run(),t(!1)},className:fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:s})}),children:[w.jsxs("div",{className:"flex items-center space-x-2",children:[w.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:s},children:"A"}),w.jsx("span",{children:i})]}),n.isActive("textStyle",{color:s})&&w.jsx(Ls,{className:"h-4 w-4"})]},l))})]})};var oe=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(oe||{});function jA(n){const[e,t]=b.useState(n),r=b.useRef(null),o=i=>{r&&r.current&&!r.current.contains(i.target)&&t(0)};return b.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const zA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_446'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_446)'%3e%3cpath%20d='M5.55%2019L2%2015.45L3.4%2014.05L5.525%2016.175L9.775%2011.925L11.175%2013.35L5.55%2019ZM5.55%2011L2%207.45005L3.4%206.05005L5.525%208.17505L9.775%203.92505L11.175%205.35005L5.55%2011ZM13%2017V15H22V17H13ZM13%209.00005V7.00005H22V9.00005H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",VA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2594'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2594)'%3e%3cpath%20d='M3.9751%2017L7.7251%207H9.5251L13.2751%2017H11.5501L10.6501%2014.45H6.6001L5.7001%2017H3.9751ZM7.1251%2013H10.1251L8.6751%208.85H8.5751L7.1251%2013ZM16.3501%2017.275C15.5334%2017.275%2014.8918%2017.0625%2014.4251%2016.6375C13.9584%2016.2125%2013.7251%2015.6333%2013.7251%2014.9C13.7251%2014.2%2013.9959%2013.6292%2014.5376%2013.1875C15.0793%2012.7458%2015.7751%2012.525%2016.6251%2012.525C17.0084%2012.525%2017.3626%2012.5542%2017.6876%2012.6125C18.0126%2012.6708%2018.2918%2012.7667%2018.5251%2012.9V12.55C18.5251%2012.1%2018.3709%2011.7417%2018.0626%2011.475C17.7543%2011.2083%2017.3334%2011.075%2016.8001%2011.075C16.4501%2011.075%2016.1209%2011.15%2015.8126%2011.3C15.5043%2011.45%2015.2418%2011.6667%2015.0251%2011.95L13.9501%2011.15C14.2668%2010.7%2014.6668%2010.3583%2015.1501%2010.125C15.6334%209.89167%2016.1918%209.775%2016.8251%209.775C17.8584%209.775%2018.6501%2010.0208%2019.2001%2010.5125C19.7501%2011.0042%2020.0251%2011.7167%2020.0251%2012.65V17.05H18.5501V16.2H18.4751C18.2584%2016.5333%2017.9668%2016.7958%2017.6001%2016.9875C17.2334%2017.1792%2016.8168%2017.275%2016.3501%2017.275ZM16.6001%2016.025C17.1334%2016.025%2017.5876%2015.8375%2017.9626%2015.4625C18.3376%2015.0875%2018.5251%2014.6333%2018.5251%2014.1C18.2918%2013.9667%2018.0251%2013.8667%2017.7251%2013.8C17.4251%2013.7333%2017.1501%2013.7%2016.9001%2013.7C16.3668%2013.7%2015.9584%2013.8042%2015.6751%2014.0125C15.3918%2014.2208%2015.2501%2014.5167%2015.2501%2014.9C15.2501%2015.2333%2015.3751%2015.5042%2015.6251%2015.7125C15.8751%2015.9208%2016.2001%2016.025%2016.6001%2016.025Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",ug="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2572'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2572)'%3e%3cpath%20d='M9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9ZM5%2020C4.45%2020%203.97917%2019.8042%203.5875%2019.4125C3.19583%2019.0208%203%2018.55%203%2018C3%2017.45%203.19583%2016.9792%203.5875%2016.5875C3.97917%2016.1958%204.45%2016%205%2016C5.55%2016%206.02083%2016.1958%206.4125%2016.5875C6.80417%2016.9792%207%2017.45%207%2018C7%2018.55%206.80417%2019.0208%206.4125%2019.4125C6.02083%2019.8042%205.55%2020%205%2020ZM5%2014C4.45%2014%203.97917%2013.8042%203.5875%2013.4125C3.19583%2013.0208%203%2012.55%203%2012C3%2011.45%203.19583%2010.9792%203.5875%2010.5875C3.97917%2010.1958%204.45%2010%205%2010C5.55%2010%206.02083%2010.1958%206.4125%2010.5875C6.80417%2010.9792%207%2011.45%207%2012C7%2012.55%206.80417%2013.0208%206.4125%2013.4125C6.02083%2013.8042%205.55%2014%205%2014ZM5%208C4.45%208%203.97917%207.80417%203.5875%207.4125C3.19583%207.02083%203%206.55%203%206C3%205.45%203.19583%204.97917%203.5875%204.5875C3.97917%204.19583%204.45%204%205%204C5.55%204%206.02083%204.19583%206.4125%204.5875C6.80417%204.97917%207%205.45%207%206C7%206.55%206.80417%207.02083%206.4125%207.4125C6.02083%207.80417%205.55%208%205%208Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",_A="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_458'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_458)'%3e%3cpath%20d='M3%2022V20.5H5.5V19.75H4V18.25H5.5V17.5H3V16H6C6.28333%2016%206.52083%2016.0958%206.7125%2016.2875C6.90417%2016.4792%207%2016.7167%207%2017V18C7%2018.2833%206.90417%2018.5208%206.7125%2018.7125C6.52083%2018.9042%206.28333%2019%206%2019C6.28333%2019%206.52083%2019.0958%206.7125%2019.2875C6.90417%2019.4792%207%2019.7167%207%2020V21C7%2021.2833%206.90417%2021.5208%206.7125%2021.7125C6.52083%2021.9042%206.28333%2022%206%2022H3ZM3%2015V12.25C3%2011.9667%203.09583%2011.7292%203.2875%2011.5375C3.47917%2011.3458%203.71667%2011.25%204%2011.25H5.5V10.5H3V9H6C6.28333%209%206.52083%209.09583%206.7125%209.2875C6.90417%209.47917%207%209.71667%207%2010V11.75C7%2012.0333%206.90417%2012.2708%206.7125%2012.4625C6.52083%2012.6542%206.28333%2012.75%206%2012.75H4.5V13.5H7V15H3ZM4.5%208V3.5H3V2H6V8H4.5ZM9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",WA="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2560'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2560)'%3e%3cpath%20d='M5%2019V17H19V19H5ZM6.9%2015L11%204H13L17.1%2015H15.2L14.25%2012.2H9.8L8.8%2015H6.9ZM10.35%2010.6H13.65L12.05%206.05H11.95L10.35%2010.6Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",qA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='m228-240%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T458-480L320-240h-92Zm360%200%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T818-480L680-240h-92ZM320-500q25%200%2042.5-17.5T380-560q0-25-17.5-42.5T320-620q-25%200-42.5%2017.5T260-560q0%2025%2017.5%2042.5T320-500Zm360%200q25%200%2042.5-17.5T740-560q0-25-17.5-42.5T680-620q-25%200-42.5%2017.5T620-560q0%2025%2017.5%2042.5T680-500Zm0-60Zm-360%200Z'/%3e%3c/svg%3e",UA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-280v-400h80v160h160v-160h80v400h-80v-160H280v160h-80Zm480%200v-320h-80v-80h160v400h-80Z'/%3e%3c/svg%3e",KA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-160q0-33%2023.5-56.5T600-520h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v80q0%2033-23.5%2056.5T760-440H600v80h240v80H520Z'/%3e%3c/svg%3e",JA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-80h240v-80H600v-80h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v240q0%2033-23.5%2056.5T760-280H520Z'/%3e%3c/svg%3e",ZA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M680-360q-17%200-28.5-11.5T640-400v-160q0-17%2011.5-28.5T680-600h120q17%200%2028.5%2011.5T840-560v40h-60v-20h-80v120h80v-20h60v40q0%2017-11.5%2028.5T800-360H680Zm-300%200v-240h160q17%200%2028.5%2011.5T580-560v40q0%2017-11.5%2028.5T540-480q17%200%2028.5%2011.5T580-440v40q0%2017-11.5%2028.5T540-360H380Zm60-150h80v-30h-80v30Zm0%2090h80v-30h-80v30Zm-320%2060v-200q0-17%2011.5-28.5T160-600h120q17%200%2028.5%2011.5T320-560v200h-60v-60h-80v60h-60Zm60-120h80v-60h-80v60Z'/%3e%3c/svg%3e",GA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M544-400%20440-504%20240-304l104%20104%20200-200Zm-47-161%20104%20104%20199-199-104-104-199%20199Zm-84-28%20216%20216-229%20229q-24%2024-56%2024t-56-24l-2-2-26%2026H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0%200%20227-227q24-24%2056-24t56%2024l104%20104q24%2024%2024%2056t-24%2056L629-373%20413-589Z'/%3e%3c/svg%3e",YA="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%205v14H5V5h14m0-2H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2zm-4.86%208.86l-3%203.87L9%2013.14L6%2017h12l-3.86-5.14z'/%3e%3c/svg%3e",dg=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=jA(oe.NONE);return{toolbar:[{icon:VA,title:"Font",onClick:()=>r(oe.FONT_FAMILY),isActive:t===oe.FONT_FAMILY},{icon:WA,title:"Text Color",onClick:()=>r(oe.TEXT_COLOR),isActive:t===oe.TEXT_COLOR},{icon:GA,title:"Highlight",onClick:()=>r(oe.HIGHLIGHT),isActive:t===oe.HIGHLIGHT},null,{icon:og,title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:ig,title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:sg,title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:ag,title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:ug,title:"List",onClick:()=>r(oe.LIST),isActive:t===oe.LIST},{icon:oc,title:"Alignment",onClick:()=>r(oe.ALIGNMENT),isActive:t===oe.ALIGNMENT},{icon:qA,title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:YA,title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const i=document.createElement("input");i.type="file",i.accept="image/*",i.onchange=async()=>{var s;if((s=i.files)!=null&&s.length){const l=i.files[0],a=n.view.state.selection.from;lp(l,n.view,a)}},i.click()},isActive:!1},{icon:cg,title:"Link",onClick:()=>r(oe.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:lg,title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},XA=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return w.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[w.jsx(Gh,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(oe.NONE)}}),r.map(o=>w.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:o.color}).run(),e(oe.NONE)},className:`w-6 ${o.code} drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:w.jsx(Ls,{size:14,className:`${n.isActive("highlight",{color:o.color})?"visible":"invisible"}`})},o.color))]})},QA=({elementRef:n,editor:e,setToolVisibility:t})=>{const r=[{title:"Trebuchet MS",command:o=>{o.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",command:o=>{o.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",command:o=>{o.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",command:o=>{o.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",command:o=>{o.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",command:o=>{o.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",command:o=>{o.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",command:o=>{o.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",command:o=>{o.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",command:o=>{o.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",command:o=>{o.chain().focus().setFontFamily("cursive").run()}}];return w.jsx("div",{ref:n,className:fe("z-50 h-auto absolute top-[50px] left-[20%] max-h-[330px] w-48 overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:r.map(o=>w.jsx("button",{onClick:()=>{o.command(e),t(oe.NONE)},style:{fontFamily:o.title},className:`flex w-full ${e.isActive("textStyle",{fontFamily:o.title})?"bg-red-500":""} items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100`,children:w.jsx("p",{className:"font-medium",children:o.title})},o.title))})},eT=({elementRef:n,editor:e,setToolVisibility:t})=>w.jsxs("div",{ref:n,className:fe("z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"left"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:oc,alt:"align left"})}),w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"center"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:pp,alt:"align center"})}),w.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"right"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:mp,alt:"align right"})})]}),tT=({elementRef:n,editor:e,setToolVisibility:t})=>w.jsxs("div",{ref:n,className:fe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:ug,alt:"bullet list"})})}),w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:_A,alt:"numbered list"})})}),w.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:w.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(oe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:w.jsx("img",{src:zA,alt:"checklist"})})})]}),fg=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:o})=>{const[i,s]=b.useState(e.getAttributes("link").href),l=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let a=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(a="https://"+i);try{a.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:a}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:a}).run(),t(oe.NONE),r&&o&&o(!1)};return w.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white p-2 shadow-md transition-all",children:[w.jsx("input",{onChange:a=>s(a.target.value),className:"border-2 focus:border-black px-2 py-1.5 rounded w-full font-medium text-sm",placeholder:"Add link here",value:i}),w.jsx("div",{className:"h-full flex items-center",children:w.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},nT=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return w.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[w.jsx(Gh,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(oe.NONE)}}),r.map(o=>w.jsx("div",{onClick:()=>{n.chain().focus().setColor(o.color).run(),e(oe.NONE)},className:`w-6 ${o.code} drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:w.jsx(Ls,{size:14,className:`${n.isActive("textStyle",{color:o.color})?"visible":"invisible"}`})},o.color))]})},rT=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:ZA,command:o=>o.chain().focus().toggleNode("paragraph","paragraph").run()},{title:"Heading 1",description:"Big",icon:UA,command:o=>{o.chain().focus().toggleHeading({level:1}).run()}},{title:"Heading 2",description:"Medium",icon:KA,command:o=>{o.chain().focus().toggleHeading({level:2}).run()}},{title:"Heading 3",description:"Small",icon:JA,command:o=>{o.chain().focus().toggleHeading({level:3}).run()}}];return w.jsx("section",{ref:t,className:fe(" absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(o=>w.jsxs("button",{onClick:()=>{o.command(n),e(oe.NONE)},className:"flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100",children:[w.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-stone-200 bg-white",children:w.jsx("img",{src:o.icon,alt:o.title})}),w.jsxs("div",{children:[w.jsx("p",{className:"font-medium",children:o.title}),w.jsxs("p",{className:"text-xs text-stone-500",children:[" ",o.description," "]})]})]},o.title))})},oT=n=>{const e=[{name:"bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:og},{name:"italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:ig},{name:"underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:sg},{name:"strike",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:ag},{name:"codeBlock",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:lg},{name:"link",isActive:()=>n.editor.isActive("link"),command:()=>a(!l),icon:cg}],t={...n,shouldShow:({state:d,editor:f})=>{const{selection:h}=d,{empty:p}=h;return!(f.isActive("image")||p||Cf(h))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{o(!1),s(!1),a(!1)}}},[r,o]=b.useState(!1),[i,s]=b.useState(!1),[l,a]=b.useState(!1),{toolRef:c,setToolVisibility:u}=dg({editor:n.editor});return w.jsxs(ph,{...t,className:"flex gap-1 overflow-hidden rounded border border-stone-200 bg-white shadow-xl",children:[w.jsx(BA,{editor:n.editor,isOpen:r,setIsOpen:()=>{o(!r),s(!1)}}),e.map((d,f)=>w.jsx("button",{onClick:d.command,className:" py-2 text-stone-600 hover:bg-stone-100 active:bg-stone-200",children:w.jsx("img",{src:d.icon,className:fe(" p-1 rounded-lg h-6 w-6",{"bg-yellow-300":d.isActive()})})},f)),w.jsx(HA,{editor:n.editor,isOpen:i,setIsOpen:()=>{s(!i),o(!1)}}),l&&w.jsx(fg,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a})]})},iT={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}};function sT(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var lT=sT;const aT=Jc(lT),cT=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,o=document.querySelectorAll(".has-focus"),i=o.length,l=o[i-1];if(l&&l.getAttribute("data-type")&&l.getAttribute("data-type")===e||l&&l.classList&&l.classList.contains(e))return l;const a=t.domAtPos(r).node;let c=a;for(c.tagName||(c=a.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},uT=({editor:n,appendTo:e})=>{const t=b.useCallback(()=>{const l=cT(n,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=b.useCallback(()=>n.isActive("columns"),[n]),o=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignLeft).run()},[n]),i=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignRight).run()},[n]),s=b.useCallback(()=>{n.chain().focus().setLayout(fr.AlignCenter).run()},[n]);return w.jsx(ph,{editor:n,pluginKey:`columnsMenu-${aT()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[q2],sticky:"popper"},children:w.jsxs(ri.Wrapper,{children:[w.jsx(ri.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:fr.AlignLeft}),onClick:o,children:w.jsx(Jx,{size:20})}),w.jsx(ri.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:fr.AlignCenter}),onClick:s,children:w.jsx(Xh,{size:20})}),w.jsx(ri.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:fr.AlignRight}),onClick:i,children:w.jsx(Zx,{size:20})})]})})},dT=({editor:n})=>{const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:o}=dg({editor:n});return w.jsxs("div",{className:"w-fit bg-transparent px-4 items-center rounded-lg h-16 flex gap-1 justify-center",children:[w.jsxs("button",{className:"hover:bg-[#f2f2f2] border gap-2 rounded-lg w-28 h-8 p-1 flex justify-center items-center",onClick:()=>r(oe.HEADING),children:[w.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),w.jsx(nc,{className:"h-4 w-4"})]}),o.map((i,s)=>i?w.jsx("div",{className:"tooltip tooltip-bottom","data-tip":i.title,children:w.jsx("span",{onClick:()=>i.onClick(),className:fe("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",i.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof i.icon=="string"?w.jsx("img",{src:i.icon,className:"w-4"}):i.icon})},i.title):w.jsx("div",{className:" w-[1px] h-[50%] bg-[#777777]"},s)),t===oe.HEADING&&w.jsx(rT,{setVisibility:r,editor:n,elementRef:e}),t===oe.TEXT_COLOR&&w.jsx(nT,{setVisibility:r,editor:n,elementRef:e}),t===oe.HIGHLIGHT&&w.jsx(XA,{setVisibility:r,editor:n,elementRef:e}),t===oe.FONT_FAMILY&&w.jsx(QA,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.ALIGNMENT&&w.jsx(eT,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.LIST&&w.jsx(tT,{setToolVisibility:r,editor:n,elementRef:e}),t===oe.LINK&&w.jsx(fg,{setToolVisibility:r,editor:n,elementRef:e})]})},fT=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r})=>{const[o,i]=b.useState({cover:{image:null,emoji:null,name:null},plugin:{title:null}}),s=Q2({extensions:[...$A],editorProps:iT,autofocus:"start"}),l=b.useRef(null),a=c=>{var u;(u=l.current)!=null&&u.contains(c.target)||s==null||s.chain().focus().run()};return b.useEffect(()=>{s==null||s.chain().focus()},[]),b.useEffect(()=>{s==null||s.setEditable(!n)},[n]),b.useEffect(()=>{t&&s&&(s==null||s.commands.setContent(t))},[t,s]),s?w.jsx("div",{"data-cy":"single-webpage",className:"h-screen w-screen bg-[#f9fbfd]",children:w.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:w.jsxs("div",{className:"w-full h-screen",children:[w.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:w.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[w.jsx("div",{className:"grow",children:w.jsx(wg,{isPreviewMode:n,metaData:o,setMetaData:i})}),!n&&w.jsx("div",{className:"grow relative",children:w.jsx(dT,{editor:s})}),w.jsx("div",{children:w.jsx(tl,{onClick:()=>r(n),children:n?"Edit":"Preview"})}),e&&w.jsx("div",{onClick:()=>e({metaData:o,editorJSONData:s.getJSON()}),className:"cursor-pointer",children:w.jsx(tl,{children:"Publish"})})]})}),w.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:w.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:w.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:w.jsxs("div",{ref:l,className:"w-full pt-4 h-full",children:[!n&&w.jsxs("div",{children:[w.jsx(oT,{editor:s}),w.jsx(uT,{editor:s,appendTo:l})]}),w.jsx(vk,{isPreviewMode:n,children:w.jsx(Y2,{editor:s})})]})})})})]})})}):w.jsxs("div",{className:" w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[w.jsx(wp,{}),w.jsx("p",{children:"Loading Editor..."})]})};et.DdocEditor=fT,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})});