zt-react-milkdown 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +2 -0
  2. package/dist/{dist-CZTw9GLV.js → dist-BjfIurm0.js} +1 -1
  3. package/dist/{dist-ZPtYoqTI.cjs → dist-D7LE16E1.cjs} +1 -1
  4. package/dist/floating-ui.dom-B_oXwL6O.cjs +1 -0
  5. package/dist/floating-ui.dom-Cm9Ov61_.js +883 -0
  6. package/dist/index.cjs +66 -22
  7. package/dist/index.mjs +4636 -2719
  8. package/dist/{lib-D_0WAhKU.js → lib-5lx86j_L.js} +1 -1
  9. package/dist/{lib-Bhr5EVOu.js → lib-72N1aRae.js} +19 -19
  10. package/dist/{lib-DVE2k9i1.js → lib-BIxqp3lX.js} +43 -43
  11. package/dist/{lib-DzY83R_P.cjs → lib-BLTQkf4j.cjs} +1 -1
  12. package/dist/{lib-De0djIEV.cjs → lib-BzlEyehQ.cjs} +1 -1
  13. package/dist/{lib-F08NY8fk.cjs → lib-C61-3fwS.cjs} +1 -1
  14. package/dist/{lib-5pUyY-Tl.cjs → lib-C82poHMJ.cjs} +1 -1
  15. package/dist/{lib-bsXGz3fj.js → lib-CDhjYvDm.js} +2 -2
  16. package/dist/{lib-Dplx6t-N.cjs → lib-CHQUpMrL.cjs} +1 -1
  17. package/dist/{lib-DmD940Fq.js → lib-CYWwNE4c.js} +1527 -1530
  18. package/dist/{lib-C1A-pN4b.js → lib-Cixz93sP.js} +4 -4
  19. package/dist/{lib-DIx8C5AZ.cjs → lib-CqJFV3ME.cjs} +1 -1
  20. package/dist/{lib-CVebEyb8.cjs → lib-D7VWCO2M.cjs} +1 -1
  21. package/dist/{lib-_NDReOAt.js → lib-DaPs62nF.js} +1 -1
  22. package/dist/{lib-DgEwQN1U.cjs → lib-Dka_BhhQ.cjs} +1 -1
  23. package/dist/{lib-BmAQCwSQ.cjs → lib-DrllUeuK.cjs} +1 -1
  24. package/dist/{lib-Dd20rlmV.js → lib-wpjVX5Vf.js} +1 -1
  25. package/dist/{lib-ChwoE6v5.js → lib-z6CKD87x.js} +2 -2
  26. package/dist/{schema-list-D9Q6QKgo.cjs → schema-list-CFEw5DQ8.cjs} +1 -1
  27. package/dist/{schema-list-DooYP5HM.js → schema-list-CiFfAlj-.js} +1 -1
  28. package/dist/src/lib/global-scroll-listener.d.ts +1 -1
  29. package/dist/src/lib/global-scroll-listener.d.ts.map +1 -1
  30. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -1
  31. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +1 -1
  32. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -1
  33. package/package.json +3 -2
  34. package/dist/floating-ui.dom-CV-TLBRq.cjs +0 -1
  35. package/dist/floating-ui.dom-CoOubeUs.js +0 -762
package/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  GitHub 仓库:[lzt-T/zt-react-milkdown](https://github.com/lzt-T/zt-react-milkdown)
6
6
 
7
+ 在线示例:[https://markdown.xjoker.top/](https://markdown.xjoker.top/)
8
+
7
9
 
8
10
  ## 安装
9
11
 
@@ -1,4 +1,4 @@
1
- import { M as e, N as t, j as n } from "./lib-DmD940Fq.js";
1
+ import { M as e, N as t, j as n } from "./lib-CYWwNE4c.js";
2
2
  import { A as r, a as i, c as a, i as o, m as s, o as c, r as l, s as u, w as d } from "./dist-CLTsQjPD.js";
3
3
  //#region node_modules/.pnpm/prosemirror-tables@1.8.5/node_modules/prosemirror-tables/dist/index.js
4
4
  var f, p;
@@ -1 +1 @@
1
- const e=require("./lib-DzY83R_P.cjs"),t=require("./dist-DQnWlYyo.cjs");var n,r;if(typeof WeakMap<`u`){let e=new WeakMap;n=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;n=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},r=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var i=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw 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 RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return n(e)||r(e,a(e))}};function a(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=o(e),n=e.childCount,r=[],a=0,c=null,l=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let i=0,o=0;i<n;i++){let s=e.child(i);o++;for(let e=0;;e++){for(;a<r.length&&r[a]!=0;)a++;if(e==s.childCount)break;let u=s.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+i>=n){(c||=[]).push({type:`overlong_rowspan`,pos:o,n:f-e});break}let s=a+e*t;for(let e=0;e<d;e++){r[s+e]==0?r[s+e]=o:(c||=[]).push({type:`collision`,row:i,pos:o,n:d-e});let n=p&&p[e];if(n){let r=(s+e)%t*2,i=l[r];i==null||i!=n&&l[r+1]==1?(l[r]=n,l[r+1]=1):i==n&&l[r+1]++}}}a+=d,o+=u.nodeSize}let u=(i+1)*t,d=0;for(;a<u;)r[a++]==0&&d++;d&&(c||=[]).push({type:`missing`,row:i,n:d}),o++}(t===0||n===0)&&(c||=[]).push({type:`zero_sized`});let u=new i(t,n,r,c),d=!1;for(let e=0;!d&&e<l.length;e+=2)l[e]!=null&&l[e+1]<n&&(d=!0);return d&&s(u,l,e),u}function o(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function s(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!l.colwidth||l.colwidth[n]!=r)&&((s||=c(l))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function c(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function l(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function u(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function d(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function f(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:d}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>l(e,t)}],toDOM(e){return[`td`,u(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>l(e,t)}],toDOM(e){return[`th`,u(e,t),0]}}}}function p(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var m=new t.a(`selectingCells`);function h(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function g(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function _(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=h(t.$head)||ee(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function ee(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function v(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function te(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function y(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function b(e,t,n){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.nextCell(e.pos-o,t,n);return s==null?null:e.node(0).resolve(o+s)}function x(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function ne(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function re(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var S=class e extends t.o{constructor(e,n=e){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.rectBetween(e.pos-o,n.pos-o),c=e.node(0),l=a.cellsInRect(s).filter(e=>e!=n.pos-o);l.unshift(n.pos-o);let u=l.map(e=>{let n=r.nodeAt(e);if(!n)throw RangeError(`No cell with offset ${e} found`);let i=o+e+1;return new t.s(c.resolve(i),c.resolve(i+n.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(n,r){let i=n.resolve(r.map(this.$anchorCell.pos)),a=n.resolve(r.map(this.$headCell.pos));if(v(i)&&v(a)&&y(i,a)){let t=this.$anchorCell.node(-1)!=i.node(-1);return t&&this.isRowSelection()?e.rowSelection(i,a):t&&this.isColSelection()?e.colSelection(i,a):new e(i,a)}return t.c.between(i,a)}content(){let e=this.$anchorCell.node(-1),n=i.get(e),r=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let r=a.top;r<a.bottom;r++){let i=[];for(let t=r*n.width+a.left,s=a.left;s<a.right;s++,t++){let r=n.map[t];if(o[r])continue;o[r]=!0;let s=n.findCell(r),c=e.nodeAt(r);if(!c)throw RangeError(`No cell with offset ${r} found`);let l=a.left-s.left,u=s.right-a.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=x(e,0,l)),u>0&&(e=x(e,e.colspan-u,u)),s.left<a.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<a.top||s.bottom>a.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,a.bottom)-Math.max(s.top,a.top)};c=s.top<a.top?c.type.createAndFill(e):c.type.create(e,c.content)}i.push(c)}s.push(e.child(r).copy(t.w.from(i)))}let c=this.isColSelection()&&this.isRowSelection()?e:s;return new t.A(t.w.from(c),1,1)}replace(e,n=t.A.empty){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:s}=i[a],c=e.mapping.slice(r);e.replace(c.map(o.pos),c.map(s.pos),a?t.A.empty:n)}let a=t.o.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);a&&e.setSelection(a)}replaceWith(e,n){this.replace(e,new t.A(t.w.from(n),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=i.get(t),r=this.$anchorCell.start(-1),a=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<a.length;n++)e(t.nodeAt(a[n]),r+a[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.top<=c.top?(s.top>0&&(t=l.resolve(o+a.map[s.left])),c.bottom<a.height&&(n=l.resolve(o+a.map[a.width*(a.height-1)+c.right-1]))):(c.top>0&&(n=l.resolve(o+a.map[c.left])),s.bottom<a.height&&(t=l.resolve(o+a.map[a.width*(a.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=i.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),a=t.colCount(this.$headCell.pos-n);if(Math.min(r,a)>0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.left<=c.left?(s.left>0&&(t=l.resolve(o+a.map[s.top*a.width])),c.right<a.width&&(n=l.resolve(o+a.map[a.width*(c.top+1)-1]))):(c.left>0&&(n=l.resolve(o+a.map[c.top*a.width])),s.right<a.width&&(t=l.resolve(o+a.map[a.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new ie(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1,t.o.jsonID(`cell`,S);var ie=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole==`row`&&r.parent.type.spec.tableRole==`row`&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&y(n,r)?new S(n,r):t.o.near(r,1)}};function ae(t){if(!(t.selection instanceof S))return null;let n=[];return t.selection.forEachCell((t,r)=>{n.push(e.j.node(r,r+t.nodeSize,{class:`selectedCell`}))}),e.M.create(t.doc,n)}function oe({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function se({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function ce(e,n,r){let a=(n||e).selection,o=(n||e).doc,s,c;if(a instanceof t.r&&(c=a.node.type.spec.tableRole)){if(c==`cell`||c==`header_cell`)s=S.create(o,a.from);else if(c==`row`){let e=o.resolve(a.from+1);s=S.rowSelection(e,e)}else if(!r){let e=i.get(a.node),t=a.from+1,n=t+e.map[e.width*e.height-1];s=S.create(o,t+1,n)}}else a instanceof t.c&&oe(a)?s=t.c.create(o,a.from):a instanceof t.c&&se(a)&&(s=t.c.create(o,a.$from.start(),a.$from.end()));return s&&(n||=e.tr).setSelection(s),n}var le=new t.a(`fix-tables`);function C(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?C(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ue(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=de(e,t,r,n))};return t?t.doc!=e.doc&&C(t.doc,e.doc,0,r):e.doc.descendants(r),n}function de(e,t,n,r){let a=i.get(t);if(!a.problems)return r;r||=e.tr;let o=[];for(let e=0;e<a.height;e++)o.push(0);for(let e=0;e<a.problems.length;e++){let i=a.problems[e];if(i.type==`collision`){let e=t.nodeAt(i.pos);if(!e)continue;let a=e.attrs;for(let e=0;e<a.rowspan;e++)o[i.row+e]+=i.n;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,x(a,a.colspan-i.n,i.n))}else if(i.type==`missing`)o[i.row]+=i.n;else if(i.type==`overlong_rowspan`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-i.n})}else if(i.type==`colwidth mismatch`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,colwidth:i.colwidth})}else if(i.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,c;for(let e=0;e<o.length;e++)o[e]&&(s??=e,c=e);for(let i=0,l=n+1;i<a.height;i++){let n=t.child(i),a=l+n.nodeSize,u=o[i];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let o=[];for(let n=0;n<u;n++){let n=p(e.schema)[t].createAndFill();n&&o.push(n)}let d=(i==0||s==i-1)&&c==i?l+1:a-1;r.insert(r.mapping.map(d),o)}l=a}return r.setMeta(le,{fixTables:!0})}function w(e){let t=i.get(e),n=[],r=t.height,a=t.width;for(let i=0;i<r;i++){let r=[];for(let n=0;n<a;n++){let o=i*a+n,s=t.map[o];if(i>0){let e=o-a;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function T(e,t){let n=[],r=i.get(e),a=r.height,o=r.width;for(let i=0;i<a;i++){let a=e.child(i),s=[];for(let n=0;n<o;n++){let a=t[i][n];if(!a)continue;let o=r.map[i*r.width+n],c=e.nodeAt(o);if(!c)continue;let l=c.type.createChecked(a.attrs,a.content,a.marks);s.push(l)}let c=a.type.createChecked(a.attrs,s,a.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function E(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function D(e){return fe(e=>e.type.spec.tableRole===`table`,e)}function fe(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function O(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function k(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function A(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=O(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=O(r,e.selection),s=k(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=O(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function j(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=k(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=k(r,e.selection),s=O(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=k(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function M(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function pe(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=A(t,n)?.indexes,l=A(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=me(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(d.height-1,p,u),h=t.doc.resolve(f+m),g=d.positionAt(0,p,u),_=t.doc.resolve(f+g);return t.setSelection(S.colSelection(h,_)),!0}function me(e,t,n,r){let i=M(w(e));return i=E(i,t,n,r),i=M(i),T(e,i)}function he(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=j(t,n)?.indexes,l=j(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=ge(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(p,d.width-1,u),h=t.doc.resolve(f+m),g=d.positionAt(p,0,u),_=t.doc.resolve(f+g);return t.setSelection(S.rowSelection(h,_)),!0}function ge(e,t,n,r){let i=w(e);return i=E(i,t,n,r),T(e,i)}function N(e){let t=e.selection,n=_(e),r=n.node(-1),a=n.start(-1),o=i.get(r);return{...t instanceof S?o.rectBetween(t.$anchorCell.pos-a,t.$headCell.pos-a):o.findCell(n.pos-a),tableStart:a,map:o,table:r}}function P(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;re(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,ne(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?p(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function _e(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.left))}return!0}function ve(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.right))}return!0}function ye(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,x(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function be(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ye(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(e)}t(r)}return!0}function xe(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function F(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;xe(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?p(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,p(r.type.schema).row.create(null,o)),e}function Se(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.top))}return!0}function Ce(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.bottom))}return!0}function we(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Te(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;we(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(n.table)}t(r)}return!0}function Ee(e,t){return function(n,r){if(!g(n))return!1;let i=_(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof S?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function De(e){return function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function I(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function L(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?De(e):function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=I(`row`,i,r),s=I(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}L(`row`,{useDeprecatedLogic:!0}),L(`column`,{useDeprecatedLogic:!0}),L(`cell`,{useDeprecatedLogic:!0});function Oe(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function ke(e){return function(n,r){if(!g(n))return!1;let i=Oe(_(n),e);if(i==null)return!1;if(r){let e=n.doc.resolve(i);r(n.tr.setSelection(t.c.between(e,te(e))).scrollIntoView())}return!0}}function Ae(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function R(e,n){let r=e.selection;if(!(r instanceof S))return!1;if(n){let i=e.tr,a=p(e.schema).cell.createAndFill().content;r.forEachCell((e,n)=>{e.content.eq(a)||i.replace(i.mapping.map(n+1),i.mapping.map(n+e.nodeSize-1),new t.A(a,0,0))}),i.docChanged&&n(i)}return!0}function je(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return he({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Me(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return pe({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ne(e){if(e.size===0)return null;let{content:n,openStart:r,openEnd:i}=e;for(;n.childCount==1&&(r>0&&i>0||n.child(0).type.spec.tableRole==`table`);)r--,i--,n=n.child(0).content;let a=n.child(0),o=a.type.spec.tableRole,s=a.type.schema,c=[];if(o==`row`)for(let e=0;e<n.childCount;e++){let a=n.child(e).content,o=e?0:Math.max(0,r-1),l=e<n.childCount-1?0:Math.max(0,i-1);(o||l)&&(a=z(p(s).row,new t.A(a,o,l)).content),c.push(a)}else if(o==`cell`||o==`header_cell`)c.push(r||i?z(p(s).row,new t.A(n,r,i)).content:n);else return null;return Pe(s,c)}function Pe(e,n){let r=[];for(let e=0;e<n.length;e++){let t=n[e];for(let n=t.childCount-1;n>=0;n--){let{rowspan:i,colspan:a}=t.child(n).attrs;for(let t=e;t<e+i;t++)r[t]=(r[t]||0)+a}}let i=0;for(let e=0;e<r.length;e++)i=Math.max(i,r[e]);for(let a=0;a<r.length;a++)if(a>=n.length&&n.push(t.w.empty),r[a]<i){let o=p(e).cell.createAndFill(),s=[];for(let e=r[a];e<i;e++)s.push(o);n[a]=n[a].append(t.w.from(s))}return{height:n.length,width:i,rows:n}}function z(e,n){let r=e.createAndFill();return new t.m(r).replace(0,r.content.size,n).doc}function Fe({width:e,height:n,rows:r},i,a){if(e!=i){let n=[],a=[];for(let e=0;e<r.length;e++){let o=r[e],s=[];for(let t=n[e]||0,r=0;t<i;r++){let a=o.child(r%o.childCount);t+a.attrs.colspan>i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,t+a.attrs.colspan-i),a.content)),s.push(a),t+=a.attrs.colspan;for(let t=1;t<a.attrs.rowspan;t++)n[e+t]=(n[e+t]||0)+a.attrs.colspan}a.push(t.w.from(s))}r=a,e=i}if(n!=a){let e=[];for(let i=0,o=0;i<a;i++,o++){let s=[],c=r[o%n];for(let e=0;e<c.childCount;e++){let t=c.child(e);i+t.attrs.rowspan>a&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,a-t.attrs.rowspan)},t.content)),s.push(t)}e.push(t.w.from(s))}r=e,n=a}return{width:e,height:n,rows:r}}function Ie(e,n,r,i,a,o,s){let c=e.doc.type.schema,l=p(c),u,d;if(a>n.width)for(let t=0,o=0;t<n.height;t++){let c=r.child(t);o+=c.nodeSize;let f=[],p;p=c.lastChild==null||c.lastChild.type==l.cell?u||=l.cell.createAndFill():d||=l.header_cell.createAndFill();for(let e=n.width;e<a;e++)f.push(p);e.insert(e.mapping.slice(s).map(o-1+i),f)}if(o>n.height){let c=[];for(let e=0,t=(n.height-1)*n.width;e<Math.max(n.width,a);e++){let i=e>=n.width?!1:r.nodeAt(n.map[t+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,t.w.from(c)),p=[];for(let e=n.height;e<o;e++)p.push(f);e.insert(e.mapping.slice(s).map(i+r.nodeSize-2),p)}return!!(u||d)}function B(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function V(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,x(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(x(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function H(e,n,r,a,o){let s=r?e.doc.nodeAt(r-1):e.doc;if(!s)throw Error(`No table found`);let c=i.get(s),{top:l,left:u}=a,d=u+o.width,f=l+o.height,p=e.tr,m=0;function h(){if(s=r?p.doc.nodeAt(r-1):p.doc,!s)throw Error(`No table found`);c=i.get(s),m=p.mapping.maps.length}Ie(p,c,s,r,d,f,m)&&h(),B(p,c,s,r,u,d,l,m)&&h(),B(p,c,s,r,u,d,f,m)&&h(),V(p,c,s,r,l,f,u,m)&&h(),V(p,c,s,r,l,f,d,m)&&h();for(let e=l;e<f;e++){let n=c.positionAt(e,u,s),i=c.positionAt(e,d,s);p.replace(p.mapping.slice(m).map(n+r),p.mapping.slice(m).map(i+r),new t.A(o.rows[e-l],0,0))}h(),p.setSelection(new S(p.doc.resolve(r+c.positionAt(l,u,s)),p.doc.resolve(r+c.positionAt(f-1,d-1,s)))),n(p)}var Le=e.N({ArrowLeft:W(`horiz`,-1),ArrowRight:W(`horiz`,1),ArrowUp:W(`vert`,-1),ArrowDown:W(`vert`,1),"Shift-ArrowLeft":G(`horiz`,-1),"Shift-ArrowRight":G(`horiz`,1),"Shift-ArrowUp":G(`vert`,-1),"Shift-ArrowDown":G(`vert`,1),Backspace:R,"Mod-Backspace":R,Delete:R,"Mod-Delete":R});function U(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function W(e,n){return(r,i,a)=>{if(!a)return!1;let o=r.selection;if(o instanceof S)return U(r,i,t.o.near(o.$headCell,n));if(e!=`horiz`&&!o.empty)return!1;let s=K(a,e,n);if(s==null)return!1;if(e==`horiz`)return U(r,i,t.o.near(r.doc.resolve(o.head+n),n));{let a=r.doc.resolve(s),o=b(a,e,n),c;return c=o?t.o.near(o,1):n<0?t.o.near(r.doc.resolve(a.before(-1)),-1):t.o.near(r.doc.resolve(a.after(-1)),1),U(r,i,c)}}}function G(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof S)o=a;else{let r=K(i,e,t);if(r==null)return!1;o=new S(n.doc.resolve(r))}let s=b(o.$headCell,e,t);return s?U(n,r,new S(o.$anchorCell,s)):!1}}function Re(e,t){let n=e.state.doc,r=h(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new S(r))),!0):!1}function ze(e,n,r){if(!g(e.state))return!1;let a=Ne(r),o=e.state.selection;if(o instanceof S){a||={width:1,height:1,rows:[t.w.from(z(p(e.state.schema).cell,r))]};let n=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),c=i.get(n).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return a=Fe(a,c.right-c.left,c.bottom-c.top),H(e.state,e.dispatch,s,c,a),!0}else if(a){let t=_(e.state),n=t.start(-1);return H(e.state,e.dispatch,n,i.get(t.node(-1)).findCell(t.pos-n),a),!0}else return!1}function Be(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=q(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=h(e.state.selection.$anchor))!=null&&J(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=J(e,n),i=m.getState(e.state)==null;if(!r||!y(t,r))if(i)r=t;else return;let a=new S(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(m,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),m.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(m,-1))}function o(r){let o=r,s=m.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(q(e,o.target)!=n&&(c=J(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function K(e,n,r){if(!(e.state.selection instanceof t.c))return null;let{$head:i}=e.state.selection;for(let t=i.depth-1;t>=0;t--){let a=i.node(t);if((r<0?i.index(t):i.indexAfter(t))!=(r<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=i.before(t),o=n==`vert`?r>0?`down`:`up`:r>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function q(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function J(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&h(e.state.doc.resolve(r))||h(e.state.doc.resolve(i))}var Ve=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Y(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,Y(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Y(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var X=new t.a(`tableColumnResizing`);function He({handleWidth:e=5,cellMinWidth:n=25,defaultCellMinWidth:r=100,View:i=Ve,lastColumnResizable:a=!0}={}){let o=new t.i({key:X,state:{init(e,t){var n;let a=(n=o.spec)==null||(n=n.props)==null?void 0:n.nodeViews,s=p(t.schema).table.name;return i&&a&&(a[s]=(e,t)=>new i(e,r,t)),new Ue(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=X.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{We(t,n,e,a)},mouseleave:e=>{Ge(e)},mousedown:(e,t)=>{Ke(e,t,n,r)}},decorations:e=>{let t=X.getState(e);if(t&&t.activeHandle>-1)return Qe(e,t.activeHandle)},nodeViews:{}}});return o}var Ue=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(X);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return v(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function We(e,t,n,r){if(!e.editable)return;let a=X.getState(e.state);if(a&&!a.dragging){let o=Je(t.target),s=-1;if(o){let{left:r,right:i}=o.getBoundingClientRect();t.clientX-r<=n?s=Z(e,t,`left`,n):i-t.clientX<=n&&(s=Z(e,t,`right`,n))}if(s!=a.activeHandle){if(!r&&s!==-1){let t=e.state.doc.resolve(s),n=t.node(-1),r=i.get(n),a=t.start(-1);if(r.colCount(t.pos-a)+t.nodeAfter.attrs.colspan-1==r.width-1)return}$(e,s)}}}function Ge(e){if(!e.editable)return;let t=X.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&$(e,-1)}function Ke(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=X.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=qe(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(X,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=X.getState(e.state);r?.dragging&&(Ye(e,r.activeHandle,Q(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(X,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=X.getState(e.state);if(i&&i.dragging){let a=Q(i.dragging,t,n);Xe(e,i.activeHandle,a,r)}}return Xe(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function qe(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Je(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Z(e,t,n,r){let a=n==`right`?-r:r,o=e.posAtCoords({left:t.clientX+a,top:t.clientY});if(!o)return-1;let{pos:s}=o,c=h(e.state.doc.resolve(s));if(!c)return-1;if(n==`right`)return c.pos;let l=i.get(c.node(-1)),u=c.start(-1),d=l.map.indexOf(c.pos-u);return d%l.width==0?-1:u+l.map[d-1]}function Q(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function $(e,t){e.dispatch(e.state.tr.setMeta(X,{setHandle:t}))}function Ye(e,t,n){let r=e.state.doc.resolve(t),a=r.node(-1),o=i.get(a),s=r.start(-1),c=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<o.height;e++){let t=e*o.width+c;if(e&&o.map[t]==o.map[t-o.width])continue;let r=o.map[t],i=a.nodeAt(r).attrs,u=i.colspan==1?0:c-o.colCount(r);if(i.colwidth&&i.colwidth[u]==n)continue;let d=i.colwidth?i.colwidth.slice():Ze(i.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...i,colwidth:d})}l.docChanged&&e.dispatch(l)}function Xe(e,t,n,r){let a=e.state.doc.resolve(t),o=a.node(-1),s=a.start(-1),c=i.get(o).colCount(a.pos-s)+a.nodeAfter.attrs.colspan-1,l=e.domAtPos(a.start(-1)).node;for(;l&&l.nodeName!=`TABLE`;)l=l.parentNode;l&&Y(o,l.firstChild,l,r,c,n)}function Ze(e){return Array(e).fill(0)}function Qe(t,n){let r=[],a=t.doc.resolve(n),o=a.node(-1);if(!o)return e.M.empty;let s=i.get(o),c=a.start(-1),l=s.colCount(a.pos-c)+a.nodeAfter.attrs.colspan-1;for(let n=0;n<s.height;n++){let i=l+n*s.width;if((l==s.width-1||s.map[i]!=s.map[i+1])&&(n==0||s.map[i]!=s.map[i-s.width])){let n=s.map[i],a=c+n+o.nodeAt(n).nodeSize-1,l=document.createElement(`div`);l.className=`column-resize-handle`,X.getState(t)?.dragging&&r.push(e.j.node(c+n,c+n+o.nodeAt(n).nodeSize,{class:`column-resize-dragging`})),r.push(e.j.widget(a,l))}}return e.M.create(t.doc,r)}function $e({allowTableNodeSelection:e=!1}={}){return new t.i({key:m,state:{init(){return null},apply(e,t){let n=e.getMeta(m);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:ae,handleDOMEvents:{mousedown:Be},createSelectionBetween(e){return m.getState(e.state)==null?null:e.state.selection},handleTripleClick:Re,handleKeyDown:Le,handlePaste:ze},appendTransaction(t,n,r){return ce(r,ue(r,n),e)}})}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return f}});
1
+ const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs");var n,r;if(typeof WeakMap<`u`){let e=new WeakMap;n=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;n=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},r=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var i=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw 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 RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return n(e)||r(e,a(e))}};function a(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=o(e),n=e.childCount,r=[],a=0,c=null,l=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let i=0,o=0;i<n;i++){let s=e.child(i);o++;for(let e=0;;e++){for(;a<r.length&&r[a]!=0;)a++;if(e==s.childCount)break;let u=s.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+i>=n){(c||=[]).push({type:`overlong_rowspan`,pos:o,n:f-e});break}let s=a+e*t;for(let e=0;e<d;e++){r[s+e]==0?r[s+e]=o:(c||=[]).push({type:`collision`,row:i,pos:o,n:d-e});let n=p&&p[e];if(n){let r=(s+e)%t*2,i=l[r];i==null||i!=n&&l[r+1]==1?(l[r]=n,l[r+1]=1):i==n&&l[r+1]++}}}a+=d,o+=u.nodeSize}let u=(i+1)*t,d=0;for(;a<u;)r[a++]==0&&d++;d&&(c||=[]).push({type:`missing`,row:i,n:d}),o++}(t===0||n===0)&&(c||=[]).push({type:`zero_sized`});let u=new i(t,n,r,c),d=!1;for(let e=0;!d&&e<l.length;e+=2)l[e]!=null&&l[e+1]<n&&(d=!0);return d&&s(u,l,e),u}function o(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function s(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!l.colwidth||l.colwidth[n]!=r)&&((s||=c(l))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function c(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function l(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function u(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function d(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function f(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:d}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>l(e,t)}],toDOM(e){return[`td`,u(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>l(e,t)}],toDOM(e){return[`th`,u(e,t),0]}}}}function p(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var m=new t.a(`selectingCells`);function h(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function g(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function _(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=h(t.$head)||ee(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function ee(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function v(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function te(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function y(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function b(e,t,n){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.nextCell(e.pos-o,t,n);return s==null?null:e.node(0).resolve(o+s)}function x(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function ne(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function re(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var S=class e extends t.o{constructor(e,n=e){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.rectBetween(e.pos-o,n.pos-o),c=e.node(0),l=a.cellsInRect(s).filter(e=>e!=n.pos-o);l.unshift(n.pos-o);let u=l.map(e=>{let n=r.nodeAt(e);if(!n)throw RangeError(`No cell with offset ${e} found`);let i=o+e+1;return new t.s(c.resolve(i),c.resolve(i+n.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(n,r){let i=n.resolve(r.map(this.$anchorCell.pos)),a=n.resolve(r.map(this.$headCell.pos));if(v(i)&&v(a)&&y(i,a)){let t=this.$anchorCell.node(-1)!=i.node(-1);return t&&this.isRowSelection()?e.rowSelection(i,a):t&&this.isColSelection()?e.colSelection(i,a):new e(i,a)}return t.c.between(i,a)}content(){let e=this.$anchorCell.node(-1),n=i.get(e),r=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let r=a.top;r<a.bottom;r++){let i=[];for(let t=r*n.width+a.left,s=a.left;s<a.right;s++,t++){let r=n.map[t];if(o[r])continue;o[r]=!0;let s=n.findCell(r),c=e.nodeAt(r);if(!c)throw RangeError(`No cell with offset ${r} found`);let l=a.left-s.left,u=s.right-a.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=x(e,0,l)),u>0&&(e=x(e,e.colspan-u,u)),s.left<a.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<a.top||s.bottom>a.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,a.bottom)-Math.max(s.top,a.top)};c=s.top<a.top?c.type.createAndFill(e):c.type.create(e,c.content)}i.push(c)}s.push(e.child(r).copy(t.w.from(i)))}let c=this.isColSelection()&&this.isRowSelection()?e:s;return new t.A(t.w.from(c),1,1)}replace(e,n=t.A.empty){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:s}=i[a],c=e.mapping.slice(r);e.replace(c.map(o.pos),c.map(s.pos),a?t.A.empty:n)}let a=t.o.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);a&&e.setSelection(a)}replaceWith(e,n){this.replace(e,new t.A(t.w.from(n),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=i.get(t),r=this.$anchorCell.start(-1),a=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<a.length;n++)e(t.nodeAt(a[n]),r+a[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.top<=c.top?(s.top>0&&(t=l.resolve(o+a.map[s.left])),c.bottom<a.height&&(n=l.resolve(o+a.map[a.width*(a.height-1)+c.right-1]))):(c.top>0&&(n=l.resolve(o+a.map[c.left])),s.bottom<a.height&&(t=l.resolve(o+a.map[a.width*(a.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=i.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),a=t.colCount(this.$headCell.pos-n);if(Math.min(r,a)>0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.left<=c.left?(s.left>0&&(t=l.resolve(o+a.map[s.top*a.width])),c.right<a.width&&(n=l.resolve(o+a.map[a.width*(c.top+1)-1]))):(c.left>0&&(n=l.resolve(o+a.map[c.top*a.width])),s.right<a.width&&(t=l.resolve(o+a.map[a.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new ie(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1,t.o.jsonID(`cell`,S);var ie=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole==`row`&&r.parent.type.spec.tableRole==`row`&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&y(n,r)?new S(n,r):t.o.near(r,1)}};function ae(t){if(!(t.selection instanceof S))return null;let n=[];return t.selection.forEachCell((t,r)=>{n.push(e.j.node(r,r+t.nodeSize,{class:`selectedCell`}))}),e.M.create(t.doc,n)}function oe({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function se({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function ce(e,n,r){let a=(n||e).selection,o=(n||e).doc,s,c;if(a instanceof t.r&&(c=a.node.type.spec.tableRole)){if(c==`cell`||c==`header_cell`)s=S.create(o,a.from);else if(c==`row`){let e=o.resolve(a.from+1);s=S.rowSelection(e,e)}else if(!r){let e=i.get(a.node),t=a.from+1,n=t+e.map[e.width*e.height-1];s=S.create(o,t+1,n)}}else a instanceof t.c&&oe(a)?s=t.c.create(o,a.from):a instanceof t.c&&se(a)&&(s=t.c.create(o,a.$from.start(),a.$from.end()));return s&&(n||=e.tr).setSelection(s),n}var le=new t.a(`fix-tables`);function C(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?C(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ue(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=de(e,t,r,n))};return t?t.doc!=e.doc&&C(t.doc,e.doc,0,r):e.doc.descendants(r),n}function de(e,t,n,r){let a=i.get(t);if(!a.problems)return r;r||=e.tr;let o=[];for(let e=0;e<a.height;e++)o.push(0);for(let e=0;e<a.problems.length;e++){let i=a.problems[e];if(i.type==`collision`){let e=t.nodeAt(i.pos);if(!e)continue;let a=e.attrs;for(let e=0;e<a.rowspan;e++)o[i.row+e]+=i.n;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,x(a,a.colspan-i.n,i.n))}else if(i.type==`missing`)o[i.row]+=i.n;else if(i.type==`overlong_rowspan`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-i.n})}else if(i.type==`colwidth mismatch`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,colwidth:i.colwidth})}else if(i.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,c;for(let e=0;e<o.length;e++)o[e]&&(s??=e,c=e);for(let i=0,l=n+1;i<a.height;i++){let n=t.child(i),a=l+n.nodeSize,u=o[i];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let o=[];for(let n=0;n<u;n++){let n=p(e.schema)[t].createAndFill();n&&o.push(n)}let d=(i==0||s==i-1)&&c==i?l+1:a-1;r.insert(r.mapping.map(d),o)}l=a}return r.setMeta(le,{fixTables:!0})}function w(e){let t=i.get(e),n=[],r=t.height,a=t.width;for(let i=0;i<r;i++){let r=[];for(let n=0;n<a;n++){let o=i*a+n,s=t.map[o];if(i>0){let e=o-a;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function T(e,t){let n=[],r=i.get(e),a=r.height,o=r.width;for(let i=0;i<a;i++){let a=e.child(i),s=[];for(let n=0;n<o;n++){let a=t[i][n];if(!a)continue;let o=r.map[i*r.width+n],c=e.nodeAt(o);if(!c)continue;let l=c.type.createChecked(a.attrs,a.content,a.marks);s.push(l)}let c=a.type.createChecked(a.attrs,s,a.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function E(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function D(e){return fe(e=>e.type.spec.tableRole===`table`,e)}function fe(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function O(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function k(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function A(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=O(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=O(r,e.selection),s=k(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=O(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function j(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=k(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=k(r,e.selection),s=O(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=k(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function M(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function pe(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=A(t,n)?.indexes,l=A(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=me(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(d.height-1,p,u),h=t.doc.resolve(f+m),g=d.positionAt(0,p,u),_=t.doc.resolve(f+g);return t.setSelection(S.colSelection(h,_)),!0}function me(e,t,n,r){let i=M(w(e));return i=E(i,t,n,r),i=M(i),T(e,i)}function he(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=j(t,n)?.indexes,l=j(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=ge(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(p,d.width-1,u),h=t.doc.resolve(f+m),g=d.positionAt(p,0,u),_=t.doc.resolve(f+g);return t.setSelection(S.rowSelection(h,_)),!0}function ge(e,t,n,r){let i=w(e);return i=E(i,t,n,r),T(e,i)}function N(e){let t=e.selection,n=_(e),r=n.node(-1),a=n.start(-1),o=i.get(r);return{...t instanceof S?o.rectBetween(t.$anchorCell.pos-a,t.$headCell.pos-a):o.findCell(n.pos-a),tableStart:a,map:o,table:r}}function P(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;re(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,ne(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?p(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function _e(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.left))}return!0}function ve(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.right))}return!0}function ye(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,x(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function be(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ye(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(e)}t(r)}return!0}function xe(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function F(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;xe(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?p(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,p(r.type.schema).row.create(null,o)),e}function Se(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.top))}return!0}function Ce(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.bottom))}return!0}function we(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Te(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;we(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(n.table)}t(r)}return!0}function Ee(e,t){return function(n,r){if(!g(n))return!1;let i=_(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof S?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function De(e){return function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function I(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function L(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?De(e):function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=I(`row`,i,r),s=I(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}L(`row`,{useDeprecatedLogic:!0}),L(`column`,{useDeprecatedLogic:!0}),L(`cell`,{useDeprecatedLogic:!0});function Oe(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function ke(e){return function(n,r){if(!g(n))return!1;let i=Oe(_(n),e);if(i==null)return!1;if(r){let e=n.doc.resolve(i);r(n.tr.setSelection(t.c.between(e,te(e))).scrollIntoView())}return!0}}function Ae(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function R(e,n){let r=e.selection;if(!(r instanceof S))return!1;if(n){let i=e.tr,a=p(e.schema).cell.createAndFill().content;r.forEachCell((e,n)=>{e.content.eq(a)||i.replace(i.mapping.map(n+1),i.mapping.map(n+e.nodeSize-1),new t.A(a,0,0))}),i.docChanged&&n(i)}return!0}function je(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return he({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Me(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return pe({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ne(e){if(e.size===0)return null;let{content:n,openStart:r,openEnd:i}=e;for(;n.childCount==1&&(r>0&&i>0||n.child(0).type.spec.tableRole==`table`);)r--,i--,n=n.child(0).content;let a=n.child(0),o=a.type.spec.tableRole,s=a.type.schema,c=[];if(o==`row`)for(let e=0;e<n.childCount;e++){let a=n.child(e).content,o=e?0:Math.max(0,r-1),l=e<n.childCount-1?0:Math.max(0,i-1);(o||l)&&(a=z(p(s).row,new t.A(a,o,l)).content),c.push(a)}else if(o==`cell`||o==`header_cell`)c.push(r||i?z(p(s).row,new t.A(n,r,i)).content:n);else return null;return Pe(s,c)}function Pe(e,n){let r=[];for(let e=0;e<n.length;e++){let t=n[e];for(let n=t.childCount-1;n>=0;n--){let{rowspan:i,colspan:a}=t.child(n).attrs;for(let t=e;t<e+i;t++)r[t]=(r[t]||0)+a}}let i=0;for(let e=0;e<r.length;e++)i=Math.max(i,r[e]);for(let a=0;a<r.length;a++)if(a>=n.length&&n.push(t.w.empty),r[a]<i){let o=p(e).cell.createAndFill(),s=[];for(let e=r[a];e<i;e++)s.push(o);n[a]=n[a].append(t.w.from(s))}return{height:n.length,width:i,rows:n}}function z(e,n){let r=e.createAndFill();return new t.m(r).replace(0,r.content.size,n).doc}function Fe({width:e,height:n,rows:r},i,a){if(e!=i){let n=[],a=[];for(let e=0;e<r.length;e++){let o=r[e],s=[];for(let t=n[e]||0,r=0;t<i;r++){let a=o.child(r%o.childCount);t+a.attrs.colspan>i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,t+a.attrs.colspan-i),a.content)),s.push(a),t+=a.attrs.colspan;for(let t=1;t<a.attrs.rowspan;t++)n[e+t]=(n[e+t]||0)+a.attrs.colspan}a.push(t.w.from(s))}r=a,e=i}if(n!=a){let e=[];for(let i=0,o=0;i<a;i++,o++){let s=[],c=r[o%n];for(let e=0;e<c.childCount;e++){let t=c.child(e);i+t.attrs.rowspan>a&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,a-t.attrs.rowspan)},t.content)),s.push(t)}e.push(t.w.from(s))}r=e,n=a}return{width:e,height:n,rows:r}}function Ie(e,n,r,i,a,o,s){let c=e.doc.type.schema,l=p(c),u,d;if(a>n.width)for(let t=0,o=0;t<n.height;t++){let c=r.child(t);o+=c.nodeSize;let f=[],p;p=c.lastChild==null||c.lastChild.type==l.cell?u||=l.cell.createAndFill():d||=l.header_cell.createAndFill();for(let e=n.width;e<a;e++)f.push(p);e.insert(e.mapping.slice(s).map(o-1+i),f)}if(o>n.height){let c=[];for(let e=0,t=(n.height-1)*n.width;e<Math.max(n.width,a);e++){let i=e>=n.width?!1:r.nodeAt(n.map[t+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,t.w.from(c)),p=[];for(let e=n.height;e<o;e++)p.push(f);e.insert(e.mapping.slice(s).map(i+r.nodeSize-2),p)}return!!(u||d)}function B(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function V(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,x(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(x(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function H(e,n,r,a,o){let s=r?e.doc.nodeAt(r-1):e.doc;if(!s)throw Error(`No table found`);let c=i.get(s),{top:l,left:u}=a,d=u+o.width,f=l+o.height,p=e.tr,m=0;function h(){if(s=r?p.doc.nodeAt(r-1):p.doc,!s)throw Error(`No table found`);c=i.get(s),m=p.mapping.maps.length}Ie(p,c,s,r,d,f,m)&&h(),B(p,c,s,r,u,d,l,m)&&h(),B(p,c,s,r,u,d,f,m)&&h(),V(p,c,s,r,l,f,u,m)&&h(),V(p,c,s,r,l,f,d,m)&&h();for(let e=l;e<f;e++){let n=c.positionAt(e,u,s),i=c.positionAt(e,d,s);p.replace(p.mapping.slice(m).map(n+r),p.mapping.slice(m).map(i+r),new t.A(o.rows[e-l],0,0))}h(),p.setSelection(new S(p.doc.resolve(r+c.positionAt(l,u,s)),p.doc.resolve(r+c.positionAt(f-1,d-1,s)))),n(p)}var Le=e.N({ArrowLeft:W(`horiz`,-1),ArrowRight:W(`horiz`,1),ArrowUp:W(`vert`,-1),ArrowDown:W(`vert`,1),"Shift-ArrowLeft":G(`horiz`,-1),"Shift-ArrowRight":G(`horiz`,1),"Shift-ArrowUp":G(`vert`,-1),"Shift-ArrowDown":G(`vert`,1),Backspace:R,"Mod-Backspace":R,Delete:R,"Mod-Delete":R});function U(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function W(e,n){return(r,i,a)=>{if(!a)return!1;let o=r.selection;if(o instanceof S)return U(r,i,t.o.near(o.$headCell,n));if(e!=`horiz`&&!o.empty)return!1;let s=K(a,e,n);if(s==null)return!1;if(e==`horiz`)return U(r,i,t.o.near(r.doc.resolve(o.head+n),n));{let a=r.doc.resolve(s),o=b(a,e,n),c;return c=o?t.o.near(o,1):n<0?t.o.near(r.doc.resolve(a.before(-1)),-1):t.o.near(r.doc.resolve(a.after(-1)),1),U(r,i,c)}}}function G(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof S)o=a;else{let r=K(i,e,t);if(r==null)return!1;o=new S(n.doc.resolve(r))}let s=b(o.$headCell,e,t);return s?U(n,r,new S(o.$anchorCell,s)):!1}}function Re(e,t){let n=e.state.doc,r=h(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new S(r))),!0):!1}function ze(e,n,r){if(!g(e.state))return!1;let a=Ne(r),o=e.state.selection;if(o instanceof S){a||={width:1,height:1,rows:[t.w.from(z(p(e.state.schema).cell,r))]};let n=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),c=i.get(n).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return a=Fe(a,c.right-c.left,c.bottom-c.top),H(e.state,e.dispatch,s,c,a),!0}else if(a){let t=_(e.state),n=t.start(-1);return H(e.state,e.dispatch,n,i.get(t.node(-1)).findCell(t.pos-n),a),!0}else return!1}function Be(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=q(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=h(e.state.selection.$anchor))!=null&&J(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=J(e,n),i=m.getState(e.state)==null;if(!r||!y(t,r))if(i)r=t;else return;let a=new S(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(m,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),m.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(m,-1))}function o(r){let o=r,s=m.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(q(e,o.target)!=n&&(c=J(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function K(e,n,r){if(!(e.state.selection instanceof t.c))return null;let{$head:i}=e.state.selection;for(let t=i.depth-1;t>=0;t--){let a=i.node(t);if((r<0?i.index(t):i.indexAfter(t))!=(r<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=i.before(t),o=n==`vert`?r>0?`down`:`up`:r>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function q(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function J(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&h(e.state.doc.resolve(r))||h(e.state.doc.resolve(i))}var Ve=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Y(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,Y(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Y(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var X=new t.a(`tableColumnResizing`);function He({handleWidth:e=5,cellMinWidth:n=25,defaultCellMinWidth:r=100,View:i=Ve,lastColumnResizable:a=!0}={}){let o=new t.i({key:X,state:{init(e,t){var n;let a=(n=o.spec)==null||(n=n.props)==null?void 0:n.nodeViews,s=p(t.schema).table.name;return i&&a&&(a[s]=(e,t)=>new i(e,r,t)),new Ue(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=X.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{We(t,n,e,a)},mouseleave:e=>{Ge(e)},mousedown:(e,t)=>{Ke(e,t,n,r)}},decorations:e=>{let t=X.getState(e);if(t&&t.activeHandle>-1)return Qe(e,t.activeHandle)},nodeViews:{}}});return o}var Ue=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(X);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return v(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function We(e,t,n,r){if(!e.editable)return;let a=X.getState(e.state);if(a&&!a.dragging){let o=Je(t.target),s=-1;if(o){let{left:r,right:i}=o.getBoundingClientRect();t.clientX-r<=n?s=Z(e,t,`left`,n):i-t.clientX<=n&&(s=Z(e,t,`right`,n))}if(s!=a.activeHandle){if(!r&&s!==-1){let t=e.state.doc.resolve(s),n=t.node(-1),r=i.get(n),a=t.start(-1);if(r.colCount(t.pos-a)+t.nodeAfter.attrs.colspan-1==r.width-1)return}$(e,s)}}}function Ge(e){if(!e.editable)return;let t=X.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&$(e,-1)}function Ke(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=X.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=qe(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(X,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=X.getState(e.state);r?.dragging&&(Ye(e,r.activeHandle,Q(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(X,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=X.getState(e.state);if(i&&i.dragging){let a=Q(i.dragging,t,n);Xe(e,i.activeHandle,a,r)}}return Xe(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function qe(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Je(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Z(e,t,n,r){let a=n==`right`?-r:r,o=e.posAtCoords({left:t.clientX+a,top:t.clientY});if(!o)return-1;let{pos:s}=o,c=h(e.state.doc.resolve(s));if(!c)return-1;if(n==`right`)return c.pos;let l=i.get(c.node(-1)),u=c.start(-1),d=l.map.indexOf(c.pos-u);return d%l.width==0?-1:u+l.map[d-1]}function Q(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function $(e,t){e.dispatch(e.state.tr.setMeta(X,{setHandle:t}))}function Ye(e,t,n){let r=e.state.doc.resolve(t),a=r.node(-1),o=i.get(a),s=r.start(-1),c=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<o.height;e++){let t=e*o.width+c;if(e&&o.map[t]==o.map[t-o.width])continue;let r=o.map[t],i=a.nodeAt(r).attrs,u=i.colspan==1?0:c-o.colCount(r);if(i.colwidth&&i.colwidth[u]==n)continue;let d=i.colwidth?i.colwidth.slice():Ze(i.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...i,colwidth:d})}l.docChanged&&e.dispatch(l)}function Xe(e,t,n,r){let a=e.state.doc.resolve(t),o=a.node(-1),s=a.start(-1),c=i.get(o).colCount(a.pos-s)+a.nodeAfter.attrs.colspan-1,l=e.domAtPos(a.start(-1)).node;for(;l&&l.nodeName!=`TABLE`;)l=l.parentNode;l&&Y(o,l.firstChild,l,r,c,n)}function Ze(e){return Array(e).fill(0)}function Qe(t,n){let r=[],a=t.doc.resolve(n),o=a.node(-1);if(!o)return e.M.empty;let s=i.get(o),c=a.start(-1),l=s.colCount(a.pos-c)+a.nodeAfter.attrs.colspan-1;for(let n=0;n<s.height;n++){let i=l+n*s.width;if((l==s.width-1||s.map[i]!=s.map[i+1])&&(n==0||s.map[i]!=s.map[i-s.width])){let n=s.map[i],a=c+n+o.nodeAt(n).nodeSize-1,l=document.createElement(`div`);l.className=`column-resize-handle`,X.getState(t)?.dragging&&r.push(e.j.node(c+n,c+n+o.nodeAt(n).nodeSize,{class:`column-resize-dragging`})),r.push(e.j.widget(a,l))}}return e.M.create(t.doc,r)}function $e({allowTableNodeSelection:e=!1}={}){return new t.i({key:m,state:{init(){return null},apply(e,t){let n=e.getMeta(m);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:ae,handleDOMEvents:{mousedown:Be},createSelectionBetween(e){return m.getState(e.state)==null?null:e.state.selection},handleTripleClick:Re,handleKeyDown:Le,handlePaste:ze},appendTransaction(t,n,r){return ce(r,ue(r,n),e)}})}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return f}});
@@ -0,0 +1 @@
1
+ var e=[`top`,`right`,`bottom`,`left`],t=Math.min,n=Math.max,r=Math.round,i=Math.floor,a=e=>({x:e,y:e}),o={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function s(e,r,i){return n(e,t(r,i))}function c(e,t){return typeof e==`function`?e(t):e}function l(e){return e.split(`-`)[0]}function u(e){return e.split(`-`)[1]}function d(e){return e===`x`?`y`:`x`}function f(e){return e===`y`?`height`:`width`}function p(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function m(e){return d(p(e))}function h(e,t,n){n===void 0&&(n=!1);let r=u(e),i=m(e),a=f(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=w(o)),[o,w(o)]}function g(e){let t=w(e);return[_(e),t,_(t)]}function _(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var v=[`left`,`right`],y=[`right`,`left`],b=[`top`,`bottom`],x=[`bottom`,`top`];function S(e,t,n){switch(e){case`top`:case`bottom`:return n?t?y:v:t?v:y;case`left`:case`right`:return t?b:x;default:return[]}}function C(e,t,n,r){let i=u(e),a=S(l(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(_)))),a}function w(e){let t=l(e);return o[t]+e.slice(t.length)}function T(e){return{top:0,right:0,bottom:0,left:0,...e}}function E(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:T(e)}function D(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function O(e,t,n){let{reference:r,floating:i}=e,a=p(t),o=m(t),s=f(o),c=l(t),d=a===`y`,h=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,_=r[s]/2-i[s]/2,v;switch(c){case`top`:v={x:h,y:r.y-i.height};break;case`bottom`:v={x:h,y:r.y+r.height};break;case`right`:v={x:r.x+r.width,y:g};break;case`left`:v={x:r.x-i.width,y:g};break;default:v={x:r.x,y:r.y}}switch(u(t)){case`start`:v[o]-=_*(n&&d?-1:1);break;case`end`:v[o]+=_*(n&&d?-1:1);break}return v}async function k(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=c(t,e),m=E(p),h=o[f?d===`floating`?`reference`:`floating`:d],g=D(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(h))??!0?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:l,rootBoundary:u,strategy:s})),_=d===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(v))&&await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1},b=D(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:v,strategy:s}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var A=50,j=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:k},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=O(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<A&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=O(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},M=e=>({name:`arrow`,options:e,async fn(n){let{x:r,y:i,placement:a,rects:o,platform:l,elements:d,middlewareData:p}=n,{element:h,padding:g=0}=c(e,n)||{};if(h==null)return{};let _=E(g),v={x:r,y:i},y=m(a),b=f(y),x=await l.getDimensions(h),S=y===`y`,C=S?`top`:`left`,w=S?`bottom`:`right`,T=S?`clientHeight`:`clientWidth`,D=o.reference[b]+o.reference[y]-v[y]-o.floating[b],O=v[y]-o.reference[y],k=await(l.getOffsetParent==null?void 0:l.getOffsetParent(h)),A=k?k[T]:0;(!A||!await(l.isElement==null?void 0:l.isElement(k)))&&(A=d.floating[T]||o.floating[b]);let j=D/2-O/2,M=A/2-x[b]/2-1,ee=t(_[C],M),N=t(_[w],M),P=ee,te=A-x[b]-N,F=A/2-x[b]/2+j,I=s(P,F,te),L=!p.arrow&&u(a)!=null&&F!==I&&o.reference[b]/2-(F<P?ee:N)-x[b]/2<0,R=L?F<P?F-P:F-te:0;return{[y]:v[y]+R,data:{[y]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ee=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:_=`bestFit`,fallbackAxisSideDirection:v=`none`,flipAlignment:y=!0,...b}=c(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let x=l(r),S=p(o),T=l(o)===o,E=await(s.isRTL==null?void 0:s.isRTL(u.floating)),D=m||(T||!y?[w(o)]:g(o)),O=v!==`none`;!m&&O&&D.push(...C(o,y,v,E));let k=[o,...D],A=await s.detectOverflow(t,b),j=[],M=i.flip?.overflows||[];if(d&&j.push(A[x]),f){let e=h(r,a,E);j.push(A[e[0]],A[e[1]])}if(M=[...M,{placement:r,overflows:j}],!j.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=k[e];if(t&&(!(f===`alignment`&&S!==p(t))||M.every(e=>p(e.placement)===S?e.overflows[0]>0:!0)))return{data:{index:e,overflows:M},reset:{placement:t}};let n=M.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(_){case`bestFit`:{let e=M.filter(e=>{if(O){let t=p(e.placement);return t===S||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function N(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function P(t){return e.some(e=>t[e]>=0)}var te=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=c(e,t);switch(i){case`referenceHidden`:{let e=N(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:P(e)}}}case`escaped`:{let e=N(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:P(e)}}}default:return{}}}}},F=new Set([`left`,`top`]);async function I(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=l(n),s=u(n),d=p(n)===`y`,f=F.has(o)?-1:1,m=a&&d?-1:1,h=c(t,e),{mainAxis:g,crossAxis:_,alignmentAxis:v}=typeof h==`number`?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return s&&typeof v==`number`&&(_=s===`end`?v*-1:v),d?{x:_*m,y:g*f}:{x:g*f,y:_*m}}var L=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await I(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},R=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:u=!1,limiter:f={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...m}=c(e,t),h={x:n,y:r},g=await a.detectOverflow(t,m),_=p(l(i)),v=d(_),y=h[v],b=h[_];if(o){let e=v===`y`?`top`:`left`,t=v===`y`?`bottom`:`right`,n=y+g[e],r=y-g[t];y=s(n,y,r)}if(u){let e=_===`y`?`top`:`left`,t=_===`y`?`bottom`:`right`,n=b+g[e],r=b-g[t];b=s(n,b,r)}let x=f.fn({...t,[v]:y,[_]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:o,[_]:u}}}}}},ne=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:u=!0,crossAxis:f=!0}=c(e,t),m={x:n,y:r},h=p(i),g=d(h),_=m[g],v=m[h],y=c(s,t),b=typeof y==`number`?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){let e=g===`y`?`height`:`width`,t=a.reference[g]-a.floating[e]+b.mainAxis,n=a.reference[g]+a.reference[e]-b.mainAxis;_<t?_=t:_>n&&(_=n)}if(f){let e=g===`y`?`width`:`height`,t=F.has(l(i)),n=a.reference[h]-a.floating[e]+(t&&o.offset?.[h]||0)+(t?0:b.crossAxis),r=a.reference[h]+a.reference[e]+(t?0:o.offset?.[h]||0)-(t?b.crossAxis:0);v<n?v=n:v>r&&(v=r)}return{[g]:_,[h]:v}}}},re=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(r){var i,a;let{placement:o,rects:s,platform:d,elements:f}=r,{apply:m=()=>{},...h}=c(e,r),g=await d.detectOverflow(r,h),_=l(o),v=u(o),y=p(o)===`y`,{width:b,height:x}=s.floating,S,C;_===`top`||_===`bottom`?(S=_,C=v===(await(d.isRTL==null?void 0:d.isRTL(f.floating))?`start`:`end`)?`left`:`right`):(C=_,S=v===`end`?`top`:`bottom`);let w=x-g.top-g.bottom,T=b-g.left-g.right,E=t(x-g[S],w),D=t(b-g[C],T),O=!r.middlewareData.shift,k=E,A=D;if((i=r.middlewareData.shift)!=null&&i.enabled.x&&(A=T),(a=r.middlewareData.shift)!=null&&a.enabled.y&&(k=w),O&&!v){let e=n(g.left,0),t=n(g.right,0),r=n(g.top,0),i=n(g.bottom,0);y?A=b-2*(e!==0||t!==0?e+t:n(g.left,g.right)):k=x-2*(r!==0||i!==0?r+i:n(g.top,g.bottom))}await m({...r,availableWidth:A,availableHeight:k});let j=await d.getDimensions(f.floating);return b!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function z(){return typeof window<`u`}function B(e){return ie(e)?(e.nodeName||``).toLowerCase():`#document`}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function H(e){return((ie(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ie(e){return z()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return z()?e instanceof Element||e instanceof V(e).Element:!1}function W(e){return z()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function ae(e){return!z()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}function G(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function oe(e){return/^(table|td|th)$/.test(B(e))}function K(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var se=/transform|translate|scale|rotate|perspective|filter/,ce=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,le;function ue(e){let t=U(e)?Y(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!fe()&&(q(t.backdropFilter)||q(t.filter))||se.test(t.willChange||``)||ce.test(t.contain||``)}function de(e){let t=X(e);for(;W(t)&&!J(t);){if(ue(t))return t;if(K(t))return null;t=X(t)}return null}function fe(){return le??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),le}function J(e){return/^(html|body|#document)$/.test(B(e))}function Y(e){return V(e).getComputedStyle(e)}function pe(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(B(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ae(e)&&e.host||H(e);return ae(t)?t.host:t}function me(e){let t=X(e);return J(t)?e.ownerDocument?e.ownerDocument.body:e.body:W(t)&&G(t)?t:me(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=me(e),i=r===e.ownerDocument?.body,a=V(r);if(i){let e=he(a);return t.concat(a,a.visualViewport||[],G(r)?r:[],e&&n?Z(e):[])}else return t.concat(r,Z(r,[],n))}function he(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ge(e){let t=Y(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,a=W(e),o=a?e.offsetWidth:n,s=a?e.offsetHeight:i,c=r(n)!==o||r(i)!==s;return c&&(n=o,i=s),{width:n,height:i,$:c}}function _e(e){return U(e)?e:e.contextElement}function Q(e){let t=_e(e);if(!W(t))return a(1);let n=t.getBoundingClientRect(),{width:i,height:o,$:s}=ge(t),c=(s?r(n.width):n.width)/i,l=(s?r(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}var ve=a(0);function ye(e){let t=V(e);return!fe()||!t.visualViewport?ve:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function be(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),o=_e(e),s=a(1);t&&(r?U(r)&&(s=Q(r)):s=Q(e));let c=be(o,n,r)?ye(o):a(0),l=(i.left+c.x)/s.x,u=(i.top+c.y)/s.y,d=i.width/s.x,f=i.height/s.y;if(o){let e=V(o),t=r&&U(r)?V(r):r,n=e,i=he(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,f*=e.y,l+=a,u+=o,n=V(i),i=he(n)}}return D({width:d,height:f,x:l,y:u})}function xe(e,t){let n=pe(e).scrollLeft;return t?t.left+n:$(H(e)).left+n}function Se(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-xe(e,n),y:n.top+t.scrollTop}}function Ce(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,o=i===`fixed`,s=H(r),c=t?K(t.floating):!1;if(r===s||c&&o)return n;let l={scrollLeft:0,scrollTop:0},u=a(1),d=a(0),f=W(r);if((f||!f&&!o)&&((B(r)!==`body`||G(s))&&(l=pe(r)),f)){let e=$(r);u=Q(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=s&&!f&&!o?Se(s,l):a(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-l.scrollTop*u.y+d.y+p.y}}function we(e){return Array.from(e.getClientRects())}function Te(e){let t=H(e),r=pe(e),i=e.ownerDocument.body,a=n(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=n(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),s=-r.scrollLeft+xe(e),c=-r.scrollTop;return Y(i).direction===`rtl`&&(s+=n(t.clientWidth,i.clientWidth)-a),{width:a,height:o,x:s,y:c}}var Ee=25;function De(e,t){let n=V(e),r=H(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=fe();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=xe(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ee&&(a-=o)}else l<=Ee&&(a+=l);return{width:a,height:o,x:s,y:c}}function Oe(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=W(e)?Q(e):a(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}function ke(e,t,n){let r;if(t===`viewport`)r=De(e,n);else if(t===`document`)r=Te(H(e));else if(U(t))r=Oe(t,n);else{let n=ye(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return D(r)}function Ae(e,t){let n=X(e);return n===t||!U(n)||J(n)?!1:Y(n).position===`fixed`||Ae(n,t)}function je(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>U(e)&&B(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?X(e):e;for(;U(o)&&!J(o);){let t=Y(o),n=ue(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||G(o)&&!n&&Ae(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Me(e){let{element:r,boundary:i,rootBoundary:a,strategy:o}=e,s=[...i===`clippingAncestors`?K(r)?[]:je(r,this._c):[].concat(i),a],c=ke(r,s[0],o),l=c.top,u=c.right,d=c.bottom,f=c.left;for(let e=1;e<s.length;e++){let i=ke(r,s[e],o);l=n(i.top,l),u=t(i.right,u),d=t(i.bottom,d),f=n(i.left,f)}return{width:u-f,height:d-l,x:f,y:l}}function Ne(e){let{width:t,height:n}=ge(e);return{width:t,height:n}}function Pe(e,t,n){let r=W(t),i=H(t),o=n===`fixed`,s=$(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=a(0);function u(){l.x=xe(i)}if(r||!r&&!o)if((B(t)!==`body`||G(i))&&(c=pe(t)),r){let e=$(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&u();o&&!r&&i&&u();let d=i&&!r&&!o?Se(i,c):a(0);return{x:s.left+c.scrollLeft-l.x-d.x,y:s.top+c.scrollTop-l.y-d.y,width:s.width,height:s.height}}function Fe(e){return Y(e).position===`static`}function Ie(e,t){if(!W(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return H(e)===n&&(n=n.ownerDocument.body),n}function Le(e,t){let n=V(e);if(K(e))return n;if(!W(e)){let t=X(e);for(;t&&!J(t);){if(U(t)&&!Fe(t))return t;t=X(t)}return n}let r=Ie(e,t);for(;r&&oe(r)&&Fe(r);)r=Ie(r,t);return r&&J(r)&&Fe(r)&&!ue(r)?n:r||de(e)||n}var Re=async function(e){let t=this.getOffsetParent||Le,n=this.getDimensions,r=await n(e.floating);return{reference:Pe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ze(e){return Y(e).direction===`rtl`}var Be={convertOffsetParentRelativeRectToViewportRelativeRect:Ce,getDocumentElement:H,getClippingRect:Me,getOffsetParent:Le,getElementRects:Re,getClientRects:we,getDimensions:Ne,getScale:Q,isElement:U,isRTL:ze};function Ve(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function He(e,r){let a=null,o,s=H(e);function c(){var e;clearTimeout(o),(e=a)==null||e.disconnect(),a=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),c();let f=e.getBoundingClientRect(),{left:p,top:m,width:h,height:g}=f;if(u||r(),!h||!g)return;let _=i(m),v=i(s.clientWidth-(p+h)),y=i(s.clientHeight-(m+g)),b=i(p),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:n(0,t(1,d))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==d){if(!S)return l();n?l(!1,n):o=setTimeout(()=>{l(!1,1e-7)},1e3)}n===1&&!Ve(f,e.getBoundingClientRect())&&l(),S=!1}try{a=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{a=new IntersectionObserver(C,x)}a.observe(e)}return l(!0),c}function Ue(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=_e(e),u=i||a?[...l?Z(l):[],...t?Z(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?He(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!Ve(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var We=L,Ge=R,Ke=ee,qe=re,Je=te,Ye=M,Xe=ne,Ze=(e,t,n)=>{let r=new Map,i={platform:Be,...n},a={...i.platform,_c:r};return j(e,t,{...i,platform:a})};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ye}});