quill-table-up 2.2.3 → 2.3.0
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.d.ts +9 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/e2e/table-blots.test.ts +39 -1
- package/src/__tests__/e2e/table-selection.test.ts +97 -9
- package/src/__tests__/unit/table-clipboard.test.ts +181 -0
- package/src/__tests__/unit/table-hack.test.ts +14 -18
- package/src/__tests__/unit/table-redo-undo.test.ts +51 -0
- package/src/formats/container-format.ts +0 -9
- package/src/formats/table-cell-inner-format.ts +24 -0
- package/src/formats/table-col-format.ts +37 -37
- package/src/modules/table-clipboard.ts +54 -14
- package/src/modules/table-resize/table-resize-common.ts +29 -6
- package/src/modules/table-resize/table-resize-scale.ts +1 -0
- package/src/modules/table-selection.ts +1 -1
- package/src/table-up.ts +20 -27
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 W(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 H(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 W(){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",W),T=!1}function H(){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",H),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",W),T=!0,R(e)})),m.addEventListener("mousedown",(function(e){document.addEventListener("mousemove",q),document.addEventListener("mouseup",H),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=We(),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 We(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function He(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 He(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 We()&&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=We();(!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)||He(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&&!He(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&&He(i)&&nt(i)&&!qe(i)?n:i||function(e){let t=Pe(e);for(;Be(t)&&!He(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)&&!He(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(W(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"),Wt=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")),Ht=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,Ht.Scope.BLOCK&Ht.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"}}}])}(Wt);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(W(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(W(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(W(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.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=H(l),d=H(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(W(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(t,n){var i=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=t,this.options=this.resolveOptions(n||{}),this.toolBox=this.initialContainer(),!this.options.scrollbar){var o=z("scrollbar");this.quill.container.classList.add(o.bm("origin"))}this.options.selection&&(this.tableSelection=new this.options.selection(this,this.quill,this.options.selectionOptions));var r=this.quill.getModule("toolbar");if(r&&this.quill.theme.pickers){var l=(r.controls||[]).find((function(e){return C(e,1)[0]===i.statics.toolName}))||[],s=C(l,2)[1];if(s&&"select"===s.tagName.toLocaleLowerCase()){var c=this.quill.theme.pickers.find((function(e){return e.select===s}));c&&(c.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,c),c.label.addEventListener("mousedown",(function(){if(i.selector&&c)if(bt(i.selector.getBoundingClientRect()).leftLimited){var e=c.label.getBoundingClientRect();Object.assign(c.options.style,{transform:"translateX(calc(-100% + ".concat(e.width,"px))")})}else Object.assign(c.options.style,{transform:void 0})})))}}for(var u=this.quill.getModule("keyboard"),h=0,f=Object.values(e.keyboradHandler);h<f.length;h++){var p=f[h];p.bindInHead?u.bindings[p.key].unshift(p):u.addBinding(p.key,p)}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(i.table===n)return i.tableSelection&&i.tableSelection.show(),i.tableAlign&&i.tableAlign.update(),i.tableResize&&i.tableResize.update(),void(i.tableScrollbar&&i.tableScrollbar.update());i.table&&i.hideTableTools(),i.showTableTools(n)}else i.table&&i.hideTableTools()}}),!1),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 W,H=0,D=c(S);try{for(D.s();!(W=D.n()).done;){H+=W.value.width}}catch(e){D.e(e)}finally{D.f()}u.querySelector("table").style.width="".concat(H,"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(e){e.some((function(e){var n=e.target;if("TABLE"===n.tagName){var i=t.find(n);if(i)return i.sortMergeChildren(),!0}return!1}))})),this.quill.on(t.events.SCROLL_OPTIMIZE,(function(t){t.some((function(t){return!!["TD","TR","TBODY","TABLE"].includes(t.target.tagName)&&(e.fixTableByLisenter(),!0)}))}))}},{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(W(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(W(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,[Wt])),e}),{});t.register(b(b({"blots/scroll":Dt,"blots/block":Wt},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=Wt,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=W,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})}));
|
|
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:"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:"insertAt",value:function(e,n,i){if(!C(this.children.find(e),1)[0]&&this.statics.defaultChild){var o=this.scroll.create(this.statics.defaultChild.blotName||"block");this.appendChild(o)}x(t,"insertAt",this,3)([e,n,i])}},{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)}if(e.statics.blotName!==N.tableCol)x(t,"insertBefore",this,3)([e,n]);else try{var v=q(this,N.tableBody),b=this.offset(v),m=v.split(b);v.parent.insertBefore(e,m),e.optimize({})}catch(e){console.warn("TableCellInner not in TableBody")}}}],[{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){if(null==i)try{var o=n.split("\n"),r=o.pop(),a=q(this,N.tableColgroup),l=a.next,s=this.scroll,d=a.split(this.offset(a));if(l){var u=l.descendants(Ot);if(u.length>0){var h=u[0],f=Ot.formats(h.domNode),p=this.scroll.create(N.tableCellInner,f),v=p.wrap(N.tableCell,f).wrap(N.tableRow,f).wrap(N.tableBody,f.tableId);a.parent.insertBefore(v,d),s=p}}var b,m=c(o);try{for(m.s();!(b=m.n()).done;){var g=b.value,y=this.scroll.create("block");y.insertAt(0,g),s.appendChild(y)}}catch(e){m.e(e)}finally{m.f()}if(r){var w=this.scroll.create("block");w.appendChild(this.scroll.create("text",r)),s.appendChild(w)}}catch(e){console.warn("TableCol not in TableColgroup")}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,"rowIds",[]),d(i,"colIds",[]),d(i,"emptyRowCount",[]),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=this.emptyRowCount.reduce((function(e,t){var n;return e.push((null!==(n=e[e.length-1])&&void 0!==n?n:0)+t),e}),[]),o=[],r=[],a=-1,l=0;l<t.ops.length;l++){var s=t.ops[l],u=s.attributes,h=s.insert,f=u||{},p=N.tableCell;f.table,f[p];var v=m(f,["table",p].map(k)),g=Z(h)&&h[N.tableCol];if(g)r.push({insert:h});else if(v[N.tableCellInner]){var y=v[N.tableCellInner],w=this.rowIds.indexOf(y.rowId);if(-1!==w){var x=y.rowspan;y.rowspan-=i[w+x-1]-i[w]}o.push({attributes:b(b({},v),{},d({},N.tableCellInner,y)),insert:h})}else o.push({attributes:v,insert:h});null!=v&&v[N.tableCellInner]||null!=v&&v[N.tableCaption]||g||!K(h)||!(h.trim().length>0)||(a=l)}var I=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 r[i]?e.push(r[i]):e.push({insert:d({},N.tableCol,{tableId:n.tableId,colId:n.colIds[i],width:t,full:!1})}),e}),[]);return o.splice.apply(o,[a+1,0].concat(M(I))),this.tableId=Mt(),this.rowIds=[],this.colIds=[],this.emptyRowCount=[],this.rowspanCount=[],this.cellCount=0,this.colCount=0,new nn(o)}},{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,t){var n=Number(e.getAttribute("span")||1);Number.isNaN(n)&&(n=1);for(var i=new nn,o=0;o<n;o++)this.colIds[this.colCount]=Mt(),i.insert(d({},N.tableCol,Object.assign(Xt.value(e),{tableId:this.tableId,colId:this.colIds[this.colCount]}))),this.colCount+=1;return i}},{key:"matchTr",value:function(e,t){this.rowIds.push(this.rowId),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=!0,d=c(t.ops);try{for(d.s();!(l=d.n()).done;){var u=l.value;if(u.attributes){var h=u.attributes,f=h.background,p=h[N.tableCellInner];if(p||(s=!1),p&&f){var v=p.style,b=wt(void 0===v?"":v);b.backgroundColor=f,u.attributes[N.tableCellInner].style=Ct(b)}}else s=!1}}catch(e){d.e(e)}finally{d.f()}var m=0;return s||(m=1,t=new nn),this.emptyRowCount.push(m),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:"getColumnRect",value:function(e){if(!this.tableMain)return null;var t=this.tableMain.getCols();if(e>=t.length)return null;for(var n=t[0].domNode.getBoundingClientRect().left,i=0;i<e;i++){n+=t[i].domNode.getBoundingClientRect().width}var o=t[e].domNode.getBoundingClientRect().width;return{left:n,right:n+o,width:o}}},{key:"handleColMouseMove",value:function(e){if(e.preventDefault(),this.dragColBreak&&this.tableMain&&-1!==this.colIndex){var t=this.tableMain.getCols(),n=this.getColumnRect(this.colIndex),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(this.getColumnRect(this.colIndex+1).right-r,n.left+r));var l=n.left+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.left<E.colMinWidthPx&&(o=n.left+E.colMinWidthPx);var s=o-n.left;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.quill.composition.isComposing&&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(!0);if(!this.getFormat(a)[N.tableCellInner]||a.length>0||r&&r.tableSelection&&r.tableSelection.selectedTds.length<=1)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
2
|
//# sourceMappingURL=index.umd.js.map
|