quill-table-up 2.2.4 → 2.3.1

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.
package/dist/index.umd.js CHANGED
@@ -1,2 +1,136 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("quill")):"function"==typeof define&&define.amd?define(["exports","quill"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TableUp={},e.Quill)}(this,(function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(e,t,n,i,o,r,a){try{var l=e[r](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(i,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,r){var a=e.apply(t,n);function l(e){i(a,o,r,l,s,"next",e)}function s(e){i(a,o,r,l,s,"throw",e)}l(void 0)}))}}function r(e,t,n){return t=h(t),g(e,p()?Reflect.construct(t,n||[],h(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,k(i.key),i)}}function s(e,t,n){return t&&l(e.prototype,t),n&&l(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,a=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,r=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw r}}}}function d(e,t,n){return(t=k(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},u.apply(null,arguments)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(e,t){if(null==e)return{};var n,i,o=function(e,t){if(null==e)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)n=r[i],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function g(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function y(){y=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},r=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function s(e,t,n,i){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i})}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function c(t,n,i,o){var r=n&&n.prototype instanceof h?n:h,a=Object.create(r.prototype);return s(a,"_invoke",function(t,n,i){var o=1;return function(r,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===r)throw a;return{value:e,done:!0}}for(i.method=r,i.arg=a;;){var l=i.delegate;if(l){var s=x(l,i);if(s){if(s===u)continue;return s}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(1===o)throw o=4,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);o=3;var c=d(t,n,i);if("normal"===c.type){if(o=i.done?4:2,c.arg===u)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(o=4,i.method="throw",i.arg=c.arg)}}}(t,i,new I(o||[])),!0),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var u={};function h(){}function f(){}function p(){}var v={};s(v,r,(function(){return this}));var b=Object.getPrototypeOf,m=b&&b(b(T([])));m&&m!==n&&i.call(m,r)&&(v=m);var g=p.prototype=h.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,r,a,l){var s=d(e[o],e,r);if("throw"!==s.type){var c=s.arg,u=c.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,l)}))}l(s.arg)}var o;s(this,"_invoke",(function(e,i){function r(){return new t((function(t,o){n(e,i,t,o)}))}return o=o?o.then(r,r):r()}),!0)}function x(t,n){var i=n.method,o=t.i[i];if(o===e)return n.delegate=null,"throw"===i&&t.i.return&&(n.method="return",n.arg=e,x(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),u;var r=d(o,t.i,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,u;var a=r.arg;return a?a.done?(n[t.r]=a.value,n.next=t.n,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,u):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,u)}function M(e){this.tryEntries.push(e)}function k(t){var n=t[4]||{};n.type="normal",n.arg=e,t[4]=n}function I(e){this.tryEntries=[[-1]],e.forEach(M,this),this.reset(!0)}function T(t){if(null!=t){var n=t[r];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function n(){for(;++o<t.length;)if(i.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return f.prototype=p,s(g,"constructor",p),s(p,"constructor",f),f.displayName=s(p,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,l,"GeneratorFunction")),e.prototype=Object.create(g),e},t.awrap=function(e){return{__await:e}},w(C.prototype),s(C.prototype,a,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,i,o,r){void 0===r&&(r=Promise);var a=new C(c(e,n,i,o),r);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},w(g),s(g,l,"Generator"),s(g,r,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.unshift(i);return function e(){for(;n.length;)if((i=n.pop())in t)return e.value=i,e.done=!1,e;return e.done=!0,e}},t.values=T,I.prototype={constructor:I,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0][4];if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(e){a.type="throw",a.arg=t,n.next=e}for(var o=n.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o],a=r[4],l=this.prev,s=r[1],c=r[2];if(-1===r[0])return i("end"),!1;if(!s&&!c)throw Error("try statement without catch or finally");if(null!=r[0]&&r[0]<=l){if(l<s)return this.method="next",this.arg=e,i(s),!0;if(l<c)return i(c),!1}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i[0]>-1&&i[0]<=this.prev&&this.prev<i[2]){var o=i;break}}o&&("break"===e||"continue"===e)&&o[0]<=t&&t<=o[2]&&(o=null);var r=o?o[4]:{};return r.type=e,r.arg=t,o?(this.method="next",this.next=o[2],u):this.complete(r)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n[2]===e)return this.complete(n[4],n[3]),k(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n[0]===e){var i=n[4];if("throw"===i.type){var o=i.arg;k(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={i:T(t),r:n,n:i},"next"===this.method&&(this.arg=e),u}},t}function w(e,t){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},w(e,t)}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,o,r,a,l=[],s=!0,c=!1;try{if(r=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(i=r.call(n)).done)&&(l.push(i.value),l.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,t)||T(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t,n,i){var o=u(h(1&i?e.prototype:e),t,n);return 2&i&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function M(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function T(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}var N={container:"table-up-container",tableCaption:"table-up-caption",tableWrapper:"table-up",tableMain:"table-up-main",tableColgroup:"table-up-colgroup",tableCol:"table-up-col",tableBody:"table-up-body",tableRow:"table-up-row",tableCell:"table-up-cell",tableCellInner:"table-up-cell-inner"},E={colMinWidthPre:5,colMinWidthPx:40,colDefaultWidth:100,rowMinHeightPx:36},S={AFTER_TABLE_RESIZE:"after-table-resize"},L={moduleName:"table-up"},B=[["rgb(255, 255, 255)","rgb(0, 0, 0)","rgb(72, 83, 104)","rgb(41, 114, 244)","rgb(0, 163, 245)","rgb(49, 155, 98)","rgb(222, 60, 54)","rgb(248, 136, 37)","rgb(245, 196, 0)","rgb(153, 56, 215)"],["rgb(242, 242, 242)","rgb(127, 127, 127)","rgb(243, 245, 247)","rgb(229, 239, 255)","rgb(229, 246, 255)","rgb(234, 250, 241)","rgb(254, 233, 232)","rgb(254, 243, 235)","rgb(254, 249, 227)","rgb(253, 235, 255)"],["rgb(216, 216, 216)","rgb(89, 89, 89)","rgb(197, 202, 211)","rgb(199, 220, 255)","rgb(199, 236, 255)","rgb(195, 234, 213)","rgb(255, 201, 199)","rgb(255, 220, 196)","rgb(255, 238, 173)","rgb(242, 199, 255)"],["rgb(191, 191, 191)","rgb(63, 63, 63)","rgb(128, 139, 158)","rgb(153, 190, 255)","rgb(153, 221, 255)","rgb(152, 215, 182)","rgb(255, 156, 153)","rgb(255, 186, 132)","rgb(255, 226, 112)","rgb(213, 142, 255)"],["rgb(165, 165, 165)","rgb(38, 38, 38)","rgb(53, 59, 69)","rgb(20, 80, 184)","rgb(18, 116, 165)","rgb(39, 124, 79)","rgb(158, 30, 26)","rgb(184, 96, 20)","rgb(163, 130, 0)","rgb(94, 34, 129)"],["rgb(147, 147, 147)","rgb(13, 13, 13)","rgb(36, 39, 46)","rgb(12, 48, 110)","rgb(10, 65, 92)","rgb(24, 78, 50)","rgb(88, 17, 14)","rgb(92, 48, 10)","rgb(102, 82, 0)","rgb(59, 21, 81)"]],R="table-up",O=new Set([N.tableCellInner]);function A(e){return!(!e||!e.parent)&&(t=e.parent,!!O.has(t.statics.blotName)||A(e.parent));var t}function z(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:R,n=t?"".concat(t,"-"):"";return{b:function(){return"".concat(n).concat(e)},be:function(t){return t?"".concat(n).concat(e,"__").concat(t):""},bm:function(t){return t?"".concat(n).concat(e,"--").concat(t):""},bem:function(t,i){return t&&i?"".concat(n).concat(e,"__").concat(t,"--").concat(i):""},ns:function(e){return e?"".concat(n).concat(e):""},bs:function(t){return t?"".concat(n).concat(e,"-").concat(t):""},cv:function(e){return e?"--".concat(n).concat(e):""},is:function(e){return"is-".concat(e)}}}function q(e,t){for(var n=e.parent;n&&n.statics.blotName!==t&&n!==e.scroll;)n=n.parent;if(n===e.scroll)throw new Error("".concat(e.statics.blotName," must be a child of ").concat(t));return n}function H(e,t){for(var n=new Array(t.length),i=new Map(t.map((function(e,t){return[e,t]}))),o=e.parent;o&&o!==e.scroll&&0!==i.size;){i.has(o.statics.blotName)&&(n[i.get(o.statics.blotName)]=o,i.delete(o.statics.blotName)),o=o.parent}if(i.size>0)throw new Error("".concat(e.statics.blotName," must be a child of ").concat(Array.from(i.keys()).join(", ")));return n}function W(e){for(var t=new Map,n=e;n&&"scroll"!==n.statics.blotName;)t.set(n.statics.blotName,n),n=n.parent;return t}function D(e,t){for(var n=[],i=e.children.iterator(),o=null;o=i();)o instanceof t&&n.push(o);return n}function j(e,t){var n,i=c(Object.getOwnPropertyNames(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;/^constructor$/.test(o)||Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}}catch(e){i.e(e)}finally{i.f()}return e}function P(e,t){return e=Math.min(t,Math.max(0,Number.parseFloat("".concat(e)))),Math.abs(e-t)<1e-6?1:e%t/Number.parseFloat(t)}function F(e){return{h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b)),a:Math.min(1,Math.max(0,e.a))}}function _(e){var t=e.r,n=e.g,i=e.b,o=e.a;t=P(t,255),n=P(n,255),i=P(i,255);var r,a=Math.max(t,n,i),l=Math.min(t,n,i),s=a,c=a-l,d=0===a?0:c/a;if(a===l)r=0;else{switch(a){case t:r=(n-i)/c+(n<i?6:0);break;case n:r=(i-t)/c+2;break;case i:r=(t-n)/c+4}r/=6}return{h:360*r,s:100*d,b:100*s,a:o}}function V(e){var t=e.h,n=e.s,i=e.b,o=e.a;t=6*P(t,360),n=P(n,100),i=P(i,100);var r=Math.floor(t),a=t-r,l=i*(1-n),s=i*(1-a*n),c=i*(1-(1-a)*n),d=r%6,u=[i,s,l,l,c,i][d],h=[c,i,i,s,l,l][d],f=[l,l,c,i,i,s][d];return{r:Math.round(255*u),g:Math.round(255*h),b:Math.round(255*f),a:o}}function X(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16),Math.round(255*e.a).toString(16)];for(var n in t)1===t[n].length&&(t[n]="0".concat(t[n]));return t.join("")}var U=function(e){return X(V(e))},Y=function(e){return"function"==typeof e},G=Array.isArray,K=function(e){return"string"==typeof e},Z=function(e){return null!==e&&"object"===I(e)};function $(e){var t=e||{},n=t.type,i=void 0===n?"default":n,o=t.content,r=z("button"),a=document.createElement("button");return a.classList.add(r.b(),i),o&&(K(o)?a.textContent=o:a.appendChild(o)),a}function Q(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=230,i=150,o=10,r=_((e=(e=t.color||"#ff0000").startsWith("#")?e.slice(1):e,{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:Number((Number.parseInt(e.slice(6,8)||"ff",16)/255).toFixed(2))})),a=z("color-picker"),l=document.createElement("div");l.classList.add(a.b());var s=document.createElement("div");s.classList.add(a.be("content"));var u=document.createElement("div");u.classList.add(a.be("selector"));var h=document.createElement("div");h.classList.add(a.be("background")),u.appendChild(h);var f=document.createElement("div");f.classList.add(a.be("background-handle")),h.appendChild(f);var p=document.createElement("div");p.classList.add(a.be("alpha"));var v=document.createElement("div");v.classList.add(a.be("alpha-bg"));var b=document.createElement("div");b.classList.add(a.be("alpha-handle")),p.appendChild(v),p.appendChild(b);var m=document.createElement("div");m.classList.add(a.be("hue"));var g=document.createElement("div");g.classList.add(a.be("hue-handle")),m.appendChild(g);var y=document.createElement("div");y.classList.add(a.be("action"));var w=C(["r","g","b","a"].map((function(e){var t=document.createElement("div");t.classList.add(a.be("action-item"),e);var n=document.createElement("label");n.textContent=e.toUpperCase();var i=document.createElement("input");return i.classList.add(a.be("input")),i.addEventListener("input",(function(){i.value=i.value.replaceAll(/[^0-9]/g,"")})),i.addEventListener("change",(function(){var t=Math.round(Number(i.value));"a"===e&&(t/=100),B(F(_(Object.assign({},V(r),d({},e,t))))),L()})),t.appendChild(n),t.appendChild(i),y.appendChild(t),i})),4),x=w[0],M=w[1],k=w[2],I=w[3];s.appendChild(m),s.appendChild(u),s.appendChild(p),l.appendChild(s),l.appendChild(y);var T=!1,N=!1,E=!1;function S(){var e,t=U(r),n=c([x,M,k].entries());try{for(n.s();!(e=n.n()).done;){var i=C(e.value,2),o=i[0];i[1].value=String(Number.parseInt(t[2*o]+t[2*o+1],16))}}catch(e){n.e(e)}finally{n.f()}I.value=String((100*r.a).toFixed(0))}function L(){var e,t,o,a;Object.assign(f.style,{left:"".concat(Math.floor(n*r.s/100),"px"),top:"".concat(Math.floor(i*(100-r.b)/100),"px")}),u.style.backgroundColor="#".concat(X(V({h:r.h,s:100,b:100,a:1}))),g.style.top="".concat(Math.floor(i-i*r.h/360),"px"),b.style.left="".concat(100*r.a,"%"),e=V(r),t=e.r,o=e.g,a=e.b,v.style.background="linear-gradient(to right, rgba(".concat(t,", ").concat(o,", ").concat(a,", 0) 0%, rgba(").concat(t,", ").concat(o,", ").concat(a,", 1) 100%)"),S()}function B(e){r=F(Object.assign({},r,e)),S(),t.onChange&&t.onChange("#".concat(U(r)))}function R(e){var t=u.getBoundingClientRect(),o=t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),r=t.left+document.body.scrollLeft;B({s:Math.floor(100*Math.max(0,Math.min(n,e.pageX-r))/n),b:Math.floor(100*(i-Math.max(0,Math.min(i,e.pageY-o)))/i)}),L()}function O(e){var t=m.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);B({h:Math.floor(360*(i-Math.max(0,Math.min(i,e.pageY-t)))/i)}),L()}function A(e){var t=e.pageX,n=p.getBoundingClientRect(),i=t-n.left;i=Math.max(o/2,i),i=Math.min(i,n.width-o/2),B({a:Math.round((i-5)/(n.width-10)*100)/100}),L()}function q(e){T&&(e.preventDefault(),R(e)),N&&(e.preventDefault(),O(e)),E&&(e.preventDefault(),A(e))}function H(){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",H),T=!1}function W(){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",W),N=!1}function D(){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",D),E=!1}return u.addEventListener("mousedown",(function(e){document.addEventListener("mousemove",q),document.addEventListener("mouseup",H),T=!0,R(e)})),m.addEventListener("mousedown",(function(e){document.addEventListener("mousemove",q),document.addEventListener("mouseup",W),N=!0,O(e)})),p.addEventListener("mousedown",(function(e){document.addEventListener("mousemove",q),document.addEventListener("mouseup",D),E=!0,A(e)})),L(),l}var J=8e3;function ee(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.child,n=e.target,i=void 0===n?document.body:n,o=e.beforeClose,r=void 0===o?function(){}:o,a=z("dialog"),l=i,s=document.createElement("div");s.classList.add(a.b()),s.style.zIndex=String(J);var c=document.createElement("div");if(c.classList.add(a.be("overlay")),s.appendChild(c),t){var d=document.createElement("div");d.classList.add(a.be("content")),d.appendChild(t),c.appendChild(d),d.addEventListener("click",(function(e){e.stopPropagation()}))}var u=getComputedStyle(l).overflow;l.style.overflow="hidden",l.appendChild(s);var h=function(){r(),s.remove(),l.style.overflow=u};return s.addEventListener("click",h),J+=1,{dialog:s,close:h}}function te(e,t){var n=z("input");t.type||(t.type="text"),t.value||(t.value="");var i=document.createElement("div");if(i.classList.add(n.be("item")),e){var o=document.createElement("span");o.classList.add(n.be("label")),o.textContent=e,i.appendChild(o)}var r=document.createElement("div");r.classList.add(n.be("input"));var a=document.createElement("input");for(var l in t)a.setAttribute(l,t[l]);(t.max||t.min)&&a.addEventListener("blur",(function(){t.max&&t.max<=Number(a.value)&&(a.value=String(t.max)),t.min&&t.min>=Number(a.value)&&(a.value=String(t.min))})),r.appendChild(a),i.appendChild(r),a.addEventListener("focus",(function(){r.classList.add("focus")})),a.addEventListener("blur",(function(){r.classList.remove("focus")}));return{item:i,input:a,errorTip:function(e){var t;r.classList.contains("error")?t=r.querySelector(".".concat(n.be("error-tip"))):(t=document.createElement("span"),t.classList.add(n.be("error-tip")),r.appendChild(t)),t.textContent=e,r.classList.add("error");return{removeError:function(){r.classList.remove("error"),t.remove()}}}}}function ne(){return ie.apply(this,arguments)}function ie(){return ie=o(y().mark((function e(){var t,n,i,r,a,l,s,c,d,u,h,f,p,v,b,m,g,w=arguments;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=w.length>0&&void 0!==w[0]?w[0]:{},n=z("creator"),(i=document.createElement("div")).classList.add(n.b()),(r=document.createElement("div")).classList.add(n.be("input")),a=te(t.rowText||"Row",{type:"number",value:String(t.row||""),max:99}),l=a.item,s=a.input,c=a.errorTip,d=te(t.colText||"Column",{type:"number",value:String(t.col||""),max:99}),u=d.item,h=d.input,f=d.errorTip,r.appendChild(l),r.appendChild(u),i.appendChild(r),(p=document.createElement("div")).classList.add(n.be("control")),v=$({type:"confirm",content:t.confirmText||"Confirm"}),b=$({type:"default",content:t.cancelText||"Cancel"}),p.appendChild(v),p.appendChild(b),i.appendChild(p),m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number(s.value),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number(h.value);if(Number.isNaN(e)||e<=0)c(t.notPositiveNumberError||"Please enter a positive integer");else{if(!(Number.isNaN(n)||n<=0))return{row:e,col:n};f(t.notPositiveNumberError||"Please enter a positive integer")}},g=function(e){"Escape"===e.key&&(close(),document.removeEventListener("keydown",g))},e.abrupt("return",new Promise((function(e,t){var n=ee({child:i,beforeClose:t}).close;s.focus();for(var r=0,a=[s,h];r<a.length;r++){a[r].addEventListener("keydown",(function(t){if("Enter"===t.key){var i=m();i&&(e(i),n())}}))}v.addEventListener("click",o(y().mark((function t(){var i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(i=m())&&(e(i),n());case 2:case"end":return t.stop()}}),t)})))),document.addEventListener("keydown",g),b.addEventListener("click",n)})));case 21:case"end":return e.stop()}}),e)}))),ie.apply(this,arguments)}function oe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=z("select-box"),n=document.createElement("div");n.classList.add(t.b());var i=document.createElement("div");i.classList.add(t.be("block"));for(var r=0;r<(e.row||8);r++)for(var a=0;a<(e.col||8);a++){var l=document.createElement("div");l.classList.add(t.be("item")),l.dataset.row=String(r+1),l.dataset.col=String(a+1),i.appendChild(l)}var s=function(){for(var e=n.dataset,t=e.row,o=e.col,r=0,a=Array.from(i.querySelectorAll(".active"));r<a.length;r++){a[r].classList.remove("active")}if(t&&o)for(var l=Array.from(i.children),s=0;s<l.length;s++){var c=l[s].dataset,d=c.row,u=c.col;if(d>t&&u>o)return;d<=t&&u<=o?l[s].classList.add("active"):l[s].classList.remove("active")}};if(i.addEventListener("mousemove",(function(e){if(e.target){var t=e.target.dataset,i=t.row,o=t.col;i&&o&&(n.dataset.row=i,n.dataset.col=o,s())}})),i.addEventListener("mouseleave",(function(){n.removeAttribute("data-row"),n.removeAttribute("data-col"),s()})),i.addEventListener("click",(function(){var t=n.dataset,i=t.row,o=t.col;i&&o&&e.onSelect&&e.onSelect(Number(i),Number(o))})),n.appendChild(i),e.customBtn){var c=e.texts||{},d=document.createElement("div");d.classList.add(t.be("custom")),d.textContent=c.customBtnText||"Custom",d.addEventListener("click",o(y().mark((function t(){var n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ne(c);case 2:(n=t.sent)&&e.onSelect&&e.onSelect(n.row,n.col);case 4:case"end":return t.stop()}}),t)})))),n.appendChild(d)}return n}const re=Math.min,ae=Math.max,le=Math.round,se=Math.floor,ce=e=>({x:e,y:e}),de={left:"right",right:"left",bottom:"top",top:"bottom"},ue={start:"end",end:"start"};function he(e,t,n){return ae(e,re(t,n))}function fe(e,t){return"function"==typeof e?e(t):e}function pe(e){return e.split("-")[0]}function ve(e){return e.split("-")[1]}function be(e){return"x"===e?"y":"x"}function me(e){return"y"===e?"height":"width"}function ge(e){return["top","bottom"].includes(pe(e))?"y":"x"}function ye(e){return be(ge(e))}function we(e){return e.replace(/start|end/g,(e=>ue[e]))}function Ce(e){return e.replace(/left|right|bottom|top/g,(e=>de[e]))}function xe(e){const{x:t,y:n,width:i,height:o}=e;return{width:i,height:o,top:n,left:t,right:t+i,bottom:n+o,x:t,y:n}}function Me(e,t,n){let{reference:i,floating:o}=e;const r=ge(t),a=ye(t),l=me(a),s=pe(t),c="y"===r,d=i.x+i.width/2-o.width/2,u=i.y+i.height/2-o.height/2,h=i[l]/2-o[l]/2;let f;switch(s){case"top":f={x:d,y:i.y-o.height};break;case"bottom":f={x:d,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:u};break;case"left":f={x:i.x-o.width,y:u};break;default:f={x:i.x,y:i.y}}switch(ve(t)){case"start":f[a]-=h*(n&&c?-1:1);break;case"end":f[a]+=h*(n&&c?-1:1)}return f}async function ke(e,t){var n;void 0===t&&(t={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:s}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=fe(t,e),p=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(f),v=l[h?"floating"===u?"reference":"floating":u],b=xe(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(v)))||n?v:v.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:s})),m="floating"===u?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,g=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),y=await(null==r.isElement?void 0:r.isElement(g))&&await(null==r.getScale?void 0:r.getScale(g))||{x:1,y:1},w=xe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:m,offsetParent:g,strategy:s}):m);return{top:(b.top-w.top+p.top)/y.y,bottom:(w.bottom-b.bottom+p.bottom)/y.y,left:(b.left-w.left+p.left)/y.x,right:(w.right-b.right+p.right)/y.x}}function Ie(){return"undefined"!=typeof window}function Te(e){return Se(e)?(e.nodeName||"").toLowerCase():"#document"}function Ne(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Ee(e){var t;return null==(t=(Se(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Se(e){return!!Ie()&&(e instanceof Node||e instanceof Ne(e).Node)}function Le(e){return!!Ie()&&(e instanceof Element||e instanceof Ne(e).Element)}function Be(e){return!!Ie()&&(e instanceof HTMLElement||e instanceof Ne(e).HTMLElement)}function Re(e){return!(!Ie()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Ne(e).ShadowRoot)}function Oe(e){const{overflow:t,overflowX:n,overflowY:i,display:o}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&!["inline","contents"].includes(o)}function Ae(e){return["table","td","th"].includes(Te(e))}function ze(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function qe(e){const t=He(),n=Le(e)?De(e):e;return["transform","translate","scale","rotate","perspective"].some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function He(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function We(e){return["html","body","#document"].includes(Te(e))}function De(e){return Ne(e).getComputedStyle(e)}function je(e){return Le(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Pe(e){if("html"===Te(e))return e;const t=e.assignedSlot||e.parentNode||Re(e)&&e.host||Ee(e);return Re(t)?t.host:t}function Fe(e){const t=Pe(e);return We(t)?e.ownerDocument?e.ownerDocument.body:e.body:Be(t)&&Oe(t)?t:Fe(t)}function _e(e,t,n){var i;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=Fe(e),r=o===(null==(i=e.ownerDocument)?void 0:i.body),a=Ne(o);if(r){const e=Ve(a);return t.concat(a,a.visualViewport||[],Oe(o)?o:[],e&&n?_e(e):[])}return t.concat(o,_e(o,[],n))}function Ve(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Xe(e){const t=De(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const o=Be(e),r=o?e.offsetWidth:n,a=o?e.offsetHeight:i,l=le(n)!==r||le(i)!==a;return l&&(n=r,i=a),{width:n,height:i,$:l}}function Ue(e){return Le(e)?e:e.contextElement}function Ye(e){const t=Ue(e);if(!Be(t))return ce(1);const n=t.getBoundingClientRect(),{width:i,height:o,$:r}=Xe(t);let a=(r?le(n.width):n.width)/i,l=(r?le(n.height):n.height)/o;return a&&Number.isFinite(a)||(a=1),l&&Number.isFinite(l)||(l=1),{x:a,y:l}}const Ge=ce(0);function Ke(e){const t=Ne(e);return He()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Ge}function Ze(e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),r=Ue(e);let a=ce(1);t&&(i?Le(i)&&(a=Ye(i)):a=Ye(e));const l=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Ne(e))&&t}(r,n,i)?Ke(r):ce(0);let s=(o.left+l.x)/a.x,c=(o.top+l.y)/a.y,d=o.width/a.x,u=o.height/a.y;if(r){const e=Ne(r),t=i&&Le(i)?Ne(i):i;let n=e,o=Ve(n);for(;o&&i&&t!==n;){const e=Ye(o),t=o.getBoundingClientRect(),i=De(o),r=t.left+(o.clientLeft+parseFloat(i.paddingLeft))*e.x,a=t.top+(o.clientTop+parseFloat(i.paddingTop))*e.y;s*=e.x,c*=e.y,d*=e.x,u*=e.y,s+=r,c+=a,n=Ne(o),o=Ve(n)}}return xe({width:d,height:u,x:s,y:c})}function $e(e,t){const n=je(e).scrollLeft;return t?t.left+n:Ze(Ee(e)).left+n}function Qe(e,t,n){void 0===n&&(n=!1);const i=e.getBoundingClientRect();return{x:i.left+t.scrollLeft-(n?0:$e(e,i)),y:i.top+t.scrollTop}}function Je(e,t,n){let i;if("viewport"===t)i=function(e,t){const n=Ne(e),i=Ee(e),o=n.visualViewport;let r=i.clientWidth,a=i.clientHeight,l=0,s=0;if(o){r=o.width,a=o.height;const e=He();(!e||e&&"fixed"===t)&&(l=o.offsetLeft,s=o.offsetTop)}return{width:r,height:a,x:l,y:s}}(e,n);else if("document"===t)i=function(e){const t=Ee(e),n=je(e),i=e.ownerDocument.body,o=ae(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=ae(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let a=-n.scrollLeft+$e(e);const l=-n.scrollTop;return"rtl"===De(i).direction&&(a+=ae(t.clientWidth,i.clientWidth)-o),{width:o,height:r,x:a,y:l}}(Ee(e));else if(Le(t))i=function(e,t){const n=Ze(e,!0,"fixed"===t),i=n.top+e.clientTop,o=n.left+e.clientLeft,r=Be(e)?Ye(e):ce(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:o*r.x,y:i*r.y}}(t,n);else{const n=Ke(e);i={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return xe(i)}function et(e,t){const n=Pe(e);return!(n===t||!Le(n)||We(n))&&("fixed"===De(n).position||et(n,t))}function tt(e,t,n){const i=Be(t),o=Ee(t),r="fixed"===n,a=Ze(e,!0,r,t);let l={scrollLeft:0,scrollTop:0};const s=ce(0);if(i||!i&&!r)if(("body"!==Te(t)||Oe(o))&&(l=je(t)),i){const e=Ze(t,!0,r,t);s.x=e.x+t.clientLeft,s.y=e.y+t.clientTop}else o&&(s.x=$e(o));const c=!o||i||r?ce(0):Qe(o,l);return{x:a.left+l.scrollLeft-s.x-c.x,y:a.top+l.scrollTop-s.y-c.y,width:a.width,height:a.height}}function nt(e){return"static"===De(e).position}function it(e,t){if(!Be(e)||"fixed"===De(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Ee(e)===n&&(n=n.ownerDocument.body),n}function ot(e,t){const n=Ne(e);if(ze(e))return n;if(!Be(e)){let t=Pe(e);for(;t&&!We(t);){if(Le(t)&&!nt(t))return t;t=Pe(t)}return n}let i=it(e,t);for(;i&&Ae(i)&&nt(i);)i=it(i,t);return i&&We(i)&&nt(i)&&!qe(i)?n:i||function(e){let t=Pe(e);for(;Be(t)&&!We(t);){if(qe(t))return t;if(ze(t))return null;t=Pe(t)}return null}(e)||n}const rt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:i,strategy:o}=e;const r="fixed"===o,a=Ee(i),l=!!t&&ze(t.floating);if(i===a||l&&r)return n;let s={scrollLeft:0,scrollTop:0},c=ce(1);const d=ce(0),u=Be(i);if((u||!u&&!r)&&(("body"!==Te(i)||Oe(a))&&(s=je(i)),Be(i))){const e=Ze(i);c=Ye(i),d.x=e.x+i.clientLeft,d.y=e.y+i.clientTop}const h=!a||u||r?ce(0):Qe(a,s,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-s.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-s.scrollTop*c.y+d.y+h.y}},getDocumentElement:Ee,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:i,strategy:o}=e;const r=[..."clippingAncestors"===n?ze(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let i=_e(e,[],!1).filter((e=>Le(e)&&"body"!==Te(e))),o=null;const r="fixed"===De(e).position;let a=r?Pe(e):e;for(;Le(a)&&!We(a);){const t=De(a),n=qe(a);n||"fixed"!==t.position||(o=null),(r?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||Oe(a)&&!n&&et(e,a))?i=i.filter((e=>e!==a)):o=t,a=Pe(a)}return t.set(e,i),i}(t,this._c):[].concat(n),i],a=r[0],l=r.reduce(((e,n)=>{const i=Je(t,n,o);return e.top=ae(i.top,e.top),e.right=re(i.right,e.right),e.bottom=re(i.bottom,e.bottom),e.left=ae(i.left,e.left),e}),Je(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:ot,getElementRects:async function(e){const t=this.getOffsetParent||ot,n=this.getDimensions,i=await n(e.floating);return{reference:tt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Xe(e);return{width:t,height:n}},getScale:Ye,isElement:Le,isRTL:function(e){return"rtl"===De(e).direction}};function at(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lt(e,t,n,i){void 0===i&&(i={});const{ancestorScroll:o=!0,ancestorResize:r=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=i,c=Ue(e),d=o||r?[...c?_e(c):[],..._e(t)]:[];d.forEach((e=>{o&&e.addEventListener("scroll",n,{passive:!0}),r&&e.addEventListener("resize",n)}));const u=c&&l?function(e,t){let n,i=null;const o=Ee(e);function r(){var e;clearTimeout(n),null==(e=i)||e.disconnect(),i=null}return function a(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const c=e.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=c;if(l||t(),!h||!f)return;const p={rootMargin:-se(u)+"px "+-se(o.clientWidth-(d+h))+"px "+-se(o.clientHeight-(u+f))+"px "+-se(d)+"px",threshold:ae(0,re(1,s))||1};let v=!0;function b(t){const i=t[0].intersectionRatio;if(i!==s){if(!v)return a();i?a(!1,i):n=setTimeout((()=>{a(!1,1e-7)}),1e3)}1!==i||at(c,e.getBoundingClientRect())||a(),v=!1}try{i=new IntersectionObserver(b,{...p,root:o.ownerDocument})}catch(e){i=new IntersectionObserver(b,p)}i.observe(e)}(!0),r}(c,n):null;let h,f=-1,p=null;a&&(p=new ResizeObserver((e=>{let[i]=e;i&&i.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(t)}))),n()})),c&&!s&&p.observe(c),p.observe(t));let v=s?Ze(e):null;return s&&function t(){const i=Ze(e);v&&!at(v,i)&&n();v=i,h=requestAnimationFrame(t)}(),n(),()=>{var e;d.forEach((e=>{o&&e.removeEventListener("scroll",n),r&&e.removeEventListener("resize",n)})),null==u||u(),null==(e=p)||e.disconnect(),p=null,s&&cancelAnimationFrame(h)}}const st=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=t,s=await async function(e,t){const{placement:n,platform:i,elements:o}=e,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=pe(n),l=ve(n),s="y"===ge(n),c=["left","top"].includes(a)?-1:1,d=r&&s?-1:1,u=fe(t,e);let{mainAxis:h,crossAxis:f,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&"number"==typeof p&&(f="end"===l?-1*p:p),s?{x:f*d,y:h*c}:{x:h*c,y:f*d}}(t,e);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+s.x,y:r+s.y,data:{...s,placement:a}}}}},ct=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:o}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...s}=fe(e,t),c={x:n,y:i},d=await ke(t,s),u=ge(pe(o)),h=be(u);let f=c[h],p=c[u];if(r){const e="y"===h?"bottom":"right";f=he(f+d["y"===h?"top":"left"],f,f-d[e])}if(a){const e="y"===u?"bottom":"right";p=he(p+d["y"===u?"top":"left"],p,p-d[e])}const v=l.fn({...t,[h]:f,[u]:p});return{...v,data:{x:v.x-n,y:v.y-i,enabled:{[h]:r,[u]:a}}}}}},dt=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l,platform:s,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:v=!0,...b}=fe(e,t);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const m=pe(o),g=ge(l),y=pe(l)===l,w=await(null==s.isRTL?void 0:s.isRTL(c.floating)),C=h||(y||!v?[Ce(l)]:function(e){const t=Ce(e);return[we(e),t,we(t)]}(l)),x="none"!==p;!h&&x&&C.push(...function(e,t,n,i){const o=ve(e);let r=function(e,t,n){const i=["left","right"],o=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:i:t?i:o;case"left":case"right":return t?r:a;default:return[]}}(pe(e),"start"===n,i);return o&&(r=r.map((e=>e+"-"+o)),t&&(r=r.concat(r.map(we)))),r}(l,v,p,w));const M=[l,...C],k=await ke(t,b),I=[];let T=(null==(i=r.flip)?void 0:i.overflows)||[];if(d&&I.push(k[m]),u){const e=function(e,t,n){void 0===n&&(n=!1);const i=ve(e),o=ye(e),r=me(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return t.reference[r]>t.floating[r]&&(a=Ce(a)),[a,Ce(a)]}(o,a,w);I.push(k[e[0]],k[e[1]])}if(T=[...T,{placement:o,overflows:I}],!I.every((e=>e<=0))){var N,E;const e=((null==(N=r.flip)?void 0:N.index)||0)+1,t=M[e];if(t)return{data:{index:e,overflows:T},reset:{placement:t}};let n=null==(E=T.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:E.placement;if(!n)switch(f){case"bestFit":{var S;const e=null==(S=T.filter((e=>{if(x){const t=ge(e.placement);return t===g||"y"===t}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])?void 0:S[0];e&&(n=e);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},ut=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=t,{offset:l=0,mainAxis:s=!0,crossAxis:c=!0}=fe(e,t),d={x:n,y:i},u=ge(o),h=be(u);let f=d[h],p=d[u];const v=fe(l,t),b="number"==typeof v?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(s){const e="y"===h?"height":"width",t=r.reference[h]-r.floating[e]+b.mainAxis,n=r.reference[h]+r.reference[e]-b.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var m,g;const e="y"===h?"width":"height",t=["top","left"].includes(pe(o)),n=r.reference[u]-r.floating[e]+(t&&(null==(m=a.offset)?void 0:m[u])||0)+(t?0:b.crossAxis),i=r.reference[u]+r.reference[e]+(t?0:(null==(g=a.offset)?void 0:g[u])||0)-(t?b.crossAxis:0);p<n?p=n:p>i&&(p=i)}return{[h]:f,[u]:p}}}},ht=(e,t,n)=>{const i=new Map,o={platform:rt,...n},r={...o.platform,_c:i};return(async(e,t,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=r.filter(Boolean),s=await(null==a.isRTL?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:u}=Me(c,i,s),h=i,f={},p=0;for(let n=0;n<l.length;n++){const{name:r,fn:v}=l[n],{x:b,y:m,data:g,reset:y}=await v({x:d,y:u,initialPlacement:i,placement:h,strategy:o,middlewareData:f,rects:c,platform:a,elements:{reference:e,floating:t}});d=null!=b?b:d,u=null!=m?m:u,f={...f,[r]:{...f[r],...g}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(h=y.placement),y.rects&&(c=!0===y.rects?await a.getElementRects({reference:e,floating:t,strategy:o}):y.rects),({x:d,y:u}=Me(c,h,s))),n=-1)}return{x:d,y:u,placement:h,strategy:o,middlewareData:f}})(e,t,{...o,platform:r})};var ft;function pt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.msg,i=void 0===n?"":n,o=t.delay,r=void 0===o?150:o,a=t.content,l=t.direction,s=void 0===l?"bottom":l,c=t.type,d=void 0===c?"hover":c,u=t.container,h=t.onOpen,f=t.onClose,p=t.closed,v=t.onDestroy,b=z("tooltip");if(i||a){ft||(ft=document.createElement("div"),document.body.appendChild(ft));var m,g,y,w=u||ft,C=document.createElement("div");C.classList.add(b.b(),"hidden","transparent"),a?C.appendChild(a):i&&(C.textContent=i);var x=function(){y&&y(),ht(e,C,{placement:s,middleware:[dt(),ct({limiter:ut()}),st(4)]}).then((function(e){var t=e.x,n=e.y;Object.assign(C.style,{left:"".concat(t,"px"),top:"".concat(n,"px")})}))},M=function(){C.classList.add("hidden"),w.contains(C)&&w.removeChild(C),y&&y(),p&&p()},k=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];g&&clearTimeout(g),m=setTimeout((function(){if(h){var n=h(t);if(!t&&n)return}w.appendChild(C),C.removeEventListener("transitionend",M),C.classList.remove("hidden"),y=lt(e,C,x),C.classList.remove("transparent")}),r)},I=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];m&&clearTimeout(m),g=setTimeout((function(){if(f){var t=f(e);if(!e&&t)return}!function(e,t,n,i,o){e.addEventListener("transitionend",n,i),setTimeout((function(){n()}),t)}(C,150,M,{once:!0}),C.classList.add("transparent")}),r)},T={hover:function(){var t=[e,C],n=I.bind(void 0,!1),i=k.bind(void 0,!1);return{prepare:function(){for(var e=0,o=t;e<o.length;e++){var r=o[e];r.addEventListener("mouseenter",i),r.addEventListener("mouseleave",n)}},show:k,hide:I,destroy:function(){for(var e=0,o=t;e<o.length;e++){var r=o[e];r.removeEventListener("mouseenter",i),r.removeEventListener("mouseleave",n)}}}},click:function(){var t=function(e){e.stopPropagation(),I(!1)},n=function(e){e.stopPropagation(),k(),document.removeEventListener("click",t),document.addEventListener("click",t,{once:!0})};return{prepare:function(){C.addEventListener("click",(function(e){return e.stopPropagation()})),e.addEventListener("click",n)},show:k,hide:function(){I(arguments.length>0&&void 0!==arguments[0]&&arguments[0]),document.removeEventListener("click",t)},destroy:function(){e.removeEventListener("click",n),document.removeEventListener("click",t)}}}},N=T[d](),E=N.prepare,S=N.show,L=N.hide,B=N.destroy;E();return{show:S,hide:L,destroy:function(){L(!0),v&&v(),B(),y&&y(),C.remove()}}}return null}function vt(e,t){var n,i,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=e.x,l=e.y,s=e.x1,c=e.y1,d=t.x,u=t.y,h=t.x1,f=t.y1;return r?(n=s<d+o||a-o>h,i=c<u+o||l-o>f):(n=s<=d+o||a-o>=h,i=c<=u+o||l-o>=f),!(n||i)}function bt(e){var t=e.left,n=e.top,i=e.width,o=e.height,r=document.documentElement,a=r.clientWidth,l=r.clientHeight,s=!1,c=!1;return t+i>a?(t=a-i-8,s=!0):t<0&&(t=8,s=!0),n+o>l?(n=l-o-8,c=!0):n<0&&(n=8,c=!0),{left:t,top:n,leftLimited:s,topLimited:c}}function mt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Symbol("ignoreFirstBind"),i=new Set,o=new ResizeObserver((function(i){t.ignoreFirstBind&&i.some((function(e){var t=e.target,i=t[n];return t[n]=!0,!i}))||e(i)})),r=o.observe;o.observe=function(e,t){i.add(e),r.call(o,e,t)};var a=o.unobserve;o.unobserve=function(e){i.has(e)&&(i.delete(e),e[n]=void 0),a.call(o,e)};var l=o.disconnect;return o.disconnect=function(){var e,t=c(i.values());try{for(t.s();!(e=t.n()).done;){e.value[n]=void 0}}catch(e){t.e(e)}finally{t.f()}l.call(o)},o}function gt(e,t){e.addEventListener("scroll",t),this.scrollHandler.push([e,t])}function yt(){for(var e=0;e<this.scrollHandler.length;e++){var t=C(this.scrollHandler[e],2),n=t[0],i=t[1];n.removeEventListener("scroll",i)}this.scrollHandler=[]}function wt(e){for(var t={},n=e.trim().split(";"),i=0;i<n.length;i++){var o=n[i].trim();if(o){var r=o.indexOf(":");if(-1!==r){var a=o.slice(0,Math.max(0,r)).trim(),l=o.slice(Math.max(0,r+1)).trim();t[xt(a)]=l}}}return t}function Ct(e){return Object.entries(e).map((function(e){var t=C(e,2),n=t[0],i=t[1];return"".concat(function(e){var t=e.replaceAll(/([A-Z])/g," $1").trim();return t.split(" ").join("-").toLowerCase()}(n),": ").concat(i,";")})).join(" ")}function xt(e){return e.replaceAll(/-(\w)/g,(function(e,t){return t.toUpperCase()}))}var Mt=function(){return Math.random().toString(36).slice(2)};function kt(e,t){var n;return function(){for(var i=this,o=arguments.length,r=new Array(o),a=0;a<o;a++)r[a]=arguments[a];n&&clearTimeout(n),n=setTimeout((function(){e.apply(i,r)}),t)}}var It=t.import("parchment"),Tt=t.import("blots/container"),Nt=t.import("blots/block"),Et=t.import("blots/block/embed"),St=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"insertAt",value:function(e,n,i){if(!C(this.children.find(e),1)[0]){var o=this.scroll.create(this.statics.defaultChild.blotName||"block");this.appendChild(o)}x(t,"insertAt",this,3)([e,n,i])}},{key:"optimize",value:function(e){if(0===this.children.length)if(null!=this.statics.defaultChild){var t=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(t)}else this.remove();this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}},{key:"enforceAllowedChildren",value:function(){var e=this;this.children.forEach((function(n){e.statics.allowedChildren.some((function(e){return n instanceof e}))||(n.statics.scope===It.Scope.BLOCK_BLOT?(n.parent instanceof t?(null!=n.next&&n.parent.splitAfter(n),null!=n.prev&&n.parent.splitAfter(n.prev)):(null!=n.next&&e.splitAfter(n),null!=n.prev&&e.splitAfter(n.prev)),n.parent.unwrap()):n instanceof It.ParentBlot?n.unwrap():n.remove())}))}}],[{key:"create",value:function(e){var t=document.createElement(this.tagName);return this.className&&t.classList.add(this.className),t}}])}(Tt);d(St,"tagName",void 0),d(St,"blotName",N.container),d(St,"scope",It.Scope.BLOCK_BLOT),d(St,"allowedChildren",[Nt,Et,Tt]),d(St,"requiredContainer",void 0),d(St,"defaultChild",void 0);var Lt=function(e){return t=e,!Number.isNaN(t)&&Number(t)>0?e:1;var t},Bt=t.import("blots/block"),Rt=t.import("blots/block/embed"),Ot=function(e){function t(e,n,i){var o;return a(this,t),o=r(this,t,[e,n]),n.setAttribute("contenteditable",String(e.isEnabled())),o}return f(t,e),s(t,[{key:"setFormatValue",value:function(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]){if(!this.statics.isAllowStyle(e))return;this.parent&&this.parent.statics.blotName===N.tableCell&&this.parent.setFormatValue(e,t)}else{if(!this.statics.allowDataAttrs.has(e))return;var n="data-".concat(e);t?this.domNode.setAttribute(n,t):this.domNode.removeAttribute(n),this.parent&&this.parent.statics.blotName===N.tableCell&&this.parent.setFormatValue(e,t)}var i,o=c(this.descendants(Bt,0));try{for(o.s();!(i=o.n()).done;){i.value.cache={}}}catch(e){o.e(e)}finally{o.f()}}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"rowId",get:function(){return this.domNode.dataset.rowId},set:function(e){this.setFormatValue("row-id",e)}},{key:"colId",get:function(){return this.domNode.dataset.colId},set:function(e){this.setFormatValue("col-id",e)}},{key:"rowspan",get:function(){return Number(this.domNode.dataset.rowspan)},set:function(e){this.setFormatValue("rowspan",e)}},{key:"colspan",get:function(){return Number(this.domNode.dataset.colspan)},set:function(e){this.setFormatValue("colspan",e)}},{key:"getColumnIndex",value:function(){return q(this,N.tableMain).getColIds().indexOf(this.colId)}},{key:"formatAt",value:function(e,n,i,o){if(0===this.children.length&&(this.appendChild(this.scroll.create(this.statics.defaultChild.blotName)),n+=1),x(t,"formatAt",this,3)([e,n,i,o]),o&&o.style)for(var r=wt(o.style),a=0,l=Object.entries(r);a<l.length;a++){var s=C(l[a],2),c=s[0],d=s[1];this.setFormatValue(c,d,!0)}}},{key:"formats",value:function(){var e=this.statics.formats(this.domNode);return d({},this.statics.blotName,e)}},{key:"checkMerge",value:function(){var e=this.colId,t=this.rowId,n=this.colspan,i=this.rowspan,o=this.next;return null!==o&&o.statics.blotName===this.statics.blotName&&o.rowId===t&&o.colId===e&&o.colspan===n&&o.rowspan===i}},{key:"optimize",value:function(){var e=this.parent,t=this.statics.formats(this.domNode);if(this.prev&&this.prev instanceof Rt){var n=this.scroll.create("block");this.appendChild(this.prev),this.appendChild(n)}if(null!==e&&e.statics.blotName!==N.tableCell&&(this.wrap(N.tableCell,t),0===this.children.length)){var i=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(i)}this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length&&this.remove()}},{key:"insertBefore",value:function(e,n){if(e.statics.blotName===this.statics.blotName){var i=e,o=this.statics.formats(i.domNode),r=this.statics.formats(this.domNode);if(Object.entries(r).every((function(e){var t=C(e,2),n=t[0];return t[1]===o[n]})))return this.parent.insertBefore(i,this.next);var a=C(H(this,[N.tableRow,N.tableCell]),2),l=a[0],s=a[1];if(n){var c=n.offset();if(c+1<this.length()){var d=this.scroll.create(N.tableCellInner,r);this.children.forEachAt(c+1,this.length(),(function(e){d.appendChild(e)})),l.insertBefore(d.wrap(N.tableCell,r),s.next),0===this.children.length&&(this.remove(),0===this.parent.children.length&&this.parent.remove())}}if(this.rowId!==i.rowId){if(n){var u=n.offset(l);l.split(u)}else if(s.next){var h=s.next.offset(l);l.split(h)}var f=this.scroll.create(N.tableRow,o),p=this.scroll.create(N.tableCell,o);return p.appendChild(i),f.appendChild(p),l.parent.insertBefore(f,l.next)}return l.insertBefore(i.wrap(N.tableCell,o),n?s:s.next)}x(t,"insertBefore",this,3)([e,n])}}],[{key:"isAllowStyle",value:function(e){var t,n=c(this.allowStyle);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(e.startsWith(i))return!0}}catch(e){n.e(e)}finally{n.f()}return!1}},{key:"create",value:function(e){var n=e.tableId,i=e.rowId,o=e.colId,r=e.rowspan,a=e.colspan,l=e.style,s=x(t,"create",this,2)([]);return s.dataset.tableId=n,s.dataset.rowId=i,s.dataset.colId=o,s.dataset.rowspan=String(Lt(r)),s.dataset.colspan=String(Lt(a)),l&&(s.dataset.style=l),s}},{key:"formats",value:function(e){var t=e.dataset,n=t.tableId,i=t.rowId,o=t.colId,r=t.rowspan,a=t.colspan,l=t.style,s={tableId:String(n),rowId:String(i),colId:String(o),rowspan:Number(Lt(r)),colspan:Number(Lt(a))};return l&&(s.style=l),s}}])}(St);d(Ot,"blotName",N.tableCellInner),d(Ot,"tagName","div"),d(Ot,"className","ql-table-cell-inner"),d(Ot,"allowDataAttrs",new Set(["table-id","row-id","col-id","rowspan","colspan"])),d(Ot,"defaultChild",Bt),d(Ot,"allowStyle",new Set(["background-color","border","height"]));var At=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"rowId",get:function(){return this.domNode.dataset.rowId}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"setHeight",value:function(e){this.foreachCellInner((function(t){t.setFormatValue("height",e,!0)}))}},{key:"getCellByColId",value:function(e,t){for(var n=q(this,N.tableMain).getColIds(),i=n.indexOf(e),o=this.children.iterator(),r=null;r=o();){if(r.colId===e)return r;var a=n.indexOf(r.colId);if(a<i&&a+r.colspan>i)return r}return this[t]&&this[t].statics.blotName===N.tableRow?this[t].getCellByColId(e,t):null}},{key:"insertCell",value:function(e,t){for(var n,i=[],o=this.children.iterator(),r=0;(n=o())&&!((r+=n.colspan)>e);)if(1!==n.rowspan)for(var a=0;a<n.rowspan-1;a++)i[a]=(i[a]||0)+n.colspan;if(n&&r-n.colspan<e){n.getCellInner().colspan+=1,1!==n.rowspan&&(i.skipRowNum=n.rowspan-1)}else{var l=this.scroll.create(N.tableCell,t),s=this.scroll.create(N.tableCellInner,t),c=this.scroll.create("block");c.appendChild(this.scroll.create("break")),s.appendChild(c),l.appendChild(s),this.insertBefore(l,n)}return i}},{key:"getCellByColumIndex",value:function(e){var t=[],n=null,i=0;if(e<0)return[n,i,t];for(var o=this.children.iterator();n=o();){if(i+=n.colspan,1!==n.rowspan)for(var r=0;r<n.rowspan-1;r++)t[r]=(t[r]||0)+n.colspan;if(i>e)break}return[n,i,t]}},{key:"removeCell",value:function(e){if(e<0)return[];var t=this.getCellByColumIndex(e),n=C(t,2),i=n[0],o=n[1],r=t[2];if(!i)return r;if(o-i.colspan<e||i.colspan>1){var a=C(i.descendants(Ot),1)[0];if(1!==i.colspan&&e===o-i.colspan){var l=q(this,N.tableMain).getColIds();a.colId=l[l.indexOf(a.colId)+1]}1!==i.rowspan&&(r.skipRowNum=i.rowspan-1),a.colspan-=1}else i.remove();return r}},{key:"foreachCellInner",value:function(e){for(var t,n=this.children.iterator(),i=0;t=n();){if(e(C(t.descendants(Ot),1)[0],i++))break}}},{key:"checkMerge",value:function(){var e=this.next;return null!==e&&e.statics.blotName===this.statics.blotName&&e.rowId===this.rowId}},{key:"optimize",value:function(e){var n=this.parent,i=this.tableId;null!==n&&n.statics.blotName!==N.tableBody&&this.wrap(N.tableBody,i),x(t,"optimize",this,3)([e])}}],[{key:"create",value:function(e){var n=x(t,"create",this,2)([]);return n.dataset.tableId=e.tableId,n.dataset.rowId=e.rowId,n}}])}(St);d(At,"blotName",N.tableRow),d(At,"tagName","tr"),d(At,"className","ql-table-row");var zt=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"insertRow",value:function(e){var t=q(this,N.tableMain);if(t){var n,i=t.getColIds(),o=this.descendants(At),r=new Set(i),a=0,l=c(o);try{for(l.s();!(n=l.n()).done;){var s=n.value;if(a===e)break;s.foreachCellInner((function(t){if(a+t.rowspan>e&&(t.rowspan+=1,r.delete(t.colId),1!==t.colspan))for(var n=i.indexOf(t.colId),o=0;o<t.colspan-1;o++)r.delete(i[n+o+1])})),a+=1}}catch(e){l.e(e)}finally{l.f()}var d,u=t.tableId,h=Mt(),f=this.scroll.create(N.tableRow,{tableId:u,rowId:h}),p=c(r);try{for(p.s();!(d=p.n()).done;){var v=d.value,b=this.scroll.create("break").wrap("block").wrap(N.tableCellInner,{tableId:u,rowId:h,colId:v,rowspan:1,colspan:1}).wrap(N.tableCell,{tableId:u,rowId:h,colId:v,rowspan:1,colspan:1});f.appendChild(b)}}catch(e){p.e(e)}finally{p.f()}this.insertBefore(f,o[e]||null)}}},{key:"checkMerge",value:function(){var e=this.next;return null!==e&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}},{key:"optimize",value:function(e){var n=this.parent;if(null!==n&&n.statics.blotName!==N.tableMain){var i=this.tableId;this.wrap(N.tableMain,{tableId:i})}x(t,"optimize",this,3)([e])}}],[{key:"create",value:function(e){var n=x(t,"create",this,2)([]);return n.dataset.tableId=e,n}}])}(St);d(zt,"blotName",N.tableBody),d(zt,"tagName","tbody");var qt=t.import("parchment"),Ht=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"replaceWith",value:function(e,t){var n="string"==typeof e?this.scroll.create(e,t):e;if(n instanceof qt.ParentBlot){if(n.statics.blotName===N.tableCellInner){var i=this.parent;if(i.statics.blotName===N.tableCellInner){if(null!=i&&i.insertBefore(n,this.prev?null:this.next),i.statics.blotName===N.tableCellInner)for(var o=this;o;){var r=o.next;n.appendChild(o),o=r}else n.appendChild(this);if(i&&0===i.length()){i.remove(),i.parent.statics.blotName===N.tableCell&&0===i.parent.length()&&i.parent.remove();var a=i.parent.parent;a.statics.blotName===N.tableRow&&0===a.children.length&&a.remove()}}else null!=i&&i.insertBefore(n,this.next),n.appendChild(this);return n}this.moveChildren(n)}return null!=this.parent&&(this.parent.insertBefore(n,this.next||void 0),this.remove()),this.attributes.copy(n),n}},{key:"format",value:function(e,n){if(e!==N.tableCellInner||this.parent.statics.blotName!==e||n)x(t,"format",this,3)([e,n]);else try{q(this,N.tableCellInner).unwrap()}catch(e){console.error("unwrap TableCellInner error")}}}])}(t.import("blots/block")),Wt=t.import("parchment"),Dt=function(e){function n(){return a(this,n),r(this,n,arguments)}return f(n,e),s(n,[{key:"enable",value:function(){for(var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=t.import("formats/".concat(N.tableCellInner)),o=this.domNode.querySelectorAll(".".concat(i.className)),r=0,a=Array.from(o);r<a.length;r++){a[r].setAttribute("contenteditable",String(!!e))}for(var l=t.import("formats/".concat(N.tableCaption)),s=this.domNode.querySelectorAll(".".concat(l.className)),c=0,d=Array.from(s);c<d.length;c++){d[c].setAttribute("contenteditable",String(!!e))}x(n,"enable",this,3)([e])}},{key:"createBlock",value:function(e,t){var n,i={};if(e[N.tableCellInner])n=N.tableCellInner;else for(var o=0,r=Object.entries(e);o<r.length;o++){var a=C(r[o],2),l=a[0],s=a[1];null!=this.query(l,Wt.Scope.BLOCK&Wt.Scope.BLOT)?n=l:i[l]=s}n===N.tableCellInner&&delete(i=b({},e))[n];var c=this.create(n||this.statics.defaultChild.blotName,n?e[n]:void 0);this.insertBefore(c,t||void 0);var d=c.length();c instanceof Ot&&0===d&&(d+=1);for(var u=0,h=Object.entries(i);u<h.length;u++){var f=C(h[u],2),p=f[0],v=f[1];c.formatAt(0,d,p,v)}return c}}])}(t.import("blots/scroll")),jt=t.import("parchment"),Pt=t.import("blots/inline"),Ft=t.import("blots/text"),_t=function(e){function t(e,n,i){var o;return a(this,t),o=r(this,t,[e,n]),n.setAttribute("contenteditable",String(e.isEnabled())),o.attachUI(o.createUI()),o.domNode.addEventListener("mouseenter",(function(){o.scroll.isEnabled()&&(o.uiNode.style.display="flex")})),o.domNode.addEventListener("mouseleave",(function(){o.scroll.isEnabled()&&(o.uiNode.style.display="none")})),o.uiNode.style.display="none",o}return f(t,e),s(t,[{key:"createUI",value:function(){var e=this,t=document.createElement("i");return t.classList.add("ql-table-caption--switch"),t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\r\n \x3c!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE --\x3e\r\n <path\r\n fill="none"\r\n stroke="currentColor"\r\n stroke-linecap="round"\r\n stroke-linejoin="round"\r\n stroke-width="2"\r\n d="M7 3v18m3-15L7 3L4 6m16 12l-3 3l-3-3m3 3V3"\r\n />\r\n</svg>\r\n',t.addEventListener("click",(function(){e.scroll.isEnabled()&&(e.side="top"===e.side?"bottom":"top")})),t}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"side",get:function(){return"bottom"===this.domNode.style.captionSide?"bottom":"top"},set:function(e){this.domNode.style.captionSide="bottom"===e?"bottom":"top"}},{key:"format",value:function(e,n){this.scroll.query(e,jt.Scope.BLOCK_BLOT)&&e!==this.statics.blotName||x(t,"format",this,3)([e,n])}},{key:"checkMerge",value:function(){var e=this.next;return null!==e&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}},{key:"optimize",value:function(e){var n=this.parent;if(null!==n&&n.statics.blotName!==N.tableMain){var i=this.tableId;this.wrap(N.tableMain,{tableId:i})}0===this.children.length?this.remove():(x(t,"optimize",this,3)([e]),null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()))}}],[{key:"create",value:function(e){var n=e.tableId,i=x(t,"create",this,2)([]);return i.dataset.tableId=n,"bottom"===e.side&&(i.style.captionSide="bottom"),i}},{key:"formats",value:function(e){var t=e.dataset.tableId;return{tableId:String(t),side:"bottom"===e.style.captionSide?"bottom":"top"}}}])}(Ht);d(_t,"blotName",N.tableCaption),d(_t,"tagName","caption"),d(_t,"className","ql-table-caption"),d(_t,"allowedChildren",[Pt,Ft]);var Vt=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"setFormatValue",value:function(e,t){if(this.statics.allowAttrs.has(e)||this.statics.allowDataAttrs.has(e)){var n=e;this.statics.allowDataAttrs.has(e)&&(n="data-".concat(e)),t?this.domNode.setAttribute(n,t):this.domNode.removeAttribute(n)}else this.statics.isAllowStyle(e)&&(Object.assign(this.domNode.style,d({},e,t)),e.startsWith("border")&&this.setStyleBoder(e,t));this.children.head&&this.children.head.statics.blotName===N.tableCellInner&&this.domNode.style.cssText&&(this.children.head.domNode.dataset.style=this.domNode.style.cssText)}},{key:"setStyleBoder",value:function(e,t){var n=Boolean(t)?t:null;if(!["left","right","top","bottom"].some((function(t){return e.includes(t)}))&&e.startsWith("border-")){var i,o=c(this.getNearByCell("left").map((function(e){return e.descendant(Ot,0)[0]})).filter(Boolean));try{for(o.s();!(i=o.n()).done;){i.value.setFormatValue(e.replace("border-","border-right-"),n,!0)}}catch(e){o.e(e)}finally{o.f()}var r,a=c(this.getNearByCell("top").map((function(e){return e.descendant(Ot,0)[0]})).filter(Boolean));try{for(a.s();!(r=a.n()).done;){r.value.setFormatValue(e.replace("border-","border-bottom-"),n,!0)}}catch(e){a.e(e)}finally{a.f()}}}},{key:"getNearByCell",value:function(e){var t=[];try{var n=q(this,N.tableMain);t.push.apply(t,M(n.getColIds()))}catch(e){console.error("Cell is not in table! ".concat(e))}if(0===t.length)return[];if("left"===e){for(var i=new Set,o=this.parent,r=0;r<this.rowspan&&o instanceof At;r++){for(var a=o.children.iterator(),l=null;l=a();){var s=t.indexOf(l.colId)+l.colspan;this.colId===t[s]&&i.add(l)}o=o.next}return Array.from(i)}if("top"===e){if(!(this.parent instanceof At&&this.parent.prev))return[];for(var c=new Set,d=this.getColumnIndex(),u=d+this.colspan,h=new Set(t.filter((function(e,t){return t>=d&&t<u}))),f=1,p=this.parent.prev;p;){for(var v=!1,b=p.children.iterator(),m=null,g=0;m=b();)h.has(m.colId)&&m.rowspan>=f&&(c.add(m),h.delete(m.colId)),g+=m.colspan,m.rowspan>=f&&(v=!0);if(!v&&g===t.length)break;p=p.prev,f+=1}return Array.from(c)}return[]}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"rowId",get:function(){return this.domNode.dataset.rowId}},{key:"colId",get:function(){return this.domNode.dataset.colId}},{key:"rowspan",get:function(){return Number(this.domNode.getAttribute("rowspan"))}},{key:"colspan",get:function(){return Number(this.domNode.getAttribute("colspan"))}},{key:"getColumnIndex",value:function(){return q(this,N.tableMain).getColIds().indexOf(this.colId)}},{key:"getCellInner",value:function(){return this.children.head}},{key:"checkMerge",value:function(){var e=this.colId,t=this.rowId,n=this.colspan,i=this.rowspan,o=this.next;return null!==o&&o.statics.blotName===this.statics.blotName&&o.rowId===t&&o.colId===e&&o.colspan===n&&o.rowspan===i}},{key:"optimize",value:function(e){var n=this.parent,i=this.tableId,o=this.rowId;null!==n&&n.statics.blotName!==N.tableRow&&this.wrap(N.tableRow,{tableId:i,rowId:o}),x(t,"optimize",this,3)([e])}}],[{key:"isAllowStyle",value:function(e){var t,n=c(this.allowStyle);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(e.startsWith(i))return!0}}catch(e){n.e(e)}finally{n.f()}return!1}},{key:"create",value:function(e){var n=e.tableId,i=e.rowId,o=e.colId,r=e.rowspan,a=e.colspan,l=e.style,s=x(t,"create",this,2)([]);return s.dataset.tableId=n,s.dataset.rowId=i,s.dataset.colId=o,s.setAttribute("rowspan",String(Lt(r))),s.setAttribute("colspan",String(Lt(a))),l&&(s.style.cssText=l),s}},{key:"formats",value:function(e){for(var t=e.dataset,n=t.tableId,i=t.rowId,o=t.colId,r=Number(e.getAttribute("rowspan")),a=Number(e.getAttribute("colspan")),l={tableId:n,rowId:i,colId:o,rowspan:Lt(r),colspan:Lt(a)},s={},c=0;c<e.style.length;c++){var d=e.style[c],u=e.style[d];this.isAllowStyle(String(d))&&!["initial","inherit"].includes(u)&&(s[d]=u)}var h=Object.entries(s);return h.length>0&&(l.style=h.map((function(e){var t=C(e,2),n=t[0],i=t[1];return"".concat(n,": ").concat(i)})).join(";")),l}}])}(St);d(Vt,"blotName",N.tableCell),d(Vt,"tagName","td"),d(Vt,"className","ql-table-cell"),d(Vt,"allowDataAttrs",new Set(["table-id","row-id","col-id"])),d(Vt,"allowAttrs",new Set(["rowspan","colspan"])),d(Vt,"allowStyle",new Set(["background-color","border","height"]));var Xt=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"width",get:function(){var e=this.domNode.getAttribute("width");if(!e){if(e=this.domNode.getBoundingClientRect().width,this.full){var t=this.domNode.closest("table");return t?e/100*t.getBoundingClientRect().width:E[this.full?"colMinWidthPre":"colMinWidthPx"]}return e}return Number.parseFloat(String(e))},set:function(e){var t=Number.parseFloat(String(e));Number.isNaN(t)&&(t=E[this.full?"colMinWidthPre":"colMinWidthPx"]),this.domNode.setAttribute("width",this.statics.validWidth(t,!!this.full))}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"colId",get:function(){return this.domNode.dataset.colId}},{key:"full",get:function(){return Object.hasOwn(this.domNode.dataset,"full")},set:function(e){e?this.domNode.dataset.full=String(!0):this.domNode.removeAttribute("data-full")}},{key:"align",get:function(){return this.domNode.dataset.align||""},set:function(e){"right"===e||"center"===e?this.domNode.dataset.align=e:this.domNode.removeAttribute("data-align")}},{key:"checkMerge",value:function(){var e=this.next,t=this.tableId,n=this.colId;return null!==e&&e.statics.blotName===this.statics.blotName&&e.tableId===t&&e.colId===n}},{key:"optimize",value:function(e){var n=this.parent;if(null!=n&&n.statics.blotName!==N.tableColgroup){var i=this.statics.value(this.domNode);this.wrap(N.tableColgroup,i)}q(this,N.tableColgroup).align=this.align,null!=this.next&&this.checkMerge()&&this.next.remove(),x(t,"optimize",this,3)([e]);try{var o=q(this,N.tableColgroup),r=!0;o.children.forEach((function(e){r&&(r=e.full)})),o.full=r}catch(e){}}},{key:"insertAt",value:function(e,n,i){var o=this;if(null==i){var r=n.split("\n"),a=r.pop(),l=r.map((function(e){var t=o.scroll.create("block");return t.insertAt(0,e),t})),s=this.split(e),d=C(H(this,[N.tableColgroup,N.tableMain]),2),u=d[0],h=d[1],f=u.next;if(s){var p=s.offset(u);u.split(p)}var v=h.parent.parent,b=h.parent.next;if(f){var m=f.descendants(Ot);if(m.length>0){var g=m[0],y=Ot.formats(g.domNode),w=this.scroll.create("block"),M=w.wrap(N.tableCellInner,y).wrap(N.tableCell,y).wrap(N.tableRow,y).wrap(N.tableBody,y.tableId);u.parent.insertBefore(M,u.next),v=w,b=w.next}}var k,I=c(l);try{for(I.s();!(k=I.n()).done;){var T=k.value;v.insertBefore(T,b)}}catch(e){I.e(e)}finally{I.f()}a&&v.insertBefore(this.scroll.create("text",a),b)}else x(t,"insertAt",this,3)([e,n,i])}}],[{key:"validWidth",value:function(e,t){var n=Number.parseFloat(String(e));return Number.isNaN(n)&&(n=E[t?"colMinWidthPre":"colMinWidthPx"]),"".concat(n).concat(t?"%":"px")}},{key:"create",value:function(e){var n=e.width,i=e.tableId,o=e.colId,r=e.full,a=e.align,l=x(t,"create",this,2)([]);return l.setAttribute("width",this.validWidth(n,!!r)),r&&(l.dataset.full=String(r)),a&&"left"!==a&&(l.dataset.align=a),l.dataset.tableId=i,l.dataset.colId=o,l}},{key:"value",value:function(e){var t=e.dataset,n=t.tableId,i=t.colId,o=e.getAttribute("width")||String(E.colDefaultWidth),r=e.dataset.align,a=Object.hasOwn(e.dataset,"full"),l={tableId:String(n),colId:String(i),full:a,width:Number.parseFloat(o)};return r&&(l.align=r),l}}])}(t.import("blots/block/embed"));d(Xt,"blotName",N.tableCol),d(Xt,"tagName","col");var Ut=function(e){function t(e,n,i){var o;return a(this,t),d(o=r(this,t,[e,n]),"scroll",void 0),o.scroll=e,o.updateAlign(),o}return f(t,e),s(t,[{key:"colWidthFillTable",value:function(){if(this.full)Object.assign(this.domNode.style,{width:null});else{var e=this.getCols();if(e){var t=e.reduce((function(e,t){return t.width+e}),0);if(0!==t&&!Number.isNaN(t))return this.domNode.style.width="".concat(t,"px"),t}}}},{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"full",get:function(){return Object.hasOwn(this.domNode.dataset,"full")},set:function(e){e?this.domNode.dataset.full=String(!0):this.domNode.removeAttribute("data-full"),this.colWidthFillTable()}},{key:"align",get:function(){return this.domNode.dataset.align||""},set:function(e){"right"===e||"center"===e?this.domNode.dataset.align=e:this.domNode.removeAttribute("data-align"),this.updateAlign()}},{key:"setFull",value:function(){if(!this.full){var e=this.getCols();if(0!==e.length){var t,n=Math.floor(this.domNode.getBoundingClientRect().width),i=c(e);try{for(i.s();!(t=i.n()).done;){var o=t.value,r=o.width/n*100;o.full=!0,o.width=r}}catch(e){i.e(e)}finally{i.f()}}}}},{key:"cancelFull",value:function(){if(this.full){var e=this.getCols();if(0!==e.length){var t,n=Math.floor(this.domNode.getBoundingClientRect().width),i=c(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;o.full=!1,o.width=Math.max(o.width/100*n,E.colMinWidthPx)}}catch(e){i.e(e)}finally{i.f()}}}}},{key:"updateAlign",value:function(){var e={marginLeft:null,marginRight:null};switch(this.align){case"center":e.marginLeft="auto",e.marginRight="auto";break;case"":case"left":e.marginRight="auto";break;case"right":e.marginLeft="auto"}Object.assign(this.domNode.style,e)}},{key:"getRows",value:function(){return this.descendants(At)}},{key:"getRowIds",value:function(){return this.getRows().map((function(e){return e.rowId}))}},{key:"getCols",value:function(){return this.descendants(Xt)}},{key:"getColIds",value:function(){return this.getCols().map((function(e){return e.colId}))}},{key:"checkMerge",value:function(){var e=this.next;return null!==e&&e.statics.blotName===this.statics.blotName&&e.domNode.dataset.tableId===this.tableId}},{key:"optimize",value:function(e){var n=this.parent;null!==n&&n.statics.blotName!==N.tableWrapper&&this.wrap(N.tableWrapper,this.tableId),x(t,"optimize",this,3)([e])}},{key:"sortMergeChildren",value:function(){var e=d(d(d({},N.tableCaption,[]),N.tableColgroup,[]),N.tableBody,[]);this.children.forEach((function(t){e[t.statics.blotName]&&e[t.statics.blotName].push(t)}));for(var t=0,n=Object.values(e);t<n.length;t++)for(var i=n[t],o=1;o<i.length;o++)i[o].moveChildren(i[0]);var r=e[N.tableCaption][0],a=e[N.tableColgroup][0],l=e[N.tableBody][0],s=r&&this.children.head!==r,c=a&&r&&r.next!==a,u=a&&!r&&this.children.head!==a,h=l&&this.children.tail!==l;if(s||c||u||h){var f=this.clone();r&&f.appendChild(r),a&&f.appendChild(a),l&&f.appendChild(l),this.children.forEach((function(e){return e.remove()})),f.moveChildren(this)}}}],[{key:"create",value:function(e){var n=x(t,"create",this,2)([]),i=e.tableId,o=e.full,r=e.align;return n.dataset.tableId=i,"right"===r||"center"===r?n.dataset.align=r:n.removeAttribute("date-align"),o&&(n.dataset.full=String(o)),n.setAttribute("cellpadding","0"),n.setAttribute("cellspacing","0"),n}}])}(St);d(Ut,"blotName",N.tableMain),d(Ut,"tagName","table"),d(Ut,"className","ql-table");var Yt=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,[{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"full",get:function(){return Object.hasOwn(this.domNode.dataset,"full")},set:function(e){e?this.domNode.dataset.full=String(!0):this.domNode.removeAttribute("data-full"),this.parent&&this.parent instanceof Ut&&(this.parent.full=e)}},{key:"align",get:function(){return this.domNode.dataset.align||""},set:function(e){"right"===e||"center"===e?this.domNode.dataset.align=e:this.domNode.removeAttribute("data-align")}},{key:"findCol",value:function(e){for(var t,n=this.children.iterator(),i=0;(t=n())&&i!==e;)i++;return t}},{key:"insertColByIndex",value:function(e,t){var n=this.parent;if(!(n instanceof Ut))throw new TypeError("TableColgroupFormat should be child of TableFormat");var i=this.findCol(e),o=this.scroll.create(N.tableCol,t);if(n.full)for(var r,a=this.children.iterator();r=a();)if(r.width-o.width>=E.colMinWidthPre){r.width-=o.width;break}this.insertBefore(o,i)}},{key:"removeColByIndex",value:function(e){var t=this.parent;if(!(t instanceof Ut))throw new TypeError("TableColgroupFormat should be child of TableMainFormat");var n=this.findCol(e);n&&(t.full&&(n.next?n.next.width+=n.width:n.prev&&(n.prev.width+=n.width)),n.remove(),t.colWidthFillTable())}},{key:"checkMerge",value:function(){var e=this.next,t=this.parent;return t instanceof Ut&&!t.full&&t.colWidthFillTable(),null!==e&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}},{key:"optimize",value:function(e){var n=this.parent,i=this.tableId,o=this.full,r=this.align;null!=n&&n.statics.blotName!==N.tableMain&&this.wrap(N.tableMain,{tableId:i,full:o,align:r}),q(this,N.tableMain).align=r,x(t,"optimize",this,3)([e])}}],[{key:"create",value:function(e){var n=x(t,"create",this,2)([]);return n.dataset.tableId=e.tableId,e.full&&(n.dataset.full=String(e.full)),e.align&&"left"!==e.align&&(n.dataset.align=e.align),n.setAttribute("contenteditable","false"),n}}])}(St);d(Yt,"blotName",N.tableColgroup),d(Yt,"tagName","colgroup");var Gt=t.import("parchment"),Kt=function(e){function n(e,i,o){var l;return a(this,n),d(l=r(this,n,[e,i]),"scroll",void 0),d(l,"insertLineAround",(function(){l.prev&&l.prev instanceof Gt.BlockBlot||l.parent.insertBefore(l.scroll.create("block"),l),l.next&&l.next instanceof Gt.BlockBlot||l.parent.insertBefore(l.scroll.create("block"),l.next)})),l.scroll=e,l.scroll.emitter.on(t.events.TEXT_CHANGE,l.insertLineAround),l}return f(n,e),s(n,[{key:"tableId",get:function(){return this.domNode.dataset.tableId}},{key:"checkMerge",value:function(){var e=this.next;return null!==e&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}},{key:"deleteAt",value:function(e,t){x(n,"deleteAt",this,3)([e,t]);var i=this.descendants(zt),o=this.descendants(Yt);0!==i.length&&0!==o.length||this.remove()}},{key:"remove",value:function(){x(n,"remove",this,3)([]),this.scroll.emitter.off(t.events.TEXT_CHANGE,this.insertLineAround)}}],[{key:"create",value:function(e){var t=x(n,"create",this,2)([]);return t.dataset.tableId=e,t.addEventListener("dragstart",(function(e){e.preventDefault(),e.stopPropagation()}),!0),t.addEventListener("drop",(function(e){e.preventDefault()})),t.addEventListener("dragover",(function(e){e.preventDefault(),e.dataTransfer.dropEffect="none"})),t.setAttribute("contenteditable","false"),t}}])}(St);function Zt(e){var t=C(D(e,zt),1)[0];return{body:t,rect:t.domNode.getBoundingClientRect()}}d(Kt,"blotName",N.tableWrapper),d(Kt,"tagName","div"),d(Kt,"className","ql-table-wrapper");var $t=function(){return s((function e(n,i,o){var r=this;a(this,e),d(this,"tableModule",void 0),d(this,"table",void 0),d(this,"quill",void 0),d(this,"tableBlot",void 0),d(this,"tableWrapperBlot",void 0),d(this,"alignBox",void 0),d(this,"cleanup",void 0),d(this,"bem",z("align")),d(this,"resizeObserver",mt((function(){return r.update()}),{ignoreFirstBind:!0})),d(this,"updateWhenTextChange",(function(){r.update()})),this.tableModule=n,this.table=i,this.quill=o,this.tableBlot=t.find(i),this.tableWrapperBlot=this.tableBlot.parent,this.alignBox=this.buildTool(),this.resizeObserver.observe(this.table),this.quill.on(t.events.TEXT_CHANGE,this.updateWhenTextChange),this.show()}),[{key:"buildTool",value:function(){for(var e=this,n=this.tableModule.addContainer(this.bem.b()),i=t.import("ui/icons"),o={left:i.align[""],center:i.align.center,right:i.align.right},r=function(){var i=C(l[a],2),o=i[0],r=i[1],s=document.createElement("span");s.dataset.align=o,s.classList.add(e.bem.be("item")),s.innerHTML='<i class="icon">'.concat(r,"</i>"),s.addEventListener("click",(function(){var n=s.dataset.align;n&&(e.setTableAlign(e.tableBlot,n),e.quill.once(t.events.SCROLL_OPTIMIZE,(function(){e.tableModule.tableSelection&&e.tableModule.tableSelection.hide(),e.tableModule.tableResize&&e.tableModule.tableResize.update(),e.tableModule.tableResizeScale&&e.tableModule.tableResizeScale.update(),e.tableModule.tableScrollbar&&e.tableModule.tableScrollbar.update()})))})),n.appendChild(s)},a=0,l=Object.entries(o);a<l.length;a++)r();return this.cleanup||(this.cleanup=lt(this.tableWrapperBlot.domNode,n,(function(){return e.update()}))),n}},{key:"setTableAlign",value:function(e,t){var n,i=c(e.getCols());try{for(i.s();!(n=i.n()).done;){n.value.align=t}}catch(e){i.e(e)}finally{i.f()}}},{key:"show",value:function(){this.alignBox&&(this.alignBox.classList.add(this.bem.bm("active")),this.update())}},{key:"hide",value:function(){this.alignBox&&(this.alignBox.classList.remove(this.bem.bm("active")),this.cleanup&&(this.cleanup(),this.cleanup=void 0))}},{key:"update",value:function(){var e=this;this.alignBox&&(this.tableBlot.full||this.tableBlot.domNode.offsetWidth>=this.quill.root.offsetWidth?this.hide():ht(this.tableWrapperBlot.domNode,this.alignBox,{placement:"top",middleware:[dt(),ct({limiter:ut()}),st(16)]}).then((function(t){var n=t.x,i=t.y;Object.assign(e.alignBox.style,{left:"".concat(n,"px"),top:"".concat(i,"px")})})))}},{key:"destroy",value:function(){this.hide(),this.resizeObserver.disconnect(),this.quill.off(t.events.TEXT_CHANGE,this.updateWhenTextChange),this.alignBox&&(this.alignBox.remove(),this.alignBox=void 0)}}])}(),Qt=["style"],Jt=["attributes"],en=["attributes"],tn=["background"],nn=t.import("delta");function on(e){var t=Number.parseFloat(e.getAttribute("width")||String(E.colDefaultWidth));if(Number.isNaN(t)){var n=e.style.width;t=n?Number.parseFloat(n):e.offsetWidth}return t}var rn=function(e){function t(e,n){var i;return a(this,t),d(i=r(this,t,[e,n]),"quill",void 0),d(i,"tableId",Mt()),d(i,"rowId",Mt()),d(i,"colIds",[]),d(i,"rowspanCount",[]),d(i,"cellCount",0),d(i,"colCount",0),i.quill=e,i.addMatcher("table",i.matchTable.bind(i)),i.addMatcher("tbody",i.matchTbody.bind(i)),i.addMatcher("colgroup",i.matchColgroup.bind(i)),i.addMatcher("col",i.matchCol.bind(i)),i.addMatcher("tr",i.matchTr.bind(i)),i.addMatcher("td",i.matchTd.bind(i)),i.addMatcher("th",i.matchTd.bind(i)),i.addMatcher("caption",i.matchCaption.bind(i)),i.addMatcher(Node.ELEMENT_NODE,i.matchTdAttributor.bind(i)),i}return f(t,e),s(t,[{key:"matchTable",value:function(e,t){var n=this;if(0===t.ops.length)return t;for(var i=[],o=[],r=-1,a=0;a<t.ops.length;a++){var l=t.ops[a],s=l.attributes,u=l.insert,h=s||{},f=N.tableCell;h.table,h[f];var p=m(h,["table",f].map(k)),v=Z(u)&&u[N.tableCol];v?o.push({insert:u}):i.push({attributes:p,insert:u}),null!=p&&p[N.tableCellInner]||null!=p&&p[N.tableCaption]||v||!K(u)||!(u.trim().length>0)||(r=a)}var b=function(e,t){for(var n=new Array(t).fill(E.colDefaultWidth),i=0,o=Array.from(e.querySelectorAll("tr"));i<o.length;i++){var r,a=o[i],l=c(Array.from(a.querySelectorAll("td")).entries());try{for(l.s();!(r=l.n()).done;){var s=C(r.value,2),d=s[0],u=s[1];if(!(d<t))break;var h=on(u);n[d]=h||n[d]}}catch(e){l.e(e)}finally{l.f()}}return n}(e,this.colIds.length).reduce((function(e,t,i){return o[i]?e.push(o[i]):e.push({insert:d({},N.tableCol,{tableId:n.tableId,colId:n.colIds[i],width:t,full:!1})}),e}),[]);return i.splice.apply(i,[r+1,0].concat(M(b))),this.tableId=Mt(),this.colIds=[],this.rowspanCount=[],this.cellCount=0,this.colCount=0,new nn(i)}},{key:"matchTbody",value:function(e,t){var n=e.style.backgroundColor;if(n){var i,o=c(t.ops);try{for(o.s();!(i=o.n()).done;){var r,a=i.value;if(null!==(r=a.attributes)&&void 0!==r&&r[N.tableCellInner]){var l=a.attributes[N.tableCellInner],s=l.style,d=m(l,Qt),u=wt(s||"");u.backgroundColor||(u.backgroundColor=n,a.attributes[N.tableCellInner]=b(b({},d),{},{style:Ct(u)}))}}}catch(e){o.e(e)}finally{o.f()}}return t}},{key:"matchColgroup",value:function(e,t){for(var n=[],i=0;i<t.ops.length;i++){var o=t.ops[i];o&&Z(o.insert)&&o.insert[N.tableCol]&&n.push(o)}return new nn(n)}},{key:"matchCol",value:function(e){this.colIds[this.colCount]=Mt();var t=(new nn).insert(d({},N.tableCol,Object.assign(Xt.value(e),{tableId:this.tableId,colId:this.colIds[this.colCount]})));return this.colCount+=1,t}},{key:"matchTr",value:function(e,t){this.rowId=Mt(),this.cellCount=0;var n,i=c(this.rowspanCount.entries());try{for(i.s();!(n=i.n()).done;){var o=C(n.value,2),r=o[0],a=o[1];a.rowspan>0&&(a.rowspan-=1),a.rowspan<=0&&(this.rowspanCount[r]={rowspan:0,colspan:0})}}catch(e){i.e(e)}finally{i.f()}var l,s=c(t.ops);try{for(s.s();!(l=s.n()).done;){var d=l.value;if(d.attributes){var u=d.attributes,h=u.background,f=u[N.tableCellInner];if(f&&h){var p=f.style,v=wt(void 0===p?"":p);v.backgroundColor=h,d.attributes[N.tableCellInner].style=Ct(v)}}}}catch(e){s.e(e)}finally{s.f()}return t}},{key:"matchTd",value:function(e,t){var n=e,i=Vt.formats(n);if(!this.colIds[this.cellCount]||!this.rowspanCount[this.cellCount])for(var o=this.cellCount;o>=0;o--)this.colIds[o]||(this.colIds[o]=Mt()),this.rowspanCount[o]||(this.rowspanCount[o]={rowspan:0,colspan:0});for(var r=this.cellCount;r<this.rowspanCount.length;r++){var a=this.rowspanCount[r],l=a.rowspan,s=a.colspan;if(0===l)break;this.cellCount+=s}i.rowspan>1&&(this.rowspanCount[this.cellCount]={rowspan:i.rowspan,colspan:i.colspan});var u=this.colIds[this.cellCount];this.cellCount+=i.colspan;var h=Object.assign(i,{tableId:this.tableId,rowId:this.rowId,colId:u});"none"===n.style.border&&(h.style=h.style.replaceAll(/border-(top|right|bottom|left)-style:none;?/g,""));var f,p=[],v=c(t.ops);try{for(v.s();!(f=v.n()).done;){var g=f.value,y=g.attributes,w=void 0===y?{}:y,C=m(g,Jt),x=N.tableCell,M=(w[x],m(w,[x].map(k)));p.push(b(b({},C),{},{attributes:b(b({},M),{},d({},N.tableCellInner,h))}))}}catch(e){v.e(e)}finally{v.f()}return(p.length<=0||!K(p[p.length-1].insert)||!p[p.length-1].insert.endsWith("\n"))&&p.push({insert:"\n",attributes:d({},N.tableCellInner,h)}),new nn(p)}},{key:"matchTdAttributor",value:function(e,t){if("td"===e.tagName.toLocaleLowerCase()){var n,i=[],o=c(t.ops);try{for(o.s();!(n=o.n()).done;){var r=n.value,a=r.attributes,l=m(r,en),s=null==a?void 0:a[N.tableCellInner];if(a&&s&&s.style){var d=a.background,u=m(a,tn),h=document.createElement("div");h.style.background=d;var f=document.createElement("div");if(f.style.cssText=s.style,h.style.background===f.style.backgroundColor){i.push(b(b({},l),{},{attributes:b({},u)}));continue}}i.push(r)}}catch(e){o.e(e)}finally{o.f()}return new nn(i)}return t}},{key:"convert",value:function(e){var n=e.html,i=e.text,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=x(t,"convert",this,3)([{html:n,text:i},o]);if(o[N.tableCellInner]){var a,l=c(r.ops);try{for(l.s();!(a=l.n()).done;){var s=a.value;Z(s.insert)&&s.insert[N.tableCol]?s.insert="":(s.attributes||(s.attributes={}),s.attributes[N.tableCellInner]=o[N.tableCellInner])}}catch(e){l.e(e)}finally{l.f()}}return r}},{key:"matchCaption",value:function(e,t){for(var n=0;n<t.ops.length;n++){var i=t.ops[n],o=i.attributes;o&&o[N.tableCaption]&&(o[N.tableCaption].tableId=this.tableId,i.attributes=o)}return t}}])}(t.import("modules/clipboard")),an="color-selector",ln={Break:{name:"break"},CopyCell:{name:"CopyCell",tip:"Copy cell",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256">\n <g fill="currentColor">\n <path d="M216 40v128h-48V88H88V40Z" opacity=".2" />\n <path\n d="M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8m-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z"\n />\n </g>\n</svg>\n',handle:function(e,t){var n=e.getTextByCell(t),i=e.getHTMLByCell(t),o=new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([i],{type:"text/html"})});navigator.clipboard.write([o]),e.hideTableTools()}},CutCell:{name:"CutCell",tip:"Cut cell",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32">\n <path\n fill="currentColor"\n d="m19.05 13.733l-1-1.733l-10.122 5.846l-.997-.576a3 3 0 0 0 .667-.769A3 3 0 1 0 3.5 17.599L5.928 19L3.5 20.402a3.034 3.034 0 1 0 3.44.323l.988-.57L14.59 24l1-1.73L9.928 19zM4.034 15.26a1 1 0 1 1 .466.607a1 1 0 0 1-.466-.607M5 22a1 1 0 1 1-.865 1.5A1 1 0 0 1 5 22m12 4h4v2h-4zm-7 0h4v2h-4z"\n />\n <path fill="currentColor" d="M28 28h-4v-2h4V4H7v4H5V4a2 2 0 0 1 2-2h21a2 2 0 0 1 2 2v22a2 2 0 0 1-2 2" />\n</svg>\n',handle:function(e,t){var n=e.getTextByCell(t),i=e.getHTMLByCell(t,!0),o=new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([i],{type:"text/html"})});navigator.clipboard.write([o]),e.hideTableTools()}},InsertTop:{name:"InsertTop",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm17.94 4.5h-2v4h-2v-4h-2l3-3z"\n />\n</svg>\n',tip:"Insert row above",handle:function(e,t){e.appendRow(t,!1),e.hideTableTools()}},InsertRight:{name:"InsertRight",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm15.44 8v-2h-4v-2h4v-2l3 3z"\n />\n</svg>\n',tip:"Insert column right",handle:function(e,t){e.appendCol(t,!0),e.hideTableTools()}},InsertBottom:{name:"InsertBottom",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm11.94 5.5h2v-4h2v4h2l-3 3z"\n />\n</svg>\n',tip:"Insert row below",handle:function(e,t){e.appendRow(t,!0),e.hideTableTools()}},InsertLeft:{name:"InsertLeft",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm14.44 2v2h4v2h-4v2l-3-3z"\n />\n</svg>\n',tip:"Insert column Left",handle:function(e,t){e.appendCol(t,!1),e.hideTableTools()}},MergeCell:{name:"MergeCell",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M5 10H3V4h8v2H5zm14 8h-6v2h8v-6h-2zM5 18v-4H3v6h8v-2zM21 4h-8v2h6v4h2zM8 13v2l3-3l-3-3v2H3v2zm8-2V9l-3 3l3 3v-2h5v-2z"\n />\n</svg>\n',tip:"Merge Cell",handle:function(e,t){e.mergeCells(t),e.hideTableTools()}},SplitCell:{name:"SplitCell",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M19 14h2v6H3v-6h2v4h14zM3 4v6h2V6h14v4h2V4zm8 7v2H8v2l-3-3l3-3v2zm5 0V9l3 3l-3 3v-2h-3v-2z"\n />\n</svg>\n',tip:"Split Cell",handle:function(e,t){e.splitCell(t),e.hideTableTools()}},DeleteRow:{name:"DeleteRow",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41zM22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2zM4 9h4V6H4zm6 0h4V6h-4zm6 0h4V6h-4z"\n />\n</svg>\n',tip:"Delete Row",handle:function(e,t){e.removeRow(t),e.hideTableTools()}},DeleteColumn:{name:"DeleteColumn",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4zm0 6v4h7v-4zM4 4v4h7V4zm13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59z"\n />\n</svg>\n',tip:"Delete Column",handle:function(e,t){e.removeCol(t),e.hideTableTools()}},DeleteTable:{name:"DeleteTable",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="currentColor"\n d="m15.46 15.88l1.42-1.42L19 16.59l2.12-2.13l1.42 1.42L20.41 18l2.13 2.12l-1.42 1.42L19 19.41l-2.12 2.13l-1.42-1.42L17.59 18zM4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4z"\n />\n</svg>\n',tip:"Delete table",handle:function(e,t){e.deleteTable(t)}},BackgroundColor:{name:"BackgroundColor",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="none"\n stroke="currentColor"\n stroke-linecap="round"\n stroke-linejoin="round"\n stroke-width="2"\n d="m4 8l4-4m6 0L4 14m0 6L20 4m0 6L10 20m10-4l-4 4"\n />\n</svg>\n',isColorChoose:!0,tip:"Set background color",key:"background-color",handle:function(e,t,n){e.setCellAttrs(t,"background-color",n,!0)}},BorderColor:{name:"BorderColor",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n <path\n fill="none"\n stroke="currentColor"\n stroke-linecap="round"\n stroke-linejoin="round"\n stroke-width="1.5"\n d="m12.01 16l-.01.011M12.01 12l-.01.011M12.01 8l-.01.011M8.01 12l-.01.011M16.01 12l-.01.011M21 3.6v16.8a.6.6 0 0 1-.6.6H3.6a.6.6 0 0 1-.6-.6V3.6a.6.6 0 0 1 .6-.6h16.8a.6.6 0 0 1 .6.6"\n />\n</svg>\n',isColorChoose:!0,tip:"Set border color",key:"border-color",handle:function(e,t,n){e.setCellAttrs(t,"border-color",n,!0)}},SwitchWidth:{name:"SwitchWidth",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n \x3c!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE --\x3e\n <path\n fill="none"\n stroke="currentColor"\n stroke-linecap="round"\n stroke-linejoin="round"\n stroke-width="2"\n d="M4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v6m-10 6H3m18 0h-7m-8-3l-3 3l3 3m12-6l3 3l-3 3"\n />\n</svg>\n',tip:"Switch table width",handle:function(e){if(e.table){var n=t.find(e.table);n&&(n.full?n.cancelFull():n.setFull())}}},InsertCaption:{name:"InsertCaption",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\n \x3c!-- Icon from TDesign Icons by TDesign - https://github.com/Tencent/tdesign-icons/blob/main/LICENSE --\x3e\n <path fill="currentColor" d="M21 10v12h-2V12H5v10H3V10zm0-8v6H3V2zm-2 2H5v2h14z" />\n</svg>\n',tip:"Insert table caption",handle:function(e){if(e.table){var n=t.find(e.table);if(n){var i=e.quill.scroll.create("text","Table Caption").wrap(N.tableCaption,{tableId:n.tableId});n.insertBefore(i,n.children.head)}}}}},sn=z("color-map"),cn={selectWrapper:sn.b(),used:sn.bm("used"),item:sn.be("item"),btn:sn.be("btn"),map:sn.be("content"),mapRow:sn.be("content-row")},dn=function(){return s((function e(n,i,o){var r=this;a(this,e),d(this,"tableModule",void 0),d(this,"quill",void 0),d(this,"usedColors",new Set),d(this,"options",void 0),d(this,"menu",null),d(this,"isMenuDisplay",!1),d(this,"isColorPicking",!1),d(this,"updateUsedColor",void 0),d(this,"tooltipItem",[]),d(this,"activeTooltip",null),d(this,"bem",z("menu")),d(this,"colorItemClass","color-".concat(Mt())),d(this,"colorChooseTooltipOption",{direction:"top"}),d(this,"updateWhenTextChange",(function(){r.isMenuDisplay&&r.update()})),this.tableModule=n,this.quill=i,this.options=this.resolveOptions(o);try{var l=localStorage.getItem(this.options.localstorageKey)||"[]",s=JSON.parse(l);G(s)||(s=[]),s.slice(-10).map((function(e){return r.usedColors.add(e)}))}catch(e){}this.updateUsedColor=kt((function(e){if(e){if(r.usedColors.add(e),r.usedColors.size>10){var t=Array.from(r.usedColors).slice(-10);r.usedColors.clear(),t.map((function(e){return r.usedColors.add(e)}))}localStorage.setItem(r.options.localstorageKey,JSON.stringify(Array.from(r.usedColors)));for(var n=0,i=Array.from(document.querySelectorAll(".".concat(r.colorItemClass,".").concat(cn.used)));n<i.length;n++){var o=i[n],a=document.createElement("div");a.classList.add(cn.item),a.style.backgroundColor=String(e),Array.from(o.querySelectorAll(".".concat(cn.item,'[style*="background-color: ').concat(a.style.backgroundColor,'"]'))).length<=0&&o.appendChild(a);var l,s=c(Array.from(o.querySelectorAll(".".concat(cn.item))).slice(0,-10));try{for(s.s();!(l=s.n()).done;){l.value.remove()}}catch(e){s.e(e)}finally{s.f()}}}}),1e3),this.quill.on(t.events.TEXT_CHANGE,this.updateWhenTextChange)}),[{key:"resolveOptions",value:function(e){return Object.assign({tipText:!0,tools:[ln.InsertTop,ln.InsertRight,ln.InsertBottom,ln.InsertLeft,ln.Break,ln.MergeCell,ln.SplitCell,ln.Break,ln.DeleteRow,ln.DeleteColumn,ln.DeleteTable,ln.Break,ln.BackgroundColor,ln.BorderColor],localstorageKey:"__table-bg-used-color",defaultColorMap:B},e)}},{key:"buildTools",value:function(){var e=this,t=document.createElement("div");t.classList.add(this.bem.b()),Object.assign(t.style,{display:"flex"});var n,i=c(this.options.tools);try{var o=function(){var i=n.value,o=i.name,r=i.icon,a=i.handle,l=i.isColorChoose,s=i.key,c=i.tip,d=void 0===c?"":c,u=document.createElement("span");if(u.classList.add(e.bem.be("item")),"break"===o)u.classList.add(e.bem.is("break"));else{var h=document.createElement("i");if(h.classList.add("icon"),Y(r)?h.appendChild(r(e.tableModule)):h.innerHTML=r,u.appendChild(h),l&&s){var f=e.createColorChoose(u,{name:o,icon:r,handle:a,isColorChoose:l,key:s,tip:d});e.tooltipItem.push(f),u.classList.add(an)}else Y(a)&&u.addEventListener("click",(function(t){e.quill.focus(),a(e.tableModule,e.getSelectedTds(),t)}),!1);var p=e.tableModule.options.texts[o]||d;e.options.tipText&&p&&d&&e.createTipText(u,p)}t.appendChild(u)};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return t}},{key:"createColorChoose",value:function(e,t){var n=this,i=t.handle,o=t.key,r=document.createElement("div");if(r.classList.add(cn.selectWrapper),this.options.defaultColorMap.length>0){var a=document.createElement("div");a.classList.add(cn.map);var l,s=c(this.options.defaultColorMap);try{for(s.s();!(l=s.n()).done;){var d=l.value,u=document.createElement("div");u.classList.add(cn.mapRow);var h,f=c(d);try{for(f.s();!(h=f.n()).done;){var p=h.value,v=document.createElement("div");v.classList.add(cn.item),v.style.backgroundColor=p,u.appendChild(v)}}catch(e){f.e(e)}finally{f.f()}a.appendChild(u)}}catch(e){s.e(e)}finally{s.f()}r.appendChild(a)}var m=document.createElement("div");m.classList.add(cn.mapRow),Object.assign(m.style,{marginTop:"4px"});var g=document.createElement("div");g.classList.add(cn.btn,"transparent"),g.textContent=this.tableModule.options.texts.transparent,g.addEventListener("click",(function(){i(n.tableModule,n.getSelectedTds(),"transparent")}));var y=document.createElement("div");y.classList.add(cn.btn,"clear"),y.textContent=this.tableModule.options.texts.clear,y.addEventListener("click",(function(){i(n.tableModule,n.getSelectedTds(),null)}));var w=document.createElement("div");w.classList.add(cn.btn,"custom"),w.textContent=this.tableModule.options.texts.custom;var C=Q({onChange:function(e){i(n.tableModule,n.getSelectedTds(),e),n.updateUsedColor(e)}}),x=pt(w,{direction:"right",type:"click",content:C,container:w}),M=x.hide,k=x.destroy;m.appendChild(g),m.appendChild(y),m.appendChild(w),r.appendChild(m);var I=document.createElement("div");I.classList.add(cn.used,this.colorItemClass);var T,N=c(this.usedColors);try{for(N.s();!(T=N.n()).done;){var E=T.value,S=document.createElement("div");S.classList.add(cn.item),S.style.backgroundColor=E,I.appendChild(S)}}catch(e){N.e(e)}finally{N.f()}r.appendChild(I),r.addEventListener("click",(function(e){e.stopPropagation(),M();var t=e.target,i=t.style.backgroundColor,r=n.getSelectedTds();if(t&&i&&r.length>0){if(n.tableModule.setCellAttrs(r,o,i,!0),!t.closest(".".concat(cn.item)))return;n.updateUsedColor(i)}}));var L=pt(e,b({type:"click",content:r,onOpen:function(){return n.isMenuDisplay&&n.tableModule.tableSelection&&n.tableModule.tableSelection.hideDisplay(),n.setActiveTooltip(L),!1},onClose:function(){return n.isMenuDisplay&&n.tableModule.tableSelection&&(n.tableModule.tableSelection.updateWithSelectedTds(),n.tableModule.tableSelection.showDisplay()),r.contains(C)&&M(),n.activeTooltip===L&&(n.activeTooltip=null),!1},onDestroy:function(){k(),n.activeTooltip===L&&(n.activeTooltip=null)}},this.colorChooseTooltipOption));return L.isColorPick=!0,L}},{key:"setActiveTooltip",value:function(e){this.activeTooltip&&this.activeTooltip!==e&&this.activeTooltip.hide(!0),this.activeTooltip=e}},{key:"getSelectedTds",value:function(){var e;return(null===(e=this.tableModule.tableSelection)||void 0===e?void 0:e.selectedTds)||[]}},{key:"createTipText",value:function(e,t){var n=pt(e,{msg:t});n&&this.tooltipItem.push(n)}},{key:"show",value:function(){this.menu&&this.tableModule.tableSelection&&this.tableModule.tableSelection.boundary&&(Object.assign(this.menu.style,{display:"flex"}),this.isMenuDisplay=!0,this.update())}},{key:"update",value:function(){}},{key:"hide",value:function(){this.menu&&Object.assign(this.menu.style,{display:"none"});var e,t=c(this.tooltipItem);try{for(t.s();!(e=t.n()).done;){e.value.hide(!0)}}catch(e){t.e(e)}finally{t.f()}this.isMenuDisplay=!1}},{key:"destroy",value:function(){this.quill.off(t.events.TEXT_CHANGE,this.updateWhenTextChange),this.activeTooltip=null;var e,n=c(this.tooltipItem);try{for(n.s();!(e=n.n()).done;){e.value.destroy()}}catch(e){n.e(e)}finally{n.f()}this.menu&&(this.hide(),this.menu.remove(),this.menu=null)}}])}(),un=function(e){function t(e,n,i){var o;return a(this,t),d(o=r(this,t,[e,n,i]),"tableModule",void 0),d(o,"quill",void 0),d(o,"colorChooseTooltipOption",{direction:"right"}),d(o,"listenContextmenu",(function(e){var t;e.preventDefault();var n=e.composedPath();!n||n.length<=0||(n.find((function(e){return e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("ql-table")}))&&null!==(t=o.tableModule.tableSelection)&&void 0!==t&&null!==(t=t.selectedTds)&&void 0!==t&&t.length?(o.menu||(o.menu=o.buildTools()),Object.assign(o.menu.style,{display:"flex"}),o.isMenuDisplay=!0,o.update({x:e.clientX,y:e.clientY}),document.addEventListener("click",(function(){o.hide()}),{once:!0})):o.hide())})),o.tableModule=e,o.quill=n,o.quill.root.addEventListener("contextmenu",o.listenContextmenu),o}return f(t,e),s(t,[{key:"buildTools",value:function(){var e=x(t,"buildTools",this,3)([]);e.classList.add(this.bem.is("contextmenu"));for(var n=e.getElementsByClassName(an),i=0,o=Array.from(n);i<o.length;i++){o[i].addEventListener("click",(function(e){return e.stopPropagation()}))}return document.body.appendChild(e),e}},{key:"createTipText",value:function(e,t){var n=document.createElement("span");n.textContent=t,e.appendChild(n)}},{key:"show",value:function(){}},{key:"update",value:function(e){if(this.isMenuDisplay&&this.menu&&this.tableModule.tableSelection&&this.tableModule.tableSelection.isDisplaySelection&&e){x(t,"update",this,3)([]);var n={display:"flex",left:0,top:0},i=e.x,o=e.y;n.left=i,n.top=o,Object.assign(this.menu.style,b(b({},n),{},{left:"".concat(n.left+window.scrollX,"px"),top:"".concat(n.top+window.scrollY,"px")}));var r=bt(this.menu.getBoundingClientRect()),a=r.left,l=r.top;Object.assign(this.menu.style,{left:"".concat(a+window.scrollX,"px"),top:"".concat(l+window.scrollY,"px")})}}},{key:"destroy",value:function(){this.quill.root.removeEventListener("contextmenu",this.listenContextmenu),x(t,"destroy",this,3)([])}}])}(dn),hn=function(e){function t(e,n,i){var o;return a(this,t),d(o=r(this,t,[e,n,i]),"tableModule",void 0),d(o,"quill",void 0),o.tableModule=e,o.quill=n,o.menu=o.buildTools(),o.tableModule.addContainer(o.menu),o.show(),o.update(),o}return f(t,e),s(t,[{key:"update",value:function(){var e=this;this.isMenuDisplay&&this.menu&&this.tableModule.tableSelection&&this.tableModule.tableSelection.isDisplaySelection&&(x(t,"update",this,3)([]),ht(this.tableModule.tableSelection.cellSelect,this.menu,{placement:"bottom",middleware:[dt(),ct({limiter:ut()}),st(20)]}).then((function(t){var n=t.x,i=t.y;Object.assign(e.menu.style,{left:"".concat(n,"px"),top:"".concat(i,"px")})})))}}])}(dn),fn=function(e){return!e.full&&"right"===e.align},pn=function(){return s((function e(t,n){a(this,e),d(this,"tableModule",void 0),d(this,"quill",void 0),d(this,"colIndex",-1),d(this,"tableMain",void 0),d(this,"dragging",!1),d(this,"dragColBreak",null),d(this,"handleColMouseUpFunc",this.handleColMouseUp.bind(this)),d(this,"handleColMouseMoveFunc",this.handleColMouseMove.bind(this)),d(this,"handleColMouseDownFunc",this.handleColMouseDown.bind(this)),d(this,"rowIndex",-1),d(this,"dragRowBreak",null),d(this,"handleRowMouseUpFunc",this.handleRowMouseUp.bind(this)),d(this,"handleRowMouseMoveFunc",this.handleRowMouseMove.bind(this)),d(this,"handleRowMouseDownFunc",this.handleRowMouseDown.bind(this)),d(this,"dragBEM",z("drag-line")),this.tableModule=t,this.quill=n}),[{key:"findCurrentColIndex",value:function(e){return-1}},{key:"colWidthChange",value:function(e,t,n){}},{key:"createConfirmDialog",value:(t=o(y().mark((function e(t){var n,i,o;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.message,i=t.confirm,o=t.cancel,e.abrupt("return",new Promise((function(e){var t=document.createElement("div");Object.assign(t.style,{padding:"8px 12px",fontSize:"14px",lineHeight:"1.5"});var r=document.createElement("p");r.textContent=n;var a=document.createElement("div");Object.assign(a.style,{display:"flex",justifyContent:"flex-end",gap:"6px"});var l=$({content:o}),s=$({type:"confirm",content:i});a.appendChild(l),a.appendChild(s),t.appendChild(r),t.appendChild(a);var c=ee({child:t}).close;l.addEventListener("click",(function(){e(!1),c()})),s.addEventListener("click",(function(){e(!0),c()}))})));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"handleColMouseUp",value:(e=o(y().mark((function e(){var t,n,i,o,r,a,l,s,d,u,h,f,p,v,b,m,g,w,x,M,k,I,T,N,L,B,R,O,A,z;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.dragColBreak&&this.tableMain&&-1!==this.colIndex){e.next=2;break}return e.abrupt("return");case 2:if(t=this.tableMain.getCols(),n=Number.parseInt(this.dragColBreak.dataset.w||"0"),i=this.tableMain.full,o=!1,r=[],i?(a=this.tableMain.domNode.getBoundingClientRect().width,l=n/a*100,s=t[this.colIndex].width,l<s?(l=Math.max(E.colMinWidthPre,l),t[this.colIndex+1]||t[this.colIndex-1]?(d=t[this.colIndex+1]?this.colIndex+1:this.colIndex-1,r.push({index:d,width:t[d].width+s-l})):l=100,o=!0,r.push({index:this.colIndex,width:l})):t[this.colIndex+1]&&(u=s+t[this.colIndex+1].width,l=Math.min(u-E.colMinWidthPre,l),o=!0,r.push({index:this.colIndex,width:l},{index:this.colIndex+1,width:u-l}))):(this.tableMain.domNode.style.width="".concat(Number.parseFloat(this.tableMain.domNode.style.width)-t[this.colIndex].domNode.getBoundingClientRect().width+n,"px"),o=!0,r.push({index:this.colIndex,width:n})),document.body.removeChild(this.dragColBreak),this.dragColBreak=null,document.removeEventListener("mouseup",this.handleColMouseUpFunc),document.removeEventListener("mousemove",this.handleColMouseMoveFunc),this.dragging=!1,!o){e.next=47;break}if(h=this.tableMain.domNode.getBoundingClientRect().width,!i){e.next=45;break}f=0,p=new Set(r.map((function(e){var t=e.index,n=e.width;return f+=n,t}))),v=c(t.entries()),e.prev=19,v.s();case 21:if((b=v.n()).done){e.next=28;break}if(m=C(b.value,2),g=m[0],w=m[1],!p.has(g)){e.next=25;break}return e.abrupt("continue",26);case 25:f+=w.width;case 26:e.next=21;break;case 28:e.next=33;break;case 30:e.prev=30,e.t0=e.catch(19),v.e(e.t0);case 33:return e.prev=33,v.f(),e.finish(33);case 36:if(!(f>100)){e.next=45;break}return e.next=39,this.createConfirmDialog({message:this.tableModule.options.texts.perWidthInsufficient,confirm:this.tableModule.options.texts.confirmText,cancel:this.tableModule.options.texts.cancelText});case 39:if(e.sent){e.next=41;break}return e.abrupt("return");case 41:this.tableMain.cancelFull(),i=!1,x=c(r.entries());try{for(x.s();!(M=x.n()).done;)k=C(M.value,2),I=k[0],T=k[1],N=T.width,L=T.index,r[I]={index:L,width:N/100*h}}catch(e){x.e(e)}finally{x.f()}case 45:B=c(r);try{for(B.s();!(R=B.n()).done;)O=R.value,A=O.index,z=O.width,t[A].width="".concat(Math.round(z)).concat(i?"%":"px"),this.colWidthChange(A,{px:Math.round(z/100*h),pre:Math.round(z)},i)}catch(e){B.e(e)}finally{B.f()}case 47:this.quill.emitter.emit(S.AFTER_TABLE_RESIZE);case 48:case"end":return e.stop()}}),e,this,[[19,30,33,36]])}))),function(){return e.apply(this,arguments)})},{key:"handleColMouseMove",value:function(e){if(e.preventDefault(),this.dragColBreak&&this.tableMain&&-1!==this.colIndex){var t=this.tableMain.getCols(),n=t[this.colIndex].domNode.getBoundingClientRect(),i=this.tableMain.domNode.getBoundingClientRect(),o=e.clientX;if(this.tableMain.full){var r=E.colMinWidthPre/100*i.width,a=i.right;o>n.right&&t[this.colIndex+1]&&(a=Math.max(t[this.colIndex+1].domNode.getBoundingClientRect().right-r,n.left+r));var l=n.x+r;o=Math.min(Math.max(o,l),a)}else fn(this.tableMain)?n.right-o<E.colMinWidthPx&&(o=n.right-E.colMinWidthPx):o-n.x<E.colMinWidthPx&&(o=n.x+E.colMinWidthPx);var s=o-n.x;return fn(this.tableMain)&&(s=n.right-o),this.dragColBreak.style.left="".concat(o,"px"),this.dragColBreak.dataset.w=String(s),{left:o,width:s}}}},{key:"handleColMouseDown",value:function(e){if(0===e.button&&(e.preventDefault(),this.tableMain)){var t=Zt(this.tableMain),n=t.rect;if(t.body){var i=this.tableMain.getCols();if(this.colIndex=this.findCurrentColIndex(e),-1!==this.colIndex){var o=i[this.colIndex].width,r=this.tableMain.full?o/100*n.width:o;document.addEventListener("mouseup",this.handleColMouseUpFunc),document.addEventListener("mousemove",this.handleColMouseMoveFunc),this.dragging=!0;var a=document.createElement("div");a.classList.add(this.dragBEM.b()),a.classList.add(this.dragBEM.is("col")),a.dataset.w=String(r);var l={top:n.y,left:e.clientX,height:n.height};Object.assign(a.style,{top:"".concat(l.top,"px"),left:"".concat(l.left,"px"),height:"".concat(l.height,"px")});var s=document.body;return s.appendChild(a),this.dragColBreak&&s.removeChild(this.dragColBreak),this.dragColBreak=a,l}}}}},{key:"findCurrentRowIndex",value:function(e){return-1}},{key:"rowHeightChange",value:function(e,t){}},{key:"handleRowMouseUp",value:function(){if(this.tableMain&&this.dragRowBreak&&-1!==this.rowIndex){var e=Number.parseInt(this.dragRowBreak.dataset.h||"0");this.tableMain.getRows()[this.rowIndex].setHeight("".concat(e,"px")),this.rowHeightChange(this.rowIndex,e),document.body.removeChild(this.dragRowBreak),this.dragRowBreak=null,document.removeEventListener("mouseup",this.handleRowMouseUpFunc),document.removeEventListener("mousemove",this.handleRowMouseMoveFunc),this.dragging=!1,this.quill.emitter.emit(S.AFTER_TABLE_RESIZE)}}},{key:"handleRowMouseMove",value:function(e){if(this.tableMain&&this.dragRowBreak&&-1!==this.rowIndex){e.preventDefault();var t=this.tableMain.getRows()[this.rowIndex].domNode.getBoundingClientRect(),n=e.clientY;return n-t.y<E.rowMinHeightPx&&(n=t.y+E.rowMinHeightPx),this.dragRowBreak.style.top="".concat(n,"px"),this.dragRowBreak.dataset.h=String(n-t.y),{top:n,height:n-t.y}}}},{key:"handleRowMouseDown",value:function(e){if(0===e.button&&(e.preventDefault(),this.tableMain&&(this.rowIndex=this.findCurrentRowIndex(e),-1!==this.rowIndex))){this.dragging=!0,document.addEventListener("mouseup",this.handleRowMouseUpFunc),document.addEventListener("mousemove",this.handleRowMouseMoveFunc);var t=this.tableMain.getRows()[this.rowIndex].domNode.getBoundingClientRect().height,n=this.tableMain.domNode.getBoundingClientRect(),i=document.createElement("div");i.classList.add(this.dragBEM.b()),i.classList.add(this.dragBEM.is("row")),i.dataset.h=String(t);var o={top:e.clientY,left:n.x,width:n.width};Object.assign(i.style,{top:"".concat(o.top,"px"),left:"".concat(o.left,"px"),width:"".concat(o.width,"px")});var r=document.body;return r.appendChild(i),this.dragRowBreak&&r.removeChild(this.dragRowBreak),this.dragRowBreak=i,o}}},{key:"update",value:function(){}},{key:"destroy",value:function(){}}]);var e,t}(),vn=function(e){function n(e,i,o){var l;return a(this,n),d(l=r(this,n,[e,o]),"tableModule",void 0),d(l,"table",void 0),d(l,"root",void 0),d(l,"tableMain",void 0),d(l,"tableWrapper",void 0),d(l,"resizeObserver",void 0),d(l,"tableCols",[]),d(l,"tableRows",[]),d(l,"rowHeadWrapper",null),d(l,"colHeadWrapper",null),d(l,"corner",null),d(l,"scrollHandler",[]),d(l,"lastHeaderSelect",null),d(l,"size",12),d(l,"bem",z("resize-box")),d(l,"updateWhenTextChange",(function(){l.update()})),d(l,"handleColMouseDownFunc",function(e){var t=this.handleColMouseDown(e);if(t&&this.dragColBreak){var n=C(D(this.tableMain,_t),1)[0],i=n&&"top"===n.side?0:this.size;Object.assign(this.dragColBreak.style,{top:"".concat(t.top-i,"px"),left:"".concat(t.left,"px"),height:"".concat(t.height+this.size,"px")})}return t}.bind(l)),d(l,"handleRowMouseDownFunc",function(e){var t=this.handleRowMouseDown(e);return t&&this.dragRowBreak&&Object.assign(this.dragRowBreak.style,{top:"".concat(t.top,"px"),left:"".concat(t.left-this.size,"px"),width:"".concat(t.width+this.size,"px")}),t}.bind(l)),l.tableModule=e,l.table=i,l.tableMain=t.find(l.table),l.tableMain?(l.tableWrapper=l.tableMain.parent,l.tableWrapper?(l.root=l.tableModule.addContainer(l.bem.b()),l.resizeObserver=new ResizeObserver((function(){l.show()})),l.resizeObserver.observe(l.table),l.quill.on(t.events.TEXT_CHANGE,l.updateWhenTextChange),l):g(l)):g(l)}return f(n,e),s(n,[{key:"handleResizerHeader",value:function(e,t,n){var i=n.clientX,o=n.clientY,r=this.table.getBoundingClientRect();if(this.tableModule.tableSelection){var a=this.tableModule.tableSelection;n.shiftKey||(this.lastHeaderSelect=null);var l=[{x:e?r.left:i,y:e?o:r.top},{x:e?r.right:i,y:e?o:r.bottom}];if(this.lastHeaderSelect){var s,c;if(this.lastHeaderSelect.isX){var d=Array.from(this.root.getElementsByClassName(this.bem.be("row-header")))[this.lastHeaderSelect.index].getBoundingClientRect();s=Math.min(d.left,r.left),c=d.top+d.height/2}else{var u=Array.from(this.root.getElementsByClassName(this.bem.be("col-header")))[this.lastHeaderSelect.index].getBoundingClientRect();s=u.left+u.width/2,c=Math.min(u.top,r.top)}this.lastHeaderSelect.isX!==e?(l[1]={x:Math.max(l[0].x,s),y:Math.max(l[0].y,c)},l[0]={x:Math.min(l[0].x,s),y:Math.min(l[0].y,c)}):e?(l[0].y=Math.min(l[0].y,c),l[1].y=Math.max(l[1].y,c)):(l[0].x=Math.min(l[0].x,s),l[1].x=Math.max(l[1].x,s))}else this.lastHeaderSelect={isX:e,index:t};a.table=this.table,a.selectedTds=a.computeSelectedTds.apply(a,l),a.show()}}},{key:"findCurrentColIndex",value:function(e){return Array.from(this.root.getElementsByClassName(this.bem.be("col-separator"))).indexOf(e.target)}},{key:"colWidthChange",value:function(e,t,n){Array.from(this.root.getElementsByClassName(this.bem.be("col-header")))[e].style.width=n?"".concat(t.pre,"%"):"".concat(t.px,"px")}},{key:"bindColEvents",value:function(){var e=this,t=Array.from(this.root.getElementsByClassName(this.bem.be("col-header"))),n=Array.from(this.root.getElementsByClassName(this.bem.be("col-separator")));gt.call(this,this.tableWrapper.domNode,(function(){e.colHeadWrapper.scrollLeft=e.tableWrapper.domNode.scrollLeft}));var i,o=c(t.entries());try{for(o.s();!(i=o.n()).done;){var r=C(i.value,2),a=r[0];r[1].addEventListener("click",this.handleResizerHeader.bind(this,!1,a))}}catch(e){o.e(e)}finally{o.f()}for(var l=0,s=n;l<s.length;l++){var d=s[l];d.addEventListener("mousedown",this.handleColMouseDownFunc),d.addEventListener("dragstart",(function(e){return e.preventDefault()}))}}},{key:"findCurrentRowIndex",value:function(e){return Array.from(this.root.getElementsByClassName(this.bem.be("row-separator"))).indexOf(e.target)}},{key:"rowHeightChange",value:function(e,t){Array.from(this.root.getElementsByClassName(this.bem.be("row-header")))[e].style.height="".concat(t,"px")}},{key:"bindRowEvents",value:function(){var e=this,t=Array.from(this.root.getElementsByClassName(this.bem.be("row-header"))),n=Array.from(this.root.getElementsByClassName(this.bem.be("row-separator")));gt.call(this,this.tableWrapper.domNode,(function(){e.rowHeadWrapper.scrollTop=e.tableWrapper.domNode.scrollTop}));var i,o=c(t.entries());try{for(o.s();!(i=o.n()).done;){var r=C(i.value,2),a=r[0];r[1].addEventListener("click",this.handleResizerHeader.bind(this,!0,a))}}catch(e){o.e(e)}finally{o.f()}for(var l=0,s=n;l<s.length;l++){var d=s[l];d.addEventListener("mousedown",this.handleRowMouseDownFunc),d.addEventListener("dragstart",(function(e){return e.preventDefault()}))}}},{key:"update",value:function(){var e=Zt(this.tableMain),t=e.rect;if(e.body){var n=this.tableWrapper.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect();Object.assign(this.root.style,{top:"".concat(Math.max(t.y,n.y)-i.y,"px"),left:"".concat(Math.max(t.x,n.x)-i.x,"px")});var o=-1*this.size,r=-1*this.size;fn(this.tableMain)?(this.root.classList.add(this.bem.is("align-right")),o=Math.min(n.width,t.width),r=Math.min(n.width,t.width)):this.root.classList.remove(this.bem.is("align-right"));var a=C(D(this.tableMain,_t),1)[0],l=!a||!(a&&"top"===a.side);l?this.root.classList.remove(this.bem.is("caption-bottom")):this.root.classList.add(this.bem.is("caption-bottom")),this.corner&&Object.assign(this.corner.style,{transform:"translateY(".concat(-1*this.size,"px) translateX(").concat(o,"px)"),top:"".concat(l?0:t.height+this.size,"px")}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:"translateX(".concat(r,"px)")}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:"".concat(l?0:t.height+this.size,"px")})}}},{key:"show",value:function(){var e=this;this.tableCols=this.tableMain.getCols(),this.tableRows=this.tableMain.getRows(),this.root.innerHTML="";var t=Zt(this.tableMain),n=t.rect;if(t.body){var i=this.tableWrapper.domNode.getBoundingClientRect();if(this.tableCols.length>0&&this.tableRows.length>0&&(this.corner=document.createElement("div"),this.corner.classList.add(this.bem.be("corner")),Object.assign(this.corner.style,{width:"".concat(this.size,"px"),height:"".concat(this.size,"px")}),this.corner.addEventListener("click",(function(){if(e.tableModule.tableSelection){var t=e.tableMain.descendants(Ot),n=e.tableModule.tableSelection;n.selectedTds=t,n.show(),n.updateWithSelectedTds()}})),this.root.appendChild(this.corner)),this.tableCols.length>0){var o,r="",a=c(this.tableCols.entries());try{for(a.s();!(o=a.n()).done;){var l=C(o.value,2)[1].domNode.getBoundingClientRect().width;r+='<div class="'.concat(this.bem.be("col-header"),'" style="width: ').concat(l,'px">\n <div class="').concat(this.bem.be("col-separator"),'" style="height: ').concat(n.height+this.size-3,'px"></div>\n </div>')}}catch(e){a.e(e)}finally{a.f()}var s=document.createElement("div");s.classList.add(this.bem.be("col"));var d=document.createElement("div");d.classList.add(this.bem.be("col-wrapper")),Object.assign(s.style,{transform:"translateY(-".concat(this.size,"px)"),maxWidth:"".concat(i.width,"px"),height:"".concat(this.size,"px")}),Object.assign(d.style,{width:"".concat(n.width,"px")}),d.innerHTML=r,s.appendChild(d),this.root.appendChild(s),s.scrollLeft=this.tableWrapper.domNode.scrollLeft,this.colHeadWrapper=s,this.bindColEvents()}if(this.tableRows.length>0){var u,h="",f=c(this.tableRows.entries());try{for(f.s();!(u=f.n()).done;){var p=C(u.value,2)[1],v="".concat(p.domNode.getBoundingClientRect().height,"px");h+='<div class="'.concat(this.bem.be("row-header"),'" style="height: ').concat(Number.parseFloat(v),'px">\n <div class="').concat(this.bem.be("row-separator"),'" style="width: ').concat(n.width+this.size-3,'px"></div>\n </div>')}}catch(e){f.e(e)}finally{f.f()}var b=document.createElement("div");b.classList.add(this.bem.be("row"));var m=document.createElement("div");m.classList.add(this.bem.be("row-wrapper")),Object.assign(b.style,{transform:"translateX(-".concat(this.size,"px)"),width:"".concat(this.size,"px"),maxHeight:"".concat(i.height,"px")}),Object.assign(m.style,{height:"".concat(n.height,"px")}),m.innerHTML=h,b.appendChild(m),this.root.appendChild(b),b.scrollTop=this.tableWrapper.domNode.scrollTop,this.rowHeadWrapper=b,this.bindRowEvents()}this.update(),gt.call(this,this.quill.root,(function(){e.update()}))}}},{key:"hide",value:function(){this.root.classList.add(this.bem.is("hidden"))}},{key:"destroy",value:function(){this.hide(),yt.call(this),this.resizeObserver.disconnect(),this.quill.off(t.events.TEXT_CHANGE,this.updateWhenTextChange);var e,n=c(this.scrollHandler);try{for(n.s();!(e=n.n()).done;){var i=C(e.value,2),o=i[0],r=i[1];o.removeEventListener("scroll",r)}}catch(e){n.e(e)}finally{n.f()}this.root.remove()}}])}(pn),bn=function(e){function n(e,i,l){var s;return a(this,n),d(s=r(this,n,[e,l]),"tableModule",void 0),d(s,"table",void 0),d(s,"colResizer",void 0),d(s,"rowResizer",void 0),d(s,"currentTableCell",void 0),d(s,"dragging",!1),d(s,"curColIndex",-1),d(s,"curRowIndex",-1),d(s,"tableCellBlot",void 0),d(s,"bem",z("resize-line")),d(s,"mousemoveHandler",(function(e){if(!(s.dragging||s.tableModule.tableSelection&&s.tableModule.tableSelection.dragging)){var n=s.findTableCell(e);if(!n)return s.hide();var i=t.find(n);i&&s.currentTableCell!==n&&(s.show(),s.currentTableCell=n,s.tableCellBlot=i,s.tableMain=q(i,N.tableMain),s.tableMain.getCols().length>0&&s.updateColResizer(),s.updateRowResizer())}})),d(s,"hideWhenTextChange",(function(){s.hide()})),d(s,"handleColMouseUpFunc",o(y().mark((function e(){return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.handleColMouseUp();case 2:this.updateColResizer();case 3:case"end":return e.stop()}}),e,this)}))).bind(s)),d(s,"handleRowMouseUpFunc",function(){this.handleRowMouseUp(),this.updateRowResizer()}.bind(s)),s.tableModule=e,s.table=i,s.colResizer=s.tableModule.addContainer(s.bem.be("col")),s.rowResizer=s.tableModule.addContainer(s.bem.be("row")),s.table.addEventListener("mousemove",s.mousemoveHandler),s.quill.on(t.events.TEXT_CHANGE,s.hideWhenTextChange),s}return f(n,e),s(n,[{key:"findTableCell",value:function(e){var t,n=c(e.composedPath());try{for(n.s();!(t=n.n()).done;){var i=t.value;if(i instanceof HTMLElement&&"TD"===i.tagName)return i;if(i===document.body)return null}}catch(e){n.e(e)}finally{n.f()}return null}},{key:"findCurrentColIndex",value:function(){return this.curColIndex}},{key:"updateColResizer",value:function(){if(this.tableMain&&this.tableCellBlot){var e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.colResizer),this.colResizer=this.tableModule.addContainer(this.bem.be("col"));var t=C(H(e,[N.tableBody]),1)[0].domNode.getBoundingClientRect(),n=e.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect(),o=n.right-i.x;fn(this.tableMain)&&(o=n.left-i.x),Object.assign(this.colResizer.style,{top:"".concat(t.y-i.y,"px"),left:"".concat(o,"px"),height:"".concat(t.height,"px")});var r=this.tableMain.getCols();this.curColIndex=r.findIndex((function(t){return t.colId===e.colId})),this.colResizer.addEventListener("mousedown",this.handleColMouseDownFunc),this.colResizer.addEventListener("dragstart",(function(e){e.preventDefault()}))}}},{key:"findCurrentRowIndex",value:function(){return this.curRowIndex}},{key:"updateRowResizer",value:function(){if(this.tableMain&&this.tableCellBlot){var e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.rowResizer),this.rowResizer=this.tableModule.addContainer(this.bem.be("row"));var t=e.parent;if(t instanceof At){var n=C(H(e,[N.tableBody]),1)[0].domNode.getBoundingClientRect(),i=e.domNode.getBoundingClientRect(),o=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:"".concat(i.bottom-o.y,"px"),left:"".concat(n.x-o.x,"px"),width:"".concat(n.width,"px")});var r=this.tableMain.getRows();this.curRowIndex=r.indexOf(t),this.rowResizer.addEventListener("mousedown",this.handleRowMouseDownFunc),this.rowResizer.addEventListener("dragstart",(function(e){e.preventDefault()}))}}}},{key:"show",value:function(){this.rowResizer.classList.remove(this.bem.is("hidden")),this.colResizer.classList.remove(this.bem.is("hidden"))}},{key:"hide",value:function(){this.currentTableCell=void 0,this.rowResizer.classList.add(this.bem.is("hidden")),this.colResizer.classList.add(this.bem.is("hidden"))}},{key:"update",value:function(){this.updateColResizer(),this.updateRowResizer()}},{key:"destroy",value:function(){this.colResizer.remove(),this.rowResizer.remove(),this.table.removeEventListener("mousemove",this.mousemoveHandler),this.quill.off(t.events.TEXT_CHANGE,this.hideWhenTextChange)}}])}(pn),mn=function(){return s((function e(n,i,o,r){var l=this;a(this,e),d(this,"tableModule",void 0),d(this,"table",void 0),d(this,"quill",void 0),d(this,"scrollHandler",[]),d(this,"tableMainBlot",null),d(this,"tableWrapperBlot",null),d(this,"bem",z("scale")),d(this,"startX",0),d(this,"startY",0),d(this,"offset",6),d(this,"options",void 0),d(this,"root",void 0),d(this,"block",void 0),d(this,"resizeobserver",new ResizeObserver((function(){return l.update()}))),d(this,"updateWhenTextChange",(function(){l.update()})),this.tableModule=n,this.table=i,this.quill=o,this.options=this.resolveOptions(r),this.tableMainBlot=t.find(i),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.buildResizer(),this.show()),this.quill.on(t.events.TEXT_CHANGE,this.updateWhenTextChange)}),[{key:"resolveOptions",value:function(e){return Object.assign({blockSize:12},e)}},{key:"buildResizer",value:function(){var e=this;if(this.tableMainBlot&&this.tableWrapperBlot){this.root=this.tableModule.addContainer(this.bem.b()),this.root.classList.add(this.bem.is("hidden")),this.block=document.createElement("div"),this.block.classList.add(this.bem.be("block")),Object.assign(this.block.style,{width:"".concat(this.options.blockSize,"px"),height:"".concat(this.options.blockSize,"px")}),this.root.appendChild(this.block);var t=[],n=[],i=function(i){if(e.tableMainBlot){var o,r=fn(e.tableMainBlot)?-1:1,a=(i.clientX-e.startX)*r,l=i.clientY-e.startY,s=Math.floor(a/t.length),d=Math.floor(l/n.length),u=c(t);try{for(u.s();!(o=u.n()).done;){var h=o.value,f=h.blot,p=h.width;f.width=Math.max(p+s,E.colMinWidthPx)}}catch(e){u.e(e)}finally{u.f()}var v,b=c(n);try{for(b.s();!(v=b.n()).done;){var m=v.value,g=m.blot,y=m.height;g.setHeight("".concat(Math.max(y+d,E.rowMinHeightPx),"px"))}}catch(e){b.e(e)}finally{b.f()}}},o=function(){t=[],n=[],document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o)};this.block.addEventListener("mousedown",(function(r){e.tableMainBlot&&!e.isTableOutofEditor()&&(e.startX=r.clientX,e.startY=r.clientY,t=e.tableMainBlot.getCols().map((function(e){return{blot:e,width:Math.floor(e.width)}})),n=e.tableMainBlot.getRows().map((function(e){return{blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)}})),document.addEventListener("mousemove",i),document.addEventListener("mouseup",o))})),this.block.addEventListener("dragstart",(function(e){return e.preventDefault()})),this.resizeobserver.observe(this.tableMainBlot.domNode),gt.call(this,this.quill.root,(function(){return e.update()})),gt.call(this,this.tableWrapperBlot.domNode,(function(){return e.update()}))}}},{key:"isTableOutofEditor",value:function(){if(!this.tableMainBlot||!this.tableWrapperBlot||this.tableMainBlot.full)return!1;var e=this.tableMainBlot.domNode.getBoundingClientRect(),t=this.tableWrapperBlot.domNode.getBoundingClientRect();if(e.width>t.width){var n,i=c(this.tableMainBlot.getCols());try{for(i.s();!(n=i.n()).done;){var o=n.value;o.width=Math.floor(o.width/e.width*t.width)}}catch(e){i.e(e)}finally{i.f()}return this.tableMainBlot.colWidthFillTable(),!0}return!1}},{key:"update",value:function(){if(this.block&&this.root&&this.tableMainBlot&&this.tableWrapperBlot)if(this.tableMainBlot.full)this.hide();else{var e=Zt(this.tableMainBlot),t=e.rect;if(e.body){var n=this.tableWrapperBlot.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect(),o=this.tableWrapperBlot.domNode,r=o.scrollTop,a=o.scrollLeft,l=2*this.options.blockSize+this.offset,s=Math.min(t.width,n.width)+l,c=Math.min(t.height,n.height)+l;Object.assign(this.root.style,{width:"".concat(s,"px"),height:"".concat(c,"px"),left:"".concat(Math.max(t.x,n.x)-i.x-this.options.blockSize,"px"),top:"".concat(Math.max(t.y,n.y)-i.y-this.options.blockSize,"px")});var d={left:"".concat(t.width+l-a,"px"),top:"".concat(c-r,"px")};fn(this.tableMainBlot)?(this.root.classList.add(this.bem.is("align-right")),d.left="".concat(this.options.blockSize+-1*a,"px")):this.root.classList.remove(this.bem.is("align-right")),Object.assign(this.block.style,d)}}}},{key:"show",value:function(){this.root&&(this.root.classList.remove(this.bem.is("hidden")),this.update())}},{key:"hide",value:function(){this.root&&this.root.classList.add(this.bem.is("hidden"))}},{key:"destroy",value:function(){this.hide(),this.quill.off(t.events.TEXT_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect(),this.root&&this.root.remove(),yt.call(this)}}])}(),gn=function(){return s((function e(n,i,o,r){var l=this;a(this,e),d(this,"quill",void 0),d(this,"isVertical",void 0),d(this,"table",void 0),d(this,"scrollbarContainer",void 0),d(this,"minSize",20),d(this,"gap",4),d(this,"move",0),d(this,"cursorDown",!1),d(this,"cursorLeave",!1),d(this,"ratioY",1),d(this,"ratioX",1),d(this,"sizeWidth",""),d(this,"sizeHeight",""),d(this,"size",""),d(this,"thumbState",{X:0,Y:0}),d(this,"ob",void 0),d(this,"container",void 0),d(this,"scrollbar",void 0),d(this,"thumb",document.createElement("div")),d(this,"scrollHandler",[]),d(this,"propertyMap",void 0),d(this,"bem",z("scrollbar")),d(this,"tableMainBlot",void 0),d(this,"showScrollbar",kt((function(){l.cursorLeave=!1,l.scrollbar.removeEventListener("transitionend",l.hideScrollbarTransitionend),l.scrollbar.style.display=l.size?"block":"none",requestAnimationFrame((function(){l.scrollbar.classList.remove(l.bem.is("transparent"))}))}),200)),d(this,"hideScrollbar",kt((function(){l.cursorLeave=!0,l.cursorDown||(l.scrollbar.removeEventListener("transitionend",l.hideScrollbarTransitionend),l.scrollbar.addEventListener("transitionend",l.hideScrollbarTransitionend,{once:!0}),l.scrollbar.classList.add(l.bem.is("transparent")))}),200)),d(this,"hideScrollbarTransitionend",(function(){l.scrollbar.style.display=l.cursorDown&&l.size?"block":"none"})),this.quill=n,this.isVertical=i,this.table=o,this.scrollbarContainer=r,this.tableMainBlot=t.find(this.table),this.container=o.parentElement,this.propertyMap=this.isVertical?{size:"height",offset:"offsetHeight",scrollDirection:"scrollTop",scrollSize:"scrollHeight",axis:"Y",direction:"top",client:"clientY"}:{size:"width",offset:"offsetWidth",scrollDirection:"scrollLeft",scrollSize:"scrollWidth",axis:"X",direction:"left",client:"clientX"},this.calculateSize(),this.ob=new ResizeObserver((function(){l.update()})),this.ob.observe(o),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),gt.call(this,this.quill.root,(function(){return l.setScrollbarPosition()})),this.showScrollbar()}),[{key:"update",value:function(){this.calculateSize(),this.setScrollbarPosition()}},{key:"setScrollbarPosition",value:function(){var e=Zt(this.tableMainBlot),t=e.rect,n=t.width,i=t.height,o=e.body;if(o){var r=this.quill.root,a=r.scrollLeft,l=r.scrollTop,s=r.offsetLeft,c=r.offsetTop,u=this.container,h=u.offsetLeft,f=u.offsetTop,p=o.domNode,v=p.offsetLeft,b=p.offsetTop,m=this.container.getBoundingClientRect(),g=m.width,y=m.height,w=h+v-s,C=f+b-c;this.isVertical?w+=Math.min(g,n):C+=Math.min(y,i),this.tableMainBlot&&"left"!==this.tableMainBlot.align&&(w+=this.table.offsetLeft-h),Object.assign(this.scrollbar.style,d(d({},this.propertyMap.size,"".concat(this.isVertical?Math.min(y,i):g,"px")),"transform","translate(".concat(w-a,"px, ").concat(C-l,"px)"))),this.containerScrollHandler(this.container)}}},{key:"calculateSize",value:function(){var e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=Math.pow(e,2)/this.container.scrollHeight,i=Math.pow(t,2)/this.container.scrollWidth,o=Math.max(n,this.minSize),r=Math.max(i,this.minSize);this.ratioY=n/(e-n)/(o/(e-o)),this.ratioX=i/(t-i)/(r/(t-r)),this.sizeWidth=r+this.gap<t?"".concat(r,"px"):"",this.sizeHeight=o+this.gap<e?"".concat(o,"px"):"",this.size=this.isVertical?this.sizeHeight:this.sizeWidth}},{key:"createScrollbar",value:function(){var e=this,t=document.createElement("div");t.classList.add(this.bem.b()),t.classList.add(this.isVertical?this.bem.is("vertical"):this.bem.is("horizontal"),this.bem.is("transparent")),Object.assign(t.style,{display:"none"}),this.thumb.classList.add(this.bem.be("thumb"));var n=null,i=function(t){if(!1!==e.cursorDown){var n=e.thumbState[e.propertyMap.axis];if(n){var i=Math.pow(e.scrollbar[e.propertyMap.offset],2)/e.container[e.propertyMap.scrollSize]/(e.isVertical?e.ratioY:e.ratioX)/e.thumb[e.propertyMap.offset],o=100*(-1*(e.scrollbar.getBoundingClientRect()[e.propertyMap.direction]-t[e.propertyMap.client])-(e.thumb[e.propertyMap.offset]-n))*i/e.scrollbar[e.propertyMap.offset];e.container[e.propertyMap.scrollDirection]=o*e.container[e.propertyMap.scrollSize]/100}}},o=function(){e.thumbState[e.propertyMap.axis]=0,e.cursorDown=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),e.cursorLeave&&e.hideScrollbar(),document.onselectstart=n};this.thumb.addEventListener("mousedown",(function(t){var r;if(t.stopPropagation(),!t.ctrlKey&&![1,2].includes(t.button)){null===(r=window.getSelection())||void 0===r||r.removeAllRanges(),function(t){t.stopImmediatePropagation(),e.cursorDown=!0,document.addEventListener("mousemove",i),document.addEventListener("mouseup",o),n=document.onselectstart,document.onselectstart=function(){return!1}}(t);var a=t.currentTarget;a&&(e.thumbState[e.propertyMap.axis]=a[e.propertyMap.offset]-(t[e.propertyMap.client]-a.getBoundingClientRect()[e.propertyMap.direction]))}}));for(var r=0,a=[this.table,t];r<a.length;r++){var l=a[r];l.addEventListener("mouseenter",this.showScrollbar),l.addEventListener("mouseleave",this.hideScrollbar)}return gt.call(this,this.container,(function(){e.containerScrollHandler(e.container)})),t.appendChild(this.thumb),t}},{key:"containerScrollHandler",value:function(e){var t=e[this.propertyMap.offset]-this.gap;this.move=100*e[this.propertyMap.scrollDirection]/t*(this.isVertical?this.ratioY:this.ratioX),Object.assign(this.thumb.style,d(d({},this.propertyMap.size,this.size),"transform","translate".concat(this.propertyMap.axis,"(").concat(this.move,"%)")))}},{key:"destroy",value:function(){this.ob.disconnect(),yt.call(this),this.table.removeEventListener("mouseenter",this.showScrollbar),this.table.removeEventListener("mouseleave",this.hideScrollbar)}}])}(),yn=function(){return s((function e(n,i,o){var r=this;a(this,e),d(this,"tableModule",void 0),d(this,"table",void 0),d(this,"quill",void 0),d(this,"scrollbarContainer",void 0),d(this,"scrollbar",void 0),d(this,"bem",z("scrollbar")),d(this,"updateWhenTextChange",(function(){r.update()})),this.tableModule=n,this.table=i,this.quill=o,this.scrollbarContainer=this.tableModule.addContainer(this.bem.be("container")),this.scrollbar=[new gn(o,!0,i,this.scrollbarContainer),new gn(o,!1,i,this.scrollbarContainer)];var l,s=c(this.scrollbar);try{for(s.s();!(l=s.n()).done;){var u=l.value;this.scrollbarContainer.appendChild(u.scrollbar)}}catch(e){s.e(e)}finally{s.f()}this.quill.on(t.events.TEXT_CHANGE,this.updateWhenTextChange)}),[{key:"hide",value:function(){var e,t=c(this.scrollbar);try{for(t.s();!(e=t.n()).done;){e.value.hideScrollbar()}}catch(e){t.e(e)}finally{t.f()}}},{key:"show",value:function(){var e,t=c(this.scrollbar);try{for(t.s();!(e=t.n()).done;){e.value.showScrollbar()}}catch(e){t.e(e)}finally{t.f()}}},{key:"update",value:function(){var e,t=c(this.scrollbar);try{for(t.s();!(e=t.n()).done;){var n=e.value;n.calculateSize(),n.setScrollbarPosition()}}catch(e){t.e(e)}finally{t.f()}}},{key:"destroy",value:function(){this.scrollbarContainer.remove(),this.quill.off(t.events.TEXT_CHANGE,this.updateWhenTextChange);var e,n=c(this.scrollbar);try{for(n.s();!(e=n.n()).done;){e.value.destroy()}}catch(e){n.e(e)}finally{n.f()}}}])}(),wn=function(){return s((function e(n,i){var o=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a(this,e),d(this,"tableModule",void 0),d(this,"quill",void 0),d(this,"options",void 0),d(this,"boundary",null),d(this,"startScrollX",0),d(this,"startScrollY",0),d(this,"selectedTableScrollX",0),d(this,"selectedTableScrollY",0),d(this,"selectedEditorScrollX",0),d(this,"selectedEditorScrollY",0),d(this,"selectedTds",[]),d(this,"cellSelectWrap",void 0),d(this,"cellSelect",void 0),d(this,"dragging",!1),d(this,"scrollHandler",[]),d(this,"tableMenu",void 0),d(this,"resizeObserver",void 0),d(this,"table",void 0),d(this,"isDisplaySelection",!1),d(this,"bem",z("selection")),d(this,"lastSelection",{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}),d(this,"updateAfterEvent",(function(){o.updateWithSelectedTds()})),d(this,"quillSelectionChangeHandler",(function(e,n,i){if(i!==t.sources.API&&e&&o.selectedTds.length>0){var r=o.quill.getFormat(e),a=C(o.quill.getLine(e.index),1)[0],l=!!r[N.tableCellInner]&&!!a,s=o.selectedTds.some((function(e){return e.children.contains(a)}));if(l&&!s)try{var c=q(a,N.tableCellInner);o.selectedTds=[c],o.updateWithSelectedTds()}catch(e){}else l&&s||o.hide()}})),d(this,"selectionChangeHandler",(function(){var e=window.getSelection();if(e){var n=e.anchorNode,i=e.focusNode,r=e.anchorOffset,a=e.focusOffset;if(n&&i){var l=t.find(n),s=t.find(i);if(l&&s&&l.scroll===o.quill.scroll&&s.scroll===o.quill.scroll){var c=W(l),d=W(s),u=c.has(N.tableColgroup),h=d.has(N.tableColgroup);if(u||h){var f=n,p=r,v=i,b=a;if(u){var m=c.get(N.tableWrapper).descendants(Ot);m.length>0&&(f=m[0].domNode,p=0)}if(h){var g=d.get(N.tableWrapper).descendants(Ot);g.length>0&&(v=g[0].domNode,b=0)}o.setSelectionData(e,{anchorNode:f,anchorOffset:p,focusNode:v,focusOffset:b})}else{var y=c.has(N.tableCellInner),w=d.has(N.tableCellInner),C=y&&w;if(C){var x=c.get(N.tableCellInner),M=d.get(N.tableCellInner);C&&(C=x!==M)}if(y&&w&&C||!y&&w||!w&&y)return o.setSelectionData(e,o.lastSelection),void(o.selectedTds.length>0&&o.hide());o.lastSelection={anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}}}}})),d(this,"mouseDownHandler",(function(e){var t=e.button,n=e.target,i=e.clientX,r=e.clientY,a=n.closest(".ql-table"),l=n.closest("tbody");if(0===t&&a&&l){o.setSelectionTable(a);var s=a.dataset.tableId,c={x:i,y:r};o.selectedTds=o.computeSelectedTds(c,c),o.dragging=!0,o.show();var d=function(e){o.tableMenu&&o.tableMenu.hide(),o.tableModule.tableResize&&o.tableModule.tableResize.hide();var t=e.button,n=e.target,i=e.clientX,r=e.clientY,a=n.closest("tbody");if(0===t&&a&&a.dataset.tableId===s){var l={x:i,y:r};o.selectedTds=o.computeSelectedTds(c,l),o.selectedTds.length>1&&o.quill.blur(),o.update()}},u=function(){document.body.removeEventListener("mousemove",d,!1),document.body.removeEventListener("mouseup",u,!1),o.dragging=!1,o.tableMenu&&o.selectedTds.length>0&&o.tableMenu.show()};document.body.addEventListener("mousemove",d,!1),document.body.addEventListener("mouseup",u,!1)}})),d(this,"removeCell",(function(e){if(!(o.quill.getSelection()||"Backspace"!==e.key&&"Delete"!==e.key)){var n,i=c(o.selectedTds);try{for(i.s();!(n=i.n()).done;){var r=n.value;r.deleteAt(0,r.length()-1)}}catch(e){i.e(e)}finally{i.f()}if(o.table){var a=t.find(o.table),l=a.descendants(Ot);o.selectedTds.length===l.length&&a.remove()}}})),this.tableModule=n,this.quill=i,this.options=this.resolveOptions(r),this.cellSelectWrap=n.addContainer(this.bem.b()),this.cellSelect=this.helpLinesInitial(),this.resizeObserver=mt((function(){return o.updateAfterEvent()}),{ignoreFirstBind:!0}),this.resizeObserver.observe(this.quill.root),this.quill.root.addEventListener("mousedown",this.mouseDownHandler,{passive:!1}),document.addEventListener("selectionchange",this.selectionChangeHandler,{passive:!1}),this.quill.on(S.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.on(t.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.on(t.events.TEXT_CHANGE,this.updateAfterEvent),this.options.tableMenu&&(this.tableMenu=new this.options.tableMenu(n,i,this.options.tableMenuOptions)),this.hide()}),[{key:"getFirstTextNode",value:function(e){for(var t=0,n=Array.from(e.childNodes);t<n.length;t++){var i=n[t];if(i.nodeType===Node.TEXT_NODE)return i}return e}},{key:"getLastTextNode",value:function(e){for(var t=e.childNodes.length-1;t>=0;t--){var n=e.childNodes[t];if(n.nodeType===Node.TEXT_NODE)return n}return e}},{key:"getNodeTailOffset",value:function(e){var t=document.createRange();return t.selectNodeContents(e),t.collapse(!1),t.startOffset}},{key:"setSelectionData",value:function(e,t){var n=t.anchorNode,i=t.anchorOffset,o=t.focusNode,r=t.focusOffset;if(n&&o){var a=document.createRange(),l=this.selectionDirectionUp(t);l?(a.setStart(n,i),a.setEnd(n,i)):(a.setStart(n,i),a.setEnd(o,r)),e.removeAllRanges(),e.addRange(a),l&&e.extend(o,r)}}},{key:"selectionDirectionUp",value:function(e){var t=e.anchorNode,n=e.anchorOffset,i=e.focusNode,o=e.focusOffset;if(!t||!i)return!1;if(t===i)return n>o;var r=t.compareDocumentPosition(i);return r&Node.DOCUMENT_POSITION_CONTAINS||r&Node.DOCUMENT_POSITION_CONTAINED_BY?!!(r&Node.DOCUMENT_POSITION_FOLLOWING):!!(r&Node.DOCUMENT_POSITION_PRECEDING)}},{key:"findWrapSelection",value:function(e){var t,n=null,i=0,o=null,r=0,a=c(e);try{for(a.s();!(t=a.n()).done;){var l=t.value,s=l.node,d=l.offset;s&&(n&&!this.selectionDirectionUp({anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:d})||(n=s,i=d),o&&!this.selectionDirectionUp({anchorNode:s,anchorOffset:d,focusNode:o,focusOffset:r})||(o=s,r=d))}}catch(e){a.e(e)}finally{a.f()}return{startNode:n,startOffset:i,endNode:o,endOffset:r}}},{key:"resolveOptions",value:function(e){return Object.assign({selectColor:"#0589f340",tableMenuOptions:{}},e)}},{key:"helpLinesInitial",value:function(){this.cellSelectWrap.style.setProperty("--select-color",this.options.selectColor);var e=document.createElement("div");return e.classList.add(this.bem.be("line")),this.cellSelectWrap.appendChild(e),e}},{key:"computeSelectedTds",value:function(e,n){if(!this.table)return[];var i=t.find(this.table);if(!i)return[];var o=i.descendants(zt)[0];if(!o)return[];var r=new Set(o.descendants(Vt).map((function(e,t){return e.index=t,e}))),a=this.getTableViewScroll(),l=a.x,s=a.y,d=this.getQuillViewScroll(),u=d.x,h=d.y;this.selectedTableScrollX=l,this.selectedTableScrollY=s,this.selectedEditorScrollX=u,this.selectedEditorScrollY=h;for(var f,p,v,m=Zt(i).rect,g=e.x-l+this.startScrollX,y=e.y-s+this.startScrollY,w={x:Math.max(m.left,Math.min(n.x,g)),y:Math.max(m.top,Math.min(n.y,y)),x1:Math.min(m.right,Math.max(n.x,g)),y1:Math.min(m.bottom,Math.max(n.y,y))},C=new Set,x=!0;x;){x=!1;var k,I=c(r);try{for(I.s();!(k=I.n()).done;){var T=k.value;T.__rect||(T.__rect=T.domNode.getBoundingClientRect());var N=T.__rect,E=N.x,S=N.y,L=N.right,B=N.bottom;if(vt({x:Math.floor(w.x),y:Math.floor(w.y),x1:Math.floor(w.x1),y1:Math.floor(w.y1)},{x:Math.floor(E),y:Math.floor(S),x1:Math.floor(L),y1:Math.floor(B)},0,0===C.size)){C.add(T),r.delete(T),w={x:Math.min(w.x,E),y:Math.min(w.y,S),x1:Math.max(w.x1,L),y1:Math.max(w.y1,B)},x=!0;break}}}catch(e){I.e(e)}finally{I.f()}}for(var R=0,O=[].concat(M(C),M(r));R<O.length;R++){delete O[R].__rect}return this.boundary=(f=b(b({},w),{},{width:w.x1-w.x,height:w.y1-w.y}),p=this.quill.root,v=p.getBoundingClientRect(),{x:f.x-v.x-p.scrollLeft,y:f.y-v.y-p.scrollTop,x1:f.x-v.x-p.scrollLeft+f.width,y1:f.y-v.y-p.scrollTop+f.height,width:f.width,height:f.height}),Array.from(C).sort((function(e,t){return e.index-t.index})).map((function(e){return delete e.index,e.getCellInner()}))}},{key:"updateWithSelectedTds",value:function(){if(!(this.selectedTds.length<=0)){var e,t={x:1/0,y:1/0},n={x:-1/0,y:-1/0},i=c(this.selectedTds);try{for(i.s();!(e=i.n()).done;){var o=e.value.domNode.getBoundingClientRect();t.x=Math.min(t.x,o.left),t.y=Math.min(t.y,o.top),n.x=Math.max(n.x,o.right),n.y=Math.max(n.y,o.bottom)}}catch(e){i.e(e)}finally{i.f()}this.selectedTds=this.computeSelectedTds(t,n),this.selectedTds.length>0?this.update():this.hide()}}},{key:"update",value:function(){if(0!==this.selectedTds.length&&this.boundary&&this.table){var e=this.getQuillViewScroll(),t=e.x,n=e.y,i=this.getTableViewScroll(),o=i.x,r=i.y,a=this.table.parentElement.getBoundingClientRect(),l=this.quill.root.getBoundingClientRect(),s=a.x-l.x,c=a.y-l.y;this.startScrollX=o,this.startScrollY=r,Object.assign(this.cellSelect.style,{left:"".concat(2*this.selectedEditorScrollX-t+this.boundary.x+this.selectedTableScrollX-o-s,"px"),top:"".concat(2*this.selectedEditorScrollY-n+this.boundary.y+this.selectedTableScrollY-r-c,"px"),width:"".concat(this.boundary.width,"px"),height:"".concat(this.boundary.height,"px")}),Object.assign(this.cellSelectWrap.style,{left:"".concat(s,"px"),top:"".concat(c,"px"),width:"".concat(a.width,"px"),height:"".concat(a.height,"px")}),!this.dragging&&this.tableMenu&&this.tableMenu.update()}}},{key:"getQuillViewScroll",value:function(){return{x:this.quill.root.scrollLeft,y:this.quill.root.scrollTop}}},{key:"getTableViewScroll",value:function(){return this.table?{x:this.table.parentElement.scrollLeft,y:this.table.parentElement.scrollTop}:{x:0,y:0}}},{key:"setSelectionTable",value:function(e){this.table!==e&&(this.table=e)}},{key:"showDisplay",value:function(){Object.assign(this.cellSelectWrap.style,{display:"block"}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}},{key:"show",value:function(){var e=this;this.table&&(yt.call(this),this.update(),this.showDisplay(),document.addEventListener("keydown",this.removeCell),gt.call(this,this.quill.root,(function(){e.update()})),gt.call(this,this.table.parentElement,(function(){e.update()})))}},{key:"hideDisplay",value:function(){Object.assign(this.cellSelectWrap.style,{display:"none"}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}},{key:"hide",value:function(){yt.call(this),document.removeEventListener("keydown",this.removeCell),this.hideDisplay(),this.boundary=null,this.selectedTds=[],this.setSelectionTable(void 0),this.tableMenu&&this.tableMenu.hide()}},{key:"destroy",value:function(){this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),this.tableMenu&&this.tableMenu.destroy(),yt.call(this),this.quill.root.removeEventListener("mousedown",this.mouseDownHandler),document.removeEventListener("selectionchange",this.selectionChangeHandler),this.quill.off(t.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.off(t.events.TEXT_CHANGE,this.updateAfterEvent),this.quill.on(S.AFTER_TABLE_RESIZE,this.updateAfterEvent)}}])}(),Cn=["attributes"],xn=["style"],Mn=t.import("parchment"),kn=t.import("delta"),In=t.import("blots/break"),Tn=t.import("ui/icons");function Nn(e){return{bindInHead:!1,key:e?"ArrowUp":"ArrowDown",collapsed:!0,format:[N.tableCellInner],handler:function(n,i){var o,r,a,l;try{var s=C(H(i.line,[N.tableWrapper,N.tableMain,N.tableRow,N.tableCell]),4);o=s[0],r=s[1],a=s[2],l=s[3]}catch(e){return!0}var c,d=r.getColIds(),u=e?"prev":"next",h=e?"tail":"head",f=o.descendants(_t,0)[0];if(f){var p=window.getComputedStyle(f.domNode);c="next"===u&&"bottom"===p.captionSide?f:"next"===u?o.next:f}else c=o[u];if(i.line[u]||!c)return!0;var v=a[u];if(v){var b=d.indexOf(l.colId),m=v.getCellByColId(d[b],u);if(!m)return!0;var g=m.children[h];g.children&&(g=g.children[h]);var y=g.offset(this.quill.scroll)+Math.min(i.offset,g.length()-1);this.quill.setSelection(y,0,t.sources.USER)}else{var w=c.offset(this.quill.scroll)+(e?c.length()-1:0);this.quill.setSelection(w,0,t.sources.USER)}return!1}}}var En=function(){return s((function e(n,i){var o=this;if(a(this,e),d(this,"quill",void 0),d(this,"options",void 0),d(this,"toolBox",void 0),d(this,"fixTableByLisenter",kt(this.balanceTables,100)),d(this,"selector",void 0),d(this,"table",void 0),d(this,"tableSelection",void 0),d(this,"tableResize",void 0),d(this,"tableScrollbar",void 0),d(this,"tableAlign",void 0),d(this,"tableResizeScale",void 0),d(this,"resizeOb",void 0),this.quill=n,this.options=this.resolveOptions(i||{}),this.toolBox=this.initialContainer(),!this.options.scrollbar){var r=z("scrollbar");this.quill.container.classList.add(r.bm("origin"))}this.options.selection&&(this.tableSelection=new this.options.selection(this,this.quill,this.options.selectionOptions));var l=this.quill.getModule("toolbar");if(l&&this.quill.theme.pickers){var s=(l.controls||[]).find((function(e){return C(e,1)[0]===o.statics.toolName}))||[],c=C(s,2)[1];if(c&&"select"===c.tagName.toLocaleLowerCase()){var u=this.quill.theme.pickers.find((function(e){return e.select===c}));u&&(u.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,u),u.label.addEventListener("mousedown",(function(){if(o.selector&&u)if(bt(o.selector.getBoundingClientRect()).leftLimited){var e=u.label.getBoundingClientRect();Object.assign(u.options.style,{transform:"translateX(calc(-100% + ".concat(e.width,"px))")})}else Object.assign(u.options.style,{transform:void 0})})))}}for(var h=this.quill.getModule("keyboard"),f=0,p=Object.values(e.keyboradHandler);f<p.length;f++){var v=p[f];v.bindInHead?h.bindings[v.key].unshift(v):h.addBinding(v.key,v)}this.quill.root.addEventListener("click",(function(e){var t=e.composedPath();if(t&&!(t.length<=0)){var n=t.find((function(e){return e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("ql-table")}));if(n){if(o.table===n)return o.tableSelection&&o.tableSelection.show(),o.tableAlign&&o.tableAlign.update(),o.tableResize&&o.tableResize.update(),void(o.tableScrollbar&&o.tableScrollbar.update());o.table&&o.hideTableTools(),o.showTableTools(n)}else o.table&&o.hideTableTools()}}),!1),this.quill.on(t.events.EDITOR_CHANGE,(function(e){e!==t.events.TEXT_CHANGE||o.table&&o.quill.root.contains(o.table)||o.hideTableTools()})),this.quillHack(),this.listenBalanceCells()}),[{key:"statics",get:function(){return this.constructor}},{key:"initialContainer",value:function(){var e=this,t=z("toolbox"),n=this.quill.addContainer(t.b());return this.resizeOb=new ResizeObserver((function(){var t=e.quill.root.getBoundingClientRect(),i=e.quill.root,o=i.offsetLeft,r=i.offsetTop;Object.assign(n.style,{top:"".concat(r,"px"),left:"".concat(o,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")})})),this.resizeOb.observe(this.quill.root),n}},{key:"addContainer",value:function(e){if(K(e)){var t,n=document.createElement("div"),i=c(e.split(" "));try{for(i.s();!(t=i.n()).done;){var o=t.value;n.classList.add(o)}}catch(e){i.e(e)}finally{i.f()}return this.toolBox.appendChild(n),n}return this.toolBox.appendChild(e),e}},{key:"resolveOptions",value:function(e){return Object.assign({customBtn:!1,texts:this.resolveTexts(e.texts||{}),full:!1,fullSwitch:!0,icon:Tn.table,selectionOptions:{},alignOptions:{},scrollbarOptions:{},resizeOptions:{},resizeScaleOptions:{}},e)}},{key:"resolveTexts",value:function(e){return Object.assign({fullCheckboxText:"Insert full width table",customBtnText:"Custom",confirmText:"Confirm",cancelText:"Cancel",rowText:"Row",colText:"Column",notPositiveNumberError:"Please enter a positive integer",custom:"Custom",clear:"Clear",transparent:"Transparent",perWidthInsufficient:"The percentage width is insufficient. To complete the operation, the table needs to be converted to a fixed width. Do you want to continue?",CopyCell:"Copy cell",CutCell:"Cut cell",InsertTop:"Insert row above",InsertRight:"Insert column right",InsertBottom:"Insert row below",InsertLeft:"Insert column Left",MergeCell:"Merge Cell",SplitCell:"Split Cell",DeleteRow:"Delete Row",DeleteColumn:"Delete Column",DeleteTable:"Delete table",BackgroundColor:"Set background color",BorderColor:"Set border color"},e)}},{key:"quillHack",value:function(){var e=this,n=this.quill.getSemanticHTML;this.quill.getSemanticHTML=function(){for(var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1?arguments[1]:void 0,r=n.call(e.quill,i,o),a=t.import("formats/".concat(N.tableWrapper)),l=(new DOMParser).parseFromString(r,"text/html"),s=0,c=Array.from(l.querySelectorAll(".".concat(a.className," caption[contenteditable], .").concat(a.className," td > [contenteditable]")));s<c.length;s++){c[s].removeAttribute("contenteditable")}return l.body.innerHTML};var i=this.quill.format;this.quill.format=function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.sources.API;if(!(this.scroll.query(e).prototype instanceof Mn.EmbedBlot)){var r=this.getModule(L.moduleName),a=this.getSelection();if(a&&a.length>0)if(this.getFormat(a)[N.tableCellInner])return i.call(this,e,n,o);if(r&&r.tableSelection&&r.tableSelection.selectedTds.length>0){var l,s=!1,u=[],h=c(r.tableSelection.selectedTds);try{for(h.s();!(l=h.n()).done;){var f=l.value,p=f.offset(this.scroll),v=f.length();u.push({index:p,length:v}),this.getFormat(p,v)[e]!==n&&(s=!0)}}catch(e){h.e(e)}finally{h.f()}var b,m=!!s&&n,g=new kn,y=c(u.entries());try{for(y.s();!(b=y.n()).done;){var w=C(b.value,2),x=w[0],M=w[1],k=M.index,I=M.length,T=0===x?0:u[x-1].index+u[x-1].length;g.retain(k-T).retain(I,d({},e,m))}}catch(e){y.e(e)}finally{y.f()}var E=this.updateContents(g,o);return this.blur(),E}}return i.call(this,e,n,o)};var o=this.quill.theme.modules.toolbar;if(o){var r,a=null===(r=o.handlers)||void 0===r?void 0:r.clean;if(a){var l=function(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return""},o=e.quill.getText(t,n),r=C(e.quill.getLine(t+n),2),a=r[0],l=r[1],s=0,c=new kn;null!=a&&(s=a.length()-l,c=a.delta().slice(l,l+s-1).insert("\n"));var u=e.quill.getContents(t,n+s),h=u.diff((new kn).insert(o).concat(c)),f=0,p=h.ops.map((function(e){var t=e.attributes,n=m(e,Cn);if(e.insert?f-=K(e.insert)?e.insert.length:1:e.retain?f+="number"==typeof e.retain?e.retain:1:e.delete&&(f+=e.delete),t){var o=N.tableCellInner;t[o];var r=m(t,[o].map(k));if(i){var a=u.slice(f-1,f).ops[0];if(a&&a.attributes&&a.attributes[N.tableCellInner]){var l=a.attributes[N.tableCellInner],s=l.style,c=m(l,xn),h=i(s);return b(b({},n),{},h?{attributes:b(b({},r),{},d({},N.tableCellInner,b({style:h},c)))}:{attributes:b(b({},r),{},d({},N.tableCellInner,c))})}}return b(b({},n),{},{attributes:b({},r)})}return e}));return new kn(p)};o.handlers.clean=function(e){var n=this,i=this.quill.getModule(L.moduleName),o=this.quill.getSelection();if(o&&o.length>0&&this.quill.getFormat(o)[N.tableCellInner]){var r=l(o.index,o.length,!1),s=(new kn).retain(o.index).concat(r);return void this.quill.updateContents(s,t.sources.USER)}if(i&&i.tableSelection&&i.tableSelection.selectedTds.length>0&&i.tableSelection.table){var d=t.find(i.tableSelection.table);if(!d)return void console.warn("TableMainFormat not found");var u,h=i.tableSelection.selectedTds,f=new Set,p=[],v=c(h);try{for(v.s();!(u=v.n()).done;){var b=u.value;if(b.parent instanceof Vt){var m,g=c(b.parent.getNearByCell("top"));try{for(g.s();!(m=g.n()).done;){var y=m.value;f.has(y)||(f.add(y),p.push({td:y,cleanBorder:"bottom"}))}}catch(e){g.e(e)}finally{g.f()}var w,C=c(b.parent.getNearByCell("left"));try{for(C.s();!(w=C.n()).done;){var x=w.value;f.has(x)||(f.add(x),p.push({td:x,cleanBorder:"right"}))}}catch(e){C.e(e)}finally{C.f()}f.add(b.parent),p.push({td:b.parent,cleanBorder:!0})}}}catch(e){v.e(e)}finally{v.f()}var M=d.descendants(Vt),k=new Map(M.map((function(e,t){return[e,t]})));p.sort((function(e,t){return k.get(e.td)-k.get(t.td)}));for(var I=new kn,T=0,E=function(){var e=B[S],t=e.td,i=e.cleanBorder,o=t.getCellInner().offset(n.quill.scroll),r=t.getCellInner().length(),a=l(o,r-1,(function(e){if(!e||!0===i)return"";var t=wt(e);return Ct(Object.keys(t).filter((function(e){return!e.startsWith(xt("border-".concat(i)))})).reduce((function(e,n){return e[n]=t[n],e}),{}))})),s=(new kn).retain(o-T).concat(a);I=I.concat(s),T=o+r},S=0,B=p;S<B.length;S++)E();return this.quill.updateContents(I,t.sources.USER),void(h.length>1&&this.quill.blur())}return a.call(this,e)}}}}},{key:"showTableTools",value:function(e){var t;e&&(this.table=e,null===(t=this.tableSelection)||void 0===t||t.show(),this.options.align&&(this.tableAlign=new this.options.align(this,e,this.quill,this.options.alignOptions)),this.options.scrollbar&&(this.tableScrollbar=new this.options.scrollbar(this,e,this.quill,this.options.scrollbarOptions)),this.options.resize&&(this.tableResize=new this.options.resize(this,e,this.quill,this.options.resizeOptions)),this.options.resizeScale&&(this.tableResizeScale=new this.options.resizeScale(this,e,this.quill,this.options.resizeScaleOptions)))}},{key:"hideTableTools",value:function(){var e;null===(e=this.tableSelection)||void 0===e||e.hide(),this.tableScrollbar&&(this.tableScrollbar.destroy(),this.tableScrollbar=void 0),this.tableAlign&&(this.tableAlign.destroy(),this.tableAlign=void 0),this.tableResize&&(this.tableResize.destroy(),this.tableResize=void 0),this.tableResizeScale&&this.tableResizeScale.destroy(),this.table=void 0}},{key:"buildCustomSelect",value:(e=o(y().mark((function e(t,n){var i,o,r,a,l,s=this;return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&Y(t)){e.next=2;break}return e.abrupt("return");case 2:return(i=document.createElement("div")).classList.add("ql-custom-select"),e.next=6,t(this,n);case 6:this.selector=e.sent,i.appendChild(this.selector),this.options.fullSwitch&&(o=z("creator"),(r=document.createElement("label")).classList.add(o.be("checkbox")),(a=document.createElement("input")).type="checkbox",a.checked=this.options.full,a.addEventListener("change",(function(){s.options.full=a.checked})),(l=document.createElement("span")).textContent=this.options.texts.fullCheckboxText,r.appendChild(a),r.appendChild(l),i.appendChild(r)),n.options.innerHTML="",n.options.appendChild(i);case 11:case"end":return e.stop()}}),e,this)}))),function(t,n){return e.apply(this,arguments)})},{key:"setCellAttrs",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(0!==e.length){var o,r=c(e);try{for(r.s();!(o=r.n()).done;){o.value.setFormatValue(t,n,i)}}catch(e){r.e(e)}finally{r.f()}}}},{key:"getTextByCell",value:function(e){var t,n="",i=c(e);try{for(i.s();!(t=i.n()).done;){var o,r=t.value,a=r.offset(this.quill.scroll),l=r.length(),s=c(this.quill.getContents(a,l).ops);try{for(s.s();!(o=s.n()).done;){var d=o.value;K(d.insert)&&(n+=d.insert)}}catch(e){s.e(e)}finally{s.f()}}}catch(e){i.e(e)}finally{i.f()}return n}},{key:"getHTMLByCell",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(0===e.length)return"";var n=null;try{var i,o=c(e);try{for(o.s();!(i=o.n()).done;){var r=q(i.value,N.tableMain);if(n||(n=r),r!==n)return console.error("tableMain is not same"),""}}catch(e){o.e(e)}finally{o.f()}}catch(e){return console.error("tds must be in same tableMain"),""}if(!n)return"";var a,l=this.quill.getIndex(n),s=n.length(),d=this.quill.getSemanticHTML(l,s),u=(new DOMParser).parseFromString(d,"text/html"),h=[],f=new Set,p=new Set,v=c(e);try{for(v.s();!(a=v.n()).done;){var b=a.value;f.add(b.colId),p.add("".concat(b.rowId,"-").concat(b.colId))}}catch(e){v.e(e)}finally{v.f()}for(var m=0,g=Array.from(u.querySelectorAll("col"));m<g.length;m++){var y=g[m];f.has(y.dataset.colId)?h.push(y.getAttribute("width")):y.remove()}for(var w=0,x=null,M=0,k=Array.from(u.querySelectorAll("td"));M<k.length;M++){var I=k[M];if(p.has("".concat(I.dataset.rowId,"-").concat(I.dataset.colId)))x!==I.dataset.rowId&&(w+=1,x=I.dataset.rowId);else{var T=I.parentElement;I.remove(),T&&T.children.length<=0&&T.remove()}}var E=Array.from(u.querySelectorAll("col")),S=E.map((function(e){return Xt.value(e)}));if(n.full){var L,B=S.reduce((function(e,t){return t.width+e}),0),R=c(S.entries());try{for(R.s();!(L=R.n()).done;){var O=C(L.value,2),A=O[0],z=O[1];z.width=Math.round(z.width/B*100),E[A].setAttribute("width","".concat(z.width,"%"))}}catch(e){R.e(e)}finally{R.f()}}else{var H,W=0,D=c(S);try{for(D.s();!(H=D.n()).done;){W+=H.value.width}}catch(e){D.e(e)}finally{D.f()}u.querySelector("table").style.width="".concat(W,"px")}if(t)if(w===n.getRows().length)this.removeCol(e);else{var j,P=c(e);try{for(P.s();!(j=P.n()).done;){j.value.domNode.innerHTML="<p><br></p>"}}catch(e){P.e(e)}finally{P.f()}}return u.body.innerHTML}},{key:"insertTable",value:function(e,n){if(e>=30||n>=30)throw new Error("Both rows and columns must be less than 30.");this.quill.focus();var i=this.quill.getSelection();if(null!=i){var o=C(this.quill.getLeaf(i.index),1)[0];if(o){if(A(o))throw new Error("Not supported ".concat(o.statics.blotName," insert into table."));for(var r=this.calculateTableCellBorderWidth(),a=getComputedStyle(this.quill.root),l=Number.parseInt(a.paddingLeft),s=Number.parseInt(a.paddingRight),c=Number.parseInt(a.width)-l-s-r,u=Mt(),h=new Array(n).fill(0).map((function(){return Mt()})),f=this.options.full?"".concat(Math.max(1/n*100,E.colMinWidthPre),"%"):"".concat(Math.max(Math.floor(c/n),E.colMinWidthPx),"px"),p=[{retain:i.index},{insert:"\n"}],v=0;v<n;v++)p.push({insert:d({},N.tableCol,{width:f,tableId:u,colId:h[v],full:this.options.full})});for(var b=0;b<e;b++)for(var m=Mt(),g=0;g<n;g++)p.push({insert:"\n",attributes:d({},N.tableCellInner,{tableId:u,rowId:m,colId:h[g],rowspan:1,colspan:1})});this.quill.updateContents(new kn(p),t.sources.USER),this.quill.setSelection(i.index+n+n*e+1,t.sources.SILENT),this.quill.focus()}}}},{key:"calculateTableCellBorderWidth",value:function(){var e='\n <table class="'.concat(Ut.className,'">\n <tbody>\n <tr>\n <td class="').concat(Vt.className,'"></td>\n </tr>\n </tbody>\n </table>\n '),t=document.createElement("div");t.className=Kt.className,t.innerHTML=e,t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.visibility="hidden",this.quill.root.appendChild(t);var n=window.getComputedStyle(t.querySelector("td")),i=Number.parseFloat(n.borderWidth)||0;return this.quill.root.removeChild(t),i}},{key:"fixUnusuaDeletelTable",value:function(e){var t=e.getRows(),n=e.getColIds();if(0===t.length)return e.remove();if(0!==n.length){var i,o,r,a,l,s,d,u=new Array(t.length).fill(0).map((function(){return new Array(n.length).fill(!1)})),h=e.tableId,f=c(t.entries());try{for(f.s();!(i=f.n()).done;){for(var p=C(i.value,2),v=p[0],b=p[1],m=0,g=0,y=u[v],w=b.descendants(Vt);g<n.length;)if(y[g])g+=1;else{var x=w[m];if(x&&x.colId===n[g]){v+x.rowspan-1>=t.length&&(x.getCellInner().rowspan=t.length-v);var M=x.colspan,k=x.rowspan;if(M>1)for(var I=1;I<M;I++)y[g+I]=!0;if(k>1)for(var T=v+1;T<v+k;T++)for(var E=0;E<M;E++)u[T][g+E]=!0;m+=1}else b.insertBefore((o=this.quill.scroll,r={tableId:h,colId:n[g],rowId:b.rowId},a=void 0,l=void 0,s=void 0,d=void 0,a={tableId:r.tableId,rowId:r.rowId,colId:r.colId,colspan:1,rowspan:1},l=o.create(N.tableCell,a),s=o.create(N.tableCellInner,a),(d=o.create("block")).appendChild(o.create("break")),s.appendChild(d),l.appendChild(s),l),x);g+=1}if(m<w.length)for(var S=m;S<w.length;S++)w[S].remove()}}catch(e){f.e(e)}finally{f.f()}}}},{key:"balanceTables",value:function(){var e,t=c(this.quill.scroll.descendants(Ut));try{for(t.s();!(e=t.n()).done;){var n=e.value;this.fixUnusuaDeletelTable(n)}}catch(e){t.e(e)}finally{t.f()}}},{key:"listenBalanceCells",value:function(){var e=this;this.quill.on(t.events.SCROLL_OPTIMIZE,(function(n){n.some((function(t){return!!["TD","TR","TBODY","TABLE"].includes(t.target.tagName)&&(e.fixTableByLisenter(),!0)}));var i,o=c(n);try{for(o.s();!(i=o.n()).done;){var r=i.value.target;if("TABLE"===r.tagName){var a=t.find(r);if(a){a.sortMergeChildren();break}}}}catch(e){o.e(e)}finally{o.f()}}))}},{key:"deleteTable",value:function(e){if(0!==e.length){var t=q(e[0],N.tableMain);t&&t.remove(),this.hideTableTools()}}},{key:"appendRow",value:function(e,t){if(!(e.length<=0)){var n=e[t?e.length-1:0],i=C(H(n,[N.tableMain,N.tableBody,N.tableRow]),3),o=i[0],r=i[1],a=i[2],l=o.getRows().indexOf(a)+(t?n.rowspan:0);r.insertRow(l)}}},{key:"appendCol",value:function(e,t){if(!(e.length<=0)){var n=e.reduce((function(e,n){var i=n.getColumnIndex();return(!t&&i<=e[1]||t&&i>=e[1])&&(e=[n,i]),e}),[e[0],e[0].getColumnIndex()]),i=C(n,1)[0],o=i.getColumnIndex()+(t?i.colspan:0),r=q(i,N.tableMain),a=r.tableId,l=Mt(),s=C(r.descendants(Yt),1)[0];s&&s.insertColByIndex(o,{tableId:a,colId:l,width:r.full?6:160,full:r.full});for(var d=r.getRows(),u=[],h=0,f=0,p=Object.values(d);f<p.length;f++){var v=p[f],b=u.shift()||0;if(h>0)h-=1;else{var m=v.insertCell(o-b,{tableId:a,rowId:v.rowId,colId:l,rowspan:1,colspan:1});m.skipRowNum&&(h+=m.skipRowNum);var g,y=c(m.entries());try{for(y.s();!(g=y.n()).done;){var w=C(g.value,2),x=w[0],M=w[1];u[x]=(u[x]||0)+M}}catch(e){y.e(e)}finally{y.f()}}}}}},{key:"fixTableByRemove",value:function(e){var t,n=e.getRows(),i=e.getCols(),o=i.reduce((function(e,t){return e[t.colId]=0,e}),{}),r=M(n).reverse(),a=[],l=c(r.entries());try{var s=function(){var e=C(t.value,2),i=e[0],r=e[1],l=n.length-i-1;r.children.length<=0?a.push(l):r.foreachCellInner((function(e){var t=a.reduce((function(t,n){return e.rowspan+l>n?t+1:t}),0);e.rowspan-=t,o[e.colId]+=1}))};for(l.s();!(t=l.n()).done;)s()}catch(e){l.e(e)}finally{l.f()}for(var d=0,u=0,h=Object.values(o);u<h.length;u++){if(0===h[u])for(var f=[],p=0,v=0,b=Object.values(n);v<b.length;v++){var m=b[v],g=f.shift()||0,y=[];p>0?(y=m.getCellByColumIndex(d-g)[2],p-=1):(y=m.removeCell(d-g)).skipRowNum&&(p+=y.skipRowNum);var w,x=c(y.entries());try{for(x.s();!(w=x.n()).done;){var k=C(w.value,2),I=k[0],T=k[1];f[I]=(f[I]||0)+T}}catch(e){x.e(e)}finally{x.f()}}else d+=1}var N,E=c(i);try{for(E.s();!(N=E.n()).done;){var S=N.value;0===o[S.colId]&&(S.prev?S.prev.width+=S.width:S.next&&(S.next.width+=S.width),S.remove())}}catch(e){E.e(e)}finally{E.f()}}},{key:"removeRow",value:function(e){if(!(e.length<=0)){var t,n=q(e[0],N.tableMain),i=n.getRows(),o=i.length,r=-1,a=c(e);try{for(a.s();!(t=a.n()).done;){var l=t.value,s=q(l,N.tableRow),d=i.indexOf(s);d<o&&(o=d),d+l.rowspan>r&&(r=d+l.rowspan)}}catch(e){a.e(e)}finally{a.f()}for(var u={},h=function(e){i[e].foreachCellInner((function(t){t.rowspan+e>r&&(u[t.colId]={rowspan:t.rowspan+e-r,colspan:t.colspan,colIndex:t.getColumnIndex()}),t.parent.remove()}))},f=o;f<Math.min(i.length,r);f++)h(f);if(i[r])for(var p=i[r],v=n.tableId,b=0,m=Object.entries(u);b<m.length;b++){var g=C(m[b],2),y=g[0],w=g[1],x=w.colIndex,M=w.colspan,k=w.rowspan;p.insertCell(x,{tableId:v,rowId:p.rowId,colId:y,colspan:M,rowspan:k})}this.fixTableByRemove(n)}}},{key:"removeCol",value:function(e){if(!(e.length<=0)){var t,n=e[0],i=q(n,N.tableMain),o={},r=c(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;o[a.rowId]||(o[a.rowId]=0),o[a.rowId]+=a.colspan}}catch(e){r.e(e)}finally{r.f()}for(var l=Math.max.apply(Math,M(Object.values(o))),s=n.getColumnIndex(),d=i.descendants(At),u=0;u<l;u++)for(var h=[],f=0,p=0,v=Object.values(d);p<v.length;p++){var b=v[p],m=h.shift()||0;if(f>0)f-=1;else{var g=b.removeCell(s-m);g.skipRowNum&&(f+=g.skipRowNum);var y,w=c(g.entries());try{for(w.s();!(y=w.n()).done;){var x=C(y.value,2),k=x[0],I=x[1];h[k]=(h[k]||0)+I}}catch(e){w.e(e)}finally{w.f()}}}var T=C(i.descendants(Yt),1)[0];if(T)for(var E=0;E<l;E++)T.removeColByIndex(s);this.fixTableByRemove(i)}}},{key:"mergeCells",value:function(e){if(!(e.length<=1)){var t=e.reduce((function(e,t,n){var i=t.colId;e[0][i]||(e[0][i]=0),e[0][i]+=t.rowspan;var o=t.rowId;return e[1][o]||(e[1][o]=0),e[1][o]+=t.colspan,0!==n&&(t.moveChildren(e[2]),t.parent.remove()),e}),[{},{},e[0]]),n=Math.max.apply(Math,M(Object.values(t[0]))),i=Math.max.apply(Math,M(Object.values(t[1]))),o=t[2];o.colspan=i,o.rowspan=n;var r=q(o,N.tableMain);this.fixTableByRemove(r)}}},{key:"splitCell",value:function(e){if(1===e.length){var t=e[0];if(1!==t.colspan||1!==t.rowspan){var n=C(H(t,[N.tableMain,N.tableRow]),2),i=n[0],o=n[1],r=i.tableId,a=t.getColumnIndex(),l=i.getColIds().slice(a,a+t.colspan).reverse(),s=o,d=t.rowspan;for(t.colspan=1,t.rowspan=1;s&&d>0;){var u,h=c(l);try{for(h.s();!(u=h.n()).done;){var f=u.value;s===o&&f===t.colId||s.insertCell(a+(s===o?1:0),{tableId:r,rowId:s.rowId,colId:f,rowspan:1,colspan:1})}}catch(e){h.e(e)}finally{h.f()}d-=1,s=s.next}}}}}],[{key:"register",value:function(){var e;Kt.allowedChildren=[Ut],Ut.allowedChildren=[zt,Yt,_t],Ut.requiredContainer=Kt,_t.requiredContainer=Ut,Yt.allowedChildren=[Xt],Yt.requiredContainer=Ut,zt.allowedChildren=[At],zt.requiredContainer=Ut,At.allowedChildren=[Vt],Vt.requiredContainer=zt,Vt.allowedChildren=[Ot,In],Vt.requiredContainer=At,Ot.requiredContainer=Vt;var n=["header","list","blockquote","code-block"].reduce((function(e,n){var i="formats/".concat(n),o=t.import(i);return e[i]=function(e){function t(){return a(this,t),r(this,t,arguments)}return f(t,e),s(t,null,[{key:"register",value:function(){}}])}(function(e,t){var n,i=function(e){function t(){a(this,t);for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return r(this,t,[].concat(n))}return f(t,e),s(t)}(e),o=c(t);try{for(o.s();!(n=o.n()).done;){var l=n.value;j(i.prototype,l.prototype)}}catch(e){o.e(e)}finally{o.f()}return i}(o,[Ht])),e}),{});t.register(b(b({"blots/scroll":Dt,"blots/block":Ht},n),{},(d(d(d(d(d(d(d(d(d(d(e={},"blots/".concat(N.container),St),"formats/".concat(N.tableCell),Vt),"formats/".concat(N.tableCellInner),Ot),"formats/".concat(N.tableRow),At),"formats/".concat(N.tableBody),zt),"formats/".concat(N.tableCol),Xt),"formats/".concat(N.tableColgroup),Yt),"formats/".concat(N.tableCaption),_t),"formats/".concat(N.tableMain),Ut),"formats/".concat(N.tableWrapper),Kt),d(e,"modules/clipboard",rn))),!0)}}]);var e}();d(En,"moduleName",L.moduleName),d(En,"toolName",N.tableWrapper),d(En,"keyboradHandler",{"forbid remove table by backspace":{bindInHead:!0,key:"Backspace",collapsed:!0,offset:0,handler:function(e,t){var n=this.quill.getLine(e.index)[0];if(n.prev instanceof Kt)return n.prev.remove(),!1;if(t.format[N.tableCellInner]&&0===n.offset(q(n,N.tableCellInner)))return!1;return!0}},"forbid remove table by delete":{bindInHead:!0,key:"Delete",collapsed:!0,handler:function(e,t){var n=this.quill.getLine(e.index),i=n[0],o=n[1];if((i.next instanceof Kt||i.next instanceof Xt)&&o===i.length()-1)return!1;if(t.format[N.tableCellInner]&&(i===q(i,N.tableCellInner).children.tail&&o===i.length()-1))return!1;return!0}},"table up":Nn(!0),"table down":Nn(!1),"table caption break":{bindInHead:!0,key:"Enter",shiftKey:null,format:[N.tableCaption],handler:function(e,t){return!1}}}),e.BlockOverride=Ht,e.ContainerFormat=St,e.ScrollOverride=Dt,e.Scrollbar=gn,e.TableAlign=$t,e.TableBodyFormat=zt,e.TableCaptionFormat=_t,e.TableCellFormat=Vt,e.TableCellInnerFormat=Ot,e.TableClipboard=rn,e.TableColFormat=Xt,e.TableColgroupFormat=Yt,e.TableMainFormat=Ut,e.TableMenuCommon=dn,e.TableMenuContextmenu=un,e.TableMenuSelect=hn,e.TableResizeBox=vn,e.TableResizeCommon=pn,e.TableResizeLine=bn,e.TableResizeScale=mn,e.TableRowFormat=At,e.TableSelection=wn,e.TableUp=En,e.TableVirtualScrollbar=yn,e.TableWrapperFormat=Kt,e.blotName=N,e.createColorPicker=Q,e.createSelectBox=oe,e.createTooltip=pt,e.default=En,e.defaultCustomSelect=function(e,t){return oe({onSelect:function(n,i){e.insertTable(n,i),t&&t.close()},customBtn:e.options.customBtn,texts:e.options.texts})},e.findParentBlot=q,e.findParentBlots=H,e.getTableMainRect=Zt,e.isTableAlignRight=fn,e.randomId=Mt,e.tableMenuTools=ln,e.tableUpEvent=S,e.tableUpInternal=L,e.tableUpSize=E,e.updateTableConstants=function(e){O.delete(N.tableCellInner),Object.assign(N,e.blotName||{}),Object.assign(E,e.tableUpSize||{}),Object.assign(S,e.tableUpEvent||{}),Object.assign(L,e.tableUpInternal||{}),En.moduleName=L.moduleName,En.toolName=N.tableWrapper,St.blotName=N.container,Kt.blotName=N.tableWrapper,Ut.blotName=N.tableMain,Yt.blotName=N.tableColgroup,Xt.blotName=N.tableCol,zt.blotName=N.tableBody,At.blotName=N.tableRow,Vt.blotName=N.tableCell,Ot.blotName=N.tableCellInner,O.add(N.tableCellInner)},Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=index.umd.js.map
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`quill`)):typeof define==`function`&&define.amd?define([`exports`,`quill`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.TableUp={},e.Quill))})(this,function(exports,t){Object.defineProperty(exports,`__esModule`,{value:!0});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},l=(e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));t=l(t);let u={container:`table-up-container`,tableCaption:`table-up-caption`,tableWrapper:`table-up`,tableMain:`table-up-main`,tableColgroup:`table-up-colgroup`,tableCol:`table-up-col`,tableBody:`table-up-body`,tableRow:`table-up-row`,tableCell:`table-up-cell`,tableCellInner:`table-up-cell-inner`},d={colMinWidthPre:5,colMinWidthPx:40,colDefaultWidth:100,rowMinHeightPx:36},f={AFTER_TABLE_RESIZE:`after-table-resize`},p={moduleName:`table-up`},m=[[`rgb(255, 255, 255)`,`rgb(0, 0, 0)`,`rgb(72, 83, 104)`,`rgb(41, 114, 244)`,`rgb(0, 163, 245)`,`rgb(49, 155, 98)`,`rgb(222, 60, 54)`,`rgb(248, 136, 37)`,`rgb(245, 196, 0)`,`rgb(153, 56, 215)`],[`rgb(242, 242, 242)`,`rgb(127, 127, 127)`,`rgb(243, 245, 247)`,`rgb(229, 239, 255)`,`rgb(229, 246, 255)`,`rgb(234, 250, 241)`,`rgb(254, 233, 232)`,`rgb(254, 243, 235)`,`rgb(254, 249, 227)`,`rgb(253, 235, 255)`],[`rgb(216, 216, 216)`,`rgb(89, 89, 89)`,`rgb(197, 202, 211)`,`rgb(199, 220, 255)`,`rgb(199, 236, 255)`,`rgb(195, 234, 213)`,`rgb(255, 201, 199)`,`rgb(255, 220, 196)`,`rgb(255, 238, 173)`,`rgb(242, 199, 255)`],[`rgb(191, 191, 191)`,`rgb(63, 63, 63)`,`rgb(128, 139, 158)`,`rgb(153, 190, 255)`,`rgb(153, 221, 255)`,`rgb(152, 215, 182)`,`rgb(255, 156, 153)`,`rgb(255, 186, 132)`,`rgb(255, 226, 112)`,`rgb(213, 142, 255)`],[`rgb(165, 165, 165)`,`rgb(38, 38, 38)`,`rgb(53, 59, 69)`,`rgb(20, 80, 184)`,`rgb(18, 116, 165)`,`rgb(39, 124, 79)`,`rgb(158, 30, 26)`,`rgb(184, 96, 20)`,`rgb(163, 130, 0)`,`rgb(94, 34, 129)`],[`rgb(147, 147, 147)`,`rgb(13, 13, 13)`,`rgb(36, 39, 46)`,`rgb(12, 48, 110)`,`rgb(10, 65, 92)`,`rgb(24, 78, 50)`,`rgb(88, 17, 14)`,`rgb(92, 48, 10)`,`rgb(102, 82, 0)`,`rgb(59, 21, 81)`]],h=`table-up`,g=new Set([u.tableCellInner]),_=e=>g.has(e.statics.blotName);function v(e){return e&&e.parent?_(e.parent)?!0:v(e.parent):!1}function y(e,t=h){let n=t?`${t}-`:``;return{b:()=>`${n}${e}`,be:t=>t?`${n}${e}__${t}`:``,bm:t=>t?`${n}${e}--${t}`:``,bem:(t,r)=>t&&r?`${n}${e}__${t}--${r}`:``,ns:e=>e?`${n}${e}`:``,bs:t=>t?`${n}${e}-${t}`:``,cv:e=>e?`--${n}${e}`:``,is:e=>`is-${e}`}}function b(e,t){let n=e.parent;for(;n&&n.statics.blotName!==t&&n!==e.scroll;)n=n.parent;if(n===e.scroll)throw Error(`${e.statics.blotName} must be a child of ${t}`);return n}function x(e,t){let n=Array(t.length),r=new Map(t.map((e,t)=>[e,t])),i=e.parent;for(;i&&i!==e.scroll&&r.size!==0;){if(r.has(i.statics.blotName)){let e=r.get(i.statics.blotName);n[e]=i,r.delete(i.statics.blotName)}i=i.parent}if(r.size>0)throw Error(`${e.statics.blotName} must be a child of ${Array.from(r.keys()).join(`, `)}`);return n}function S(e){let t=new Map,n=e;for(;n&&n.statics.blotName!==`scroll`;)t.set(n.statics.blotName,n),n=n.parent;return t}function C(e,t){let n=[],r=e.children.iterator(),i=null;for(;i=r();)i instanceof t&&n.push(i);return n}function ee(e,t){for(let n of Object.getOwnPropertyNames(t)){if(/^constructor$/.test(n))continue;Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}return e}function te(e,t){let n=class extends e{constructor(...e){super(...e)}};for(let e of t)ee(n.prototype,e.prototype);return n}function w(e,t){return e=Math.min(t,Math.max(0,Number.parseFloat(`${e}`))),Math.abs(e-t)<1e-6?1:e%t/Number.parseFloat(t)}function T(e){return{h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b)),a:Math.min(1,Math.max(0,e.a))}}function ne(e){e=e.startsWith(`#`)?e.slice(1):e;let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=Number((Number.parseInt(e.slice(6,8)||`ff`,16)/255).toFixed(2));return{r:t,g:n,b:r,a:i}}function re(e){let{r:t,g:n,b:r,a:i}=e;t=w(t,255),n=w(n,255),r=w(r,255);let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c=a,l=a-o,u=a===0?0:l/a;if(a===o)s=0;else{switch(a){case t:s=(n-r)/l+(n<r?6:0);break;case n:s=(r-t)/l+2;break;case r:s=(t-n)/l+4;break}s/=6}return{h:s*360,s:u*100,b:c*100,a:i}}function ie(e){let{h:t,s:n,b:r,a:i}=e;t=w(t,360)*6,n=w(n,100),r=w(r,100);let a=Math.floor(t),o=t-a,s=r*(1-n),c=r*(1-o*n),l=r*(1-(1-o)*n),u=a%6,d=[r,c,s,s,l,r][u],f=[l,r,r,c,s,s][u],p=[s,s,l,r,r,c][u];return{r:Math.round(d*255),g:Math.round(f*255),b:Math.round(p*255),a:i}}function ae(e){let t=[e.r.toString(16),e.g.toString(16),e.b.toString(16),Math.round(e.a*255).toString(16)];for(let e in t)t[e].length===1&&(t[e]=`0${t[e]}`);return t.join(``)}let oe=e=>ae(ie(e)),se=e=>typeof e==`function`,ce=Array.isArray,le=e=>typeof e==`string`,ue=e=>typeof e==`number`,de=e=>typeof e==`object`&&!!e,fe=e=>!Number.isNaN(e)&&Number(e)>0;function pe(e){let{type:t=`default`,content:n}=e||{},r=y(`button`),i=document.createElement(`button`);return i.classList.add(r.b(),t),n&&(le(n)?i.textContent=n:i.appendChild(n)),i}function me(e={}){let t=230,n=150,r=10,i=re(ne(e.color||`#ff0000`)),a=y(`color-picker`),o=document.createElement(`div`);o.classList.add(a.b());let s=document.createElement(`div`);s.classList.add(a.be(`content`));let c=document.createElement(`div`);c.classList.add(a.be(`selector`));let l=document.createElement(`div`);l.classList.add(a.be(`background`)),c.appendChild(l);let u=document.createElement(`div`);u.classList.add(a.be(`background-handle`)),l.appendChild(u);let d=document.createElement(`div`);d.classList.add(a.be(`alpha`));let f=document.createElement(`div`);f.classList.add(a.be(`alpha-bg`));let p=document.createElement(`div`);p.classList.add(a.be(`alpha-handle`)),d.appendChild(f),d.appendChild(p);let m=document.createElement(`div`);m.classList.add(a.be(`hue`));let h=document.createElement(`div`);h.classList.add(a.be(`hue-handle`)),m.appendChild(h);let g=document.createElement(`div`);g.classList.add(a.be(`action`));let[_,v,b,x]=[`r`,`g`,`b`,`a`].map(e=>{let t=document.createElement(`div`);t.classList.add(a.be(`action-item`),e);let n=document.createElement(`label`);n.textContent=e.toUpperCase();let r=document.createElement(`input`);return r.classList.add(a.be(`input`)),r.addEventListener(`input`,()=>{r.value=r.value.replaceAll(/[^0-9]/g,``)}),r.addEventListener(`change`,()=>{let t=Math.round(Number(r.value));e===`a`&&(t/=100);let n=T(re(Object.assign({},ie(i),{[e]:t})));fe(n),de()}),t.appendChild(n),t.appendChild(r),g.appendChild(t),r});s.appendChild(m),s.appendChild(c),s.appendChild(d),o.appendChild(s),o.appendChild(g);let S=!1,C=!1,ee=!1;function te(){let e=oe(i);for(let[t,n]of[_,v,b].entries())n.value=String(Number.parseInt(e[t*2]+e[t*2+1],16));x.value=String((i.a*100).toFixed(0))}function w(){Object.assign(u.style,{left:`${Math.floor(t*i.s/100)}px`,top:`${Math.floor(n*(100-i.b)/100)}px`})}function se(){c.style.backgroundColor=`#${ae(ie({h:i.h,s:100,b:100,a:1}))}`}function ce(){h.style.top=`${Math.floor(n-n*i.h/360)}px`}function le(){p.style.left=`${i.a*100}%`}function ue(){let{r:e,g:t,b:n}=ie(i);f.style.background=`linear-gradient(to right, rgba(${e}, ${t}, ${n}, 0) 0%, rgba(${e}, ${t}, ${n}, 1) 100%)`}function de(){w(),se(),ce(),le(),ue(),te()}function fe(t){i=T(Object.assign({},i,t)),te(),e.onChange&&e.onChange(`#${oe(i)}`)}function pe(e){let r=c.getBoundingClientRect(),i=r.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),a=r.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(t,e.pageX-a))/t),s=Math.floor(100*(n-Math.max(0,Math.min(n,e.pageY-i)))/n);fe({s:o,b:s}),de()}function me(e){let t=m.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);fe({h:Math.floor(360*(n-Math.max(0,Math.min(n,e.pageY-t)))/n)}),de()}function he(e){let{pageX:t}=e,n=d.getBoundingClientRect(),i=t-n.left;i=Math.max(r/2,i),i=Math.min(i,n.width-r/2),fe({a:Math.round((i-10/2)/(n.width-10)*100)/100}),de()}function E(e){S&&(e.preventDefault(),pe(e)),C&&(e.preventDefault(),me(e)),ee&&(e.preventDefault(),he(e))}function ge(){document.removeEventListener(`mousemove`,E),document.removeEventListener(`mouseup`,ge),S=!1}function _e(e){document.addEventListener(`mousemove`,E),document.addEventListener(`mouseup`,ge),S=!0,pe(e)}c.addEventListener(`mousedown`,_e);function D(){document.removeEventListener(`mousemove`,E),document.removeEventListener(`mouseup`,D),C=!1}function ve(e){document.addEventListener(`mousemove`,E),document.addEventListener(`mouseup`,D),C=!0,me(e)}m.addEventListener(`mousedown`,ve);function ye(){document.removeEventListener(`mousemove`,E),document.removeEventListener(`mouseup`,ye),ee=!1}function be(e){document.addEventListener(`mousemove`,E),document.addEventListener(`mouseup`,ye),ee=!0,he(e)}return d.addEventListener(`mousedown`,be),de(),o}let he=8e3;function E({child:e,target:t=document.body,beforeClose:n=()=>{}}={}){let r=y(`dialog`),i=t,a=document.createElement(`div`);a.classList.add(r.b()),a.style.zIndex=String(he);let o=document.createElement(`div`);if(o.classList.add(r.be(`overlay`)),a.appendChild(o),e){let t=document.createElement(`div`);t.classList.add(r.be(`content`)),t.appendChild(e),o.appendChild(t),t.addEventListener(`click`,e=>{e.stopPropagation()})}let s=getComputedStyle(i).overflow;i.style.overflow=`hidden`,i.appendChild(a);let c=()=>{n(),a.remove(),i.style.overflow=s};return a.addEventListener(`click`,c),he+=1,{dialog:a,close:c}}function ge(e,t){let n=y(`input`);t.type||(t.type=`text`),t.value||(t.value=``);let r=document.createElement(`div`);if(r.classList.add(n.be(`item`)),e){let t=document.createElement(`span`);t.classList.add(n.be(`label`)),t.textContent=e,r.appendChild(t)}let i=document.createElement(`div`);i.classList.add(n.be(`input`));let a=document.createElement(`input`);for(let e in t)a.setAttribute(e,t[e]);(t.max||t.min)&&a.addEventListener(`blur`,()=>{t.max&&t.max<=Number(a.value)&&(a.value=String(t.max)),t.min&&t.min>=Number(a.value)&&(a.value=String(t.min))}),i.appendChild(a),r.appendChild(i),a.addEventListener(`focus`,()=>{i.classList.add(`focus`)}),a.addEventListener(`blur`,()=>{i.classList.remove(`focus`)});let o=e=>{let t;i.classList.contains(`error`)?t=i.querySelector(`.${n.be(`error-tip`)}`):(t=document.createElement(`span`),t.classList.add(n.be(`error-tip`)),i.appendChild(t)),t.textContent=e,i.classList.add(`error`);let r=()=>{i.classList.remove(`error`),t.remove()};return{removeError:r}};return{item:r,input:a,errorTip:o}}function _e(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function D(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){_e(a,r,i,o,s,`next`,e)}function s(e){_e(a,r,i,o,s,`throw`,e)}o(void 0)})}}function ve(){return ye.apply(this,arguments)}function ye(){return ye=D(function*(e={}){let t=y(`creator`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`input`));let{item:i,input:a,errorTip:o}=ge(e.rowText||`Row`,{type:`number`,value:String(e.row||``),max:99}),{item:s,input:c,errorTip:l}=ge(e.colText||`Column`,{type:`number`,value:String(e.col||``),max:99});r.appendChild(i),r.appendChild(s),n.appendChild(r);let u=document.createElement(`div`);u.classList.add(t.be(`control`));let d=pe({type:`confirm`,content:e.confirmText||`Confirm`}),f=pe({type:`default`,content:e.cancelText||`Cancel`});u.appendChild(d),u.appendChild(f),n.appendChild(u);let p=(t=Number(a.value),n=Number(c.value))=>{if(Number.isNaN(t)||t<=0){o(e.notPositiveNumberError||`Please enter a positive integer`);return}if(Number.isNaN(n)||n<=0){l(e.notPositiveNumberError||`Please enter a positive integer`);return}return{row:t,col:n}},m=e=>{e.key===`Escape`&&(close(),document.removeEventListener(`keydown`,m))};return new Promise((e,t)=>{let{close:r}=E({child:n,beforeClose:t});a.focus();for(let t of[a,c])t.addEventListener(`keydown`,t=>{if(t.key===`Enter`){let t=p();t&&(e(t),r())}});d.addEventListener(`click`,D(function*(){let t=p();t&&(e(t),r())})),document.addEventListener(`keydown`,m),f.addEventListener(`click`,r)})}),ye.apply(this,arguments)}function be(e={}){let t=y(`select-box`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`block`));for(let n=0;n<(e.row||8);n++)for(let i=0;i<(e.col||8);i++){let e=document.createElement(`div`);e.classList.add(t.be(`item`)),e.dataset.row=String(n+1),e.dataset.col=String(i+1),r.appendChild(e)}let i=()=>{let{row:e,col:t}=n.dataset;for(let e of Array.from(r.querySelectorAll(`.active`)))e.classList.remove(`active`);if(!e||!t)return;let i=Array.from(r.children);for(let n=0;n<i.length;n++){let{row:r,col:a}=i[n].dataset;if(r>e&&a>t)return;r<=e&&a<=t?i[n].classList.add(`active`):i[n].classList.remove(`active`)}};if(r.addEventListener(`mousemove`,e=>{if(!e.target)return;let{row:t,col:r}=e.target.dataset;!t||!r||(n.dataset.row=t,n.dataset.col=r,i())}),r.addEventListener(`mouseleave`,()=>{n.removeAttribute(`data-row`),n.removeAttribute(`data-col`),i()}),r.addEventListener(`click`,()=>{let{row:t,col:r}=n.dataset;!t||!r||e.onSelect&&e.onSelect(Number(t),Number(r))}),n.appendChild(r),e.customBtn){let r=e.texts||{},i=document.createElement(`div`);i.classList.add(t.be(`custom`)),i.textContent=r.customBtnText||`Custom`,i.addEventListener(`click`,D(function*(){let t=yield ve(r);t&&e.onSelect&&e.onSelect(t.row,t.col)})),n.appendChild(i)}return n}function xe(e){"@babel/helpers - typeof";return xe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xe(e)}function Se(e,t){if(xe(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(xe(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ce(e){var t=Se(e,`string`);return xe(t)==`symbol`?t:t+``}function O(e,t,n){return(t=Ce(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function we(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?we(Object(n),!0).forEach(function(t){O(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):we(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Te=Math.min,Ee=Math.max,De=Math.round,Oe=Math.floor,A=e=>({x:e,y:e}),ke={left:`right`,right:`left`,bottom:`top`,top:`bottom`},Ae={start:`end`,end:`start`};function je(e,t,n){return Ee(e,Te(t,n))}function Me(e,t){return typeof e==`function`?e(t):e}function j(e){return e.split(`-`)[0]}function Ne(e){return e.split(`-`)[1]}function Pe(e){return e===`x`?`y`:`x`}function Fe(e){return e===`y`?`height`:`width`}function M(e){return[`top`,`bottom`].includes(j(e))?`y`:`x`}function Ie(e){return Pe(M(e))}function Le(e,t,n){n===void 0&&(n=!1);let r=Ne(e),i=Ie(e),a=Fe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=He(o)),[o,He(o)]}function Re(e){let t=He(e);return[ze(e),t,ze(t)]}function ze(e){return e.replace(/start|end/g,e=>Ae[e])}function Be(e,t,n){let r=[`left`,`right`],i=[`right`,`left`],a=[`top`,`bottom`],o=[`bottom`,`top`];switch(e){case`top`:case`bottom`:return n?t?i:r:t?r:i;case`left`:case`right`:return t?a:o;default:return[]}}function Ve(e,t,n,r){let i=Ne(e),a=Be(j(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ze)))),a}function He(e){return e.replace(/left|right|bottom|top/g,e=>ke[e])}function Ue(e){return k({top:0,right:0,bottom:0,left:0},e)}function We(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ue(e)}function Ge(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 Ke(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function N(e,t){if(e==null)return{};var n,r,i=Ke(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}let qe=[`crossAxis`,`alignment`,`allowedPlacements`,`autoAlignment`],Je=[`mainAxis`,`crossAxis`,`fallbackPlacements`,`fallbackStrategy`,`fallbackAxisSideDirection`,`flipAlignment`],Ye=[`strategy`],Xe=[`mainAxis`,`crossAxis`,`limiter`],Ze=[`apply`];function Qe(e,t,n){let{reference:r,floating:i}=e,a=M(t),o=Ie(t),s=Fe(o),c=j(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Ne(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}let $e=function(){var e=D(function*(e,t,n){let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=yield o.isRTL==null?void 0:o.isRTL(t),l=yield o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Qe(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=yield h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:o,elements:{reference:e,floating:t}});u=g==null?u:g,d=_==null?d:_,p=k(k({},p),{},{[a]:k(k({},p[a]),v)}),y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?yield o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=Qe(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}});return function(t,n,r){return e.apply(this,arguments)}}();function et(e,t){return tt.apply(this,arguments)}function tt(){return tt=D(function*(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=Me(t,e),m=We(p),h=d===`floating`?`reference`:`floating`,g=s[f?h:d],_=Ge(yield a.getClippingRect({element:(n=yield a.isElement==null?void 0:a.isElement(g))==null||n?g:g.contextElement||(yield a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=yield a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating),b=(yield a.isElement==null?void 0:a.isElement(y))&&(yield a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},x=Ge(a.convertOffsetParentRelativeRectToViewportRelativeRect?yield a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:c}):v);return{top:(_.top-x.top+m.top)/b.y,bottom:(x.bottom-_.bottom+m.bottom)/b.y,left:(_.left-x.left+m.left)/b.x,right:(x.right-_.right+m.right)/b.x}}),tt.apply(this,arguments)}let nt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,fn(t){return D(function*(){var n,r;let{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:c,elements:l}=t,u=Me(e,t),{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m=`bestFit`,fallbackAxisSideDirection:h=`none`,flipAlignment:g=!0}=u,_=N(u,Je);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let v=j(i),y=M(s),b=j(s)===s,x=yield c.isRTL==null?void 0:c.isRTL(l.floating),S=p||(b||!g?[He(s)]:Re(s)),C=h!==`none`;!p&&C&&S.push(...Ve(s,g,h,x));let ee=[s,...S],te=yield et(t,_),w=[],T=((r=a.flip)==null?void 0:r.overflows)||[];if(d&&w.push(te[v]),f){let e=Le(i,o,x);w.push(te[e[0]],te[e[1]])}if(T=[...T,{placement:i,overflows:w}],!w.every(e=>e<=0)){var ne,re;let e=(((ne=a.flip)==null?void 0:ne.index)||0)+1,t=ee[e];if(t){let n=f===`alignment`?y!==M(t):!1;if(!n||T.every(e=>e.overflows[0]>0&&M(e.placement)===y))return{data:{index:e,overflows:T},reset:{placement:t}}}let n=(re=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])==null?void 0:re.placement;if(!n)switch(m){case`bestFit`:{var ie;let e=(ie=T.filter(e=>{if(C){let t=M(e.placement);return t===y||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])==null?void 0:ie[0];e&&(n=e);break}case`initialPlacement`:n=s;break}if(i!==n)return{reset:{placement:n}}}return{}})()}}};function rt(e,t){return it.apply(this,arguments)}function it(){return it=D(function*(e,t){let{placement:n,platform:r,elements:i}=e,a=yield r.isRTL==null?void 0:r.isRTL(i.floating),o=j(n),s=Ne(n),c=M(n)===`y`,l=[`left`,`top`].includes(o)?-1:1,u=a&&c?-1:1,d=Me(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}),it.apply(this,arguments)}let at=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,fn(t){return D(function*(){var n,r;let{x:i,y:a,placement:o,middlewareData:s}=t,c=yield rt(t,e);return o===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:k(k({},c),{},{placement:o})}})()}}},ot=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,fn(t){return D(function*(){let{x:n,y:r,placement:i}=t,a=Me(e,t),{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}}}=a,l=N(a,Xe),u={x:n,y:r},d=yield et(t,l),f=M(j(i)),p=Pe(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=je(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=je(n,h,r)}let g=c.fn(k(k({},t),{},{[p]:m,[f]:h}));return k(k({},g),{},{data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}})})()}}},st=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:c=!0,crossAxis:l=!0}=Me(e,t),u={x:n,y:r},d=M(i),f=Pe(d),p=u[f],m=u[d],h=Me(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:k({mainAxis:0,crossAxis:0},h);if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){var _,v;let e=f===`y`?`width`:`height`,t=[`top`,`left`].includes(j(i)),n=a.reference[d]-a.floating[e]+(t&&((_=o.offset)==null?void 0:_[d])||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:((v=o.offset)==null?void 0:v[d])||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}};function ct(){return typeof window<`u`}function lt(e){return ut(e)?(e.nodeName||``).toLowerCase():`#document`}function P(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function F(e){var t;return(t=(ut(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ut(e){return ct()?e instanceof Node||e instanceof P(e).Node:!1}function I(e){return ct()?e instanceof Element||e instanceof P(e).Element:!1}function L(e){return ct()?e instanceof HTMLElement||e instanceof P(e).HTMLElement:!1}function dt(e){return!ct()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof P(e).ShadowRoot}function ft(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=R(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&![`inline`,`contents`].includes(i)}function pt(e){return[`table`,`td`,`th`].includes(lt(e))}function mt(e){return[`:popover-open`,`:modal`].some(t=>{try{return e.matches(t)}catch(e){return!1}})}function ht(e){let t=_t(),n=I(e)?R(e):e;return[`transform`,`translate`,`scale`,`rotate`,`perspective`].some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`].some(e=>(n.willChange||``).includes(e))||[`paint`,`layout`,`strict`,`content`].some(e=>(n.contain||``).includes(e))}function gt(e){let t=z(e);for(;L(t)&&!vt(t);){if(ht(t))return t;if(mt(t))return null;t=z(t)}return null}function _t(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}function vt(e){return[`html`,`body`,`#document`].includes(lt(e))}function R(e){return P(e).getComputedStyle(e)}function yt(e){return I(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function z(e){if(lt(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||dt(e)&&e.host||F(e);return dt(t)?t.host:t}function bt(e){let t=z(e);return vt(t)?e.ownerDocument?e.ownerDocument.body:e.body:L(t)&&ft(t)?t:bt(t)}function xt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=bt(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=P(i);if(a){let e=St(o);return t.concat(o,o.visualViewport||[],ft(i)?i:[],e&&n?xt(e):[])}return t.concat(i,xt(i,[],n))}function St(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ct(e){let t=R(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=L(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=De(n)!==a||De(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function wt(e){return I(e)?e:e.contextElement}function Tt(e){let t=wt(e);if(!L(t))return A(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ct(t),o=(a?De(n.width):n.width)/r,s=(a?De(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}let Et=A(0);function Dt(e){let t=P(e);return!_t()||!t.visualViewport?Et:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ot(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==P(e)?!1:t}function kt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=wt(e),o=A(1);t&&(r?I(r)&&(o=Tt(r)):o=Tt(e));let s=Ot(a,n,r)?Dt(a):A(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=P(a),t=r&&I(r)?P(r):r,n=e,i=St(n);for(;i&&r&&t!==n;){let e=Tt(i),t=i.getBoundingClientRect(),r=R(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=P(i),i=St(n)}}return Ge({width:u,height:d,x:c,y:l})}function At(e,t){let n=yt(e).scrollLeft;return t?t.left+n:kt(F(e)).left+n}function jt(e,t,n){n===void 0&&(n=!1);let r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:At(e,r)),a=r.top+t.scrollTop;return{x:i,y:a}}function Mt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=F(r),s=t?mt(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=A(1),u=A(0),d=L(r);if((d||!d&&!a)&&((lt(r)!==`body`||ft(o))&&(c=yt(r)),L(r))){let e=kt(r);l=Tt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?jt(o,c,!0):A(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Nt(e){return Array.from(e.getClientRects())}function Pt(e){let t=F(e),n=yt(e),r=e.ownerDocument.body,i=Ee(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ee(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+At(e),s=-n.scrollTop;return R(r).direction===`rtl`&&(o+=Ee(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}function Ft(e,t){let n=P(e),r=F(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=_t();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s,y:c}}function It(e,t){let n=kt(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=L(e)?Tt(e):A(1),o=e.clientWidth*a.x,s=e.clientHeight*a.y,c=i*a.x,l=r*a.y;return{width:o,height:s,x:c,y:l}}function Lt(e,t,n){let r;if(t===`viewport`)r=Ft(e,n);else if(t===`document`)r=Pt(F(e));else if(I(t))r=It(t,n);else{let n=Dt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ge(r)}function Rt(e,t){let n=z(e);return n===t||!I(n)||vt(n)?!1:R(n).position===`fixed`||Rt(n,t)}function zt(e,t){let n=t.get(e);if(n)return n;let r=xt(e,[],!1).filter(e=>I(e)&&lt(e)!==`body`),i=null,a=R(e).position===`fixed`,o=a?z(e):e;for(;I(o)&&!vt(o);){let t=R(o),n=ht(o);!n&&t.position===`fixed`&&(i=null);let s=a?!n&&!i:!n&&t.position===`static`&&!!i&&[`absolute`,`fixed`].includes(i.position)||ft(o)&&!n&&Rt(e,o);s?r=r.filter(e=>e!==o):i=t,o=z(o)}return t.set(e,r),r}function Bt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=n===`clippingAncestors`?mt(t)?[]:zt(t,this._c):[].concat(n),o=[...a,r],s=o[0],c=o.reduce((e,n)=>{let r=Lt(t,n,i);return e.top=Ee(r.top,e.top),e.right=Te(r.right,e.right),e.bottom=Te(r.bottom,e.bottom),e.left=Ee(r.left,e.left),e},Lt(t,s,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Vt(e){let{width:t,height:n}=Ct(e);return{width:t,height:n}}function Ht(e,t,n){let r=L(t),i=F(t),a=n===`fixed`,o=kt(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=A(0);function l(){c.x=At(i)}if(r||!r&&!a)if((lt(t)!==`body`||ft(i))&&(s=yt(t)),r){let e=kt(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?jt(i,s):A(0),d=o.left+s.scrollLeft-c.x-u.x,f=o.top+s.scrollTop-c.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function Ut(e){return R(e).position===`static`}function Wt(e,t){if(!L(e)||R(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return F(e)===n&&(n=n.ownerDocument.body),n}function Gt(e,t){let n=P(e);if(mt(e))return n;if(!L(e)){let t=z(e);for(;t&&!vt(t);){if(I(t)&&!Ut(t))return t;t=z(t)}return n}let r=Wt(e,t);for(;r&&pt(r)&&Ut(r);)r=Wt(r,t);return r&&vt(r)&&Ut(r)&&!ht(r)?n:r||gt(e)||n}let Kt=function(){var e=D(function*(e){let t=this.getOffsetParent||Gt,n=this.getDimensions,r=yield n(e.floating);return{reference:Ht(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}});return function(t){return e.apply(this,arguments)}}();function qt(e){return R(e).direction===`rtl`}let Jt={convertOffsetParentRelativeRectToViewportRelativeRect:Mt,getDocumentElement:F,getClippingRect:Bt,getOffsetParent:Gt,getElementRects:Kt,getClientRects:Nt,getDimensions:Vt,getScale:Tt,isElement:I,isRTL:qt};function Yt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xt(e,t){let n=null,r,i=F(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Oe(d),h=Oe(i.clientWidth-(u+f)),g=Oe(i.clientHeight-(d+p)),_=Oe(u),v=-m+`px `+-h+`px `+-g+`px `+-_+`px`,y={rootMargin:v,threshold:Ee(0,Te(1,c))||1},b=!0;function x(t){let n=t[0].intersectionRatio;if(n!==c){if(!b)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Yt(l,e.getBoundingClientRect())&&o(),b=!1}try{n=new IntersectionObserver(x,k(k({},y),{},{root:i.ownerDocument}))}catch(e){n=new IntersectionObserver(x,y)}n.observe(e)}return o(!0),a}function Zt(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=wt(e),u=i||a?[...l?xt(l):[],...xt(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Xt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?kt(e):null;c&&g();function g(){let t=kt(e);h&&!Yt(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)}}let Qt=at,$t=ot,en=nt,tn=st,nn=(e,t,n)=>{let r=new Map,i=k({platform:Jt},n),a=k(k({},i.platform),{},{_c:r});return $e(e,t,k(k({},i),{},{platform:a}))};function rn(e,t,n,r,i){return i&&clearTimeout(i),e.addEventListener(`transitionend`,n,r),setTimeout(()=>{n()},t)}let an=4,on;function sn(e,t={}){let{msg:n=``,delay:r=150,content:i,direction:a=`bottom`,type:o=`hover`,container:s,onOpen:c,onClose:l,closed:u,onDestroy:d}=t,f=y(`tooltip`);if(n||i){on||(on=document.createElement(`div`),document.body.appendChild(on));let t=s||on,p=document.createElement(`div`);p.classList.add(f.b(),`hidden`,`transparent`),i?p.appendChild(i):n&&(p.textContent=n);let m,h,g,_=()=>{g&&g(),nn(e,p,{placement:a,middleware:[en(),$t({limiter:tn()}),Qt(an)]}).then(({x:e,y:t})=>{Object.assign(p.style,{left:`${e}px`,top:`${t}px`})})},v=()=>{p.classList.add(`hidden`),t.contains(p)&&t.removeChild(p),g&&g(),u&&u()},y=(n=!1)=>{h&&clearTimeout(h),m=setTimeout(()=>{if(c){let e=c(n);if(!n&&e)return}t.appendChild(p),p.removeEventListener(`transitionend`,v),p.classList.remove(`hidden`),g=Zt(e,p,_),p.classList.remove(`transparent`)},r)},b=(e=!1)=>{m&&clearTimeout(m),h=setTimeout(()=>{if(l){let t=l(e);if(!e&&t)return}rn(p,150,v,{once:!0}),p.classList.add(`transparent`)},r)},x=()=>{let t=[e,p],n=b.bind(void 0,!1),r=y.bind(void 0,!1),i=()=>{for(let e of t)e.addEventListener(`mouseenter`,r),e.addEventListener(`mouseleave`,n)};return{prepare:i,show:y,hide:b,destroy:()=>{for(let e of t)e.removeEventListener(`mouseenter`,r),e.removeEventListener(`mouseleave`,n)}}},S=()=>{let t=e=>{e.stopPropagation(),b(!1)},n=e=>{e.stopPropagation(),y(),document.removeEventListener(`click`,t),document.addEventListener(`click`,t,{once:!0})};return{prepare:()=>{p.addEventListener(`click`,e=>e.stopPropagation()),e.addEventListener(`click`,n)},show:y,hide:(e=!1)=>{b(e),document.removeEventListener(`click`,t)},destroy:()=>{e.removeEventListener(`click`,n),document.removeEventListener(`click`,t)}}},C={hover:x,click:S},{prepare:ee,show:te,hide:w,destroy:T}=C[o]();ee();let ne=()=>{w(!0),d&&d(),T(),g&&g(),p.remove()};return{show:te,hide:w,destroy:ne}}return null}function cn(e,t,n=0,r=!0){let{x:i,y:a,x1:o,y1:s}=e,{x:c,y:l,x1:u,y1:d}=t,f,p;return r?(f=o<c+n||i-n>u,p=s<l+n||a-n>d):(f=o<=c+n||i-n>=u,p=s<=l+n||a-n>=d),!(f||p)}function ln(e,t){let n=t.getBoundingClientRect();return{x:e.x-n.x-t.scrollLeft,y:e.y-n.y-t.scrollTop,x1:e.x-n.x-t.scrollLeft+e.width,y1:e.y-n.y-t.scrollTop+e.height,width:e.width,height:e.height}}let un=8;function dn(e){let{left:t,top:n,width:r,height:i}=e,{clientWidth:a,clientHeight:o}=document.documentElement,s=!1,c=!1;return t+r>a?(t=a-r-un,s=!0):t<0&&(t=un,s=!0),n+i>o?(n=o-i-un,c=!0):n<0&&(n=un,c=!0),{left:t,top:n,leftLimited:s,topLimited:c}}function fn(e,t={}){let n=Symbol(`ignoreFirstBind`),r=new Set,i=new ResizeObserver(r=>{t.ignoreFirstBind&&r.some(e=>{let t=e.target,r=t[n];return t[n]=!0,!r})||e(r)}),a=i.observe;i.observe=(e,t)=>{r.add(e),a.call(i,e,t)};let o=i.unobserve;i.unobserve=e=>{r.has(e)&&(r.delete(e),e[n]=void 0),o.call(i,e)};let s=i.disconnect;return i.disconnect=()=>{for(let e of r.values())e[n]=void 0;s.call(i)},i}function B(e,t){e.addEventListener(`scroll`,t),this.scrollHandler.push([e,t])}function pn(){for(let e=0;e<this.scrollHandler.length;e++){let[t,n]=this.scrollHandler[e];t.removeEventListener(`scroll`,n)}this.scrollHandler=[]}function mn(e){let t={},n=e.trim().split(`;`);for(let e=0;e<n.length;e++){let r=n[e].trim();if(!r)continue;let i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,Math.max(0,i)).trim(),o=r.slice(Math.max(0,i+1)).trim();t[_n(a)]=o}return t}function hn(e){return Object.entries(e).map(([e,t])=>`${gn(e)}: ${t};`).join(` `)}function gn(e){let t=e.replaceAll(RegExp(`([A-Z])`,`g`),` $1`).trim();return t.split(` `).join(`-`).toLowerCase()}function _n(e){return e.replaceAll(RegExp(`-(\\w)`,`g`),(e,t)=>t.toUpperCase())}let V=()=>Math.random().toString(36).slice(2);function vn(e,t){let n;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r)},t)}}let yn=t.default.import(`parchment`),bn=t.default.import(`blots/container`),xn=t.default.import(`blots/block`),Sn=t.default.import(`blots/block/embed`);var H=class e extends bn{static create(e){let t=document.createElement(this.tagName);return this.className&&t.classList.add(this.className),t}optimize(e){if(this.children.length===0)if(this.statics.defaultChild!=null){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}enforceAllowedChildren(){this.children.forEach(t=>{let n=this.statics.allowedChildren.some(e=>t instanceof e);n||(t.statics.scope===yn.Scope.BLOCK_BLOT?(t.parent instanceof e?(t.next!=null&&t.parent.splitAfter(t),t.prev!=null&&t.parent.splitAfter(t.prev)):(t.next!=null&&this.splitAfter(t),t.prev!=null&&this.splitAfter(t.prev)),t.parent.unwrap()):t instanceof yn.ParentBlot?t.unwrap():t.remove())})}};O(H,`tagName`,void 0),O(H,`blotName`,u.container),O(H,`scope`,yn.Scope.BLOCK_BLOT),O(H,`allowedChildren`,[xn,Sn,bn]),O(H,`requiredContainer`,void 0),O(H,`defaultChild`,void 0);let Cn=e=>fe(e)?e:1,wn=t.default.import(`blots/block`),Tn=t.default.import(`blots/block/embed`);var U=class extends H{static isAllowStyle(e){for(let t of this.allowStyle)if(e.startsWith(t))return!0;return!1}static create(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o}=e,s=super.create();return s.dataset.tableId=t,s.dataset.rowId=n,s.dataset.colId=r,s.dataset.rowspan=String(Cn(i)),s.dataset.colspan=String(Cn(a)),o&&(s.dataset.style=o),s}static formats(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o}=e.dataset,s={tableId:String(t),rowId:String(n),colId:String(r),rowspan:Number(Cn(i)),colspan:Number(Cn(a))};return o&&(s.style=o),s}constructor(e,t,n){super(e,t),t.setAttribute(`contenteditable`,String(e.isEnabled()))}setFormatValue(e,t,n=!1){if(n){if(!this.statics.isAllowStyle(e))return;this.parent&&this.parent.statics.blotName===u.tableCell&&this.parent.setFormatValue(e,t)}else{if(!this.statics.allowDataAttrs.has(e))return;let n=`data-${e}`;t?this.domNode.setAttribute(n,t):this.domNode.removeAttribute(n),this.parent&&this.parent.statics.blotName===u.tableCell&&this.parent.setFormatValue(e,t)}let r=this.descendants(wn,0);for(let e of r)e.cache={}}get tableId(){return this.domNode.dataset.tableId}get rowId(){return this.domNode.dataset.rowId}set rowId(e){this.setFormatValue(`row-id`,e)}get colId(){return this.domNode.dataset.colId}set colId(e){this.setFormatValue(`col-id`,e)}get rowspan(){return Number(this.domNode.dataset.rowspan)}set rowspan(e){this.setFormatValue(`rowspan`,e)}get colspan(){return Number(this.domNode.dataset.colspan)}set colspan(e){this.setFormatValue(`colspan`,e)}getColumnIndex(){let e=b(this,u.tableMain);return e.getColIds().indexOf(this.colId)}formatAt(e,t,n,r){if(this.children.length===0&&(this.appendChild(this.scroll.create(this.statics.defaultChild.blotName)),t+=1),super.formatAt(e,t,n,r),r&&r.style){let e=mn(r.style);for(let[t,n]of Object.entries(e))this.setFormatValue(t,n,!0)}}insertAt(e,t,n){let[r]=this.children.find(e);if(!r&&this.statics.defaultChild){let e=this.scroll.create(this.statics.defaultChild.blotName||`block`);this.appendChild(e)}super.insertAt(e,t,n)}formats(){let e=this.statics.formats(this.domNode);return{[this.statics.blotName]:e}}checkMerge(){let{colId:e,rowId:t,colspan:n,rowspan:r}=this,i=this.next;return i!==null&&i.statics.blotName===this.statics.blotName&&i.rowId===t&&i.colId===e&&i.colspan===n&&i.rowspan===r}optimize(){let e=this.parent,t=this.statics.formats(this.domNode);if(this.prev&&this.prev instanceof Tn){let e=this.scroll.create(`block`);this.appendChild(this.prev),this.appendChild(e)}if(e!==null&&e.statics.blotName!==u.tableCell&&(this.wrap(u.tableCell,t),this.children.length===0)){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0&&this.remove()}insertBefore(e,t){if(e.statics.blotName===this.statics.blotName){let n=e,r=this.statics.formats(n.domNode),i=this.statics.formats(this.domNode),a=Object.entries(i).every(([e,t])=>t===r[e]);if(a)return this.parent.insertBefore(n,this.next);{let[e,a]=x(this,[u.tableRow,u.tableCell]);if(t){let n=t.offset(),r=this.length();if(n+1<r){let t=this.scroll.create(u.tableCellInner,i);this.children.forEachAt(n+1,this.length(),e=>{t.appendChild(e)}),e.insertBefore(t.wrap(u.tableCell,i),a.next),this.children.length===0&&(this.remove(),this.parent.children.length===0&&this.parent.remove())}}if(this.rowId!==n.rowId){if(t){let n=t.offset(e);e.split(n)}else if(a.next){let t=a.next.offset(e);e.split(t)}let i=this.scroll.create(u.tableRow,r),o=this.scroll.create(u.tableCell,r);return o.appendChild(n),i.appendChild(o),e.parent.insertBefore(i,e.next)}return e.insertBefore(n.wrap(u.tableCell,r),t?a:a.next)}}else if(e.statics.blotName===u.tableCol){try{let t=b(this,u.tableBody),n=this.offset(t),r=t.split(n);t.parent.insertBefore(e,r),e.optimize({})}catch(e){console.warn(`TableCellInner not in TableBody`)}return}super.insertBefore(e,t)}};O(U,`blotName`,u.tableCellInner),O(U,`tagName`,`div`),O(U,`className`,`ql-table-cell-inner`),O(U,`allowDataAttrs`,new Set([`table-id`,`row-id`,`col-id`,`rowspan`,`colspan`])),O(U,`defaultChild`,wn),O(U,`allowStyle`,new Set([`background-color`,`border`,`height`]));var W=class extends H{static create(e){let t=super.create();return t.dataset.tableId=e.tableId,t.dataset.rowId=e.rowId,t}get rowId(){return this.domNode.dataset.rowId}get tableId(){return this.domNode.dataset.tableId}setHeight(e){this.foreachCellInner(t=>{t.setFormatValue(`height`,e,!0)})}getCellByColId(e,t){let n=b(this,u.tableMain),r=n.getColIds(),i=r.indexOf(e),a=this.children.iterator(),o=null;for(;o=a();){if(o.colId===e)return o;let t=r.indexOf(o.colId);if(t<i&&t+o.colspan>i)return o}return this[t]&&this[t].statics.blotName===u.tableRow?this[t].getCellByColId(e,t):null}insertCell(e,t){let n=[],r=this.children.iterator(),i=0,a;for(;(a=r())&&(i+=a.colspan,!(i>e));)if(a.rowspan!==1)for(let e=0;e<a.rowspan-1;e++)n[e]=(n[e]||0)+a.colspan;if(a&&i-a.colspan<e){let e=a.getCellInner();e.colspan+=1,a.rowspan!==1&&(n.skipRowNum=a.rowspan-1)}else{let e=this.scroll.create(u.tableCell,t),n=this.scroll.create(u.tableCellInner,t),r=this.scroll.create(`block`);r.appendChild(this.scroll.create(`break`)),n.appendChild(r),e.appendChild(n),this.insertBefore(e,a)}return n}getCellByColumIndex(e){let t=[],n=null,r=0;if(e<0)return[n,r,t];let i=this.children.iterator();for(;n=i();){if(r+=n.colspan,n.rowspan!==1)for(let e=0;e<n.rowspan-1;e++)t[e]=(t[e]||0)+n.colspan;if(r>e)break}return[n,r,t]}removeCell(e){if(e<0)return[];let t=this.getCellByColumIndex(e),[n,r]=t,i=t[2];if(!n)return i;if(r-n.colspan<e||n.colspan>1){let[t]=n.descendants(U);if(n.colspan!==1&&e===r-n.colspan){let e=b(this,u.tableMain),n=e.getColIds();t.colId=n[n.indexOf(t.colId)+1]}n.rowspan!==1&&(i.skipRowNum=n.rowspan-1),--t.colspan}else n.remove();return i}foreachCellInner(e){let t=this.children.iterator(),n=0,r;for(;r=t();){let[t]=r.descendants(U);if(e(t,n++))break}}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.rowId===this.rowId}optimize(e){let t=this.parent,{tableId:n}=this;t!==null&&t.statics.blotName!==u.tableBody&&this.wrap(u.tableBody,n),super.optimize(e)}};O(W,`blotName`,u.tableRow),O(W,`tagName`,`tr`),O(W,`className`,`ql-table-row`);var G=class extends H{static create(e){let t=super.create();return t.dataset.tableId=e,t}get tableId(){return this.domNode.dataset.tableId}insertRow(e){let t=b(this,u.tableMain);if(!t)return;let n=t.getColIds(),r=this.descendants(W),i=new Set(n),a=0;for(let t of r){if(a===e)break;t.foreachCellInner(t=>{if(a+t.rowspan>e&&(t.rowspan+=1,i.delete(t.colId),t.colspan!==1)){let e=n.indexOf(t.colId);for(let r=0;r<t.colspan-1;r++)i.delete(n[e+r+1])}}),a+=1}let o=t.tableId,s=V(),c=this.scroll.create(u.tableRow,{tableId:o,rowId:s});for(let e of i){let t=this.scroll.create(`break`),n=t.wrap(`block`),r=n.wrap(u.tableCellInner,{tableId:o,rowId:s,colId:e,rowspan:1,colspan:1}),i=r.wrap(u.tableCell,{tableId:o,rowId:s,colId:e,rowspan:1,colspan:1});c.appendChild(i)}this.insertBefore(c,r[e]||null)}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}optimize(e){let t=this.parent;if(t!==null&&t.statics.blotName!==u.tableMain){let{tableId:e}=this;this.wrap(u.tableMain,{tableId:e})}super.optimize(e)}};O(G,`blotName`,u.tableBody),O(G,`tagName`,`tbody`);let En=t.default.import(`parchment`),Dn=t.default.import(`blots/block`);var On=class extends Dn{replaceWith(e,t){let n=typeof e==`string`?this.scroll.create(e,t):e;if(n instanceof En.ParentBlot)if(n.statics.blotName===u.tableCellInner){let e=this.parent;if(e.statics.blotName===u.tableCellInner){if(e!=null&&e.insertBefore(n,this.prev?null:this.next),e.statics.blotName===u.tableCellInner){let e=this;for(;e;){let t=e.next;n.appendChild(e),e=t}}else n.appendChild(this);if(e&&e.length()===0){e.remove(),e.parent.statics.blotName===u.tableCell&&e.parent.length()===0&&e.parent.remove();let t=e.parent.parent;t.statics.blotName===u.tableRow&&t.children.length===0&&t.remove()}}else e!=null&&e.insertBefore(n,this.next),n.appendChild(this);return n}else this.moveChildren(n);return this.parent!=null&&(this.parent.insertBefore(n,this.next||void 0),this.remove()),this.attributes.copy(n),n}format(e,t){if(e===u.tableCellInner&&this.parent.statics.blotName===e&&!t)try{let e=b(this,u.tableCellInner);e.unwrap()}catch(e){console.error(`unwrap TableCellInner error`)}else super.format(e,t)}};let kn=t.default.import(`parchment`),An=t.default.import(`blots/scroll`);var jn=class extends An{enable(e=!0){let n=t.default.import(`formats/${u.tableCellInner}`),r=this.domNode.querySelectorAll(`.${n.className}`);for(let t of Array.from(r))t.setAttribute(`contenteditable`,String(!!e));let i=t.default.import(`formats/${u.tableCaption}`),a=this.domNode.querySelectorAll(`.${i.className}`);for(let t of Array.from(a))t.setAttribute(`contenteditable`,String(!!e));super.enable(e)}createBlock(e,t){let n,r={};if(e[u.tableCellInner])n=u.tableCellInner;else for(let[t,i]of Object.entries(e)){let e=this.query(t,kn.Scope.BLOCK&kn.Scope.BLOT)!=null;e?n=t:r[t]=i}n===u.tableCellInner&&(r=k({},e),delete r[n]);let i=this.create(n||this.statics.defaultChild.blotName,n?e[n]:void 0);this.insertBefore(i,t||void 0);let a=i.length();i instanceof U&&a===0&&(a+=1);for(let[e,t]of Object.entries(r))i.formatAt(0,a,e,t);return i}},Mn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\r
2
+ <!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE -->\r
3
+ <path\r
4
+ fill="none"\r
5
+ stroke="currentColor"\r
6
+ stroke-linecap="round"\r
7
+ stroke-linejoin="round"\r
8
+ stroke-width="2"\r
9
+ d="M7 3v18m3-15L7 3L4 6m16 12l-3 3l-3-3m3 3V3"\r
10
+ />\r
11
+ </svg>\r
12
+ `;let Nn=t.default.import(`parchment`),Pn=t.default.import(`blots/inline`),Fn=t.default.import(`blots/text`);var K=class extends On{static create(e){let{tableId:t}=e,n=super.create();return n.dataset.tableId=t,e.side===`bottom`&&(n.style.captionSide=`bottom`),n}static formats(e){let{tableId:t}=e.dataset,n={tableId:String(t),side:e.style.captionSide===`bottom`?`bottom`:`top`};return n}constructor(e,t,n){super(e,t),t.setAttribute(`contenteditable`,String(e.isEnabled())),this.attachUI(this.createUI()),this.domNode.addEventListener(`mouseenter`,()=>{this.scroll.isEnabled()&&(this.uiNode.style.display=`flex`)}),this.domNode.addEventListener(`mouseleave`,()=>{this.scroll.isEnabled()&&(this.uiNode.style.display=`none`)}),this.uiNode.style.display=`none`}createUI(){let e=document.createElement(`i`);return e.classList.add(`ql-table-caption--switch`),e.innerHTML=Mn,e.addEventListener(`click`,()=>{this.scroll.isEnabled()&&(this.side=this.side===`top`?`bottom`:`top`)}),e}get tableId(){return this.domNode.dataset.tableId}set side(e){this.domNode.style.captionSide=e===`bottom`?`bottom`:`top`}get side(){return this.domNode.style.captionSide===`bottom`?`bottom`:`top`}format(e,t){let n=this.scroll.query(e,Nn.Scope.BLOCK_BLOT);(!n||e===this.statics.blotName)&&super.format(e,t)}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}optimize(e){let t=this.parent;if(t!==null&&t.statics.blotName!==u.tableMain){let{tableId:e}=this;this.wrap(u.tableMain,{tableId:e})}this.children.length===0?this.remove():(super.optimize(e),this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()))}};O(K,`blotName`,u.tableCaption),O(K,`tagName`,`caption`),O(K,`className`,`ql-table-caption`),O(K,`allowedChildren`,[Pn,Fn]);var q=class extends H{static isAllowStyle(e){for(let t of this.allowStyle)if(e.startsWith(t))return!0;return!1}static create(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o}=e,s=super.create();return s.dataset.tableId=t,s.dataset.rowId=n,s.dataset.colId=r,s.setAttribute(`rowspan`,String(Cn(i))),s.setAttribute(`colspan`,String(Cn(a))),o&&(s.style.cssText=o),s}static formats(e){let{tableId:t,rowId:n,colId:r}=e.dataset,i=Number(e.getAttribute(`rowspan`)),a=Number(e.getAttribute(`colspan`)),o={tableId:t,rowId:n,colId:r,rowspan:Cn(i),colspan:Cn(a)},s={};for(let t=0;t<e.style.length;t++){let n=e.style[t],r=e.style[n];this.isAllowStyle(String(n))&&![`initial`,`inherit`].includes(r)&&(s[n]=r)}let c=Object.entries(s);return c.length>0&&(o.style=c.map(([e,t])=>`${e}: ${t}`).join(`;`)),o}setFormatValue(e,t){if(this.statics.allowAttrs.has(e)||this.statics.allowDataAttrs.has(e)){let n=e;this.statics.allowDataAttrs.has(e)&&(n=`data-${e}`),t?this.domNode.setAttribute(n,t):this.domNode.removeAttribute(n)}else this.statics.isAllowStyle(e)&&(Object.assign(this.domNode.style,{[e]:t}),e.startsWith(`border`)&&this.setStyleBoder(e,t));this.children.head&&this.children.head.statics.blotName===u.tableCellInner&&this.domNode.style.cssText&&(this.children.head.domNode.dataset.style=this.domNode.style.cssText)}setStyleBoder(e,t){let n=t||null,r=![`left`,`right`,`top`,`bottom`].some(t=>e.includes(t))&&e.startsWith(`border-`);if(!r)return;let i=this.getNearByCell(`left`).map(e=>e.descendant(U,0)[0]).filter(Boolean);for(let t of i)t.setFormatValue(e.replace(`border-`,`border-right-`),n,!0);let a=this.getNearByCell(`top`).map(e=>e.descendant(U,0)[0]).filter(Boolean);for(let t of a)t.setFormatValue(e.replace(`border-`,`border-bottom-`),n,!0)}getNearByCell(e){let t=[];try{let e=b(this,u.tableMain);t.push(...e.getColIds())}catch(e){console.error(`Cell is not in table! ${e}`)}if(t.length===0)return[];if(e===`left`){let e=new Set,n=this.parent;for(let r=0;r<this.rowspan&&n instanceof W;r++){let r=n.children.iterator(),i=null;for(;i=r();){let n=t.indexOf(i.colId)+i.colspan;this.colId===t[n]&&e.add(i)}n=n.next}return Array.from(e)}else if(e===`top`){if(!(this.parent instanceof W)||!this.parent.prev)return[];let e=new Set,n=this.getColumnIndex(),r=n+this.colspan,i=new Set(t.filter((e,t)=>t>=n&&t<r)),a=1,o=this.parent.prev;for(;o;){let n=!1,r=o.children.iterator(),s=null,c=0;for(;s=r();)i.has(s.colId)&&s.rowspan>=a&&(e.add(s),i.delete(s.colId)),c+=s.colspan,s.rowspan>=a&&(n=!0);if(!n&&c===t.length)break;o=o.prev,a+=1}return Array.from(e)}return[]}get tableId(){return this.domNode.dataset.tableId}get rowId(){return this.domNode.dataset.rowId}get colId(){return this.domNode.dataset.colId}get rowspan(){return Number(this.domNode.getAttribute(`rowspan`))}get colspan(){return Number(this.domNode.getAttribute(`colspan`))}getColumnIndex(){let e=b(this,u.tableMain);return e.getColIds().indexOf(this.colId)}getCellInner(){return this.children.head}checkMerge(){let{colId:e,rowId:t,colspan:n,rowspan:r}=this,i=this.next;return i!==null&&i.statics.blotName===this.statics.blotName&&i.rowId===t&&i.colId===e&&i.colspan===n&&i.rowspan===r}optimize(e){let t=this.parent,{tableId:n,rowId:r}=this;t!==null&&t.statics.blotName!==u.tableRow&&this.wrap(u.tableRow,{tableId:n,rowId:r}),super.optimize(e)}};O(q,`blotName`,u.tableCell),O(q,`tagName`,`td`),O(q,`className`,`ql-table-cell`),O(q,`allowDataAttrs`,new Set([`table-id`,`row-id`,`col-id`])),O(q,`allowAttrs`,new Set([`rowspan`,`colspan`])),O(q,`allowStyle`,new Set([`background-color`,`border`,`height`]));let In=t.default.import(`blots/block/embed`);var J=class extends In{static validWidth(e,t){let n=Number.parseFloat(String(e));return Number.isNaN(n)&&(n=d[t?`colMinWidthPre`:`colMinWidthPx`]),`${n}${t?`%`:`px`}`}static create(e){let{width:t,tableId:n,colId:r,full:i,align:a}=e,o=super.create();return o.setAttribute(`width`,this.validWidth(t,!!i)),i&&(o.dataset.full=String(i)),a&&a!==`left`&&(o.dataset.align=a),o.dataset.tableId=n,o.dataset.colId=r,o}static value(e){let{tableId:t,colId:n}=e.dataset,r=e.getAttribute(`width`)||String(d.colDefaultWidth),i=e.dataset.align,a=Object.hasOwn(e.dataset,`full`),o={tableId:String(t),colId:String(n),full:a,width:Number.parseFloat(r)};return i&&(o.align=i),o}get width(){let e=this.domNode.getAttribute(`width`);if(!e){if(e=this.domNode.getBoundingClientRect().width,this.full){let t=this.domNode.closest(`table`);return t?e/100*t.getBoundingClientRect().width:d[this.full?`colMinWidthPre`:`colMinWidthPx`]}return e}return Number.parseFloat(String(e))}set width(e){let t=Number.parseFloat(String(e));Number.isNaN(t)&&(t=d[this.full?`colMinWidthPre`:`colMinWidthPx`]),this.domNode.setAttribute(`width`,this.statics.validWidth(t,!!this.full))}get tableId(){return this.domNode.dataset.tableId}get colId(){return this.domNode.dataset.colId}get full(){return Object.hasOwn(this.domNode.dataset,`full`)}set full(e){e?this.domNode.dataset.full=`true`:this.domNode.removeAttribute(`data-full`)}get align(){return this.domNode.dataset.align||``}set align(e){e===`right`||e===`center`?this.domNode.dataset.align=e:this.domNode.removeAttribute(`data-align`)}checkMerge(){let e=this.next,{tableId:t,colId:n}=this;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===t&&e.colId===n}optimize(e){let t=this.parent;if(t!=null&&t.statics.blotName!==u.tableColgroup){let e=this.statics.value(this.domNode);this.wrap(u.tableColgroup,e)}let n=b(this,u.tableColgroup);n.align=this.align,this.next!=null&&this.checkMerge()&&this.next.remove(),super.optimize(e);try{let e=b(this,u.tableColgroup),t=!0;e.children.forEach(e=>{t&&(t=e.full)}),e.full=t}catch(e){}}insertAt(e,t,n){if(n!=null){super.insertAt(e,t,n);return}try{let e=t.split(`
13
+ `),n=e.pop(),r=b(this,u.tableColgroup),i=r.next,a=this.scroll,o=r.split(this.offset(r));if(i){let e=i.descendants(U);if(e.length>0){let t=e[0],n=U.formats(t.domNode),i=this.scroll.create(u.tableCellInner,n),s=i.wrap(u.tableCell,n),c=s.wrap(u.tableRow,n),l=c.wrap(u.tableBody,n.tableId);r.parent.insertBefore(l,o),a=i}}for(let t of e){let e=this.scroll.create(`block`);e.insertAt(0,t),a.appendChild(e)}if(n){let e=this.scroll.create(`block`);e.appendChild(this.scroll.create(`text`,n)),a.appendChild(e)}}catch(e){console.warn(`TableCol not in TableColgroup`)}}};O(J,`blotName`,u.tableCol),O(J,`tagName`,`col`);var Y=class extends H{static create(e){let t=super.create(),{tableId:n,full:r,align:i}=e;return t.dataset.tableId=n,i===`right`||i===`center`?t.dataset.align=i:t.removeAttribute(`date-align`),r&&(t.dataset.full=String(r)),t.setAttribute(`cellpadding`,`0`),t.setAttribute(`cellspacing`,`0`),t}constructor(e,t,n){super(e,t),this.scroll=e,this.updateAlign()}colWidthFillTable(){if(this.full){Object.assign(this.domNode.style,{width:null});return}let e=this.getCols();if(!e)return;let t=e.reduce((e,t)=>t.width+e,0);if(!(t===0||Number.isNaN(t)))return this.domNode.style.width=`${t}px`,t}get tableId(){return this.domNode.dataset.tableId}get full(){return Object.hasOwn(this.domNode.dataset,`full`)}set full(e){e?this.domNode.dataset.full=`true`:this.domNode.removeAttribute(`data-full`),this.colWidthFillTable()}get align(){return this.domNode.dataset.align||``}set align(e){e===`right`||e===`center`?this.domNode.dataset.align=e:this.domNode.removeAttribute(`data-align`),this.updateAlign()}setFull(){if(this.full)return;let e=this.getCols();if(e.length===0)return;let t=Math.floor(this.domNode.getBoundingClientRect().width);for(let n of e){let e=n.width/t*100;n.full=!0,n.width=e}}cancelFull(){if(!this.full)return;let e=this.getCols();if(e.length===0)return;let t=Math.floor(this.domNode.getBoundingClientRect().width);for(let n of e)n.full=!1,n.width=Math.max(n.width/100*t,d.colMinWidthPx)}updateAlign(){let e=this.align,t={marginLeft:null,marginRight:null};switch(e){case`center`:t.marginLeft=`auto`,t.marginRight=`auto`;break;case``:case`left`:t.marginRight=`auto`;break;case`right`:t.marginLeft=`auto`;break;default:break}Object.assign(this.domNode.style,t)}getRows(){return this.descendants(W)}getRowIds(){return this.getRows().map(e=>e.rowId)}getCols(){return this.descendants(J)}getColIds(){return this.getCols().map(e=>e.colId)}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.domNode.dataset.tableId===this.tableId}optimize(e){let t=this.parent;t!==null&&t.statics.blotName!==u.tableWrapper&&this.wrap(u.tableWrapper,this.tableId),super.optimize(e)}sortMergeChildren(){let e={[u.tableCaption]:[],[u.tableColgroup]:[],[u.tableBody]:[]};this.children.forEach(t=>{e[t.statics.blotName]&&e[t.statics.blotName].push(t)});for(let t of Object.values(e))for(let e=1;e<t.length;e++)t[e].moveChildren(t[0]);let t=e[u.tableCaption][0],n=e[u.tableColgroup][0],r=e[u.tableBody][0],i=t&&this.children.head!==t,a=n&&t&&t.next!==n,o=n&&!t&&this.children.head!==n,s=r&&this.children.tail!==r;if(i||a||o||s){let e=this.clone();t&&e.appendChild(t),n&&e.appendChild(n),r&&e.appendChild(r),this.children.forEach(e=>e.remove()),e.moveChildren(this)}}};O(Y,`blotName`,u.tableMain),O(Y,`tagName`,`table`),O(Y,`className`,`ql-table`);var X=class extends H{static create(e){let t=super.create();return t.dataset.tableId=e.tableId,e.full&&(t.dataset.full=String(e.full)),e.align&&e.align!==`left`&&(t.dataset.align=e.align),t.setAttribute(`contenteditable`,`false`),t}get tableId(){return this.domNode.dataset.tableId}get full(){return Object.hasOwn(this.domNode.dataset,`full`)}set full(e){e?this.domNode.dataset.full=`true`:this.domNode.removeAttribute(`data-full`),this.parent&&this.parent instanceof Y&&(this.parent.full=e)}get align(){return this.domNode.dataset.align||``}set align(e){e===`right`||e===`center`?this.domNode.dataset.align=e:this.domNode.removeAttribute(`data-align`)}findCol(e){let t=this.children.iterator(),n=0,r;for(;(r=t())&&n!==e;)n++;return r}insertColByIndex(e,t){let n=this.parent;if(!(n instanceof Y))throw TypeError(`TableColgroupFormat should be child of TableFormat`);let r=this.findCol(e),i=this.scroll.create(u.tableCol,t);if(n.full){let e=this.children.iterator(),t;for(;t=e();)if(t.width-i.width>=d.colMinWidthPre){t.width-=i.width;break}}this.insertBefore(i,r)}removeColByIndex(e){let t=this.parent;if(!(t instanceof Y))throw TypeError(`TableColgroupFormat should be child of TableMainFormat`);let n=this.findCol(e);n&&(t.full&&(n.next?n.next.width+=n.width:n.prev&&(n.prev.width+=n.width)),n.remove(),t.colWidthFillTable())}checkMerge(){let e=this.next,t=this.parent;return t instanceof Y&&!t.full&&t.colWidthFillTable(),e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}optimize(e){let t=this.parent,{tableId:n,full:r,align:i}=this;t!=null&&t.statics.blotName!==u.tableMain&&this.wrap(u.tableMain,{tableId:n,full:r,align:i});let a=b(this,u.tableMain);a.align=i,super.optimize(e)}};O(X,`blotName`,u.tableColgroup),O(X,`tagName`,`colgroup`);let Ln=t.default.import(`parchment`);var Z=class extends H{static create(e){let t=super.create();return t.dataset.tableId=e,t.addEventListener(`dragstart`,e=>{e.preventDefault(),e.stopPropagation()},!0),t.addEventListener(`drop`,e=>{e.preventDefault()}),t.addEventListener(`dragover`,e=>{e.preventDefault(),e.dataTransfer.dropEffect=`none`}),t.setAttribute(`contenteditable`,`false`),t}constructor(e,n,r){super(e,n),this.scroll=e,O(this,`insertLineAround`,()=>{(!this.prev||!this.isBlockLine(this.prev))&&this.parent.insertBefore(this.scroll.create(`block`),this),(!this.next||!this.isBlockLine(this.next))&&this.parent.insertBefore(this.scroll.create(`block`),this.next)}),this.scroll.emitter.on(t.default.events.TEXT_CHANGE,this.insertLineAround)}get tableId(){return this.domNode.dataset.tableId}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}deleteAt(e,t){super.deleteAt(e,t);let n=this.descendants(G),r=this.descendants(X);(n.length===0||r.length===0)&&this.remove()}remove(){super.remove(),this.scroll.emitter.off(t.default.events.TEXT_CHANGE,this.insertLineAround)}isBlockLine(e){return e instanceof Ln.BlockBlot||new Set([`list-container`,`code-block-container`]).has(e.statics.blotName)}};O(Z,`blotName`,u.tableWrapper),O(Z,`tagName`,`div`),O(Z,`className`,`ql-table-wrapper`);function Rn(e){let[t]=C(e,G);return{body:t,rect:t.domNode.getBoundingClientRect()}}var zn=class{constructor(e,n,r){this.tableModule=e,this.table=n,this.quill=r,O(this,`tableBlot`,void 0),O(this,`tableWrapperBlot`,void 0),O(this,`alignBox`,void 0),O(this,`cleanup`,void 0),O(this,`bem`,y(`align`)),O(this,`resizeObserver`,fn(()=>this.update(),{ignoreFirstBind:!0})),O(this,`updateWhenTextChange`,()=>{this.update()}),this.tableBlot=t.default.find(n),this.tableWrapperBlot=this.tableBlot.parent,this.alignBox=this.buildTool(),this.resizeObserver.observe(this.table),this.quill.on(t.default.events.TEXT_CHANGE,this.updateWhenTextChange),this.show()}buildTool(){let e=this.tableModule.addContainer(this.bem.b()),n=t.default.import(`ui/icons`),r={left:n.align[``],center:n.align.center,right:n.align.right};for(let[n,i]of Object.entries(r)){let r=document.createElement(`span`);r.dataset.align=n,r.classList.add(this.bem.be(`item`)),r.innerHTML=`<i class="icon">${i}</i>`,r.addEventListener(`click`,()=>{let e=r.dataset.align;e&&(this.setTableAlign(this.tableBlot,e),this.quill.once(t.default.events.SCROLL_OPTIMIZE,()=>{this.tableModule.tableSelection&&this.tableModule.tableSelection.hide(),this.tableModule.tableResize&&this.tableModule.tableResize.update(),this.tableModule.tableResizeScale&&this.tableModule.tableResizeScale.update(),this.tableModule.tableScrollbar&&this.tableModule.tableScrollbar.update()}))}),e.appendChild(r)}return this.cleanup||(this.cleanup=Zt(this.tableWrapperBlot.domNode,e,()=>this.update())),e}setTableAlign(e,t){let n=e.getCols();for(let e of n)e.align=t}show(){this.alignBox&&(this.alignBox.classList.add(this.bem.bm(`active`)),this.update())}hide(){this.alignBox&&(this.alignBox.classList.remove(this.bem.bm(`active`)),this.cleanup&&(this.cleanup(),this.cleanup=void 0))}update(){if(this.alignBox){if(this.tableBlot.full||this.tableBlot.domNode.offsetWidth>=this.quill.root.offsetWidth){this.hide();return}nn(this.tableWrapperBlot.domNode,this.alignBox,{placement:`top`,middleware:[en(),$t({limiter:tn()}),Qt(16)]}).then(({x:e,y:t})=>{Object.assign(this.alignBox.style,{left:`${e}px`,top:`${t}px`})})}}destroy(){this.hide(),this.resizeObserver.disconnect(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange),this.alignBox&&(this.alignBox.remove(),this.alignBox=void 0)}};let Bn=[`style`],Vn=[`attributes`],Hn=[`attributes`],Un=[`background`],Wn=t.default.import(`delta`),Gn=t.default.import(`modules/clipboard`);function Kn(e){let t=Number.parseFloat(e.getAttribute(`width`)||String(d.colDefaultWidth));if(Number.isNaN(t)){let n=e.style.width;t=n?Number.parseFloat(n):e.offsetWidth}return t}function qn(e,t){let n=Array(t).fill(d.colDefaultWidth),r=Array.from(e.querySelectorAll(`tr`));for(let e of r){let r=Array.from(e.querySelectorAll(`td`));for(let[e,i]of r.entries())if(e<t){let t=Kn(i);n[e]=t||n[e]}else break}return n}var Jn=class extends Gn{constructor(e,t){super(e,t),this.quill=e,O(this,`tableId`,V()),O(this,`rowId`,V()),O(this,`rowIds`,[]),O(this,`colIds`,[]),O(this,`emptyRowCount`,[]),O(this,`rowspanCount`,[]),O(this,`cellCount`,0),O(this,`colCount`,0),this.addMatcher(`table`,this.matchTable.bind(this)),this.addMatcher(`tbody`,this.matchTbody.bind(this)),this.addMatcher(`colgroup`,this.matchColgroup.bind(this)),this.addMatcher(`col`,this.matchCol.bind(this)),this.addMatcher(`tr`,this.matchTr.bind(this)),this.addMatcher(`td`,this.matchTd.bind(this)),this.addMatcher(`th`,this.matchTd.bind(this)),this.addMatcher(`caption`,this.matchCaption.bind(this)),this.addMatcher(Node.ELEMENT_NODE,this.matchTdAttributor.bind(this))}matchTable(e,t){if(t.ops.length===0)return t;let n=this.emptyRowCount.reduce((e,t)=>{var n;return e.push(((n=e[e.length-1])==null?0:n)+t),e},[]),r=[],i=[],a=-1;for(let e=0;e<t.ops.length;e++){let{attributes:o,insert:s}=t.ops[e],c=o||{},l=u.tableCell,{table:d,[l]:f}=c,p=N(c,[`table`,l].map(Ce)),m=de(s)&&s[u.tableCol];if(m)i.push({insert:s});else if(p[u.tableCellInner]){let e=p[u.tableCellInner],t=this.rowIds.indexOf(e.rowId);if(t!==-1){let r=e.rowspan;e.rowspan-=n[t+r-1]-n[t]}r.push({attributes:k(k({},p),{},{[u.tableCellInner]:e}),insert:s})}else r.push({attributes:p,insert:s});!(p!=null&&p[u.tableCellInner])&&!(p!=null&&p[u.tableCaption])&&!m&&le(s)&&s.trim().length>0&&(a=e)}let o=qn(e,this.colIds.length),s=o.reduce((e,t,n)=>(i[n]?e.push(i[n]):e.push({insert:{[u.tableCol]:{tableId:this.tableId,colId:this.colIds[n],width:t,full:!1}}}),e),[]);return r.splice(a+1,0,...s),this.tableId=V(),this.rowIds=[],this.colIds=[],this.emptyRowCount=[],this.rowspanCount=[],this.cellCount=0,this.colCount=0,new Wn(r)}matchTbody(e,t){let n=e.style.backgroundColor;if(n)for(let e of t.ops){var r;if((r=e.attributes)!=null&&r[u.tableCellInner]){let t=e.attributes[u.tableCellInner],{style:r}=t,i=N(t,Bn),a=mn(r||``);a.backgroundColor||(a.backgroundColor=n,e.attributes[u.tableCellInner]=k(k({},i),{},{style:hn(a)}))}}return t}matchColgroup(e,t){let n=[];for(let e=0;e<t.ops.length;e++){let r=t.ops[e];r&&de(r.insert)&&r.insert[u.tableCol]&&n.push(r)}return new Wn(n)}matchCol(e,t){let n=Number(e.getAttribute(`span`)||1);Number.isNaN(n)&&(n=1);let r=new Wn;for(let t=0;t<n;t++)this.colIds[this.colCount]=V(),r.insert({[u.tableCol]:Object.assign(J.value(e),{tableId:this.tableId,colId:this.colIds[this.colCount]})}),this.colCount+=1;return r}matchTr(e,t){this.rowIds.push(this.rowId),this.rowId=V(),this.cellCount=0;for(let[e,t]of this.rowspanCount.entries())t.rowspan>0&&--t.rowspan,t.rowspan<=0&&(this.rowspanCount[e]={rowspan:0,colspan:0});let n=!0;for(let e of t.ops)if(e.attributes){let{background:t,[u.tableCellInner]:r}=e.attributes;if(r||(n=!1),r&&t){let{style:n=``}=r,i=mn(n);i.backgroundColor=t,e.attributes[u.tableCellInner].style=hn(i)}}else n=!1;let r=0;return n||(r=1,t=new Wn),this.emptyRowCount.push(r),t}matchTd(e,t){let n=e,r=q.formats(n);if(!this.colIds[this.cellCount]||!this.rowspanCount[this.cellCount])for(let e=this.cellCount;e>=0;e--)this.colIds[e]||(this.colIds[e]=V()),this.rowspanCount[e]||(this.rowspanCount[e]={rowspan:0,colspan:0});for(let e=this.cellCount;e<this.rowspanCount.length;e++){let{rowspan:t,colspan:n}=this.rowspanCount[e];if(t===0)break;this.cellCount+=n}r.rowspan>1&&(this.rowspanCount[this.cellCount]={rowspan:r.rowspan,colspan:r.colspan});let i=this.colIds[this.cellCount];this.cellCount+=r.colspan;let a=Object.assign(r,{tableId:this.tableId,rowId:this.rowId,colId:i});n.style.border===`none`&&(a.style=a.style.replaceAll(RegExp(`border-(top|right|bottom|left)-style:none;?`,`g`),``));let o=[];for(let e of t.ops){let{attributes:t={}}=e,n=N(e,Vn),r=u.tableCell,{[r]:i}=t,s=N(t,[r].map(Ce));o.push(k(k({},n),{},{attributes:k(k({},s),{},{[u.tableCellInner]:a})}))}return(o.length<=0||!le(o[o.length-1].insert)||!o[o.length-1].insert.endsWith(`
14
+ `))&&o.push({insert:`
15
+ `,attributes:{[u.tableCellInner]:a}}),new Wn(o)}matchTdAttributor(e,t){let n=e;if(n.tagName.toLocaleLowerCase()===`td`){let e=[];for(let n of t.ops){let{attributes:t}=n,r=N(n,Hn),i=t==null?void 0:t[u.tableCellInner];if(t&&i&&i.style){let{background:n}=t,a=N(t,Un),o=document.createElement(`div`);o.style.background=n;let s=document.createElement(`div`);if(s.style.cssText=i.style,o.style.background===s.style.backgroundColor){e.push(k(k({},r),{},{attributes:k({},a)}));continue}}e.push(n)}return new Wn(e)}return t}convert({html:e,text:t},n={}){let r=super.convert({html:e,text:t},n);if(n[u.tableCellInner])for(let e of r.ops){if(de(e.insert)&&e.insert[u.tableCol]){e.insert=``;continue}e.attributes||(e.attributes={}),e.attributes[u.tableCellInner]=n[u.tableCellInner]}return r}matchCaption(e,t){for(let e=0;e<t.ops.length;e++){let n=t.ops[e],{attributes:r}=n;r&&r[u.tableCaption]&&(r[u.tableCaption].tableId=this.tableId,n.attributes=r)}return t}},Yn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
16
+ <!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE -->
17
+ <path
18
+ fill="none"
19
+ stroke="currentColor"
20
+ stroke-linecap="round"
21
+ stroke-linejoin="round"
22
+ stroke-width="2"
23
+ d="M4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v6m-10 6H3m18 0h-7m-8-3l-3 3l3 3m12-6l3 3l-3 3"
24
+ />
25
+ </svg>
26
+ `,Xn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
27
+ <path
28
+ fill="none"
29
+ stroke="currentColor"
30
+ stroke-linecap="round"
31
+ stroke-linejoin="round"
32
+ stroke-width="2"
33
+ d="m4 8l4-4m6 0L4 14m0 6L20 4m0 6L10 20m10-4l-4 4"
34
+ />
35
+ </svg>
36
+ `,Zn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
37
+ <path
38
+ fill="none"
39
+ stroke="currentColor"
40
+ stroke-linecap="round"
41
+ stroke-linejoin="round"
42
+ stroke-width="1.5"
43
+ d="m12.01 16l-.01.011M12.01 12l-.01.011M12.01 8l-.01.011M8.01 12l-.01.011M16.01 12l-.01.011M21 3.6v16.8a.6.6 0 0 1-.6.6H3.6a.6.6 0 0 1-.6-.6V3.6a.6.6 0 0 1 .6-.6h16.8a.6.6 0 0 1 .6.6"
44
+ />
45
+ </svg>
46
+ `,Qn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256">
47
+ <g fill="currentColor">
48
+ <path d="M216 40v128h-48V88H88V40Z" opacity=".2" />
49
+ <path
50
+ d="M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8m-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z"
51
+ />
52
+ </g>
53
+ </svg>
54
+ `,$n=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32">
55
+ <path
56
+ fill="currentColor"
57
+ d="m19.05 13.733l-1-1.733l-10.122 5.846l-.997-.576a3 3 0 0 0 .667-.769A3 3 0 1 0 3.5 17.599L5.928 19L3.5 20.402a3.034 3.034 0 1 0 3.44.323l.988-.57L14.59 24l1-1.73L9.928 19zM4.034 15.26a1 1 0 1 1 .466.607a1 1 0 0 1-.466-.607M5 22a1 1 0 1 1-.865 1.5A1 1 0 0 1 5 22m12 4h4v2h-4zm-7 0h4v2h-4z"
58
+ />
59
+ <path fill="currentColor" d="M28 28h-4v-2h4V4H7v4H5V4a2 2 0 0 1 2-2h21a2 2 0 0 1 2 2v22a2 2 0 0 1-2 2" />
60
+ </svg>
61
+ `,er=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
62
+ <path
63
+ fill="currentColor"
64
+ d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm11.94 5.5h2v-4h2v4h2l-3 3z"
65
+ />
66
+ </svg>
67
+ `,tr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
68
+ <path
69
+ fill="currentColor"
70
+ d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm14.44 2v2h4v2h-4v2l-3-3z"
71
+ />
72
+ </svg>
73
+ `,nr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
74
+ <path
75
+ fill="currentColor"
76
+ d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm15.44 8v-2h-4v-2h4v-2l3 3z"
77
+ />
78
+ </svg>
79
+ `,rr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
80
+ <path
81
+ fill="currentColor"
82
+ d="M4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4zm17.94 4.5h-2v4h-2v-4h-2l3-3z"
83
+ />
84
+ </svg>
85
+ `,ir=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
86
+ <path
87
+ fill="currentColor"
88
+ d="M5 10H3V4h8v2H5zm14 8h-6v2h8v-6h-2zM5 18v-4H3v6h8v-2zM21 4h-8v2h6v4h2zM8 13v2l3-3l-3-3v2H3v2zm8-2V9l-3 3l3 3v-2h5v-2z"
89
+ />
90
+ </svg>
91
+ `,ar=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
92
+ <path
93
+ fill="currentColor"
94
+ d="M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4zm0 6v4h7v-4zM4 4v4h7V4zm13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59z"
95
+ />
96
+ </svg>
97
+ `,or=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
98
+ <path
99
+ fill="currentColor"
100
+ d="M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41zM22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2zM4 9h4V6H4zm6 0h4V6h-4zm6 0h4V6h-4z"
101
+ />
102
+ </svg>
103
+ `,sr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
104
+ <path
105
+ fill="currentColor"
106
+ d="m15.46 15.88l1.42-1.42L19 16.59l2.12-2.13l1.42 1.42L20.41 18l2.13 2.12l-1.42 1.42L19 19.41l-2.12 2.13l-1.42-1.42L17.59 18zM4 3h14a2 2 0 0 1 2 2v7.08a6 6 0 0 0-4.32.92H12v4h1.08c-.11.68-.11 1.35 0 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m0 4v4h6V7zm8 0v4h6V7zm-8 6v4h6v-4z"
107
+ />
108
+ </svg>
109
+ `,cr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
110
+ <path
111
+ fill="currentColor"
112
+ d="M19 14h2v6H3v-6h2v4h14zM3 4v6h2V6h14v4h2V4zm8 7v2H8v2l-3-3l3-3v2zm5 0V9l3 3l-3 3v-2h-3v-2z"
113
+ />
114
+ </svg>
115
+ `,lr=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
116
+ <!-- Icon from TDesign Icons by TDesign - https://github.com/Tencent/tdesign-icons/blob/main/LICENSE -->
117
+ <path fill="currentColor" d="M21 10v12h-2V12H5v10H3V10zm0-8v6H3V2zm-2 2H5v2h14z" />
118
+ </svg>
119
+ `;let ur=`color-selector`,Q={Break:{name:`break`},CopyCell:{name:`CopyCell`,tip:`Copy cell`,icon:Qn,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},CutCell:{name:`CutCell`,tip:`Cut cell`,icon:$n,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t,!0),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},InsertTop:{name:`InsertTop`,icon:rr,tip:`Insert row above`,handle:(e,t)=>{e.appendRow(t,!1),e.hideTableTools()}},InsertRight:{name:`InsertRight`,icon:nr,tip:`Insert column right`,handle:(e,t)=>{e.appendCol(t,!0),e.hideTableTools()}},InsertBottom:{name:`InsertBottom`,icon:er,tip:`Insert row below`,handle:(e,t)=>{e.appendRow(t,!0),e.hideTableTools()}},InsertLeft:{name:`InsertLeft`,icon:tr,tip:`Insert column Left`,handle:(e,t)=>{e.appendCol(t,!1),e.hideTableTools()}},MergeCell:{name:`MergeCell`,icon:ir,tip:`Merge Cell`,handle:(e,t)=>{e.mergeCells(t),e.hideTableTools()}},SplitCell:{name:`SplitCell`,icon:cr,tip:`Split Cell`,handle:(e,t)=>{e.splitCell(t),e.hideTableTools()}},DeleteRow:{name:`DeleteRow`,icon:or,tip:`Delete Row`,handle:(e,t)=>{e.removeRow(t),e.hideTableTools()}},DeleteColumn:{name:`DeleteColumn`,icon:ar,tip:`Delete Column`,handle:(e,t)=>{e.removeCol(t),e.hideTableTools()}},DeleteTable:{name:`DeleteTable`,icon:sr,tip:`Delete table`,handle:(e,t)=>{e.deleteTable(t)}},BackgroundColor:{name:`BackgroundColor`,icon:Xn,isColorChoose:!0,tip:`Set background color`,key:`background-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`background-color`,n,!0)}},BorderColor:{name:`BorderColor`,icon:Zn,isColorChoose:!0,tip:`Set border color`,key:`border-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`border-color`,n,!0)}},SwitchWidth:{name:`SwitchWidth`,icon:Yn,tip:`Switch table width`,handle:e=>{if(!e.table)return;let n=t.default.find(e.table);n&&(n.full?n.cancelFull():n.setFull())}},InsertCaption:{name:`InsertCaption`,icon:lr,tip:`Insert table caption`,handle(e){if(!e.table)return;let n=t.default.find(e.table);if(!n)return;let r=e.quill.scroll.create(`text`,`Table Caption`).wrap(u.tableCaption,{tableId:n.tableId});n.insertBefore(r,n.children.head)}}},dr=10,fr=y(`color-map`),$={selectWrapper:fr.b(),used:fr.bm(`used`),item:fr.be(`item`),btn:fr.be(`btn`),map:fr.be(`content`),mapRow:fr.be(`content-row`)};var pr=class{constructor(e,n,r){this.tableModule=e,this.quill=n,O(this,`usedColors`,new Set),O(this,`options`,void 0),O(this,`menu`,null),O(this,`isMenuDisplay`,!1),O(this,`isColorPicking`,!1),O(this,`updateUsedColor`,void 0),O(this,`tooltipItem`,[]),O(this,`activeTooltip`,null),O(this,`bem`,y(`menu`)),O(this,`colorItemClass`,`color-${V()}`),O(this,`colorChooseTooltipOption`,{direction:`top`}),O(this,`updateWhenTextChange`,()=>{this.isMenuDisplay&&this.update()}),this.options=this.resolveOptions(r);try{let e=localStorage.getItem(this.options.localstorageKey)||`[]`,t=JSON.parse(e);ce(t)||(t=[]),t.slice(-1*dr).map(e=>this.usedColors.add(e))}catch(e){}this.updateUsedColor=vn(e=>{if(!e)return;if(this.usedColors.add(e),this.usedColors.size>dr){let e=Array.from(this.usedColors).slice(-1*dr);this.usedColors.clear(),e.map(e=>this.usedColors.add(e))}localStorage.setItem(this.options.localstorageKey,JSON.stringify(Array.from(this.usedColors)));let t=Array.from(document.querySelectorAll(`.${this.colorItemClass}.${$.used}`));for(let n of t){let t=document.createElement(`div`);t.classList.add($.item),t.style.backgroundColor=String(e);let r=Array.from(n.querySelectorAll(`.${$.item}[style*="background-color: ${t.style.backgroundColor}"]`));r.length<=0&&n.appendChild(t);let i=Array.from(n.querySelectorAll(`.${$.item}`)).slice(0,-1*dr);for(let e of i)e.remove()}},1e3),this.quill.on(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)}resolveOptions(e){let t=Object.assign({tipText:!0,tools:[Q.InsertTop,Q.InsertRight,Q.InsertBottom,Q.InsertLeft,Q.Break,Q.MergeCell,Q.SplitCell,Q.Break,Q.DeleteRow,Q.DeleteColumn,Q.DeleteTable,Q.Break,Q.BackgroundColor,Q.BorderColor],localstorageKey:`__table-bg-used-color`,defaultColorMap:m},e);return t}buildTools(){let e=document.createElement(`div`);e.classList.add(this.bem.b()),Object.assign(e.style,{display:`flex`});for(let t of this.options.tools){let{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s=``}=t,c=document.createElement(`span`);if(c.classList.add(this.bem.be(`item`)),n===`break`)c.classList.add(this.bem.is(`break`));else{let e=document.createElement(`i`);if(e.classList.add(`icon`),se(r)?e.appendChild(r(this.tableModule)):e.innerHTML=r,c.appendChild(e),a&&o){let e=this.createColorChoose(c,{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s});this.tooltipItem.push(e),c.classList.add(ur)}else se(i)&&c.addEventListener(`click`,e=>{this.quill.focus(),i(this.tableModule,this.getSelectedTds(),e)},!1);let t=this.tableModule.options.texts[n]||s;this.options.tipText&&t&&s&&this.createTipText(c,t)}e.appendChild(c)}return e}createColorChoose(e,{handle:t,key:n}){let r=document.createElement(`div`);if(r.classList.add($.selectWrapper),this.options.defaultColorMap.length>0){let e=document.createElement(`div`);e.classList.add($.map);for(let t of this.options.defaultColorMap){let n=document.createElement(`div`);n.classList.add($.mapRow);for(let e of t){let t=document.createElement(`div`);t.classList.add($.item),t.style.backgroundColor=e,n.appendChild(t)}e.appendChild(n)}r.appendChild(e)}let i=document.createElement(`div`);i.classList.add($.mapRow),Object.assign(i.style,{marginTop:`4px`});let a=document.createElement(`div`);a.classList.add($.btn,`transparent`),a.textContent=this.tableModule.options.texts.transparent,a.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),`transparent`)});let o=document.createElement(`div`);o.classList.add($.btn,`clear`),o.textContent=this.tableModule.options.texts.clear,o.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),null)});let s=document.createElement(`div`);s.classList.add($.btn,`custom`),s.textContent=this.tableModule.options.texts.custom;let c=me({onChange:e=>{t(this.tableModule,this.getSelectedTds(),e),this.updateUsedColor(e)}}),{hide:l,destroy:u}=sn(s,{direction:`right`,type:`click`,content:c,container:s});i.appendChild(a),i.appendChild(o),i.appendChild(s),r.appendChild(i);let d=document.createElement(`div`);d.classList.add($.used,this.colorItemClass);for(let e of this.usedColors){let t=document.createElement(`div`);t.classList.add($.item),t.style.backgroundColor=e,d.appendChild(t)}r.appendChild(d),r.addEventListener(`click`,e=>{e.stopPropagation(),l();let t=e.target,r=t.style.backgroundColor,i=this.getSelectedTds();if(t&&r&&i.length>0){if(this.tableModule.setCellAttrs(i,n,r,!0),!t.closest(`.${$.item}`))return;this.updateUsedColor(r)}});let f=sn(e,k({type:`click`,content:r,onOpen:()=>(this.isMenuDisplay&&this.tableModule.tableSelection&&this.tableModule.tableSelection.hideDisplay(),this.setActiveTooltip(f),!1),onClose:()=>{this.isMenuDisplay&&this.tableModule.tableSelection&&(this.tableModule.tableSelection.updateWithSelectedTds(),this.tableModule.tableSelection.showDisplay());let e=r.contains(c);return e&&l(),this.activeTooltip===f&&(this.activeTooltip=null),!1},onDestroy:()=>{u(),this.activeTooltip===f&&(this.activeTooltip=null)}},this.colorChooseTooltipOption));return f.isColorPick=!0,f}setActiveTooltip(e){this.activeTooltip&&this.activeTooltip!==e&&this.activeTooltip.hide(!0),this.activeTooltip=e}getSelectedTds(){var e;return((e=this.tableModule.tableSelection)==null?void 0:e.selectedTds)||[]}createTipText(e,t){let n=sn(e,{msg:t});n&&this.tooltipItem.push(n)}show(){!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.boundary||(Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update())}update(){}hide(){this.menu&&Object.assign(this.menu.style,{display:`none`});for(let e of this.tooltipItem)e.hide(!0);this.isMenuDisplay=!1}destroy(){this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange),this.activeTooltip=null;for(let e of this.tooltipItem)e.destroy();this.menu&&(this.hide(),this.menu.remove(),this.menu=null)}},mr=class extends pr{constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,O(this,`colorChooseTooltipOption`,{direction:`right`}),O(this,`listenContextmenu`,e=>{var t;e.preventDefault();let n=e.composedPath();if(!n||n.length<=0)return;let r=n.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));r&&!((t=this.tableModule.tableSelection)==null||(t=t.selectedTds)==null)&&t.length?(this.menu||(this.menu=this.buildTools()),Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update({x:e.clientX,y:e.clientY}),document.addEventListener(`click`,()=>{this.hide()},{once:!0})):this.hide()}),this.quill.root.addEventListener(`contextmenu`,this.listenContextmenu)}buildTools(){let e=super.buildTools();e.classList.add(this.bem.is(`contextmenu`));let t=e.getElementsByClassName(ur);for(let e of Array.from(t))e.addEventListener(`click`,e=>e.stopPropagation());return document.body.appendChild(e),e}createTipText(e,t){let n=document.createElement(`span`);n.textContent=t,e.appendChild(n)}show(){}update(e){if(!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||!e)return;super.update();let t={display:`flex`,left:0,top:0},{x:n,y:r}=e;t.left=n,t.top=r,Object.assign(this.menu.style,k(k({},t),{},{left:`${t.left+window.scrollX}px`,top:`${t.top+window.scrollY}px`}));let i=this.menu.getBoundingClientRect(),{left:a,top:o}=dn(i);Object.assign(this.menu.style,{left:`${a+window.scrollX}px`,top:`${o+window.scrollY}px`})}destroy(){this.quill.root.removeEventListener(`contextmenu`,this.listenContextmenu),super.destroy()}},hr=class extends pr{constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,this.menu=this.buildTools(),this.tableModule.addContainer(this.menu),this.show(),this.update()}update(){!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||(super.update(),nn(this.tableModule.tableSelection.cellSelect,this.menu,{placement:`bottom`,middleware:[en(),$t({limiter:tn()}),Qt(20)]}).then(({x:e,y:t})=>{Object.assign(this.menu.style,{left:`${e}px`,top:`${t}px`})}))}};let gr=e=>!e.full&&e.align===`right`;var _r=class{constructor(e,t){this.tableModule=e,this.quill=t,O(this,`colIndex`,-1),O(this,`tableMain`,void 0),O(this,`dragging`,!1),O(this,`dragColBreak`,null),O(this,`handleColMouseUpFunc`,this.handleColMouseUp.bind(this)),O(this,`handleColMouseMoveFunc`,this.handleColMouseMove.bind(this)),O(this,`handleColMouseDownFunc`,this.handleColMouseDown.bind(this)),O(this,`rowIndex`,-1),O(this,`dragRowBreak`,null),O(this,`handleRowMouseUpFunc`,this.handleRowMouseUp.bind(this)),O(this,`handleRowMouseMoveFunc`,this.handleRowMouseMove.bind(this)),O(this,`handleRowMouseDownFunc`,this.handleRowMouseDown.bind(this)),O(this,`dragBEM`,y(`drag-line`))}findCurrentColIndex(e){return-1}colWidthChange(e,t,n){}createConfirmDialog({message:e,confirm:t,cancel:n}){return D(function*(){return new Promise(r=>{let i=document.createElement(`div`);Object.assign(i.style,{padding:`8px 12px`,fontSize:`14px`,lineHeight:`1.5`});let a=document.createElement(`p`);a.textContent=e;let o=document.createElement(`div`);Object.assign(o.style,{display:`flex`,justifyContent:`flex-end`,gap:`6px`});let s=pe({content:n}),c=pe({type:`confirm`,content:t});o.appendChild(s),o.appendChild(c),i.appendChild(a),i.appendChild(o);let{close:l}=E({child:i});s.addEventListener(`click`,()=>{r(!1),l()}),c.addEventListener(`click`,()=>{r(!0),l()})})})()}handleColMouseUp(){var e=this;return D(function*(){if(!e.dragColBreak||!e.tableMain||e.colIndex===-1)return;let t=e.tableMain.getCols(),n=Number.parseInt(e.dragColBreak.dataset.w||`0`),r=e.tableMain.full,i=!1,a=[];if(r){let r=e.tableMain.domNode.getBoundingClientRect().width,o=n/r*100,s=t[e.colIndex].width;if(o<s){if(o=Math.max(d.colMinWidthPre,o),t[e.colIndex+1]||t[e.colIndex-1]){let n=t[e.colIndex+1]?e.colIndex+1:e.colIndex-1;a.push({index:n,width:t[n].width+s-o})}else o=100;i=!0,a.push({index:e.colIndex,width:o})}else if(t[e.colIndex+1]){let n=s+t[e.colIndex+1].width;o=Math.min(n-d.colMinWidthPre,o),i=!0,a.push({index:e.colIndex,width:o},{index:e.colIndex+1,width:n-o})}}else e.tableMain.domNode.style.width=`${Number.parseFloat(e.tableMain.domNode.style.width)-t[e.colIndex].domNode.getBoundingClientRect().width+n}px`,i=!0,a.push({index:e.colIndex,width:n});if(document.body.removeChild(e.dragColBreak),e.dragColBreak=null,document.removeEventListener(`mouseup`,e.handleColMouseUpFunc),document.removeEventListener(`mousemove`,e.handleColMouseMoveFunc),e.dragging=!1,i){let n=e.tableMain.domNode.getBoundingClientRect().width;if(r){let i=0,o=new Set(a.map(({index:e,width:t})=>(i+=t,e)));for(let[e,n]of t.entries()){if(o.has(e))continue;i+=n.width}if(i>100){if(!(yield e.createConfirmDialog({message:e.tableModule.options.texts.perWidthInsufficient,confirm:e.tableModule.options.texts.confirmText,cancel:e.tableModule.options.texts.cancelText})))return;e.tableMain.cancelFull(),r=!1;for(let[e,t]of a.entries()){let{width:r,index:i}=t;a[e]={index:i,width:r/100*n}}}}for(let{index:i,width:o}of a)t[i].width=`${Math.round(o)}${r?`%`:`px`}`,e.colWidthChange(i,{px:Math.round(o/100*n),pre:Math.round(o)},r)}e.quill.emitter.emit(f.AFTER_TABLE_RESIZE)})()}getColumnRect(e){if(!this.tableMain)return null;let t=this.tableMain.getCols();if(e>=t.length)return null;let n=t[0].domNode.getBoundingClientRect().left;for(let r=0;r<e;r++){let e=t[r].domNode.getBoundingClientRect();n+=e.width}let r=t[e],i=r.domNode.getBoundingClientRect().width;return{left:n,right:n+i,width:i}}handleColMouseMove(e){if(e.preventDefault(),!this.dragColBreak||!this.tableMain||this.colIndex===-1)return;let t=this.tableMain.getCols(),n=this.getColumnRect(this.colIndex),r=this.tableMain.domNode.getBoundingClientRect(),i=e.clientX;if(this.tableMain.full){let e=d.colMinWidthPre/100*r.width,a=r.right;i>n.right&&t[this.colIndex+1]&&(a=Math.max(this.getColumnRect(this.colIndex+1).right-e,n.left+e));let o=n.left+e;i=Math.min(Math.max(i,o),a)}else gr(this.tableMain)?n.right-i<d.colMinWidthPx&&(i=n.right-d.colMinWidthPx):i-n.left<d.colMinWidthPx&&(i=n.left+d.colMinWidthPx);let a=i-n.left;return gr(this.tableMain)&&(a=n.right-i),this.dragColBreak.style.left=`${i}px`,this.dragColBreak.dataset.w=String(a),{left:i,width:a}}handleColMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain))return;let{rect:t,body:n}=Rn(this.tableMain);if(!n)return;let r=this.tableMain.getCols();if(this.colIndex=this.findCurrentColIndex(e),this.colIndex===-1)return;let i=r[this.colIndex].width,a=this.tableMain.full?i/100*t.width:i;document.addEventListener(`mouseup`,this.handleColMouseUpFunc),document.addEventListener(`mousemove`,this.handleColMouseMoveFunc),this.dragging=!0;let o=document.createElement(`div`);o.classList.add(this.dragBEM.b()),o.classList.add(this.dragBEM.is(`col`)),o.dataset.w=String(a);let s={top:t.y,left:e.clientX,height:t.height};Object.assign(o.style,{top:`${s.top}px`,left:`${s.left}px`,height:`${s.height}px`});let c=document.body;return c.appendChild(o),this.dragColBreak&&c.removeChild(this.dragColBreak),this.dragColBreak=o,s}findCurrentRowIndex(e){return-1}rowHeightChange(e,t){}handleRowMouseUp(){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;let e=Number.parseInt(this.dragRowBreak.dataset.h||`0`),t=this.tableMain.getRows();t[this.rowIndex].setHeight(`${e}px`),this.rowHeightChange(this.rowIndex,e),document.body.removeChild(this.dragRowBreak),this.dragRowBreak=null,document.removeEventListener(`mouseup`,this.handleRowMouseUpFunc),document.removeEventListener(`mousemove`,this.handleRowMouseMoveFunc),this.dragging=!1,this.quill.emitter.emit(f.AFTER_TABLE_RESIZE)}handleRowMouseMove(e){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;e.preventDefault();let t=this.tableMain.getRows(),n=t[this.rowIndex].domNode.getBoundingClientRect(),r=e.clientY;return r-n.y<d.rowMinHeightPx&&(r=n.y+d.rowMinHeightPx),this.dragRowBreak.style.top=`${r}px`,this.dragRowBreak.dataset.h=String(r-n.y),{top:r,height:r-n.y}}handleRowMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain)||(this.rowIndex=this.findCurrentRowIndex(e),this.rowIndex===-1))return;this.dragging=!0,document.addEventListener(`mouseup`,this.handleRowMouseUpFunc),document.addEventListener(`mousemove`,this.handleRowMouseMoveFunc);let t=this.tableMain.getRows(),n=t[this.rowIndex].domNode.getBoundingClientRect().height,r=this.tableMain.domNode.getBoundingClientRect(),i=document.createElement(`div`);i.classList.add(this.dragBEM.b()),i.classList.add(this.dragBEM.is(`row`)),i.dataset.h=String(n);let a={top:e.clientY,left:r.x,width:r.width};Object.assign(i.style,{top:`${a.top}px`,left:`${a.left}px`,width:`${a.width}px`});let o=document.body;return o.appendChild(i),this.dragRowBreak&&o.removeChild(this.dragRowBreak),this.dragRowBreak=i,a}update(){}destroy(){}},vr=class extends _r{constructor(e,n,r){super(e,r),this.tableModule=e,this.table=n,O(this,`root`,void 0),O(this,`tableMain`,void 0),O(this,`tableWrapper`,void 0),O(this,`resizeObserver`,void 0),O(this,`tableCols`,[]),O(this,`tableRows`,[]),O(this,`rowHeadWrapper`,null),O(this,`colHeadWrapper`,null),O(this,`corner`,null),O(this,`scrollHandler`,[]),O(this,`lastHeaderSelect`,null),O(this,`size`,12),O(this,`bem`,y(`resize-box`)),O(this,`updateWhenTextChange`,()=>{this.update()}),O(this,`handleColMouseDownFunc`,function(e){let t=this.handleColMouseDown(e);if(t&&this.dragColBreak){let[e]=C(this.tableMain,K),n=e&&e.side===`top`?0:this.size;Object.assign(this.dragColBreak.style,{top:`${t.top-n}px`,left:`${t.left}px`,height:`${t.height+this.size}px`})}return t}.bind(this)),O(this,`handleRowMouseDownFunc`,function(e){let t=this.handleRowMouseDown(e);return t&&this.dragRowBreak&&Object.assign(this.dragRowBreak.style,{top:`${t.top}px`,left:`${t.left-this.size}px`,width:`${t.width+this.size}px`}),t}.bind(this)),this.tableMain=t.default.find(this.table),this.tableMain&&(this.tableWrapper=this.tableMain.parent,this.tableWrapper&&(this.root=this.tableModule.addContainer(this.bem.b()),this.resizeObserver=new ResizeObserver(()=>{this.show()}),this.resizeObserver.observe(this.table),this.quill.on(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)))}handleResizerHeader(e,t,n){let{clientX:r,clientY:i}=n,a=this.table.getBoundingClientRect();if(this.tableModule.tableSelection){let o=this.tableModule.tableSelection;n.shiftKey||(this.lastHeaderSelect=null);let s=[{x:e?a.left:r,y:e?i:a.top},{x:e?a.right:r,y:e?i:a.bottom}];if(this.lastHeaderSelect){let t,n;if(this.lastHeaderSelect.isX){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=Math.min(r.left,a.left),n=r.top+r.height/2}else{let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=r.left+r.width/2,n=Math.min(r.top,a.top)}this.lastHeaderSelect.isX===e?e?(s[0].y=Math.min(s[0].y,n),s[1].y=Math.max(s[1].y,n)):(s[0].x=Math.min(s[0].x,t),s[1].x=Math.max(s[1].x,t)):(s[1]={x:Math.max(s[0].x,t),y:Math.max(s[0].y,n)},s[0]={x:Math.min(s[0].x,t),y:Math.min(s[0].y,n)})}else this.lastHeaderSelect={isX:e,index:t};o.table=this.table,o.selectedTds=o.computeSelectedTds(...s),o.show()}}findCurrentColIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`))).indexOf(e.target)}colWidthChange(e,t,n){let r=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`)));r[e].style.width=n?`${t.pre}%`:`${t.px}px`}bindColEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`)));B.call(this,this.tableWrapper.domNode,()=>{this.colHeadWrapper.scrollLeft=this.tableWrapper.domNode.scrollLeft});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!1,t));for(let e of t)e.addEventListener(`mousedown`,this.handleColMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}findCurrentRowIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`))).indexOf(e.target)}rowHeightChange(e,t){let n=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`)));n[e].style.height=`${t}px`}bindRowEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`)));B.call(this,this.tableWrapper.domNode,()=>{this.rowHeadWrapper.scrollTop=this.tableWrapper.domNode.scrollTop});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!0,t));for(let e of t)e.addEventListener(`mousedown`,this.handleRowMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}update(){let{rect:e,body:t}=Rn(this.tableMain);if(!t)return;let n=this.tableWrapper.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect();Object.assign(this.root.style,{top:`${Math.max(e.y,n.y)-r.y}px`,left:`${Math.max(e.x,n.x)-r.x}px`});let i=-1*this.size,a=-1*this.size;gr(this.tableMain)?(this.root.classList.add(this.bem.is(`align-right`)),i=Math.min(n.width,e.width),a=Math.min(n.width,e.width)):this.root.classList.remove(this.bem.is(`align-right`));let[o]=C(this.tableMain,K),s=!o||!(o&&o.side===`top`);s?this.root.classList.remove(this.bem.is(`caption-bottom`)):this.root.classList.add(this.bem.is(`caption-bottom`)),this.corner&&Object.assign(this.corner.style,{transform:`translateY(${-1*this.size}px) translateX(${i}px)`,top:`${s?0:e.height+this.size}px`}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:`translateX(${a}px)`}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:`${s?0:e.height+this.size}px`})}show(){this.tableCols=this.tableMain.getCols(),this.tableRows=this.tableMain.getRows(),this.root.innerHTML=``;let{rect:e,body:t}=Rn(this.tableMain);if(!t)return;let n=this.tableWrapper.domNode.getBoundingClientRect();if(this.tableCols.length>0&&this.tableRows.length>0&&(this.corner=document.createElement(`div`),this.corner.classList.add(this.bem.be(`corner`)),Object.assign(this.corner.style,{width:`${this.size}px`,height:`${this.size}px`}),this.corner.addEventListener(`click`,()=>{if(this.tableModule.tableSelection){let e=this.tableMain.descendants(U),t=this.tableModule.tableSelection;t.selectedTds=e,t.show(),t.updateWithSelectedTds()}}),this.root.appendChild(this.corner)),this.tableCols.length>0){let t=``;for(let[,n]of this.tableCols.entries()){let r=n.domNode.getBoundingClientRect().width;t+=`<div class="${this.bem.be(`col-header`)}" style="width: ${r}px">
120
+ <div class="${this.bem.be(`col-separator`)}" style="height: ${e.height+this.size-3}px"></div>
121
+ </div>`}let r=document.createElement(`div`);r.classList.add(this.bem.be(`col`));let i=document.createElement(`div`);i.classList.add(this.bem.be(`col-wrapper`)),Object.assign(r.style,{transform:`translateY(-${this.size}px)`,maxWidth:`${n.width}px`,height:`${this.size}px`}),Object.assign(i.style,{width:`${e.width}px`}),i.innerHTML=t,r.appendChild(i),this.root.appendChild(r),r.scrollLeft=this.tableWrapper.domNode.scrollLeft,this.colHeadWrapper=r,this.bindColEvents()}if(this.tableRows.length>0){let t=``;for(let[,n]of this.tableRows.entries()){let r=`${n.domNode.getBoundingClientRect().height}px`;t+=`<div class="${this.bem.be(`row-header`)}" style="height: ${Number.parseFloat(r)}px">
122
+ <div class="${this.bem.be(`row-separator`)}" style="width: ${e.width+this.size-3}px"></div>
123
+ </div>`}let r=document.createElement(`div`);r.classList.add(this.bem.be(`row`));let i=document.createElement(`div`);i.classList.add(this.bem.be(`row-wrapper`)),Object.assign(r.style,{transform:`translateX(-${this.size}px)`,width:`${this.size}px`,maxHeight:`${n.height}px`}),Object.assign(i.style,{height:`${e.height}px`}),i.innerHTML=t,r.appendChild(i),this.root.appendChild(r),r.scrollTop=this.tableWrapper.domNode.scrollTop,this.rowHeadWrapper=r,this.bindRowEvents()}this.update(),B.call(this,this.quill.root,()=>{this.update()})}hide(){this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),pn.call(this),this.resizeObserver.disconnect(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange);for(let[e,t]of this.scrollHandler)e.removeEventListener(`scroll`,t);this.root.remove()}},yr=class extends _r{constructor(e,n,r){super(e,r),this.tableModule=e,this.table=n,O(this,`colResizer`,void 0),O(this,`rowResizer`,void 0),O(this,`currentTableCell`,void 0),O(this,`dragging`,!1),O(this,`curColIndex`,-1),O(this,`curRowIndex`,-1),O(this,`tableCellBlot`,void 0),O(this,`bem`,y(`resize-line`)),O(this,`mousemoveHandler`,e=>{if(this.dragging||this.tableModule.tableSelection&&this.tableModule.tableSelection.dragging)return;let n=this.findTableCell(e);if(!n)return this.hide();let r=t.default.find(n);r&&this.currentTableCell!==n&&(this.show(),this.currentTableCell=n,this.tableCellBlot=r,this.tableMain=b(r,u.tableMain),this.tableMain.getCols().length>0&&this.updateColResizer(),this.updateRowResizer())}),O(this,`hideWhenTextChange`,()=>{this.hide()}),O(this,`handleColMouseUpFunc`,D(function*(){yield this.handleColMouseUp(),this.updateColResizer()}).bind(this)),O(this,`handleRowMouseUpFunc`,function(){this.handleRowMouseUp(),this.updateRowResizer()}.bind(this)),this.colResizer=this.tableModule.addContainer(this.bem.be(`col`)),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`)),this.table.addEventListener(`mousemove`,this.mousemoveHandler),this.quill.on(t.default.events.TEXT_CHANGE,this.hideWhenTextChange)}findTableCell(e){for(let t of e.composedPath()){if(t instanceof HTMLElement&&t.tagName===`TD`)return t;if(t===document.body)return null}return null}findCurrentColIndex(){return this.curColIndex}updateColResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.colResizer),this.colResizer=this.tableModule.addContainer(this.bem.be(`col`));let[t]=x(e,[u.tableBody]),n=t.domNode.getBoundingClientRect(),r=e.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect(),a=r.right-i.x;gr(this.tableMain)&&(a=r.left-i.x),Object.assign(this.colResizer.style,{top:`${n.y-i.y}px`,left:`${a}px`,height:`${n.height}px`});let o=this.tableMain.getCols();this.curColIndex=o.findIndex(t=>t.colId===e.colId),this.colResizer.addEventListener(`mousedown`,this.handleColMouseDownFunc),this.colResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}findCurrentRowIndex(){return this.curRowIndex}updateRowResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.rowResizer),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`));let t=e.parent;if(!(t instanceof W))return;let[n]=x(e,[u.tableBody]),r=n.domNode.getBoundingClientRect(),i=e.domNode.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:`${i.bottom-a.y}px`,left:`${r.x-a.x}px`,width:`${r.width}px`});let o=this.tableMain.getRows();this.curRowIndex=o.indexOf(t),this.rowResizer.addEventListener(`mousedown`,this.handleRowMouseDownFunc),this.rowResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}show(){this.rowResizer.classList.remove(this.bem.is(`hidden`)),this.colResizer.classList.remove(this.bem.is(`hidden`))}hide(){this.currentTableCell=void 0,this.rowResizer.classList.add(this.bem.is(`hidden`)),this.colResizer.classList.add(this.bem.is(`hidden`))}update(){this.updateColResizer(),this.updateRowResizer()}destroy(){this.colResizer.remove(),this.rowResizer.remove(),this.table.removeEventListener(`mousemove`,this.mousemoveHandler),this.quill.off(t.default.events.TEXT_CHANGE,this.hideWhenTextChange)}},br=class{constructor(e,n,r,i){this.tableModule=e,this.table=n,this.quill=r,O(this,`scrollHandler`,[]),O(this,`tableMainBlot`,null),O(this,`tableWrapperBlot`,null),O(this,`bem`,y(`scale`)),O(this,`startX`,0),O(this,`startY`,0),O(this,`offset`,6),O(this,`options`,void 0),O(this,`root`,void 0),O(this,`block`,void 0),O(this,`resizeobserver`,new ResizeObserver(()=>this.update())),O(this,`updateWhenTextChange`,()=>{this.update()}),this.options=this.resolveOptions(i),this.tableMainBlot=t.default.find(n),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.buildResizer(),this.show()),this.quill.on(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)}resolveOptions(e){return Object.assign({blockSize:12},e)}buildResizer(){if(!this.tableMainBlot||!this.tableWrapperBlot)return;this.root=this.tableModule.addContainer(this.bem.b()),this.root.classList.add(this.bem.is(`hidden`)),this.block=document.createElement(`div`),this.block.classList.add(this.bem.be(`block`)),Object.assign(this.block.style,{width:`${this.options.blockSize}px`,height:`${this.options.blockSize}px`}),this.root.appendChild(this.block);let e=[],t=[],n=n=>{if(!this.tableMainBlot)return;let r=gr(this.tableMainBlot)?-1:1,i=(n.clientX-this.startX)*r,a=n.clientY-this.startY,o=Math.floor(i/e.length),s=Math.floor(a/t.length);for(let{blot:t,width:n}of e)t.width=Math.max(n+o,d.colMinWidthPx);for(let{blot:e,height:n}of t)e.setHeight(`${Math.max(n+s,d.rowMinHeightPx)}px`)},r=()=>{e=[],t=[],document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r)};this.block.addEventListener(`mousedown`,i=>{!this.tableMainBlot||this.isTableOutofEditor()||(this.startX=i.clientX,this.startY=i.clientY,e=this.tableMainBlot.getCols().map(e=>({blot:e,width:Math.floor(e.width)})),t=this.tableMainBlot.getRows().map(e=>({blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)})),document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r))}),this.block.addEventListener(`dragstart`,e=>e.preventDefault()),this.resizeobserver.observe(this.tableMainBlot.domNode),B.call(this,this.quill.root,()=>this.update()),B.call(this,this.tableWrapperBlot.domNode,()=>this.update())}isTableOutofEditor(){if(!this.tableMainBlot||!this.tableWrapperBlot||this.tableMainBlot.full)return!1;let e=this.tableMainBlot.domNode.getBoundingClientRect(),t=this.tableWrapperBlot.domNode.getBoundingClientRect();if(e.width>t.width){for(let n of this.tableMainBlot.getCols())n.width=Math.floor(n.width/e.width*t.width);return this.tableMainBlot.colWidthFillTable(),!0}return!1}update(){if(!this.block||!this.root||!this.tableMainBlot||!this.tableWrapperBlot)return;if(this.tableMainBlot.full){this.hide();return}let{rect:e,body:t}=Rn(this.tableMainBlot);if(!t)return;let n=this.tableWrapperBlot.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect(),{scrollTop:i,scrollLeft:a}=this.tableWrapperBlot.domNode,o=this.options.blockSize*2+this.offset,s=Math.min(e.width,n.width)+o,c=Math.min(e.height,n.height)+o;Object.assign(this.root.style,{width:`${s}px`,height:`${c}px`,left:`${Math.max(e.x,n.x)-r.x-this.options.blockSize}px`,top:`${Math.max(e.y,n.y)-r.y-this.options.blockSize}px`});let l={left:`${e.width+o-a}px`,top:`${c-i}px`};gr(this.tableMainBlot)?(this.root.classList.add(this.bem.is(`align-right`)),l.left=`${this.options.blockSize+-1*a}px`):this.root.classList.remove(this.bem.is(`align-right`)),Object.assign(this.block.style,l)}show(){this.root&&(this.root.classList.remove(this.bem.is(`hidden`)),this.update())}hide(){this.root&&this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect(),this.root&&this.root.remove(),pn.call(this)}},xr=class{constructor(e,n,r,i){this.quill=e,this.isVertical=n,this.table=r,this.scrollbarContainer=i,O(this,`minSize`,20),O(this,`gap`,4),O(this,`move`,0),O(this,`cursorDown`,!1),O(this,`cursorLeave`,!1),O(this,`ratioY`,1),O(this,`ratioX`,1),O(this,`sizeWidth`,``),O(this,`sizeHeight`,``),O(this,`size`,``),O(this,`thumbState`,{X:0,Y:0}),O(this,`ob`,void 0),O(this,`container`,void 0),O(this,`scrollbar`,void 0),O(this,`thumb`,document.createElement(`div`)),O(this,`scrollHandler`,[]),O(this,`propertyMap`,void 0),O(this,`bem`,y(`scrollbar`)),O(this,`tableMainBlot`,void 0),O(this,`showScrollbar`,vn(()=>{this.cursorLeave=!1,this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.style.display=this.size?`block`:`none`,requestAnimationFrame(()=>{this.scrollbar.classList.remove(this.bem.is(`transparent`))})},200)),O(this,`hideScrollbar`,vn(()=>{this.cursorLeave=!0,!this.cursorDown&&(this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.addEventListener(`transitionend`,this.hideScrollbarTransitionend,{once:!0}),this.scrollbar.classList.add(this.bem.is(`transparent`)))},200)),O(this,`hideScrollbarTransitionend`,()=>{this.scrollbar.style.display=this.cursorDown&&this.size?`block`:`none`}),this.tableMainBlot=t.default.find(this.table),this.container=r.parentElement,this.propertyMap=this.isVertical?{size:`height`,offset:`offsetHeight`,scrollDirection:`scrollTop`,scrollSize:`scrollHeight`,axis:`Y`,direction:`top`,client:`clientY`}:{size:`width`,offset:`offsetWidth`,scrollDirection:`scrollLeft`,scrollSize:`scrollWidth`,axis:`X`,direction:`left`,client:`clientX`},this.calculateSize(),this.ob=new ResizeObserver(()=>{this.update()}),this.ob.observe(r),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),B.call(this,this.quill.root,()=>this.setScrollbarPosition()),this.showScrollbar()}update(){this.calculateSize(),this.setScrollbarPosition()}setScrollbarPosition(){let{rect:{width:e,height:t},body:n}=Rn(this.tableMainBlot);if(!n)return;let{scrollLeft:r,scrollTop:i,offsetLeft:a,offsetTop:o}=this.quill.root,{offsetLeft:s,offsetTop:c}=this.container,{offsetLeft:l,offsetTop:u}=n.domNode,{width:d,height:f}=this.container.getBoundingClientRect(),p=s+l-a,m=c+u-o;this.isVertical?p+=Math.min(d,e):m+=Math.min(f,t),this.tableMainBlot&&this.tableMainBlot.align!==`left`&&(p+=this.table.offsetLeft-s),Object.assign(this.scrollbar.style,{[this.propertyMap.size]:`${this.isVertical?Math.min(f,t):d}px`,transform:`translate(${p-r}px, ${m-i}px)`}),this.containerScrollHandler(this.container)}calculateSize(){let e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=Math.pow(e,2)/this.container.scrollHeight,r=Math.pow(t,2)/this.container.scrollWidth,i=Math.max(n,this.minSize),a=Math.max(r,this.minSize);this.ratioY=n/(e-n)/(i/(e-i)),this.ratioX=r/(t-r)/(a/(t-a)),this.sizeWidth=a+this.gap<t?`${a}px`:``,this.sizeHeight=i+this.gap<e?`${i}px`:``,this.size=this.isVertical?this.sizeHeight:this.sizeWidth}createScrollbar(){let e=document.createElement(`div`);e.classList.add(this.bem.b()),e.classList.add(this.isVertical?this.bem.is(`vertical`):this.bem.is(`horizontal`),this.bem.is(`transparent`)),Object.assign(e.style,{display:`none`}),this.thumb.classList.add(this.bem.be(`thumb`));let t=null,n=e=>{if(this.cursorDown===!1)return;let t=this.thumbState[this.propertyMap.axis];if(!t)return;let n=Math.pow(this.scrollbar[this.propertyMap.offset],2)/this.container[this.propertyMap.scrollSize]/(this.isVertical?this.ratioY:this.ratioX)/this.thumb[this.propertyMap.offset],r=(this.scrollbar.getBoundingClientRect()[this.propertyMap.direction]-e[this.propertyMap.client])*-1,i=this.thumb[this.propertyMap.offset]-t,a=(r-i)*100*n/this.scrollbar[this.propertyMap.offset];this.container[this.propertyMap.scrollDirection]=a*this.container[this.propertyMap.scrollSize]/100},r=()=>{this.thumbState[this.propertyMap.axis]=0,this.cursorDown=!1,document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r),this.cursorLeave&&this.hideScrollbar(),document.onselectstart=t},i=e=>{e.stopImmediatePropagation(),this.cursorDown=!0,document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r),t=document.onselectstart,document.onselectstart=()=>!1};this.thumb.addEventListener(`mousedown`,e=>{var t;if(e.stopPropagation(),e.ctrlKey||[1,2].includes(e.button))return;(t=window.getSelection())==null||t.removeAllRanges(),i(e);let n=e.currentTarget;n&&(this.thumbState[this.propertyMap.axis]=n[this.propertyMap.offset]-(e[this.propertyMap.client]-n.getBoundingClientRect()[this.propertyMap.direction]))});let a=[this.table,e];for(let e of a)e.addEventListener(`mouseenter`,this.showScrollbar),e.addEventListener(`mouseleave`,this.hideScrollbar);return B.call(this,this.container,()=>{this.containerScrollHandler(this.container)}),e.appendChild(this.thumb),e}containerScrollHandler(e){let t=e[this.propertyMap.offset]-this.gap;this.move=e[this.propertyMap.scrollDirection]*100/t*(this.isVertical?this.ratioY:this.ratioX),Object.assign(this.thumb.style,{[this.propertyMap.size]:this.size,transform:`translate${this.propertyMap.axis}(${this.move}%)`})}destroy(){this.ob.disconnect(),pn.call(this),this.table.removeEventListener(`mouseenter`,this.showScrollbar),this.table.removeEventListener(`mouseleave`,this.hideScrollbar)}},Sr=class{constructor(e,n,r){this.tableModule=e,this.table=n,this.quill=r,O(this,`scrollbarContainer`,void 0),O(this,`scrollbar`,void 0),O(this,`bem`,y(`scrollbar`)),O(this,`updateWhenTextChange`,()=>{this.update()}),this.scrollbarContainer=this.tableModule.addContainer(this.bem.be(`container`)),this.scrollbar=[new xr(r,!0,n,this.scrollbarContainer),new xr(r,!1,n,this.scrollbarContainer)];for(let e of this.scrollbar)this.scrollbarContainer.appendChild(e.scrollbar);this.quill.on(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)}hide(){for(let e of this.scrollbar)e.hideScrollbar()}show(){for(let e of this.scrollbar)e.showScrollbar()}update(){for(let e of this.scrollbar)e.calculateSize(),e.setScrollbarPosition()}destroy(){this.scrollbarContainer.remove(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange);for(let e of this.scrollbar)e.destroy()}};let Cr=0;var wr=class{constructor(e,n,r={}){this.tableModule=e,this.quill=n,O(this,`options`,void 0),O(this,`boundary`,null),O(this,`startScrollX`,0),O(this,`startScrollY`,0),O(this,`selectedTableScrollX`,0),O(this,`selectedTableScrollY`,0),O(this,`selectedEditorScrollX`,0),O(this,`selectedEditorScrollY`,0),O(this,`selectedTds`,[]),O(this,`cellSelectWrap`,void 0),O(this,`cellSelect`,void 0),O(this,`dragging`,!1),O(this,`scrollHandler`,[]),O(this,`tableMenu`,void 0),O(this,`resizeObserver`,void 0),O(this,`table`,void 0),O(this,`isDisplaySelection`,!1),O(this,`bem`,y(`selection`)),O(this,`lastSelection`,{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}),O(this,`updateAfterEvent`,()=>{this.updateWithSelectedTds()}),O(this,`quillSelectionChangeHandler`,(e,n,r)=>{if(r!==t.default.sources.API&&e&&!this.quill.composition.isComposing&&this.selectedTds.length>0){let t=this.quill.getFormat(e),[n]=this.quill.getLine(e.index),r=!!t[u.tableCellInner]&&!!n,i=this.selectedTds.some(e=>e.children.contains(n));if(r&&!i)try{let e=b(n,u.tableCellInner);this.selectedTds=[e],this.updateWithSelectedTds()}catch(e){}else r&&i||this.hide()}}),O(this,`selectionChangeHandler`,()=>{let e=window.getSelection();if(!e)return;let{anchorNode:n,focusNode:r,anchorOffset:i,focusOffset:a}=e;if(!n||!r)return;let o=t.default.find(n),s=t.default.find(r);if(!o||!s||o.scroll!==this.quill.scroll||s.scroll!==this.quill.scroll)return;let c=S(o),l=S(s),d=c.has(u.tableColgroup),f=l.has(u.tableColgroup);if(d||f){let t=n,o=i,s=r,p=a;if(d){let e=c.get(u.tableWrapper),n=e.descendants(U);n.length>0&&(t=n[0].domNode,o=0)}if(f){let e=l.get(u.tableWrapper),t=e.descendants(U);t.length>0&&(s=t[0].domNode,p=0)}this.setSelectionData(e,{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:p});return}let p=c.has(u.tableCellInner),m=l.has(u.tableCellInner),h=p&&m;if(h){let e=c.get(u.tableCellInner),t=l.get(u.tableCellInner);h&&(h=e!==t)}if(p&&m&&h||!p&&m||!m&&p){this.setSelectionData(e,this.lastSelection),this.selectedTds.length>0&&this.hide();return}this.lastSelection={anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:a}}),O(this,`mouseDownHandler`,e=>{let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`.ql-table`),o=n.closest(`tbody`);if(t!==0||!a||!o)return;this.setSelectionTable(a);let s=a.dataset.tableId,c={x:r,y:i};this.selectedTds=this.computeSelectedTds(c,c),this.dragging=!0,this.show();let l=e=>{this.tableMenu&&this.tableMenu.hide(),this.tableModule.tableResize&&this.tableModule.tableResize.hide();let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`tbody`);if(t!==0||!a||a.dataset.tableId!==s)return;let o={x:r,y:i};this.selectedTds=this.computeSelectedTds(c,o),this.selectedTds.length>1&&this.quill.blur(),this.update()},u=()=>{document.body.removeEventListener(`mousemove`,l,!1),document.body.removeEventListener(`mouseup`,u,!1),this.dragging=!1,this.tableMenu&&this.selectedTds.length>0&&this.tableMenu.show()};document.body.addEventListener(`mousemove`,l,!1),document.body.addEventListener(`mouseup`,u,!1)}),O(this,`removeCell`,e=>{let n=this.quill.getSelection();if(!(n||e.key!==`Backspace`&&e.key!==`Delete`)){for(let e of this.selectedTds)e.deleteAt(0,e.length()-1);if(this.table){let e=t.default.find(this.table),n=e.descendants(U);this.selectedTds.length===n.length&&e.remove()}}}),this.options=this.resolveOptions(r),this.cellSelectWrap=e.addContainer(this.bem.b()),this.cellSelect=this.helpLinesInitial(),this.resizeObserver=fn(()=>this.updateAfterEvent(),{ignoreFirstBind:!0}),this.resizeObserver.observe(this.quill.root),this.quill.root.addEventListener(`mousedown`,this.mouseDownHandler,{passive:!1}),document.addEventListener(`selectionchange`,this.selectionChangeHandler,{passive:!1}),this.quill.on(f.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.on(t.default.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.on(t.default.events.TEXT_CHANGE,this.updateAfterEvent),this.options.tableMenu&&(this.tableMenu=new this.options.tableMenu(e,n,this.options.tableMenuOptions)),this.hide()}getFirstTextNode(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.TEXT_NODE)return t;return e}getLastTextNode(e){for(let t=e.childNodes.length-1;t>=0;t--){let n=e.childNodes[t];if(n.nodeType===Node.TEXT_NODE)return n}return e}getNodeTailOffset(e){let t=document.createRange();return t.selectNodeContents(e),t.collapse(!1),t.startOffset}setSelectionData(e,t){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t;if(!n||!i)return;let o=document.createRange(),s=this.selectionDirectionUp(t);s?(o.setStart(n,r),o.setEnd(n,r)):(o.setStart(n,r),o.setEnd(i,a)),e.removeAllRanges(),e.addRange(o),s&&e.extend(i,a)}selectionDirectionUp(e){let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:i}=e;if(!t||!r)return!1;if(t===r)return n>i;let a=t.compareDocumentPosition(r);return a&Node.DOCUMENT_POSITION_CONTAINS||a&Node.DOCUMENT_POSITION_CONTAINED_BY?(a&Node.DOCUMENT_POSITION_FOLLOWING)!==0:(a&Node.DOCUMENT_POSITION_PRECEDING)!==0}findWrapSelection(e){let t=null,n=0,r=null,i=0;for(let{node:a,offset:o}of e)a&&((!t||this.selectionDirectionUp({anchorNode:t,anchorOffset:n,focusNode:a,focusOffset:o}))&&(t=a,n=o),(!r||this.selectionDirectionUp({anchorNode:a,anchorOffset:o,focusNode:r,focusOffset:i}))&&(r=a,i=o));return{startNode:t,startOffset:n,endNode:r,endOffset:i}}resolveOptions(e){return Object.assign({selectColor:`#0589f340`,tableMenuOptions:{}},e)}helpLinesInitial(){this.cellSelectWrap.style.setProperty(`--select-color`,this.options.selectColor);let e=document.createElement(`div`);return e.classList.add(this.bem.be(`line`)),this.cellSelectWrap.appendChild(e),e}computeSelectedTds(e,n){if(!this.table)return[];let r=t.default.find(this.table);if(!r)return[];let i=r.descendants(G)[0];if(!i)return[];let a=new Set(i.descendants(q).map((e,t)=>(e.index=t,e))),{x:o,y:s}=this.getTableViewScroll(),{x:c,y:l}=this.getQuillViewScroll();this.selectedTableScrollX=o,this.selectedTableScrollY=s,this.selectedEditorScrollX=c,this.selectedEditorScrollY=l;let{rect:u}=Rn(r),d=e.x-o+this.startScrollX,f=e.y-s+this.startScrollY,p={x:Math.max(u.left,Math.min(n.x,d)),y:Math.max(u.top,Math.min(n.y,f)),x1:Math.min(u.right,Math.max(n.x,d)),y1:Math.min(u.bottom,Math.max(n.y,f))},m=new Set,h=!0;for(;h;){h=!1;for(let e of a){e.__rect||(e.__rect=e.domNode.getBoundingClientRect());let{x:t,y:n,right:r,bottom:i}=e.__rect;if(cn({x:Math.floor(p.x),y:Math.floor(p.y),x1:Math.floor(p.x1),y1:Math.floor(p.y1)},{x:Math.floor(t),y:Math.floor(n),x1:Math.floor(r),y1:Math.floor(i)},Cr,m.size===0)){m.add(e),a.delete(e),p={x:Math.min(p.x,t),y:Math.min(p.y,n),x1:Math.max(p.x1,r),y1:Math.max(p.y1,i)},h=!0;break}}}for(let e of[...m,...a])delete e.__rect;return this.boundary=ln(k(k({},p),{},{width:p.x1-p.x,height:p.y1-p.y}),this.quill.root),Array.from(m).sort((e,t)=>e.index-t.index).map(e=>(delete e.index,e.getCellInner()))}updateWithSelectedTds(){if(this.selectedTds.length<=0)return;let e={x:1/0,y:1/0},t={x:-1/0,y:-1/0};for(let n of this.selectedTds){let r=n.domNode.getBoundingClientRect();e.x=Math.min(e.x,r.left),e.y=Math.min(e.y,r.top),t.x=Math.max(t.x,r.right),t.y=Math.max(t.y,r.bottom)}this.selectedTds=this.computeSelectedTds(e,t),this.selectedTds.length>0?this.update():this.hide()}update(){if(this.selectedTds.length===0||!this.boundary||!this.table)return;let{x:e,y:t}=this.getQuillViewScroll(),{x:n,y:r}=this.getTableViewScroll(),i=this.table.parentElement.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect(),o=i.x-a.x,s=i.y-a.y;this.startScrollX=n,this.startScrollY=r,Object.assign(this.cellSelect.style,{left:`${this.selectedEditorScrollX*2-e+this.boundary.x+this.selectedTableScrollX-n-o}px`,top:`${this.selectedEditorScrollY*2-t+this.boundary.y+this.selectedTableScrollY-r-s}px`,width:`${this.boundary.width}px`,height:`${this.boundary.height}px`}),Object.assign(this.cellSelectWrap.style,{left:`${o}px`,top:`${s}px`,width:`${i.width}px`,height:`${i.height}px`}),!this.dragging&&this.tableMenu&&this.tableMenu.update()}getQuillViewScroll(){return{x:this.quill.root.scrollLeft,y:this.quill.root.scrollTop}}getTableViewScroll(){return this.table?{x:this.table.parentElement.scrollLeft,y:this.table.parentElement.scrollTop}:{x:0,y:0}}setSelectionTable(e){this.table!==e&&(this.table=e)}showDisplay(){Object.assign(this.cellSelectWrap.style,{display:`block`}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}show(){this.table&&(pn.call(this),this.update(),this.showDisplay(),document.addEventListener(`keydown`,this.removeCell),B.call(this,this.quill.root,()=>{this.update()}),B.call(this,this.table.parentElement,()=>{this.update()}))}hideDisplay(){Object.assign(this.cellSelectWrap.style,{display:`none`}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}hide(){pn.call(this),document.removeEventListener(`keydown`,this.removeCell),this.hideDisplay(),this.boundary=null,this.selectedTds=[],this.setSelectionTable(void 0),this.tableMenu&&this.tableMenu.hide()}destroy(){this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),this.tableMenu&&this.tableMenu.destroy(),pn.call(this),this.quill.root.removeEventListener(`mousedown`,this.mouseDownHandler),document.removeEventListener(`selectionchange`,this.selectionChangeHandler),this.quill.off(t.default.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.off(t.default.events.TEXT_CHANGE,this.updateAfterEvent),this.quill.on(f.AFTER_TABLE_RESIZE,this.updateAfterEvent)}};let Tr=[`attributes`],Er=[`style`],Dr=t.default.import(`parchment`),Or=t.default.import(`delta`),kr=t.default.import(`blots/break`),Ar=t.default.import(`ui/icons`);function jr(e,{tableId:t,rowId:n,colId:r}){let i={tableId:t,rowId:n,colId:r,colspan:1,rowspan:1},a=e.create(u.tableCell,i),o=e.create(u.tableCellInner,i),s=e.create(`block`);return s.appendChild(e.create(`break`)),o.appendChild(s),a.appendChild(o),a}function Mr(e){g.delete(u.tableCellInner),Object.assign(u,e.blotName||{}),Object.assign(d,e.tableUpSize||{}),Object.assign(f,e.tableUpEvent||{}),Object.assign(p,e.tableUpInternal||{}),Fr.moduleName=p.moduleName,Fr.toolName=u.tableWrapper,H.blotName=u.container,Z.blotName=u.tableWrapper,Y.blotName=u.tableMain,X.blotName=u.tableColgroup,J.blotName=u.tableCol,G.blotName=u.tableBody,W.blotName=u.tableRow,q.blotName=u.tableCell,U.blotName=u.tableCellInner,g.add(u.tableCellInner)}function Nr(e,t){return be({onSelect:(n,r)=>{e.insertTable(n,r),t&&t.close()},customBtn:e.options.customBtn,texts:e.options.texts})}function Pr(e){return{bindInHead:!1,key:e?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[u.tableCellInner],handler(n,r){let i,a,o,s;try{[i,a,o,s]=x(r.line,[u.tableWrapper,u.tableMain,u.tableRow,u.tableCell])}catch(e){return!0}let c=a.getColIds(),l=e?`prev`:`next`,d=e?`tail`:`head`,f=i.descendants(K,0)[0],p;if(f){let e=window.getComputedStyle(f.domNode);p=l===`next`&&e.captionSide===`bottom`?f:l===`next`?i.next:f}else p=i[l];if(r.line[l]||!p)return!0;let m=o[l];if(m){let e=c.indexOf(s.colId),n=m.getCellByColId(c[e],l);if(!n)return!0;let i=n.children[d];i.children&&(i=i.children[d]);let a=i.offset(this.quill.scroll)+Math.min(r.offset,i.length()-1);this.quill.setSelection(a,0,t.default.sources.USER)}else{let n=p.offset(this.quill.scroll)+(e?p.length()-1:0);this.quill.setSelection(n,0,t.default.sources.USER)}return!1}}}var Fr=class e{static register(){Z.allowedChildren=[Y],Y.allowedChildren=[G,X,K],Y.requiredContainer=Z,K.requiredContainer=Y,X.allowedChildren=[J],X.requiredContainer=Y,G.allowedChildren=[W],G.requiredContainer=Y,W.allowedChildren=[q],q.requiredContainer=G,q.allowedChildren=[U,kr],q.requiredContainer=W,U.requiredContainer=q;let e=[`header`,`list`,`blockquote`,`code-block`].reduce((e,n)=>{let r=`formats/${n}`,i=t.default.import(r);return e[r]=class extends te(i,[On]){static register(){}},e},{});t.default.register(k(k({"blots/scroll":jn,"blots/block":On},e),{},{[`blots/${u.container}`]:H,[`formats/${u.tableCell}`]:q,[`formats/${u.tableCellInner}`]:U,[`formats/${u.tableRow}`]:W,[`formats/${u.tableBody}`]:G,[`formats/${u.tableCol}`]:J,[`formats/${u.tableColgroup}`]:X,[`formats/${u.tableCaption}`]:K,[`formats/${u.tableMain}`]:Y,[`formats/${u.tableWrapper}`]:Z,"modules/clipboard":Jn}),!0)}get statics(){return this.constructor}constructor(n,r){if(O(this,`quill`,void 0),O(this,`options`,void 0),O(this,`toolBox`,void 0),O(this,`fixTableByLisenter`,vn(this.balanceTables,100)),O(this,`selector`,void 0),O(this,`table`,void 0),O(this,`tableSelection`,void 0),O(this,`tableResize`,void 0),O(this,`tableScrollbar`,void 0),O(this,`tableAlign`,void 0),O(this,`tableResizeScale`,void 0),O(this,`resizeOb`,void 0),this.quill=n,this.options=this.resolveOptions(r||{}),this.toolBox=this.initialContainer(),!this.options.scrollbar){let e=y(`scrollbar`);this.quill.container.classList.add(e.bm(`origin`))}this.options.selection&&(this.tableSelection=new this.options.selection(this,this.quill,this.options.selectionOptions));let i=this.quill.getModule(`toolbar`);if(i&&this.quill.theme.pickers){let[,e]=(i.controls||[]).find(([e])=>e===this.statics.toolName)||[];if(e&&e.tagName.toLocaleLowerCase()===`select`){let t=this.quill.theme.pickers.find(t=>t.select===e);t&&(t.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,t),t.label.addEventListener(`mousedown`,()=>{if(!this.selector||!t)return;let e=this.selector.getBoundingClientRect(),{leftLimited:n}=dn(e);if(n){let e=t.label.getBoundingClientRect();Object.assign(t.options.style,{transform:`translateX(calc(-100% + ${e.width}px))`})}else Object.assign(t.options.style,{transform:void 0})}))}}let a=this.quill.getModule(`keyboard`);for(let t of Object.values(e.keyboradHandler))t.bindInHead?a.bindings[t.key].unshift(t):a.addBinding(t.key,t);this.quill.root.addEventListener(`click`,e=>{let t=e.composedPath();if(!t||t.length<=0)return;let n=t.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));if(n){if(this.table===n){this.tableSelection&&this.tableSelection.show(),this.tableAlign&&this.tableAlign.update(),this.tableResize&&this.tableResize.update(),this.tableScrollbar&&this.tableScrollbar.update();return}this.table&&this.hideTableTools(),this.showTableTools(n)}else this.table&&this.hideTableTools()},!1),this.quill.on(t.default.events.EDITOR_CHANGE,e=>{e===t.default.events.TEXT_CHANGE&&(!this.table||!this.quill.root.contains(this.table))&&this.hideTableTools()}),this.quillHack(),this.listenBalanceCells()}initialContainer(){let e=y(`toolbox`),t=this.quill.addContainer(e.b()),n=()=>{let e=this.quill.root.getBoundingClientRect(),{offsetLeft:n,offsetTop:r}=this.quill.root;Object.assign(t.style,{top:`${r}px`,left:`${n}px`,width:`${e.width}px`,height:`${e.height}px`})};return this.resizeOb=new ResizeObserver(n),this.resizeOb.observe(this.quill.root),t}addContainer(e){if(le(e)){let t=document.createElement(`div`);for(let n of e.split(` `))t.classList.add(n);return this.toolBox.appendChild(t),t}else return this.toolBox.appendChild(e),e}resolveOptions(e){return Object.assign({customBtn:!1,texts:this.resolveTexts(e.texts||{}),full:!1,fullSwitch:!0,icon:Ar.table,selectionOptions:{},alignOptions:{},scrollbarOptions:{},resizeOptions:{},resizeScaleOptions:{}},e)}resolveTexts(e){return Object.assign({fullCheckboxText:`Insert full width table`,customBtnText:`Custom`,confirmText:`Confirm`,cancelText:`Cancel`,rowText:`Row`,colText:`Column`,notPositiveNumberError:`Please enter a positive integer`,custom:`Custom`,clear:`Clear`,transparent:`Transparent`,perWidthInsufficient:`The percentage width is insufficient. To complete the operation, the table needs to be converted to a fixed width. Do you want to continue?`,CopyCell:`Copy cell`,CutCell:`Cut cell`,InsertTop:`Insert row above`,InsertRight:`Insert column right`,InsertBottom:`Insert row below`,InsertLeft:`Insert column Left`,MergeCell:`Merge Cell`,SplitCell:`Split Cell`,DeleteRow:`Delete Row`,DeleteColumn:`Delete Column`,DeleteTable:`Delete table`,BackgroundColor:`Set background color`,BorderColor:`Set border color`},e)}quillHack(){let e=this.quill.getSemanticHTML;this.quill.getSemanticHTML=(n=0,r)=>{let i=e.call(this.quill,n,r),a=t.default.import(`formats/${u.tableWrapper}`),o=new DOMParser,s=o.parseFromString(i,`text/html`);for(let e of Array.from(s.querySelectorAll(`.${a.className} caption[contenteditable], .${a.className} td > [contenteditable]`)))e.removeAttribute(`contenteditable`);return s.body.innerHTML};let n=this.quill.format;this.quill.format=function(e,r,i=t.default.sources.API){let a=this.scroll.query(e);if(!(a.prototype instanceof Dr.EmbedBlot)){let t=this.getModule(p.moduleName),a=this.getSelection(!0),o=this.getFormat(a);if(!o[u.tableCellInner]||a.length>0||t&&t.tableSelection&&t.tableSelection.selectedTds.length<=1)return n.call(this,e,r,i);if(t&&t.tableSelection&&t.tableSelection.selectedTds.length>0){let n=t.tableSelection.selectedTds,a=!1,o=[];for(let t of n){let n=t.offset(this.scroll),i=t.length();o.push({index:n,length:i});let s=this.getFormat(n,i);s[e]!==r&&(a=!0)}let s=a?r:!1,c=new Or;for(let[t,{index:n,length:r}]of o.entries()){let i=t===0?0:o[t-1].index+o[t-1].length;c.retain(n-i).retain(r,{[e]:s})}let l=this.updateContents(c,i);return this.blur(),l}}return n.call(this,e,r,i)};let r=this.quill.theme.modules.toolbar;if(r){var i;let e=(i=r.handlers)==null?void 0:i.clean;if(e){let n=(e,t,n=()=>``)=>{let r=this.quill.getText(e,t),[i,a]=this.quill.getLine(e+t),o=0,s=new Or;i!=null&&(o=i.length()-a,s=i.delta().slice(a,a+o-1).insert(`
124
+ `));let c=this.quill.getContents(e,t+o),l=c.diff(new Or().insert(r).concat(s)),d=0,f=l.ops.map(e=>{let{attributes:t}=e,r=N(e,Tr);if(e.insert?d-=le(e.insert)?e.insert.length:1:e.retain?d+=ue(e.retain)?e.retain:1:e.delete&&(d+=e.delete),t){let e=u.tableCellInner,{[e]:i}=t,a=N(t,[e].map(Ce));if(n){let e=c.slice(d-1,d).ops[0];if(e&&e.attributes&&e.attributes[u.tableCellInner]){let t=e.attributes[u.tableCellInner],{style:i}=t,o=N(t,Er),s=n(i);return s?k(k({},r),{},{attributes:k(k({},a),{},{[u.tableCellInner]:k({style:s},o)})}):k(k({},r),{},{attributes:k(k({},a),{},{[u.tableCellInner]:o})})}}return k(k({},r),{},{attributes:k({},a)})}return e});return new Or(f)};r.handlers.clean=function(r){let i=this.quill.getModule(p.moduleName),a=this.quill.getSelection();if(a&&a.length>0){let e=this.quill.getFormat(a);if(e[u.tableCellInner]){let e=n(a.index,a.length,!1),r=new Or().retain(a.index).concat(e);this.quill.updateContents(r,t.default.sources.USER);return}}if(i&&i.tableSelection&&i.tableSelection.selectedTds.length>0&&i.tableSelection.table){let e=t.default.find(i.tableSelection.table);if(!e){console.warn(`TableMainFormat not found`);return}let r=i.tableSelection.selectedTds,a=new Set,o=[];for(let e of r)if(e.parent instanceof q){for(let t of e.parent.getNearByCell(`top`)){if(a.has(t))continue;a.add(t),o.push({td:t,cleanBorder:`bottom`})}for(let t of e.parent.getNearByCell(`left`)){if(a.has(t))continue;a.add(t),o.push({td:t,cleanBorder:`right`})}a.add(e.parent),o.push({td:e.parent,cleanBorder:!0})}let s=e.descendants(q),c=new Map(s.map((e,t)=>[e,t]));o.sort((e,t)=>c.get(e.td)-c.get(t.td));let l=new Or,u=0;for(let{td:e,cleanBorder:t}of o){let r=e.getCellInner().offset(this.quill.scroll),i=e.getCellInner().length(),a=n(r,i-1,e=>{if(!e||t===!0)return``;let n=mn(e),r=Object.keys(n).filter(e=>!e.startsWith(_n(`border-${t}`))).reduce((e,t)=>(e[t]=n[t],e),{});return hn(r)}),o=new Or().retain(r-u).concat(a);l=l.concat(o),u=r+i}this.quill.updateContents(l,t.default.sources.USER),r.length>1&&this.quill.blur();return}return e.call(this,r)}}}}showTableTools(e){if(e){var t;this.table=e,(t=this.tableSelection)==null||t.show(),this.options.align&&(this.tableAlign=new this.options.align(this,e,this.quill,this.options.alignOptions)),this.options.scrollbar&&(this.tableScrollbar=new this.options.scrollbar(this,e,this.quill,this.options.scrollbarOptions)),this.options.resize&&(this.tableResize=new this.options.resize(this,e,this.quill,this.options.resizeOptions)),this.options.resizeScale&&(this.tableResizeScale=new this.options.resizeScale(this,e,this.quill,this.options.resizeScaleOptions))}}hideTableTools(){var e;(e=this.tableSelection)==null||e.hide(),this.tableScrollbar&&(this.tableScrollbar.destroy(),this.tableScrollbar=void 0),this.tableAlign&&(this.tableAlign.destroy(),this.tableAlign=void 0),this.tableResize&&(this.tableResize.destroy(),this.tableResize=void 0),this.tableResizeScale&&this.tableResizeScale.destroy(),this.table=void 0}buildCustomSelect(e,t){var n=this;return D(function*(){if(!e||!se(e))return;let r=document.createElement(`div`);if(r.classList.add(`ql-custom-select`),n.selector=yield e(n,t),r.appendChild(n.selector),n.options.fullSwitch){let e=y(`creator`),t=document.createElement(`label`);t.classList.add(e.be(`checkbox`));let i=document.createElement(`input`);i.type=`checkbox`,i.checked=n.options.full,i.addEventListener(`change`,()=>{n.options.full=i.checked});let a=document.createElement(`span`);a.textContent=n.options.texts.fullCheckboxText,t.appendChild(i),t.appendChild(a),r.appendChild(t)}t.options.innerHTML=``,t.options.appendChild(r)})()}setCellAttrs(e,t,n,r=!1){if(e.length!==0)for(let i of e)i.setFormatValue(t,n,r)}getTextByCell(e){let t=``;for(let n of e){let e=n.offset(this.quill.scroll),r=n.length();for(let n of this.quill.getContents(e,r).ops)le(n.insert)&&(t+=n.insert)}return t}getHTMLByCell(e,t=!1){if(e.length===0)return``;let n=null;try{for(let t of e){let e=b(t,u.tableMain);if(n||(n=e),e!==n)return console.error(`tableMain is not same`),``}}catch(e){return console.error(`tds must be in same tableMain`),``}if(!n)return``;let r=this.quill.getIndex(n),i=n.length(),a=this.quill.getSemanticHTML(r,i),o=new DOMParser,s=o.parseFromString(a,`text/html`),c=[],l=new Set,d=new Set;for(let t of e)l.add(t.colId),d.add(`${t.rowId}-${t.colId}`);for(let e of Array.from(s.querySelectorAll(`col`)))l.has(e.dataset.colId)?c.push(e.getAttribute(`width`)):e.remove();let f=0,p=null;for(let e of Array.from(s.querySelectorAll(`td`)))if(d.has(`${e.dataset.rowId}-${e.dataset.colId}`))p!==e.dataset.rowId&&(f+=1,p=e.dataset.rowId);else{let t=e.parentElement;e.remove(),t&&t.children.length<=0&&t.remove()}let m=Array.from(s.querySelectorAll(`col`)),h=m.map(e=>J.value(e));if(n.full){let e=h.reduce((e,t)=>t.width+e,0);for(let[t,n]of h.entries())n.width=Math.round(n.width/e*100),m[t].setAttribute(`width`,`${n.width}%`)}else{let e=0;for(let t of h)e+=t.width;let t=s.querySelector(`table`);t.style.width=`${e}px`}if(t){let t=n.getRows();if(f===t.length)this.removeCol(e);else for(let t of e)t.domNode.innerHTML=`<p><br></p>`}return s.body.innerHTML}insertTable(e,n){if(e>=30||n>=30)throw Error(`Both rows and columns must be less than 30.`);this.quill.focus();let r=this.quill.getSelection();if(r==null)return;let[i]=this.quill.getLeaf(r.index);if(!i)return;if(v(i))throw Error(`Not supported ${i.statics.blotName} insert into table.`);let a=this.calculateTableCellBorderWidth(),o=getComputedStyle(this.quill.root),s=Number.parseInt(o.paddingLeft),c=Number.parseInt(o.paddingRight),l=Number.parseInt(o.width)-s-c-a,f=V(),p=Array(n).fill(0).map(()=>V()),m=this.options.full?`${Math.max(1/n*100,d.colMinWidthPre)}%`:`${Math.max(Math.floor(l/n),d.colMinWidthPx)}px`,h=[{retain:r.index}],g=this.quill.getContents(r.index,1),[,_]=this.quill.getLine(r.index);g.ops[0].insert!==`
125
+ `&&_!==0&&h.push({insert:`
126
+ `});for(let e=0;e<n;e++)h.push({insert:{[u.tableCol]:{width:m,tableId:f,colId:p[e],full:this.options.full}}});for(let t=0;t<e;t++){let e=V();for(let t=0;t<n;t++)h.push({insert:`
127
+ `,attributes:{[u.tableCellInner]:{tableId:f,rowId:e,colId:p[t],rowspan:1,colspan:1}}})}this.quill.updateContents(new Or(h),t.default.sources.USER),this.quill.setSelection(r.index+n,t.default.sources.SILENT),this.quill.focus()}calculateTableCellBorderWidth(){let e=`
128
+ <table class="${Y.className}">
129
+ <tbody>
130
+ <tr>
131
+ <td class="${q.className}"></td>
132
+ </tr>
133
+ </tbody>
134
+ </table>
135
+ `,t=document.createElement(`div`);t.className=Z.className,t.innerHTML=e,t.style.position=`absolute`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.visibility=`hidden`,this.quill.root.appendChild(t);let n=window.getComputedStyle(t.querySelector(`td`)),r=Number.parseFloat(n.borderWidth)||0;return this.quill.root.removeChild(t),r}fixUnusuaDeletelTable(e){let t=e.getRows(),n=e.getColIds();if(t.length===0)return e.remove();if(n.length===0)return;let r=Array(t.length).fill(0).map(()=>Array(n.length).fill(!1)),i=e.tableId;for(let[e,a]of t.entries()){let o=0,s=0,c=r[e],l=a.descendants(q);for(;s<n.length;){if(c[s]){s+=1;continue}let u=l[o];if(!u||u.colId!==n[s])a.insertBefore(jr(this.quill.scroll,{tableId:i,colId:n[s],rowId:a.rowId}),u);else{e+u.rowspan-1>=t.length&&(u.getCellInner().rowspan=t.length-e);let{colspan:n,rowspan:i}=u;if(n>1)for(let e=1;e<n;e++)c[s+e]=!0;if(i>1)for(let t=e+1;t<e+i;t++)for(let e=0;e<n;e++)r[t][s+e]=!0;o+=1}s+=1}if(o<l.length)for(let e=o;e<l.length;e++)l[e].remove()}}balanceTables(){for(let e of this.quill.scroll.descendants(Y))this.fixUnusuaDeletelTable(e)}listenBalanceCells(){this.quill.on(t.default.events.SCROLL_OPTIMIZE,e=>{e.some(e=>[`TD`,`TR`,`TBODY`,`TABLE`].includes(e.target.tagName)?(this.fixTableByLisenter(),!0):!1);for(let n of e){let e=n.target;if(e.tagName===`TABLE`){let n=t.default.find(e);if(n){n.sortMergeChildren();break}}}})}deleteTable(e){if(e.length===0)return;let t=b(e[0],u.tableMain);t&&t.remove(),this.hideTableTools()}appendRow(e,t){if(e.length<=0)return;let n=e[t?e.length-1:0],[r,i,a]=x(n,[u.tableMain,u.tableBody,u.tableRow]),o=r.getRows(),s=o.indexOf(a),c=s+(t?n.rowspan:0);i.insertRow(c)}appendCol(e,t){if(e.length<=0)return;let[n]=e.reduce((e,n)=>{let r=n.getColumnIndex();return(!t&&r<=e[1]||t&&r>=e[1])&&(e=[n,r]),e},[e[0],e[0].getColumnIndex()]),r=n.getColumnIndex()+(t?n.colspan:0),i=b(n,u.tableMain),a=i.tableId,o=V(),[s]=i.descendants(X);s&&s.insertColByIndex(r,{tableId:a,colId:o,width:i.full?6:160,full:i.full});let c=i.getRows(),l=[],d=0;for(let e of Object.values(c)){let t=l.shift()||0;if(d>0){--d;continue}let n=e.insertCell(r-t,{tableId:a,rowId:e.rowId,colId:o,rowspan:1,colspan:1});n.skipRowNum&&(d+=n.skipRowNum);for(let[e,t]of n.entries())l[e]=(l[e]||0)+t}}fixTableByRemove(e){let t=e.getRows(),n=e.getCols(),r=n.reduce((e,t)=>(e[t.colId]=0,e),{}),i=[...t].reverse(),a=[];for(let[e,n]of i.entries()){let i=t.length-e-1;n.children.length<=0?a.push(i):n.foreachCellInner(e=>{let t=a.reduce((t,n)=>e.rowspan+i>n?t+1:t,0);e.rowspan-=t,r[e.colId]+=1})}let o=0;for(let e of Object.values(r))if(e===0){let e=[],n=0;for(let r of Object.values(t)){let t=e.shift()||0,i=[];n>0?(i=r.getCellByColumIndex(o-t)[2],--n):(i=r.removeCell(o-t),i.skipRowNum&&(n+=i.skipRowNum));for(let[t,n]of i.entries())e[t]=(e[t]||0)+n}}else o+=1;for(let e of n)r[e.colId]===0&&(e.prev?e.prev.width+=e.width:e.next&&(e.next.width+=e.width),e.remove())}removeRow(e){if(e.length<=0)return;let t=e[0],n=b(t,u.tableMain),r=n.getRows(),i=r.length,a=-1;for(let t of e){let e=b(t,u.tableRow),n=r.indexOf(e);n<i&&(i=n),n+t.rowspan>a&&(a=n+t.rowspan)}let o={};for(let e=i;e<Math.min(r.length,a);e++){let t=r[e];t.foreachCellInner(t=>{t.rowspan+e>a&&(o[t.colId]={rowspan:t.rowspan+e-a,colspan:t.colspan,colIndex:t.getColumnIndex()}),t.parent.remove()})}if(r[a]){let e=r[a],t=n.tableId;for(let[n,{colIndex:r,colspan:i,rowspan:a}]of Object.entries(o))e.insertCell(r,{tableId:t,rowId:e.rowId,colId:n,colspan:i,rowspan:a})}this.fixTableByRemove(n)}removeCol(e){if(e.length<=0)return;let t=e[0],n=b(t,u.tableMain),r={};for(let t of e)r[t.rowId]||(r[t.rowId]=0),r[t.rowId]+=t.colspan;let i=Math.max(...Object.values(r)),a=t.getColumnIndex(),o=n.descendants(W);for(let e=0;e<i;e++){let e=[],t=0;for(let n of Object.values(o)){let r=e.shift()||0;if(t>0){--t;continue}let i=n.removeCell(a-r);i.skipRowNum&&(t+=i.skipRowNum);for(let[t,n]of i.entries())e[t]=(e[t]||0)+n}}let[s]=n.descendants(X);if(s)for(let e=0;e<i;e++)s.removeColByIndex(a);this.fixTableByRemove(n)}mergeCells(e){if(e.length<=1)return;let t=e.reduce((e,t,n)=>{let r=t.colId;e[0][r]||(e[0][r]=0),e[0][r]+=t.rowspan;let i=t.rowId;return e[1][i]||(e[1][i]=0),e[1][i]+=t.colspan,n!==0&&(t.moveChildren(e[2]),t.parent.remove()),e},[{},{},e[0]]),n=Math.max(...Object.values(t[0])),r=Math.max(...Object.values(t[1])),i=t[2];i.colspan=r,i.rowspan=n;let a=b(i,u.tableMain);this.fixTableByRemove(a)}splitCell(e){if(e.length!==1)return;let t=e[0];if(t.colspan===1&&t.rowspan===1)return;let[n,r]=x(t,[u.tableMain,u.tableRow]),i=n.tableId,a=t.getColumnIndex(),o=n.getColIds().slice(a,a+t.colspan).reverse(),s=t.formats()[u.tableCellInner].style,c=r,l=t.rowspan;for(t.colspan=1,t.rowspan=1;c&&l>0;){for(let e of o){if(c===r&&e===t.colId)continue;let n={tableId:i,rowId:c.rowId,colId:e,rowspan:1,colspan:1};s&&(n.style=s),c.insertCell(a+(c===r?1:0),n)}--l,c=c.next}}};O(Fr,`moduleName`,p.moduleName),O(Fr,`toolName`,u.tableWrapper),O(Fr,`keyboradHandler`,{"forbid remove table by backspace":{bindInHead:!0,key:`Backspace`,collapsed:!0,offset:0,handler(e,t){let n=this.quill.getLine(e.index),r=n[0];if(r.prev instanceof Z)return r.prev.remove(),!1;if(t.format[u.tableCellInner]){let e=r.offset(b(r,u.tableCellInner));if(e===0)return!1}return!0}},"forbid remove table by delete":{bindInHead:!0,key:`Delete`,collapsed:!0,handler(e,t){let n=this.quill.getLine(e.index),r=n[0],i=n[1];if((r.next instanceof Z||r.next instanceof J)&&i===r.length()-1)return!1;if(t.format[u.tableCellInner]){let e=b(r,u.tableCellInner);if(r===e.children.tail&&i===r.length()-1)return!1}return!0}},"table up":Pr(!0),"table down":Pr(!1),"table caption break":{bindInHead:!0,key:`Enter`,shiftKey:null,format:[u.tableCaption],handler(e,t){return!1}}});var Ir=Fr;exports.BlockOverride=On,exports.ContainerFormat=H,exports.ScrollOverride=jn,exports.Scrollbar=xr,exports.TableAlign=zn,exports.TableBodyFormat=G,exports.TableCaptionFormat=K,exports.TableCellFormat=q,exports.TableCellInnerFormat=U,exports.TableClipboard=Jn,exports.TableColFormat=J,exports.TableColgroupFormat=X,exports.TableMainFormat=Y,exports.TableMenuCommon=pr,exports.TableMenuContextmenu=mr,exports.TableMenuSelect=hr,exports.TableResizeBox=vr,exports.TableResizeCommon=_r,exports.TableResizeLine=yr,exports.TableResizeScale=br,exports.TableRowFormat=W,exports.TableSelection=wr,exports.TableUp=Fr,exports.TableVirtualScrollbar=Sr,exports.TableWrapperFormat=Z,exports.blotName=u,exports.createColorPicker=me,exports.createSelectBox=be,exports.createTooltip=sn,exports.default=Ir,exports.defaultCustomSelect=Nr,exports.findParentBlot=b,exports.findParentBlots=x,exports.getTableMainRect=Rn,exports.isTableAlignRight=gr,exports.randomId=V,exports.tableMenuTools=Q,exports.tableUpEvent=f,exports.tableUpInternal=p,exports.tableUpSize=d,exports.updateTableConstants=Mr});
136
+ //# sourceMappingURL=index.umd.js.map