e-virt-table 1.2.10 → 1.2.11

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.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(":root{--evt-header-font: 12px normal Arial;--evt-body-font: 12px normal Arial;--evt-color-white: #fff;--evt-color-black: #000000;--evt-color-primary: rgb(82, 146, 247);--evt-text-color-primary: #333;--evt-text-color-regular: #666;--evt-text-color-secondary: #999;--evt-box-shadow: 0 2px 12px 0 #0000001a;--evt-editor-bg-color: #fff;--evt-editor-text-color: #333;--evt-border-color: #e1e6eb;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--evt-body-bg-color: #fff;--evt-header-text-color: #1d2129;--evt-body-text-color: #4e5969;--evt-footer-text-color: #4e5969;--evt-loading-icon-color: #4e5969;--evt-expand-icon-color: #4e5969;--evt-shrink-icon-color: #4e5969;--evt-error-tip-icon-color: red;--evt-cell-hover-icon-bg-color: #fff;--evt-cell-hover-icon-border-color: #dde0ea;--evt-scroller-color: #dee0e3;--evt-scroller-track-color: #fff;--evt-scroller-focus-color: #bbbec4;--evt-select-border-color: var(--evt-color-primary);--evt-select-area-color: rgba(82, 146, 247, .1);--evt-select-row-col-bg-color: transparent;--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-readonly-color: #fff;--evt-readonly-text-color: var(--evt-body-text-color);--evt-error-tip-color: #ed3f14;--evt-footer-bg-color: #fafafa;--evt-highlight-hover-row-color: rgba(186, 203, 231, .1);--evt-highlight-selected-row-color: rgba(82, 146, 247, .1);--evt-tooltip-bg-color: #303133;--evt-tooltip-text-color: #fff;--evt-resize-row-line-color: #e1e6eb;--evt-resize-column-line-color: #e1e6eb}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-readonly-text-color: #cfd3dc;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;box-sizing:border-box;z-index:10;border-radius:8px;border:1px solid var(--evt-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--evt-editor-bg-color);border:2px solid var(--evt-color-primary);box-sizing:border-box;box-shadow:var(--evt-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--evt-editor-bg-color);color:var(--evt-editor-text-color);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--evt-text-color-regular);background-color:var(--evt-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--evt-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}")),document.head.appendChild(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- "use strict";var be=Object.defineProperty;var ve=(a,t,e)=>t in a?be(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var l=(a,t,e)=>ve(a,typeof t!="symbol"?t+"":t,e);function q(){return q=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i])}return a},q.apply(this,arguments)}function Re(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,st(a,t)}function Et(a){return Et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Et(a)}function st(a,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(a,t)}function _e(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function dt(a,t,e){return _e()?dt=Reflect.construct.bind():dt=function(s,r,o){var n=[null];n.push.apply(n,r);var h=Function.bind.apply(s,n),c=new h;return o&&st(c,o.prototype),c},dt.apply(null,arguments)}function Ie(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function Ct(a){var t=typeof Map=="function"?new Map:void 0;return Ct=function(i){if(i===null||!Ie(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,s)}function s(){return dt(i,arguments,Et(this).constructor)}return s.prototype=Object.create(i.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),st(s,i)},Ct(a)}var Oe=/%[sdj%]/g,Ut=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(Ut=function(t,e){typeof console<"u"&&console.warn&&typeof ASYNC_VALIDATOR_NO_WARNING>"u"&&e.every(function(i){return typeof i=="string"})&&console.warn(t,e)});function bt(a){if(!a||!a.length)return null;var t={};return a.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function D(a){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var s=0,r=e.length;if(typeof a=="function")return a.apply(null,e);if(typeof a=="string"){var o=a.replace(Oe,function(n){if(n==="%%")return"%";if(s>=r)return n;switch(n){case"%s":return String(e[s++]);case"%d":return Number(e[s++]);case"%j":try{return JSON.stringify(e[s++])}catch{return"[Circular]"}break;default:return n}});return o}return a}function Le(a){return a==="string"||a==="url"||a==="hex"||a==="email"||a==="date"||a==="pattern"}function H(a,t){return!!(a==null||t==="array"&&Array.isArray(a)&&!a.length||Le(t)&&typeof a=="string"&&!a)}function Se(a,t,e){var i=[],s=0,r=a.length;function o(n){i.push.apply(i,n||[]),s++,s===r&&e(i)}a.forEach(function(n){t(n,o)})}function Nt(a,t,e){var i=0,s=a.length;function r(o){if(o&&o.length){e(o);return}var n=i;i=i+1,n<s?t(a[n],r):e([])}r([])}function Te(a){var t=[];return Object.keys(a).forEach(function(e){t.push.apply(t,a[e]||[])}),t}var Ft=function(a){Re(t,a);function t(e,i){var s;return s=a.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Ct(Error));function Ae(a,t,e,i,s){if(t.first){var r=new Promise(function(u,g){var m=function(p){return i(p),p.length?g(new Ft(p,bt(p))):u(s)},x=Te(a);Nt(x,e,m)});return r.catch(function(u){return u}),r}var o=t.firstFields===!0?Object.keys(a):t.firstFields||[],n=Object.keys(a),h=n.length,c=0,d=[],f=new Promise(function(u,g){var m=function(w){if(d.push.apply(d,w),c++,c===h)return i(d),d.length?g(new Ft(d,bt(d))):u(s)};n.length||(i(d),u(s)),n.forEach(function(x){var w=a[x];o.indexOf(x)!==-1?Nt(w,e,m):Se(w,e,m)})});return f.catch(function(u){return u}),f}function Me(a){return!!(a&&a.message!==void 0)}function He(a,t){for(var e=a,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Bt(a,t){return function(e){var i;return a.fullFields?i=He(t,a.fullFields):i=t[e.field||a.fullField],Me(e)?(e.field=e.field||a.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||a.fullField}}}function kt(a,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof a[e]=="object"?a[e]=q({},a[e],i):a[e]=i}}return a}var Zt=function(t,e,i,s,r,o){t.required&&(!i.hasOwnProperty(t.field)||H(e,o||t.type))&&s.push(D(r.messages.required,t.fullField))},De=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(D(r.messages.whitespace,t.fullField))},ct,Xe=function(){if(ct)return ct;var a="[a-fA-F\\d:]",t=function(b){return b&&b.includeBoundaries?"(?:(?<=\\s|^)(?="+a+")|(?<="+a+")(?=\\s|$))":""},e="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",i="[a-fA-F\\d]{1,4}",s=(`
2
+ "use strict";var be=Object.defineProperty;var ve=(l,t,e)=>t in l?be(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var a=(l,t,e)=>ve(l,typeof t!="symbol"?t+"":t,e);function q(){return q=Object.assign?Object.assign.bind():function(l){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(l[i]=e[i])}return l},q.apply(this,arguments)}function Re(l,t){l.prototype=Object.create(t.prototype),l.prototype.constructor=l,st(l,t)}function Et(l){return Et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Et(l)}function st(l,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(l,t)}function _e(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function dt(l,t,e){return _e()?dt=Reflect.construct.bind():dt=function(s,r,o){var n=[null];n.push.apply(n,r);var h=Function.bind.apply(s,n),c=new h;return o&&st(c,o.prototype),c},dt.apply(null,arguments)}function Ie(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function Ct(l){var t=typeof Map=="function"?new Map:void 0;return Ct=function(i){if(i===null||!Ie(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,s)}function s(){return dt(i,arguments,Et(this).constructor)}return s.prototype=Object.create(i.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),st(s,i)},Ct(l)}var Oe=/%[sdj%]/g,Ut=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(Ut=function(t,e){typeof console<"u"&&console.warn&&typeof ASYNC_VALIDATOR_NO_WARNING>"u"&&e.every(function(i){return typeof i=="string"})&&console.warn(t,e)});function bt(l){if(!l||!l.length)return null;var t={};return l.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function D(l){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var s=0,r=e.length;if(typeof l=="function")return l.apply(null,e);if(typeof l=="string"){var o=l.replace(Oe,function(n){if(n==="%%")return"%";if(s>=r)return n;switch(n){case"%s":return String(e[s++]);case"%d":return Number(e[s++]);case"%j":try{return JSON.stringify(e[s++])}catch{return"[Circular]"}break;default:return n}});return o}return l}function Le(l){return l==="string"||l==="url"||l==="hex"||l==="email"||l==="date"||l==="pattern"}function H(l,t){return!!(l==null||t==="array"&&Array.isArray(l)&&!l.length||Le(t)&&typeof l=="string"&&!l)}function Se(l,t,e){var i=[],s=0,r=l.length;function o(n){i.push.apply(i,n||[]),s++,s===r&&e(i)}l.forEach(function(n){t(n,o)})}function Bt(l,t,e){var i=0,s=l.length;function r(o){if(o&&o.length){e(o);return}var n=i;i=i+1,n<s?t(l[n],r):e([])}r([])}function Te(l){var t=[];return Object.keys(l).forEach(function(e){t.push.apply(t,l[e]||[])}),t}var Ft=function(l){Re(t,l);function t(e,i){var s;return s=l.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Ct(Error));function Ae(l,t,e,i,s){if(t.first){var r=new Promise(function(x,g){var p=function(m){return i(m),m.length?g(new Ft(m,bt(m))):x(s)},u=Te(l);Bt(u,e,p)});return r.catch(function(x){return x}),r}var o=t.firstFields===!0?Object.keys(l):t.firstFields||[],n=Object.keys(l),h=n.length,c=0,d=[],f=new Promise(function(x,g){var p=function(w){if(d.push.apply(d,w),c++,c===h)return i(d),d.length?g(new Ft(d,bt(d))):x(s)};n.length||(i(d),x(s)),n.forEach(function(u){var w=l[u];o.indexOf(u)!==-1?Bt(w,e,p):Se(w,e,p)})});return f.catch(function(x){return x}),f}function Me(l){return!!(l&&l.message!==void 0)}function He(l,t){for(var e=l,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Nt(l,t){return function(e){var i;return l.fullFields?i=He(t,l.fullFields):i=t[e.field||l.fullField],Me(e)?(e.field=e.field||l.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||l.fullField}}}function kt(l,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof l[e]=="object"?l[e]=q({},l[e],i):l[e]=i}}return l}var Zt=function(t,e,i,s,r,o){t.required&&(!i.hasOwnProperty(t.field)||H(e,o||t.type))&&s.push(D(r.messages.required,t.fullField))},De=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(D(r.messages.whitespace,t.fullField))},ct,Xe=function(){if(ct)return ct;var l="[a-fA-F\\d:]",t=function(C){return C&&C.includeBoundaries?"(?:(?<=\\s|^)(?="+l+")|(?<="+l+")(?=\\s|$))":""},e="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",i="[a-fA-F\\d]{1,4}",s=(`
3
3
  (?:
4
4
  (?:`+i+":){7}(?:"+i+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
5
  (?:`+i+":){6}(?:"+e+"|:"+i+`|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
@@ -10,8 +10,8 @@
10
10
  (?:`+i+":){1}(?:(?::"+i+"){0,4}:"+e+"|(?::"+i+`){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
11
  (?::(?:(?::`+i+"){0,5}:"+e+"|(?::"+i+`){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
12
12
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
13
- `).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),r=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),o=new RegExp("^"+e+"$"),n=new RegExp("^"+s+"$"),h=function(b){return b&&b.exact?r:new RegExp("(?:"+t(b)+e+t(b)+")|(?:"+t(b)+s+t(b)+")","g")};h.v4=function(y){return y&&y.exact?o:new RegExp(""+t(y)+e+t(y),"g")},h.v6=function(y){return y&&y.exact?n:new RegExp(""+t(y)+s+t(y),"g")};var c="(?:(?:[a-z]+:)?//)",d="(?:\\S+(?::\\S*)?@)?",f=h.v4().source,u=h.v6().source,g="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",m="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",x="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",w="(?::\\d{2,5})?",p='(?:[/?#][^\\s"]*)?',C="(?:"+c+"|www\\.)"+d+"(?:localhost|"+f+"|"+u+"|"+g+m+x+")"+w+p;return ct=new RegExp("(?:^"+C+"$)","i"),ct},Kt={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},et={integer:function(t){return et.number(t)&&parseInt(t,10)===t},float:function(t){return et.number(t)&&!et.integer(t)},array:function(t){return Array.isArray(t)},regexp:function(t){if(t instanceof RegExp)return!0;try{return!!new RegExp(t)}catch{return!1}},date:function(t){return typeof t.getTime=="function"&&typeof t.getMonth=="function"&&typeof t.getYear=="function"&&!isNaN(t.getTime())},number:function(t){return isNaN(t)?!1:typeof t=="number"},object:function(t){return typeof t=="object"&&!et.array(t)},method:function(t){return typeof t=="function"},email:function(t){return typeof t=="string"&&t.length<=320&&!!t.match(Kt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Xe())},hex:function(t){return typeof t=="string"&&!!t.match(Kt.hex)}},Ne=function(t,e,i,s,r){if(t.required&&e===void 0){Zt(t,e,i,s,r);return}var o=["integer","float","array","regexp","object","method","email","number","date","url","hex"],n=t.type;o.indexOf(n)>-1?et[n](e)||s.push(D(r.messages.types[n],t.fullField,t.type)):n&&typeof e!==t.type&&s.push(D(r.messages.types[n],t.fullField,t.type))},Fe=function(t,e,i,s,r){var o=typeof t.len=="number",n=typeof t.min=="number",h=typeof t.max=="number",c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,d=e,f=null,u=typeof e=="number",g=typeof e=="string",m=Array.isArray(e);if(u?f="number":g?f="string":m&&(f="array"),!f)return!1;m&&(d=e.length),g&&(d=e.replace(c,"_").length),o?d!==t.len&&s.push(D(r.messages[f].len,t.fullField,t.len)):n&&!h&&d<t.min?s.push(D(r.messages[f].min,t.fullField,t.min)):h&&!n&&d>t.max?s.push(D(r.messages[f].max,t.fullField,t.max)):n&&h&&(d<t.min||d>t.max)&&s.push(D(r.messages[f].range,t.fullField,t.min,t.max))},j="enum",Be=function(t,e,i,s,r){t[j]=Array.isArray(t[j])?t[j]:[],t[j].indexOf(e)===-1&&s.push(D(r.messages[j],t.fullField,t[j].join(", ")))},ke=function(t,e,i,s,r){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(D(r.messages.pattern.mismatch,t.fullField,e,t.pattern));else if(typeof t.pattern=="string"){var o=new RegExp(t.pattern);o.test(e)||s.push(D(r.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},L={required:Zt,whitespace:De,type:Ne,range:Fe,enum:Be,pattern:ke},Ke=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"string")&&!t.required)return i();L.required(t,e,s,o,r,"string"),H(e,"string")||(L.type(t,e,s,o,r),L.range(t,e,s,o,r),L.pattern(t,e,s,o,r),t.whitespace===!0&&L.whitespace(t,e,s,o,r))}i(o)},Ye=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},Ve=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e===""&&(e=void 0),H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},We=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},Pe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),H(e)||L.type(t,e,s,o,r)}i(o)},ze=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},$e=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},qe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e==null&&!t.required)return i();L.required(t,e,s,o,r,"array"),e!=null&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},Ge=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},je="enum",Ue=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L[je](t,e,s,o,r)}i(o)},Ze=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"string")&&!t.required)return i();L.required(t,e,s,o,r),H(e,"string")||L.pattern(t,e,s,o,r)}i(o)},Je=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"date")&&!t.required)return i();if(L.required(t,e,s,o,r),!H(e,"date")){var h;e instanceof Date?h=e:h=new Date(e),L.type(t,h,s,o,r),h&&L.range(t,h.getTime(),s,o,r)}}i(o)},Qe=function(t,e,i,s,r){var o=[],n=Array.isArray(e)?"array":typeof e;L.required(t,e,s,o,r,n),i(o)},mt=function(t,e,i,s,r){var o=t.type,n=[],h=t.required||!t.required&&s.hasOwnProperty(t.field);if(h){if(H(e,o)&&!t.required)return i();L.required(t,e,s,n,r,o),H(e,o)||L.type(t,e,s,n,r)}i(n)},ti=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r)}i(o)},it={string:Ke,method:Ye,number:Ve,boolean:We,regexp:Pe,integer:ze,float:$e,array:qe,object:Ge,enum:Ue,pattern:Ze,date:Je,url:mt,hex:mt,email:mt,required:Qe,any:ti};function vt(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var t=JSON.parse(JSON.stringify(this));return t.clone=this.clone,t}}}var Rt=vt(),nt=function(){function a(e){this.rules=null,this._messages=Rt,this.define(e)}var t=a.prototype;return t.define=function(i){var s=this;if(!i)throw new Error("Cannot configure a schema with no rules");if(typeof i!="object"||Array.isArray(i))throw new Error("Rules must be an object");this.rules={},Object.keys(i).forEach(function(r){var o=i[r];s.rules[r]=Array.isArray(o)?o:[o]})},t.messages=function(i){return i&&(this._messages=kt(vt(),i)),this._messages},t.validate=function(i,s,r){var o=this;s===void 0&&(s={}),r===void 0&&(r=function(){});var n=i,h=s,c=r;if(typeof h=="function"&&(c=h,h={}),!this.rules||Object.keys(this.rules).length===0)return c&&c(null,n),Promise.resolve(n);function d(x){var w=[],p={};function C(b){if(Array.isArray(b)){var E;w=(E=w).concat.apply(E,b)}else w.push(b)}for(var y=0;y<x.length;y++)C(x[y]);w.length?(p=bt(w),c(w,p)):c(null,n)}if(h.messages){var f=this.messages();f===Rt&&(f=vt()),kt(f,h.messages),h.messages=f}else h.messages=this.messages();var u={},g=h.keys||Object.keys(this.rules);g.forEach(function(x){var w=o.rules[x],p=n[x];w.forEach(function(C){var y=C;typeof y.transform=="function"&&(n===i&&(n=q({},n)),p=n[x]=y.transform(p)),typeof y=="function"?y={validator:y}:y=q({},y),y.validator=o.getValidationMethod(y),y.validator&&(y.field=x,y.fullField=y.fullField||x,y.type=o.getType(y),u[x]=u[x]||[],u[x].push({rule:y,value:p,source:n,field:x}))})});var m={};return Ae(u,h,function(x,w){var p=x.rule,C=(p.type==="object"||p.type==="array")&&(typeof p.fields=="object"||typeof p.defaultField=="object");C=C&&(p.required||!p.required&&x.value),p.field=x.field;function y(R,O){return q({},O,{fullField:p.fullField+"."+R,fullFields:p.fullFields?[].concat(p.fullFields,[R]):[R]})}function b(R){R===void 0&&(R=[]);var O=Array.isArray(R)?R:[R];!h.suppressWarning&&O.length&&a.warning("async-validator:",O),O.length&&p.message!==void 0&&(O=[].concat(p.message));var I=O.map(Bt(p,n));if(h.first&&I.length)return m[p.field]=1,w(I);if(!C)w(I);else{if(p.required&&!x.value)return p.message!==void 0?I=[].concat(p.message).map(Bt(p,n)):h.error&&(I=[h.error(p,D(h.messages.required,p.field))]),w(I);var _={};p.defaultField&&Object.keys(x.value).map(function(T){_[T]=p.defaultField}),_=q({},_,x.rule.fields);var v={};Object.keys(_).forEach(function(T){var M=_[T],A=Array.isArray(M)?M:[M];v[T]=A.map(y.bind(null,T))});var S=new a(v);S.messages(h.messages),x.rule.options&&(x.rule.options.messages=h.messages,x.rule.options.error=h.error),S.validate(x.value,x.rule.options||h,function(T){var M=[];I&&I.length&&M.push.apply(M,I),T&&T.length&&M.push.apply(M,T),w(M.length?M:null)})}}var E;if(p.asyncValidator)E=p.asyncValidator(p,x.value,b,x.source,h);else if(p.validator){try{E=p.validator(p,x.value,b,x.source,h)}catch(R){console.error==null||console.error(R),h.suppressValidatorError||setTimeout(function(){throw R},0),b(R.message)}E===!0?b():E===!1?b(typeof p.message=="function"?p.message(p.fullField||p.field):p.message||(p.fullField||p.field)+" fails"):E instanceof Array?b(E):E instanceof Error&&b(E.message)}E&&E.then&&E.then(function(){return b()},function(R){return b(R)})},function(x){d(x)},n)},t.getType=function(i){if(i.type===void 0&&i.pattern instanceof RegExp&&(i.type="pattern"),typeof i.validator!="function"&&i.type&&!it.hasOwnProperty(i.type))throw new Error(D("Unknown rule type %s",i.type));return i.type||"string"},t.getValidationMethod=function(i){if(typeof i.validator=="function")return i.validator;var s=Object.keys(i),r=s.indexOf("message");return r!==-1&&s.splice(r,1),s.length===1&&s[0]==="required"?it.required:it[this.getType(i)]||void 0},a}();nt.register=function(t,e){if(typeof e!="function")throw new Error("Cannot register a validator by type, validator is not a function");it[t]=e};nt.warning=Ut;nt.messages=Rt;nt.validators=it;function Jt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(a){const t=Math.random()*16|0;return(a==="x"?t:t&3|8).toString(16)})}function Qt(a,t){let e=0,i;return function(...s){const r=new Date().getTime(),o=r-e;!e||o>=t?(a.apply(this,s),e=r):i||(i=setTimeout(()=>{a.apply(this,s),e=new Date().getTime(),i=void 0},t-o))}}function te(a=[]){return a.length?a.map(t=>te(t.children)+1).sort((t,e)=>e-t)[0]:0}function ei(a=[]){let t=[],e=[],i=[];return a.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,r)=>(s.sort??0)-(r.sort??0)),...e.sort((s,r)=>(s.sort??0)-(r.sort??0)),...i.sort((s,r)=>(s.sort??0)-(r.sort??0))]}function ee(a=[],t=1,e=0){return a.map(i=>{if(i.children){let s=0,r=i.fixed;i.children.forEach(n=>{n.fixed=r});const o=ee(i.children,t-1,e+1);return o&&o.forEach(n=>{s+=n.colspan??0}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:o}}return{...i,level:e,rowspan:t,colspan:1}})}function _t(a=[]){let t=[];return a.forEach(e=>{e.children?t=t.concat(_t(e.children)):t.push(e)}),t}const Yt=/^(\r\n|\n\r|\r|\n)/,ii=/^[^\t\r\n]+/,Vt=/^\t/;function si(a){let t=[[""]];if(a.length===0)return t;let e=0,i=0,s;for(;a.length>0&&s!==a.length;)if(s=a.length,a.match(Vt))a=a.replace(Vt,""),e+=1,t[i][e]="";else if(a.match(Yt))a=a.replace(Yt,""),e=0,i+=1,t[i]=[""];else{let r="";if(a.startsWith('"')){let o=0,n=!0;for(;n;){const h=a.slice(0,1);h==='"'&&(o+=1),r+=h,a=a.slice(1),(a.length===0||a.match(/^[\t\r\n]/)&&o%2===0)&&(n=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,h=>new Array(Math.floor(h.length/2)).fill('"').join(""))}else{const o=a.match(ii);r=o?o[0]:"",a=a.slice(r.length)}t[i][e]=r}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function ri(a){let t,e,i,s,r="",o;for(t=0,e=a.length;t<e;t+=1){for(s=a[t].length,i=0;i<s;i+=1)i>0&&(r+=" "),o=a[t][i],typeof o=="string"?o.indexOf(`
13
+ `).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),r=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),o=new RegExp("^"+e+"$"),n=new RegExp("^"+s+"$"),h=function(C){return C&&C.exact?r:new RegExp("(?:"+t(C)+e+t(C)+")|(?:"+t(C)+s+t(C)+")","g")};h.v4=function(y){return y&&y.exact?o:new RegExp(""+t(y)+e+t(y),"g")},h.v6=function(y){return y&&y.exact?n:new RegExp(""+t(y)+s+t(y),"g")};var c="(?:(?:[a-z]+:)?//)",d="(?:\\S+(?::\\S*)?@)?",f=h.v4().source,x=h.v6().source,g="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",p="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",u="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",w="(?::\\d{2,5})?",m='(?:[/?#][^\\s"]*)?',b="(?:"+c+"|www\\.)"+d+"(?:localhost|"+f+"|"+x+"|"+g+p+u+")"+w+m;return ct=new RegExp("(?:^"+b+"$)","i"),ct},Kt={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},et={integer:function(t){return et.number(t)&&parseInt(t,10)===t},float:function(t){return et.number(t)&&!et.integer(t)},array:function(t){return Array.isArray(t)},regexp:function(t){if(t instanceof RegExp)return!0;try{return!!new RegExp(t)}catch{return!1}},date:function(t){return typeof t.getTime=="function"&&typeof t.getMonth=="function"&&typeof t.getYear=="function"&&!isNaN(t.getTime())},number:function(t){return isNaN(t)?!1:typeof t=="number"},object:function(t){return typeof t=="object"&&!et.array(t)},method:function(t){return typeof t=="function"},email:function(t){return typeof t=="string"&&t.length<=320&&!!t.match(Kt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Xe())},hex:function(t){return typeof t=="string"&&!!t.match(Kt.hex)}},Be=function(t,e,i,s,r){if(t.required&&e===void 0){Zt(t,e,i,s,r);return}var o=["integer","float","array","regexp","object","method","email","number","date","url","hex"],n=t.type;o.indexOf(n)>-1?et[n](e)||s.push(D(r.messages.types[n],t.fullField,t.type)):n&&typeof e!==t.type&&s.push(D(r.messages.types[n],t.fullField,t.type))},Fe=function(t,e,i,s,r){var o=typeof t.len=="number",n=typeof t.min=="number",h=typeof t.max=="number",c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,d=e,f=null,x=typeof e=="number",g=typeof e=="string",p=Array.isArray(e);if(x?f="number":g?f="string":p&&(f="array"),!f)return!1;p&&(d=e.length),g&&(d=e.replace(c,"_").length),o?d!==t.len&&s.push(D(r.messages[f].len,t.fullField,t.len)):n&&!h&&d<t.min?s.push(D(r.messages[f].min,t.fullField,t.min)):h&&!n&&d>t.max?s.push(D(r.messages[f].max,t.fullField,t.max)):n&&h&&(d<t.min||d>t.max)&&s.push(D(r.messages[f].range,t.fullField,t.min,t.max))},j="enum",Ne=function(t,e,i,s,r){t[j]=Array.isArray(t[j])?t[j]:[],t[j].indexOf(e)===-1&&s.push(D(r.messages[j],t.fullField,t[j].join(", ")))},ke=function(t,e,i,s,r){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(D(r.messages.pattern.mismatch,t.fullField,e,t.pattern));else if(typeof t.pattern=="string"){var o=new RegExp(t.pattern);o.test(e)||s.push(D(r.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},L={required:Zt,whitespace:De,type:Be,range:Fe,enum:Ne,pattern:ke},Ke=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"string")&&!t.required)return i();L.required(t,e,s,o,r,"string"),H(e,"string")||(L.type(t,e,s,o,r),L.range(t,e,s,o,r),L.pattern(t,e,s,o,r),t.whitespace===!0&&L.whitespace(t,e,s,o,r))}i(o)},Ye=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},Ve=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e===""&&(e=void 0),H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},We=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},Pe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),H(e)||L.type(t,e,s,o,r)}i(o)},ze=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},$e=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},qe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e==null&&!t.required)return i();L.required(t,e,s,o,r,"array"),e!=null&&(L.type(t,e,s,o,r),L.range(t,e,s,o,r))}i(o)},Ge=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L.type(t,e,s,o,r)}i(o)},je="enum",Ue=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r),e!==void 0&&L[je](t,e,s,o,r)}i(o)},Ze=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"string")&&!t.required)return i();L.required(t,e,s,o,r),H(e,"string")||L.pattern(t,e,s,o,r)}i(o)},Je=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e,"date")&&!t.required)return i();if(L.required(t,e,s,o,r),!H(e,"date")){var h;e instanceof Date?h=e:h=new Date(e),L.type(t,h,s,o,r),h&&L.range(t,h.getTime(),s,o,r)}}i(o)},Qe=function(t,e,i,s,r){var o=[],n=Array.isArray(e)?"array":typeof e;L.required(t,e,s,o,r,n),i(o)},mt=function(t,e,i,s,r){var o=t.type,n=[],h=t.required||!t.required&&s.hasOwnProperty(t.field);if(h){if(H(e,o)&&!t.required)return i();L.required(t,e,s,n,r,o),H(e,o)||L.type(t,e,s,n,r)}i(n)},ti=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(H(e)&&!t.required)return i();L.required(t,e,s,o,r)}i(o)},it={string:Ke,method:Ye,number:Ve,boolean:We,regexp:Pe,integer:ze,float:$e,array:qe,object:Ge,enum:Ue,pattern:Ze,date:Je,url:mt,hex:mt,email:mt,required:Qe,any:ti};function vt(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var t=JSON.parse(JSON.stringify(this));return t.clone=this.clone,t}}}var Rt=vt(),nt=function(){function l(e){this.rules=null,this._messages=Rt,this.define(e)}var t=l.prototype;return t.define=function(i){var s=this;if(!i)throw new Error("Cannot configure a schema with no rules");if(typeof i!="object"||Array.isArray(i))throw new Error("Rules must be an object");this.rules={},Object.keys(i).forEach(function(r){var o=i[r];s.rules[r]=Array.isArray(o)?o:[o]})},t.messages=function(i){return i&&(this._messages=kt(vt(),i)),this._messages},t.validate=function(i,s,r){var o=this;s===void 0&&(s={}),r===void 0&&(r=function(){});var n=i,h=s,c=r;if(typeof h=="function"&&(c=h,h={}),!this.rules||Object.keys(this.rules).length===0)return c&&c(null,n),Promise.resolve(n);function d(u){var w=[],m={};function b(C){if(Array.isArray(C)){var E;w=(E=w).concat.apply(E,C)}else w.push(C)}for(var y=0;y<u.length;y++)b(u[y]);w.length?(m=bt(w),c(w,m)):c(null,n)}if(h.messages){var f=this.messages();f===Rt&&(f=vt()),kt(f,h.messages),h.messages=f}else h.messages=this.messages();var x={},g=h.keys||Object.keys(this.rules);g.forEach(function(u){var w=o.rules[u],m=n[u];w.forEach(function(b){var y=b;typeof y.transform=="function"&&(n===i&&(n=q({},n)),m=n[u]=y.transform(m)),typeof y=="function"?y={validator:y}:y=q({},y),y.validator=o.getValidationMethod(y),y.validator&&(y.field=u,y.fullField=y.fullField||u,y.type=o.getType(y),x[u]=x[u]||[],x[u].push({rule:y,value:m,source:n,field:u}))})});var p={};return Ae(x,h,function(u,w){var m=u.rule,b=(m.type==="object"||m.type==="array")&&(typeof m.fields=="object"||typeof m.defaultField=="object");b=b&&(m.required||!m.required&&u.value),m.field=u.field;function y(R,O){return q({},O,{fullField:m.fullField+"."+R,fullFields:m.fullFields?[].concat(m.fullFields,[R]):[R]})}function C(R){R===void 0&&(R=[]);var O=Array.isArray(R)?R:[R];!h.suppressWarning&&O.length&&l.warning("async-validator:",O),O.length&&m.message!==void 0&&(O=[].concat(m.message));var I=O.map(Nt(m,n));if(h.first&&I.length)return p[m.field]=1,w(I);if(!b)w(I);else{if(m.required&&!u.value)return m.message!==void 0?I=[].concat(m.message).map(Nt(m,n)):h.error&&(I=[h.error(m,D(h.messages.required,m.field))]),w(I);var _={};m.defaultField&&Object.keys(u.value).map(function(T){_[T]=m.defaultField}),_=q({},_,u.rule.fields);var v={};Object.keys(_).forEach(function(T){var M=_[T],A=Array.isArray(M)?M:[M];v[T]=A.map(y.bind(null,T))});var S=new l(v);S.messages(h.messages),u.rule.options&&(u.rule.options.messages=h.messages,u.rule.options.error=h.error),S.validate(u.value,u.rule.options||h,function(T){var M=[];I&&I.length&&M.push.apply(M,I),T&&T.length&&M.push.apply(M,T),w(M.length?M:null)})}}var E;if(m.asyncValidator)E=m.asyncValidator(m,u.value,C,u.source,h);else if(m.validator){try{E=m.validator(m,u.value,C,u.source,h)}catch(R){console.error==null||console.error(R),h.suppressValidatorError||setTimeout(function(){throw R},0),C(R.message)}E===!0?C():E===!1?C(typeof m.message=="function"?m.message(m.fullField||m.field):m.message||(m.fullField||m.field)+" fails"):E instanceof Array?C(E):E instanceof Error&&C(E.message)}E&&E.then&&E.then(function(){return C()},function(R){return C(R)})},function(u){d(u)},n)},t.getType=function(i){if(i.type===void 0&&i.pattern instanceof RegExp&&(i.type="pattern"),typeof i.validator!="function"&&i.type&&!it.hasOwnProperty(i.type))throw new Error(D("Unknown rule type %s",i.type));return i.type||"string"},t.getValidationMethod=function(i){if(typeof i.validator=="function")return i.validator;var s=Object.keys(i),r=s.indexOf("message");return r!==-1&&s.splice(r,1),s.length===1&&s[0]==="required"?it.required:it[this.getType(i)]||void 0},l}();nt.register=function(t,e){if(typeof e!="function")throw new Error("Cannot register a validator by type, validator is not a function");it[t]=e};nt.warning=Ut;nt.messages=Rt;nt.validators=it;function Jt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(l){const t=Math.random()*16|0;return(l==="x"?t:t&3|8).toString(16)})}function Qt(l,t){let e=0,i;return function(...s){const r=new Date().getTime(),o=r-e;!e||o>=t?(l.apply(this,s),e=r):i||(i=setTimeout(()=>{l.apply(this,s),e=new Date().getTime(),i=void 0},t-o))}}function te(l=[]){return l.length?l.map(t=>te(t.children)+1).sort((t,e)=>e-t)[0]:0}function ei(l=[]){let t=[],e=[],i=[];return l.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,r)=>(s.sort??0)-(r.sort??0)),...e.sort((s,r)=>(s.sort??0)-(r.sort??0)),...i.sort((s,r)=>(s.sort??0)-(r.sort??0))]}function ee(l=[],t=1,e=0){return l.map(i=>{if(i.children){let s=0,r=i.fixed;i.children.forEach(n=>{n.fixed=r});const o=ee(i.children,t-1,e+1);return o&&o.forEach(n=>{s+=n.colspan??0}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:o}}return{...i,level:e,rowspan:t,colspan:1}})}function _t(l=[]){let t=[];return l.forEach(e=>{e.children?t=t.concat(_t(e.children)):t.push(e)}),t}const Yt=/^(\r\n|\n\r|\r|\n)/,ii=/^[^\t\r\n]+/,Vt=/^\t/;function si(l){let t=[[""]];if(l.length===0)return t;let e=0,i=0,s;for(;l.length>0&&s!==l.length;)if(s=l.length,l.match(Vt))l=l.replace(Vt,""),e+=1,t[i][e]="";else if(l.match(Yt))l=l.replace(Yt,""),e=0,i+=1,t[i]=[""];else{let r="";if(l.startsWith('"')){let o=0,n=!0;for(;n;){const h=l.slice(0,1);h==='"'&&(o+=1),r+=h,l=l.slice(1),(l.length===0||l.match(/^[\t\r\n]/)&&o%2===0)&&(n=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,h=>new Array(Math.floor(h.length/2)).fill('"').join(""))}else{const o=l.match(ii);r=o?o[0]:"",l=l.slice(r.length)}t[i][e]=r}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function ri(l){let t,e,i,s,r="",o;for(t=0,e=l.length;t<e;t+=1){for(s=l[t].length,i=0;i<s;i+=1)i>0&&(r+=" "),o=l[t][i],typeof o=="string"?o.indexOf(`
14
14
  `)>-1?r+=`"${o.replace(/"/g,'""')}"`:r+=o:o==null?r+="":r+=o;t!==e-1&&(r+=`
15
- `)}return r}function ie(a,t,e=[]){let i=0;const s=[];return a.forEach((r,o)=>{if(o===0)s.push(1);else{const n=e.reduce((c,d)=>`${c}${r[d]??""}`,"")||r[t],h=e.reduce((c,d)=>`${c}${a[o-1][d]??""}`,"")||a[o-1][t];n===h?(s[i]+=1,s.push(0)):(s.push(1),i=o)}}),s}function se(a,t){let e="",i="";const s={};return t.forEach((r,o)=>{o===0?(e=r.key,i=r.key,s[r.key]=1):a[r.key]===a[e]?(s[r.key]=0,s[i]+=1):(s[r.key]=1,e=r.key,i=r.key)}),s}function oi(a,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:r}=a,o=ie(i,t,e);return o[s-r]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:o[s-r],colspan:1,relationRowKeys:e,mergeRow:!0}}function ni(a,t=[]){const{column:e,row:i,visibleLeafColumns:s}=a,r=s.filter(o=>t.includes(o.key));if(t.includes(e.key)){const o=se(i,r);return o[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:o[e.key],relationColKeys:t,mergeCol:!0}}}function ai(a,t=document.documentElement){const e=a.startsWith("--")?a:`--${a}`;return getComputedStyle(t).getPropertyValue(e).trim()}class re{constructor(t,e,i,s,r,o,n){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"fixed");l(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=n,this.cellType=o}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,r=t;return!(this.x+this.width-e-i<=0||this.x-i>=r-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class At extends re{constructor(e,i,s,r,o,n,h,c,d,f="body"){super(e,r,o,n,h,f,c.fixed);l(this,"formatter");l(this,"formatterFooter");l(this,"hoverIconName","");l(this,"operation",!1);l(this,"align");l(this,"verticalAlign");l(this,"fixed");l(this,"type");l(this,"editorType");l(this,"editorProps");l(this,"cellType");l(this,"level");l(this,"colspan",1);l(this,"rowspan",1);l(this,"mergeRow",!1);l(this,"mergeCol",!1);l(this,"relationRowKeys",[]);l(this,"relationColKeys",[]);l(this,"key");l(this,"column");l(this,"rowIndex");l(this,"colIndex");l(this,"rowKey");l(this,"row");l(this,"value");l(this,"render");l(this,"renderFooter");l(this,"style",{});l(this,"rules",[]);l(this,"message","");l(this,"text","");l(this,"displayText","");l(this,"visibleWidth",0);l(this,"visibleHeight",0);l(this,"isHasChanged",!1);l(this,"drawX",0);l(this,"drawY",0);l(this,"drawCellBgColor","");l(this,"drawCellSkyBgColor","");l(this,"drawTextColor","");l(this,"drawTextX",0);l(this,"drawTextY",0);l(this,"drawImageX",0);l(this,"drawImageY",0);l(this,"drawImageWidth",0);l(this,"drawImageHeight",0);l(this,"drawImageName","");l(this,"drawImageSource");l(this,"ellipsis",!1);l(this,"rowExpand",!1);l(this,"rowHasChildren",!1);l(this,"overflowTooltipShow",!0);l(this,"overflowTooltipMaxWidth",500);l(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=c.key,this.type=c.type||"",this.editorType=c.editorType||"text",this.editorProps=c.editorProps||{},this.cellType=f,this.align=c.align||"center",this.verticalAlign=c.verticalAlign||"middle",this.fixed=c.fixed,this.level=c.level||0,this.operation=c.operation||!1,this.column=c,this.rules=c.rules||[],this.row=d,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=c.render,this.overflowTooltipShow=c.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=c.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=c.overflowTooltipPlacement||"top",this.renderFooter=c.renderFooter,this.hoverIconName=c.hoverIconName,this.formatter=c.formatter,this.formatterFooter=c.formatterFooter,this.update()}setWidthHeight(e,i){this.width=e,this.height=i}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:r=1,relationRowKeys:o,relationColKeys:n,mergeRow:h=!1,mergeCol:c=!1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};Array.isArray(o)&&o.length>0?this.relationRowKeys=o:this.relationRowKeys=[this.key],Array.isArray(n)&&n.length>0?this.relationColKeys=n:this.relationColKeys=[this.key],this.mergeCol=c,this.mergeRow=h,this.colspan=s,this.rowspan=r,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){const e=this.getSpanInfo();this.height=e.height,this.width=e.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=e.offsetTop,this.drawX-=e.offsetLeft}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditor(){const{BODY_CELL_EDITOR_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(s!==void 0){const{type:r,props:o={}}=s;this.editorType=r,this.editorProps=o}}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let r,o=0,n="";if(this.type==="tree"&&s==="body"){const h=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:d=!1,expandLoading:f=!1,level:u=0}=h||{};if(this.rowExpand=c,this.rowHasChildren=d,f){const x=this.ctx.icons.get("loading");n="loading",r=x,o=u*8}else if(d){const x=this.ctx.icons.get("expand"),w=this.ctx.icons.get("shrink");r=c?w:x,n=c?"shrink":"expand",o=u*8}else o=u*8;let g=20,m=20;if(r){let x=this.drawX+o+e,w=this.drawY+(this.visibleHeight-m)/2;this.ctx.paint.drawImage(r,x,w,g,m),this.drawImageX=x,this.drawImageY=w,this.drawImageWidth=g,this.drawImageHeight=m,this.drawImageName=n,this.drawImageSource=r}this.align="left",this.drawTextX=o+this.drawX+g-.5}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:r,READONLY_TEXT_COLOR:o,BODY_TEXT_COLOR:n,FOOTER_TEXT_COLOR:h,FOOTER_BG_COLOR:c,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:g,STRIPE:m,STRIPE_COLOR:x}=this.ctx.config;if(this.cellType==="footer"){let O=c,I=h;if(typeof r=="function"){const _=r,{backgroundColor:v,color:S}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};v&&(O=v),S&&(I=S)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=O,this.drawTextColor=I;return}let w="transparent";const p=this.ctx.focusCell,C=this.ctx.hoverCell;let y=this.rowIndex,b=this.rowIndex;if(this.rowspan!==1&&(u||d)){const O=this.getSpanInfo(),{yArr:I}=O;y=I[0],b=I[1]}u&&C&&(C.rowKey===this.rowKey&&(w=g),C.rowIndex>=y&&C.rowIndex<=b&&(w=g)),d&&p&&(p.rowKey===this.rowKey&&(w=f),p.rowIndex>=y&&p.rowIndex<=b&&(w=f)),this.drawCellSkyBgColor=w;let E=e,R=n;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(E=i,R=o),m&&(this.rowIndex%2?E=x:E=e),typeof s=="function"){const O=s,{backgroundColor:I,color:_}=O({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};I&&(E=I),_&&(R=_)}this.drawCellBgColor=E,this.drawTextColor=R}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:r,cellType:o,type:n,rowIndex:h,rowKey:c}=this;if(!(s===0||r===0)&&o!=="footer"&&["index-selection","selection"].includes(n)){const d=this.ctx.database.getRowSelection(c),f=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:u=0}=this.ctx.config,g=this.drawX+(e-u)/2,m=this.drawY+(i-u)/2;let x=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";d&&f?(x=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):d&&f?(x=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!d&&f?(x=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(x=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),x&&n=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===h||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=g,this.drawImageY=m,this.drawImageWidth=u,this.drawImageHeight=u,this.drawImageName=w,this.drawImageSource=x):x&&n==="selection"&&(this.drawImageX=g,this.drawImageY=m,this.drawImageWidth=u,this.drawImageHeight=u,this.drawImageName=w,this.drawImageSource=x)}}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;const{BODY_CELL_HOVER_ICON_METHOD:i,CELL_HOVER_ICON_SIZE:s,CELL_PADDING:r,ENABLE_MERGE_CELL_LINK:o}=this.ctx.config;if(typeof i=="function"){const c=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});c!==void 0&&(this.hoverIconName=c)}const{hoverCell:n}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&n){let h=0,c=0;if(n.rowKey===this.rowKey&&(h=this.drawX+this.width-s-r,c=this.drawY+(this.height-s)/2),this.rowspan!==1&&o){const f=this.getSpanInfo(),{yArr:u}=f,g=u[0],m=u[1];if(n.rowIndex>=g&&n.rowIndex<=m){const{width:x,height:w,offsetTop:p,offsetLeft:C}=f;h=this.drawX-C+x-s-r,c=this.drawY-p+(w-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawImageX=h,this.drawImageY=c,this.drawImageWidth=s,this.drawImageHeight=s,this.drawImageName=this.hoverIconName,this.drawImageSource=d}}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(e){this.ctx.setItemValueByEditor(this.rowKey,this.key,e)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:r,drawY:o}=this;e.drawRect(r,o,this.visibleWidth,this.visibleHeight,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(r,o,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),s||this.ctx.paint.drawLine([r,o+this.visibleHeight,r+this.visibleWidth,o+this.visibleHeight],{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s,AUTOFILL_POINT_BORDER_COLOR:r}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:o,yArr:n}=this.ctx.selector,h=o[1],c=n[1],{colIndex:d,rowIndex:f,drawX:u,drawY:g}=this;if(d===h&&f===c){const x=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-x,g+this.height-x,6,6,{borderColor:r,fillColor:e})}}draw(){this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let r=e;r<e+i;r++){const o=this.ctx.header.leafCellHeaders[r];s+=o.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s}=this.ctx.config;let r=this.visibleWidth;if(this.type==="tree"){const f=this.drawTextX-this.drawX;r=this.visibleWidth-f}const{ellipsis:o}=this.ctx.paint.handleEllipsis(this.displayText,r,e,i);this.ellipsis=o;const{placeholder:n}=this.column;let h=this.displayText,c=this.drawTextColor;return!this.ctx.database.getReadonly(this.rowKey,this.key)&&n&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(h=n,c=s),this.ctx.paint.drawText(h,this.drawTextX,this.drawTextY,r,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:c})}drawImage(){if(this.drawImageSource){if(this.hoverIconName){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawImageX-2,this.drawImageY-2,this.drawImageWidth+4,this.drawImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e})}this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:r,yArrCopy:o}=this.ctx.selector;this.drawBorder({xArr:r,yArr:o,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});const[n,h]=i,[c,d]=s;!(n===h&&c===d)&&this.colIndex>=n&&this.colIndex<=h&&this.rowIndex>=c&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)"}),this.operation&&this.rowIndex>=c&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.visibleWidth,this.visibleHeight,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawErrorTip(){if(this.cellType==="footer"||!this.message||this.rowspan===0||this.colspan===0)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,r=this.drawX,o=this.drawY,n=[r+s-e-.5,o,r+s-.5,o,r+s-.5,o+e];this.ctx.paint.drawLine(n,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:r,colIndex:o,height:n,width:h}=this;let c=i,d=s;const{xArr:f,yArr:u,lineDash:g=[],borderWidth:m=1,borderColor:x,fillColor:w}=e,p=f[0],C=f[1],y=u[0],b=u[1];if(o>=p&&o<=C&&r===y){const E=o===C?1:0,R=o===p?1:0;this.ctx.paint.drawLine([c+R,d+1,c+h-E,d+1],{borderColor:x,fillColor:w,borderWidth:m,lineCap:"round",lineJoin:"round",lineDash:g})}if(o===C&&r>=y&&r<=b){const E=r===y?1:0,R=r===b?1:0;this.ctx.paint.drawLine([c+h-1,d+E,c+h-1,d+n-R],{borderColor:x,fillColor:w,borderWidth:m,lineCap:"round",lineJoin:"round",lineDash:g})}if(o>=p&&o<=C&&r===b){const E=o===C?1:0,R=o===p?1:0;this.ctx.paint.drawLine([c+R,d+n-1,c+h-E,d+n-1],{borderColor:x,fillColor:w,borderWidth:m,lineCap:"round",lineJoin:"round",lineDash:g})}if(o===p&&r>=y&&r<=b){const E=r===b?1:0,R=r===y?1:0;this.ctx.paint.drawLine([c+1,d+R,c+1,d+n-E],{borderColor:x,fillColor:w,borderWidth:m,lineCap:"round",lineJoin:"round",lineDash:g})}}}class li{constructor(t,e){l(this,"loading",!1);l(this,"ctx");l(this,"data");l(this,"columns");l(this,"footerData",[]);l(this,"rowKeyMap",new Map);l(this,"colIndexKeyMap",new Map);l(this,"headerMap",new Map);l(this,"rowIndexRowKeyMap",new Map);l(this,"rowKeyRowIndexMap",new Map);l(this,"checkboxKeyMap",new Map);l(this,"selectionMap",new Map);l(this,"originalDataMap",new Map);l(this,"changedDataMap",new Map);l(this,"validationErrorMap",new Map);l(this,"itemRowKeyMap",new WeakMap);l(this,"bufferData",[]);l(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});l(this,"sumHeight",0);l(this,"filterMethod");l(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:r=[]}=e;this.data=i,this.footerData=r,this.columns=s,this.setLoading(!0),this.init()}init(){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear(),this.itemRowKeyMap=new WeakMap;const{ROW_KEY:t,ENABLE_RESERVE_SELECTION:e}=this.ctx.config;e&&t||this.selectionMap.clear(),this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0){t.forEach((i,s)=>{var w;let r=i._hasChildren||!1;Array.isArray(i.children)&&i.children.length&&(r=!0,this.initData(i.children,e+1));const{ROW_KEY:o="",DEFAULT_EXPAND_ALL:n,CELL_HEIGHT:h,SELECTABLE_METHOD:c,CHECKBOX_KEY:d}=this.ctx.config,f=i[o],u=f!=null?`${f}`:Jt();this.itemRowKeyMap.set(i,u);const g=i._height||h,m=i._readonly;let x=!0;if(typeof c=="function"&&(x=c),d){const p=i[d];if(this.checkboxKeyMap.has(p)){const C=this.checkboxKeyMap.get(p)||[];C.push(u),this.checkboxKeyMap.set(p,C)}else this.checkboxKeyMap.set(p,[u])}this.selectionMap.set(u,{key:d?i[d]:u,row:i,check:((w=this.selectionMap.get(u))==null?void 0:w.check)||!1}),this.rowKeyMap.set(u,{readonly:m,index:s,rowIndex:s,level:e,height:g,check:!1,selectable:x,expand:n,expandLazy:!1,hasChildren:r,expandLoading:!1,item:i})})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t);if(i===void 0)return;const s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const r={...i};r.children&&Array.isArray(r.children)&&(r.children=this.filterColumns(r.children)),e.push(r)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.columns.length&&this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=r=>{r.forEach(o=>{t.push(o);const n=this.itemRowKeyMap.get(o),{expand:h,hasChildren:c,height:d}=this.rowKeyMap.get(n),f=this.sumHeight;this.sumHeight+=d,this.rowIndexRowKeyMap.set(e,n),this.rowKeyRowIndexMap.set(n,e),this.positions.push({top:f,height:d,bottom:this.sumHeight}),e+=1,h&&c&&i(o.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){t.forEach(i=>{const s=this.rowKeyMap.get(i);s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.rowKeyMap.forEach(e=>{e.expand=t}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowForRowIndex(t){const e=this.getRowKeyForRowIndex(t);return this.rowKeyMap.get(e)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)||""}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyRowIndexMap.get(t)}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),r=this.colIndexKeyMap.get(e);return s===void 0||r===void 0?null:{rowKey:s,key:r,value:this.getItemValue(s,r)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1){let i=[];const s=new Set;let r=[],o=t.map(d=>{const{rowKey:f,key:u}=d;let g=d.value,m=g;const x=this.getRowDataItemForRowKey(f),w=this.getItemValue(f,u),p=this.getVirtualBodyCellByKey(f,u);return(p==null?void 0:p.type)==="number"&&(["",void 0,null].includes(g)?m=null:/^-?\d+(\.\d+)?$/.test(`${g}`)?m=Number(g):(m=w,r.push({...d,value:m,oldValue:w,row:x}))),{...d,value:m,oldValue:w,row:x}});if(o=o.filter(d=>!r.some(f=>d.rowKey===f.rowKey&&d.key===f.key)),r.length){const d={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:r};this.ctx.emit("error",d)}if(!o.length)return;const{BEFORE_VALUE_CHANGE_METHOD:n}=this.ctx.config;typeof n=="function"&&(o=await n(o)),o.forEach(d=>{const{value:f,rowKey:u,key:g,oldValue:m}=d;s.add(u),this.setItemValue(u,g,f),i.push({rowKey:u,key:g,oldValue:m,newValue:f})});let h=[];s.forEach(d=>{h.push(this.ctx.database.getRowDataItemForRowKey(d))});const c=o.map(({rowKey:d,key:f})=>this.getValidator(d,f));Promise.all(c).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",o,h),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,r=!1,o=!1){if(!this.rowKeyMap.has(t))return{};const{item:n}=this.rowKeyMap.get(t);let h=n[e],c=i;if(this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};n[e]!==null&&typeof n[e]=="object"&&(h=JSON.parse(JSON.stringify(n[e])));const d=`${t}​_${e}`;this.originalDataMap.has(d)||this.originalDataMap.set(d,h);const f=this.originalDataMap.get(d),u=this.getRowDataItemForRowKey(t);if(o){const g=this.getVirtualBodyCellByKey(t,e);if((g==null?void 0:g.type)==="number")if(["",void 0,null].includes(i))c=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))c=Number(i);else{c=h;const w={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:c,oldValue:h,row:u}]};this.ctx.emit("error",w)}if(c===h)return{oldValue:h,newValue:h};const{BEFORE_VALUE_CHANGE_METHOD:m}=this.ctx.config;if(typeof m=="function"){const p=await m([{rowKey:t,key:e,value:c,oldValue:n[e],row:u}]);p&&p.length&&(c=p[0].value)}this.changedDataMap.set(d,c),n[e]=c;const x={rowKey:t,key:e,oldValue:h,value:c,row:u};this.getValidator(t,e).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",[x],[u]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:c,originalValue:f,row:u})}else this.changedDataMap.set(d,c),n[e]=c;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:h,value:c,originalValue:this.originalDataMap.get(d),row:u}),s&&this.ctx.history.pushState({type:"single",scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,changeList:[{rowKey:t,key:e,oldValue:h,newValue:c}]}),r&&this.ctx.emit("draw"),{oldValue:h,newValue:c}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),r=s[i];this.checkboxKeyMap.has(r)&&(this.checkboxKeyMap.get(r)||[]).forEach(n=>{const h=this.selectionMap.get(n);h&&(h.check=e)})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t),i=this.selectionMap.get(t);if(!i)return;i.check=!i.check,this.setRowSelectionByCheckboxKey(t,i.check),this.ctx.emit("toggleRowSelection",e);const s=this.getSelectionRows();this.ctx.emit("selectionChange",s),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}setRowSelection(t,e,i=!0){const s=this.selectionMap.get(t);s&&(s.check=e,this.setRowSelectionByCheckboxKey(t,s.check),this.ctx.emit("setRowSelection",e,s.row),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}getSelectionRows(){let t=[];return this.selectionMap.forEach(e=>{e.check&&t.push(e.row)}),t}getRowSelection(t){const e=this.selectionMap.get(t);return e?e.check:!1}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.rowKeyMap.forEach((e,i)=>{let s=e.selectable;typeof s=="function"&&(s=s({row:e.item,rowIndex:e.rowIndex})),s&&this.setRowSelection(i,!0,!1)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){t?this.rowKeyMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)}):this.selectionMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)});const e=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}getCheckedState(){const{buffer:t,...e}=this.bufferCheckState;if(t)return e;const i=this.rowKeyMap.size;let s=0,r=0;const o=this.selectionMap.size,n=Array.from(this.selectionMap.values()).some(u=>u.check);this.rowKeyMap.forEach((u,g)=>{var x;(x=this.selectionMap.get(g))!=null&&x.check&&(s+=1);let m=u.selectable;typeof m=="function"&&(m=m({row:u.item,rowIndex:u.rowIndex})),m&&(r+=1)});const h=o>i&&s===0&&n,c=r&&r>s&&s>0||h,d=r!==0,f=!!r&&r===s;return this.bufferCheckState={buffer:!0,check:f,indeterminate:c,selectable:d},{check:f,indeterminate:c,selectable:d}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getColumnByColIndex(t){var i;const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return(i=this.headerMap.get(e))==null?void 0:i.column}getColumnByKey(t){const e=this.headerMap.get(t);if(e)return e}getColIndexForKey(t){var e;if(t&&this.headerMap.has(t))return(e=this.headerMap.get(t))==null?void 0:e.colIndex}getColHeaderByIndex(t){const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return this.headerMap.get(e)}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),r=i.split("​_")[0],o=i.split("​_")[1];s!==e&&t.push({rowKey:r,colKey:o,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(r),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const r=this.originalDataMap.get(s),o=s.split("​_")[0];r!==i&&t.add(o)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}​_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),r=this.changedDataMap.get(i);return s!==r}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const{DISABLED:i}=this.ctx.config;if(i)return!0;const s=this.rowKeyMap.get(t),r=this.headerMap.get(e);if(!s||!r)return!0;const o=s.readonly,n=r.readonly,{BODY_CELL_READONLY_METHOD:h}=this.ctx.config;if(typeof h=="function"&&r){const d=h({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:r.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return n||o}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:o}=this.ctx.config;if(r===void 0)return i([]);const n=r.column;let h=n.rules;if(typeof o=="function"){const d=o({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:n,value:this.getItemValue(t,e)});d&&(h=d)}if(h){let c={},d={};if(d[e]=this.getItemValue(t,e),Array.isArray(h)){const u=h.map(g=>({...g,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex}));c[e]=u}else c[e]={...h,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex};new nt(c).validate(d).then(()=>{this.clearValidationError(t,e),i([])}).catch(({errors:u})=>{const g=u.map(m=>({...m,column:n,key:e,row:s.item,rowKey:t}));this.setValidationError(t,e,g),i(g)})}else i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const r=this.positions[t+s];r&&(i+=r.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:r,value:o,colIndex:n,relationRowKeys:h,relationColKeys:c,rowspan:d,height:f,width:u,colspan:g,mergeRow:m,mergeCol:x}=t;if(d===1&&g===1)return{xArr:[n,n],yArr:[e,e],rowspan:d,colspan:g,height:f,width:u,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:r,value:o}]};let w=e,p=e,C=n,y=n,b=[],E=0,R=0,O=0,I=0;if(d!==1&&m){I=u;const _=h.reduce((v,S)=>{const T=this.getItemValue(s,S)??"";return`${v}${T}`},"");for(let v=e-1;v>=0;v--){const S=this.rowIndexRowKeyMap.get(v)||"",T=h.reduce((M,A)=>{const B=this.getItemValue(S,A)??"";return`${M}${B}`},"");if(_===T)w=v;else break}for(let v=e;v<=this.ctx.maxRowIndex;v++){const S=this.rowIndexRowKeyMap.get(v)||"",T=h.reduce((M,A)=>{const B=this.getItemValue(S,A)??"";return`${M}${B}`},"");if(_===T)p=v;else break}for(let v=w;v<e;v++){const{height:S}=this.positions[v];E+=S}for(let v=w;v<=p;v++){const{height:S}=this.positions[v];O+=S;const T=this.rowIndexRowKeyMap.get(v)||"",{item:M}=this.rowKeyMap.get(T),A=this.getItemValue(T,i);b.push({rowKey:T,key:i,value:A,row:M})}}if(g!==1&&x){O=f;for(let _=n-1;_>=0;_--){const v=this.getColumnByColIndex(_);if(!v)break;const S=this.getItemValue(s,i),T=this.getItemValue(s,v.key);if(S===T&&c.includes(v.key))C=_;else break}for(let _=n;_<=this.ctx.maxColIndex;_++){const v=this.getColumnByColIndex(_);if(!v)break;const S=this.getItemValue(s,i),T=this.getItemValue(s,v.key);if(S===T&&c.includes(v.key))y=_;else break}for(let _=C;_<n;_++){const v=this.getColumnByColIndex(_);if(!v)break;R+=v.width||100}for(let _=C;_<=y;_++){const v=this.getColumnByColIndex(_);if(!v)break;I+=v.width||100,b.push({rowKey:s,key:v.key,value:this.getItemValue(s,v.key),row:r})}}return{xArr:[C,y],yArr:[w,p],rowspan:d,colspan:g,height:O,width:I,offsetTop:E,offsetLeft:R,dataList:b}}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const r=`${this.rowIndexRowKeyMap.get(t)}​_${e}`,o=[{message:i}];this.validationErrorMap.set(r,o)}setValidationError(t,e,i){const s=`${t}​_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}​_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}​_${e}`;return this.validationErrorMap.get(i)||[]}getVirtualBodyCell(t,e){const i=this.getColumnByColIndex(e),s=this.getRowForRowIndex(t);return!i||!s?void 0:new At(this.ctx,t,e,0,0,0,0,i,s.item,"body")}getVirtualBodyCellByKey(t,e){const i=this.getRowIndexForRowKey(t),s=this.getColIndexForKey(e);if(!(i===void 0||s===void 0))return this.getVirtualBodyCell(i,s)}hasMergeCell(t,e){let i=!1;for(let s=e[0];s<=e[1];s++)for(let r=t[0];r<=t[1];r++){const o=this.getVirtualBodyCell(s,r);if(o&&(o.rowspan!==1||o.colspan!==1)){i=!0;break}}return i}}class hi{constructor(t){l(this,"ctx");l(this,"history",[]);l(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(r=>({rowKey:r.rowKey,key:r.key,value:r.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1)}}clear(){this.history=[],this.historyIndex=-1}}class ci{constructor(t){l(this,"eventTasks",new Map);l(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"blur",this.handleOutsideMousedown.bind(this)),this.bind(window,"mousedown",this.handleOutsideMousedown.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchstart",this.handleTouchstart.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchend",this.handleTouchend.bind(this)),this.bind(this.ctx.stageElement,"touchmove",this.handleTouchmove.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this)),this.bind(this.ctx.stageElement,"mouseover",this.handleMouseover.bind(this)),this.bind(this.ctx.stageElement,"mouseout",this.handleMouseout.bind(this))}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){t.button===0&&(this.ctx.mousedown=!0),this.ctx.containerElement.focus({preventScroll:!0}),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget(t)&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleTouchstart(t){this.ctx.emit("touchstart",t)}handleTouchend(t){this.ctx.emit("touchend",t)}handleTouchmove(t){this.ctx.emit("touchmove",t)}handleContextMenu(t){this.ctx.emit("contextMenu",t)}handleMouseover(t){this.ctx.isMouseoverTargetContainer=!0,this.ctx.emit("mouseover",t)}handleMouseout(t){this.ctx.isMouseoverTargetContainer=!1,this.ctx.emit("mouseout",t)}handleDblclick(t){this.ctx.emit("dblclick",t)}handleOutsideMousedown(t){this.ctx.selector.enable&&(t.target instanceof Window||t.target instanceof Node&&!this.ctx.containerElement.contains(t.target))&&this.ctx.emit("outsideMousedown",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class di{constructor(){l(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class fi{constructor(t){l(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}scale(t){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,r){const{fillColor:o,side:n,shadowWidth:h,colorStart:c,colorEnd:d}=r;this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s));let f;switch(n){case"left":f=this.ctx.createLinearGradient(t-h,e,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-h,e,h,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+h,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,h,s);break;case"top":f=this.ctx.createLinearGradient(t,e-h,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-h,i,h);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+h),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,h);break;default:console.error("Invalid side specified for shadow");break}}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let r=2;r<t.length;r+=2)this.ctx.lineTo(t[r]-.5,t[r+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=4,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,r){this.ctx.save(),this.ctx.drawImage(t,e,i,s,r),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:r=1,borderColor:o,fillColor:n,radius:h=0}={}){if(this.ctx.save(),this.ctx.beginPath(),n!==void 0&&(this.ctx.fillStyle=n),o!==void 0&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=o),h===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,d,f,u]=typeof h=="number"?[h,h,h,h]:h;this.ctx.moveTo(t+c,e),this.ctx.arcTo(t+i,e,t+i,e+d,d),this.ctx.arcTo(t+i,e+s,t+i-f,e+s,f),this.ctx.arcTo(t,e+s,t,e+s-u,u),this.ctx.arcTo(t,e,t+c,e,c)}n!==void 0&&this.ctx.fill(),o!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,r,o={}){this.ctx.save();const{font:n="12px Arial",align:h="center",color:c="#495060",padding:d=0,verticalAlign:f="middle"}=o;this.ctx.font=n,this.ctx.fillStyle=c,this.ctx.textBaseline=f,this.ctx.textAlign=h;let u=0;f==="top"?u=i+d:f==="bottom"?u=i+r-d:u=i+(r+1)/2;let g=0;h==="left"?g=e+d:h==="right"?g=e+s-d:g=e+s/2;const{_text:m,ellipsis:x}=this.handleEllipsis(t,s,d,n);return this.ctx.fillText(m,g,u),this.ctx.restore(),x}handleEllipsis(t,e,i=0,s="12px Arial"){let r=!1,o=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:r};const n=this.ctx.measureText("...").width,h=this.ctx.measureText(t).width;if(h&&h+n>=e-i*2){r=!0;let c=0;for(let d=0;d<t.length;d++)if(c+=this.ctx.measureText(t[d]).width,c>=e-i*2-n){o=t.slice(0,d)+"...";break}}return{_text:o,ellipsis:r}}}class Wt{constructor(t){l(this,"_config",{});l(this,"CSS_PREFIX","e-virt-table");l(this,"ICONS",[]);l(this,"ROW_KEY","");l(this,"DISABLED",!1);l(this,"HEADER_FONT","12px normal Arial");l(this,"BODY_FONT","12px normal Arial");l(this,"BORDER",!0);l(this,"STRIPE",!1);l(this,"STRIPE_COLOR","#fafafa");l(this,"BORDER_COLOR","#e1e6eb");l(this,"WIDTH",0);l(this,"RESIZE_MIN_WIDTH",40);l(this,"HEIGHT",0);l(this,"PLACEHOLDER_COLOR","#CDD0DC");l(this,"EMPTY_BODY_HEIGHT",120);l(this,"EMPTY_CUSTOM_STYLE",{});l(this,"EMPTY_TEXT","暂无数据");l(this,"MAX_HEIGHT",1e3);l(this,"BORDER_RADIUS",8);l(this,"ENABLE_OFFSET_HEIGHT",!1);l(this,"OFFSET_HEIGHT",0);l(this,"HEADER_HEIGHT",36);l(this,"ENABLE_RESERVE_SELECTION",!1);l(this,"ENABLE_HEADER_STICKY",!1);l(this,"HEADER_BG_COLOR","#F8FAFF");l(this,"BODY_BG_COLOR","#FFF");l(this,"HEADER_TEXT_COLOR","#1D2129");l(this,"BODY_TEXT_COLOR","#4E5969");l(this,"FOOTER_TEXT_COLOR","#4E5969");l(this,"LOADING_ICON_SVG","");l(this,"LOADING_ICON_COLOR","#4E5969");l(this,"EXPAND_ICON_SVG","");l(this,"SHRINK_ICON_SVG","");l(this,"EXPAND_ICON_COLOR","#4E5969");l(this,"SHRINK_ICON_COLOR","#4E5969");l(this,"ERROR_TIP_ICON_COLOR","red");l(this,"ERROR_TIP_ICON_SIZE",6);l(this,"EXPAND_LAZY",!0);l(this,"DEFAULT_EXPAND_ALL",!1);l(this,"CELL_WIDTH",100);l(this,"CELL_HEIGHT",36);l(this,"CELL_PADDING",8);l(this,"CELL_HOVER_ICON_SIZE",14);l(this,"CELL_HOVER_ICON_BG_COLOR","#fff");l(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");l(this,"SCROLLER_TRACK_SIZE",14);l(this,"SCROLLER_SIZE",8);l(this,"SCROLLER_COLOR","#dee0e3");l(this,"SCROLLER_TRACK_COLOR","#fff");l(this,"SCROLLER_FOCUS_COLOR","#bbbec4");l(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");l(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");l(this,"SELECT_ROW_COL_BG_COLOR","transparent");l(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");l(this,"EDIT_BG_COLOR","#fcf6ed");l(this,"CHECKBOX_KEY","");l(this,"CHECKBOX_COLOR","rgb(82,146,247)");l(this,"CHECKBOX_SIZE",20);l(this,"CHECKBOX_DISABLED_SVG","");l(this,"CHECKBOX_CHECK_SVG","");l(this,"CHECKBOX_UNCHECK_SVG","");l(this,"CHECKBOX_INDETERMINATE_SVG","");l(this,"READONLY_COLOR","#fff");l(this,"READONLY_TEXT_COLOR","#4E5969");l(this,"ERROR_TIP_COLOR","#ED3F14");l(this,"FOOTER_BG_COLOR","#fafafa");l(this,"FOOTER_FIXED",!0);l(this,"FOOTER_POSITION","bottom");l(this,"CELL_FOOTER_HEIGHT",36);l(this,"ENABLE_SELECTOR",!0);l(this,"ENABLE_EDIT_SINGLE_CLICK",!1);l(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);l(this,"SELECTOR_AREA_MIN_X",0);l(this,"SELECTOR_AREA_MAX_X_OFFSET",0);l(this,"SELECTOR_AREA_MAX_X",0);l(this,"SELECTOR_AREA_MIN_Y",0);l(this,"SELECTOR_AREA_MAX_Y",0);l(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);l(this,"ENABLE_AUTO_THEME",!0);l(this,"ENABLE_SELECTOR_SINGLE",!1);l(this,"ENABLE_SELECTOR_SPAN_COL",!0);l(this,"ENABLE_SELECTOR_SPAN_ROW",!0);l(this,"ENABLE_SELECTOR_ALL_ROWS",!0);l(this,"ENABLE_SELECTOR_ALL_COLS",!0);l(this,"ENABLE_MERGE_CELL_LINK",!1);l(this,"ENABLE_AUTOFILL",!1);l(this,"ENABLE_CONTEXT_MENU",!1);l(this,"ENABLE_COPY",!0);l(this,"ENABLE_PASTER",!0);l(this,"ENABLE_RESIZE_ROW",!0);l(this,"ENABLE_RESIZE_COLUMN",!0);l(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");l(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");l(this,"RESIZE_ROW_MIN_HEIGHT",36);l(this,"RESIZE_COLUMN_MIN_WIDTH",40);l(this,"ENABLE_KEYBOARD",!0);l(this,"ENABLE_HISTORY",!1);l(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);l(this,"HISTORY_NUM",50);l(this,"HIGHLIGHT_HOVER_ROW",!1);l(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");l(this,"HIGHLIGHT_SELECTED_ROW",!1);l(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");l(this,"TOOLTIP_BG_COLOR","#303133");l(this,"TOOLTIP_TEXT_COLOR","#fff");l(this,"TOOLTIP_ZINDEX",3e3);l(this,"TOOLTIP_CUSTOM_STYLE",{});l(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);l(this,"HEADER_CELL_STYLE_METHOD");l(this,"BODY_CELL_STYLE_METHOD");l(this,"FOOTER_CELL_STYLE_METHOD");l(this,"BODY_CELL_READONLY_METHOD");l(this,"BODY_CELL_FORMATTER_METHOD");l(this,"BODY_CELL_RULES_METHOD");l(this,"BODY_CELL_TYPE_METHOD");l(this,"BODY_CELL_EDITOR_METHOD");l(this,"BODY_CELL_RENDER_METHOD");l(this,"BODY_CELL_HOVER_ICON_METHOD");l(this,"SPAN_METHOD");l(this,"SELECTABLE_METHOD");l(this,"EXPAND_LAZY_METHOD");l(this,"BEFORE_VALUE_CHANGE_METHOD");l(this,"BEFORE_PASTE_DATA_METHOD");l(this,"BEFORE_AUTOFILL_DATA_METHOD");l(this,"BEFORE_SET_SELECTOR_METHOD");l(this,"BEFORE_SET_AUTOFILL_METHOD");l(this,"BEFORE_COPY_METHOD");this._config=t,this.updateCssVar()}init(t){this._config=t,this.updateCssVar()}updateCssVar(){let t={};Object.keys(this).forEach(e=>{if(e.endsWith("_COLOR")||e.endsWith("_FONT")){const i=`--evt-${e.toLocaleLowerCase().replace(/_/g,"-")}`,s=ai(i);t[e]=s}}),Object.assign(this,t,this._config)}}const Pt='<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>';class ui{constructor(t){l(this,"ctx");l(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Pt,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_SVG",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" fill="#F1F2F4" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:""},{name:"icon-edit",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1744798692576" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6606" width="200" height="200"><path d="M855.296 894.528H168.768v-76.8h686.528v76.8z m38.4-38.4q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.824 4.8-3.2 2.112-6.656 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.52-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.76 4.736 2.752 2.688 4.864 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488z m-686.528 0q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.76 4.8-3.2 2.112-6.72 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.456-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.824 4.736 2.688 2.688 4.8 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488zM652.032 211.2l-369.92 370.368v89.344h90.048l369.664-369.856L652.032 211.2z m-54.4-54.272q22.528-22.528 54.4-22.528 31.808 0 54.336 22.528l89.792 89.856q22.464 22.464 22.464 54.272t-22.464 54.272l-369.664 369.856q-22.464 22.528-54.336 22.528H282.24q-31.808 0-54.336-22.528-22.464-22.464-22.464-54.272V581.568q0-31.808 22.4-54.272l369.92-370.368z" p-id="6607"></path></svg>',color:"#4E5969"},{name:"icon-select",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Pt,color:"#4E5969"}]);l(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color,r=i.svg;if(i.configColorName){const n=this.ctx.config[i.configColorName];n&&(s=n)}if(i.configName){const n=this.ctx.config[i.configName];n&&(r=n)}const o=this.createImageFromSVG(r,s).then(n=>{this.icons.set(i.name,n)});t.push(o)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const r=this.createImageFromSVG(i.svg,s,i.isBlob).then(o=>{this.icons.set(i.name,o)});t.push(r)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&o.querySelectorAll("*").forEach(c=>{c.setAttribute("fill",e)});const n=new Image;let h="";if(i){const c=new Blob([new XMLSerializer().serializeToString(o)],{type:"image/svg+xml"});h=URL.createObjectURL(c)}else h="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(o));return n.src=h,new Promise((c,d)=>{n.onerror=()=>d(new Error("Failed to load image")),n.onload=()=>{c(n)}})}get(t){return this.icons.get(t)}}class oe extends re{constructor(e,i,s,r,o,n,h){super(e,s,r,o,n,"header",h.fixed);l(this,"align");l(this,"verticalAlign","middle");l(this,"fixed");l(this,"widthFillDisable");l(this,"type");l(this,"operation",!1);l(this,"editorType");l(this,"level");l(this,"text");l(this,"displayText","");l(this,"colspan");l(this,"rowspan");l(this,"row");l(this,"key");l(this,"required",!1);l(this,"readonly",!1);l(this,"children",[]);l(this,"column");l(this,"colIndex");l(this,"rowKey");l(this,"rules");l(this,"hasChildren");l(this,"render");l(this,"style",{});l(this,"drawX",0);l(this,"drawY",0);l(this,"drawCellBgColor","");l(this,"drawTextColor","");l(this,"drawImageX",0);l(this,"drawImageY",0);l(this,"drawImageWidth",0);l(this,"drawImageHeight",0);l(this,"drawImageName","");l(this,"drawImageSource");this.ctx=e,this.x=s,this.y=r,this.width=o,this.height=n,this.colIndex=i,this.key=h.key,this.type=h.type||"",this.editorType=h.editorType||"text",this.align=h.align||"center",this.verticalAlign=h.verticalAlign||"middle",this.fixed=h.fixed,this.level=h.level||0,this.operation=h.operation||!1,this.text=h.title,this.column=h,this.colspan=h.colspan||1,this.widthFillDisable=h.widthFillDisable||!1,this.rowspan=h.rowspan||1,this.rules=h.rules,this.readonly=h.readonly||!1,this.required=h.required||!1,this.rowKey=Jt(),this.hasChildren=h.children&&h.children.length>0||!1,this.render=h.renderHeader}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let r=i,o=s;if(typeof e=="function"){const n=e,{backgroundColor:h,color:c}=n({colIndex:this.colIndex,column:this.column})||{};h&&(r=h),c&&(o=c)}this.drawCellBgColor=r,this.drawTextColor=o}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:r,BORDER:o}}=this.ctx,{drawX:n,drawY:h,displayText:c}=this;e.drawRect(n,h,this.width,this.height,{borderColor:o?i:"transparent",fillColor:this.drawCellBgColor}),e.drawText(c,n,h,this.width,this.height,{font:r,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection(),this.drawSelector()}drawSelector(){const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i}=this.ctx.selector,[s,r]=i;this.colIndex>=s&&this.colIndex<=r&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawSelection(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:r,check:o,selectable:n}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:h=0}=this.ctx.config,c=this.drawX+(e-h)/2,d=this.drawY+(i-h)/2;let f=this.ctx.icons.get("checkbox-uncheck"),u="checkbox-uncheck";r?(f=this.ctx.icons.get("checkbox-indeterminate"),u="checkbox-indeterminate"):o&&n?(f=this.ctx.icons.get("checkbox-check"),u="checkbox-check"):o&&n?(f=this.ctx.icons.get("checkbox-check-disabled"),u="checkbox-check-disabled"):!o&&n?(f=this.ctx.icons.get("checkbox-uncheck"),u="checkbox-uncheck"):(f=this.ctx.icons.get("checkbox-disabled"),u="checkbox-disabled"),f&&(this.drawImageX=c,this.drawImageY=d,this.drawImageWidth=h,this.drawImageHeight=h,this.drawImageName=u,this.drawImageSource=f,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":this.text}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class xi{constructor(t){l(this,"ctx");l(this,"visibleHoverCell");l(this,"resizeObserver");l(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(t=>{for(const e of t)e.type==="attributes"&&e.attributeName==="class"&&(this.ctx.config.updateCssVar(),this.ctx.emit("draw"))}),this.ctx.config.ENABLE_AUTO_THEME&&this.mutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.focusCellHeader=o,this.ctx.emit("cellHeaderMousedown",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.setFocusCell(o),this.ctx.emit("cellMousedown",o,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s),this.hoverIconClick(s)})}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.emit("cellHeaderContextMenuClick",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.emit("cellContextMenuClick",o,t)})}),this.ctx.on("mouseout",t=>{!this.ctx.containerElement.contains(t.relatedTarget)&&this.ctx.hoverCell!==void 0&&(this.ctx.hoverRow=void 0,this.ctx.hoverCell=void 0,this.ctx.emit("draw"))}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default");const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.ctx.emit("cellHeaderHoverChange",s))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.selectionEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var r;this.imageEnterAndLeave(s,t),this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((r=this.ctx.hoverCell)==null?void 0:r.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(o=>o.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}hoverIconClick(t){t.hoverIconName&&this.ctx.isPointer&&this.ctx.emit("hoverIconClick",t)}selectionClick(t){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof oe)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:o}=this.ctx.config;if(r&&o&&!i&&!s)typeof o=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),o({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(h=>{this.ctx.database.setExpandChildren(t.rowKey,h),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(h=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(h)}));else{const n=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!n),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0)}selectionEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight&&t instanceof At&&["selection","index-selection"].includes(t.type)&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;if(!this.ctx.isTarget(t)||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:o}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-o||r>this.ctx.stageWidth-o)}handleBodyEvent(t,e,i,s,r=!1){if(this.isInsideBody(e))for(const o of i){const n=o.fixedCells.concat(o.noFixedCells);for(const h of n){const c=h.getDrawX(),d=h.getDrawY();if(r){if(t>c&&t<c+h.visibleWidth&&e>d&&e<d+h.visibleHeight){s(h);return}}else if(t>c&&t<c+h.width&&e>d&&e<d+h.height){s(h);return}}}}handleHeaderEvent(t,e,i,s){for(const r of i){const o=r.getDrawX(),n=r.getDrawY();if(t>o&&t<o+r.width&&e>n&&e<n+r.height){s(r);return}}}isInsideBody(t){return t>this.ctx.body.y&&t<this.ctx.body.y+this.ctx.body.visibleHeight}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}class gi{constructor(t,e){l(this,"eventBus");l(this,"eventBrowser");l(this,"eventTable");l(this,"containerElement");l(this,"stageElement");l(this,"canvasElement");l(this,"overlayerElement");l(this,"editorElement");l(this,"emptyElement");l(this,"contextMenuElement");l(this,"stageWidth",0);l(this,"stageHeight",0);l(this,"paint");l(this,"icons");l(this,"isMouseoverTargetContainer",!1);l(this,"mousedown",!1);l(this,"isPointer",!1);l(this,"rowResizing",!1);l(this,"columnResizing",!1);l(this,"scrollerMove",!1);l(this,"scrollerFocus",!1);l(this,"autofillMove",!1);l(this,"selectorMove",!1);l(this,"adjustPositioning",!1);l(this,"editing",!1);l(this,"onlyMergeCell",!1);l(this,"selectOnlyOne",!1);l(this,"scrollY",0);l(this,"scrollX",0);l(this,"fixedLeftWidth",0);l(this,"fixedRightWidth",0);l(this,"lastCenterColIndex",0);l(this,"maxColIndex",0);l(this,"maxRowIndex",0);l(this,"hoverRow");l(this,"clickCell");l(this,"focusCell");l(this,"hoverCell");l(this,"clickCellHeader");l(this,"focusCellHeader");l(this,"hoverCellHeader");l(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});l(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});l(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});l(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});l(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});l(this,"database");l(this,"history");l(this,"config");const{containerElement:i,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:n,emptyElement:h,contextMenuElement:c}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=r,this.overlayerElement=o,this.editorElement=n,this.emptyElement=h,this.contextMenuElement=c,this.config=new Wt(e.config||{}),this.eventBus=new di,this.eventBrowser=new ci(this),this.eventTable=new xi(this),this.paint=new fi(this.canvasElement),this.database=new li(this,e),this.history=new hi(this),this.icons=new ui(this)}setConfig(t){this.config=new Wt(t)}setItemValueByEditor(t,e,i,s=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const o=this.database.getVirtualBodyCellByKey(t,e);if(o&&(o.mergeRow||o.mergeCol)){const{dataList:n}=o.getSpanInfo(),h=n.map(c=>({...c,value:i}));this.database.batchSetItemValue(h,s);return}}this.database.setItemValue(t,e,i,s,r,!0)}batchSetItemValueByEditor(t,e=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const i=[];t.forEach(s=>{const r=this.database.getRowIndexForRowKey(s.rowKey),o=this.database.getColIndexForKey(s.key);if(r===void 0||o===void 0)return;const n=this.database.getVirtualBodyCell(r,o);if(n){const{dataList:h}=n.getSpanInfo(),c=h.map(d=>({...d,value:s.value}));i.push(...c)}}),this.database.batchSetItemValue(i,e)}else this.database.batchSetItemValue(t,e)}setFocusCell(t){var e;this.focusCell!==t&&(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey&&(this.focusCell=t,this.emit("rowFocusChange",t)),this.focusCell=t,this.emit("cellFocusChange",t))}clearSelector(){this.selector.enable=!1,this.selector.xArr=[-1,-1],this.selector.yArr=[-1,-1],this.emit("clearSelector")}clearSelectorCopy(){this.selector.xArrCopy=[-1,-1],this.selector.yArrCopy=[-1,-1]}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let r=0;r<=e[1]-e[0];r++){const o=[];for(let n=0;n<=i[1]-i[0];n++){const h=r+e[0],c=n+i[0],d=this.database.getItemValueForRowIndexAndColIndex(h,c);d&&o.push(d.value)}s+=`${o.join(" ")}\r`,t.push(o)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let r=Math.floor(e),o=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(o=this.body.height+this.footer.height-this.body.visibleHeight),r<0?r=0:r>o&&(r=o),this.emit("setScroll",i,r)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class zt{constructor(t,e){l(this,"ctx");l(this,"type");l(this,"isFocus",!1);l(this,"trackX",0);l(this,"trackY",0);l(this,"trackWidth",0);l(this,"trackHeight",0);l(this,"splitPoints",[]);l(this,"barX",0);l(this,"barY",0);l(this,"barWidth",0);l(this,"barHeight",0);l(this,"distance",0);l(this,"visibleDistance",0);l(this,"clientX",0);l(this,"clientY",0);l(this,"dragStart",0);l(this,"isDragging",!1);l(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onTouchmove(t){const{clientY:e,clientX:i}=t.touches[0],s=e-this.clientY,r=i-this.clientX;let o=0;this.type==="vertical"?(o=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(o===0&&s>0||o===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(o=Math.max(0,Math.min(this.dragStart-r,this.distance))),this.scroll=o}onTouchstart(t){const{clientY:e,clientX:i}=t.touches[0];this.clientX=i,this.clientY=e,this.dragStart=this.scroll}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget(t))return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(!(s==this.clientX&&r==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=r,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let o=0;this.type==="vertical"?o=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:o=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(o,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:r,buttons:o}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,o===0||s==this.clientX&&r==this.clientY)return;let n=0;if(this.type==="horizontal"?n=s-this.clientX:n=r-this.clientY,this.isDragging&&n!==0){let h=0;this.type==="vertical"?h=this.dragStart+n/(this.visibleDistance-this.barHeight)*this.distance:h=this.dragStart+n/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(h,this.distance))}}isPointInElement(t,e,i,s,r,o){return t>=i&&t<=i+r&&e>=s&&e<=s+o}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:r=0,SCROLLER_SIZE:o=0,BORDER:n}}=this.ctx,h=s,c=i,d=e.height,f=e.width,u=t.height,g=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=c-r-d,this.distance=u-this.visibleDistance+g,this.trackX=h-r,this.trackY=0,this.splitPoints=[this.trackX,d,this.trackX+r,d],this.trackWidth=r,this.trackHeight=c,this.barX=this.trackX-1+(r-o)/2,this.barWidth=o;const m=this.distance?this.visibleDistance/(u+g):0;let x=Math.floor(m*this.visibleDistance);x<30?x=30:x>this.visibleDistance&&(x=0),this.barHeight=x,this.barY=d+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=h-r,this.distance=f-this.visibleDistance,this.splitPoints=[h-r,c-r,h-r,c];const m=n?0:.5;this.trackX=0,this.trackY=c-r+m,this.trackWidth=h,this.trackHeight=r;const x=this.distance?this.visibleDistance/f:0;let w=Math.floor(x*this.visibleDistance);this.barY=this.trackY-1+(r-o)/2,w<30?w=30:w>=this.visibleDistance&&(w=0),this.barWidth=w,this.barHeight=o,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,BORDER:s,SCROLLER_TRACK_COLOR:r}}=this.ctx;this.updatedSize();let o=i;s||(o="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:o,fillColor:r}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:o,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class wi{constructor(t){l(this,"ctx");l(this,"verticalScrollbar");l(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new zt(t,"vertical"),this.horizontalScrollbar=new zt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("touchmove",e=>this.onTouchmove(e)),this.ctx.on("touchstart",e=>{this.onTouchstart(e)}),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onTouchmove(t){this.verticalScrollbar.onTouchmove(t),this.horizontalScrollbar.onTouchmove(t),this.draw()}onTouchstart(t){this.verticalScrollbar.onTouchstart(t),this.horizontalScrollbar.onTouchstart(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw"),this.ctx.emit("onScroll",t,e)}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:r}=i.getPositionForRowIndex(s);this.setScrollY(r-e.visibleHeight/2)}}class pi{constructor(t){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"resizeTarget",null);l(this,"resizeNum",0);l(this,"isResizing",!1);l(this,"clientX",0);l(this,"resizeDiff",0);l(this,"columnIndex",0);l(this,"isMouseDown",!1);l(this,"columns");l(this,"visibleLeafColumns",[]);l(this,"visibleHeight",0);l(this,"visibleWidth",0);l(this,"allCellHeaders",[]);l(this,"leafCellHeaders",[]);l(this,"renderLeafCellHeaders",[]);l(this,"fixedLeftCellHeaders",[]);l(this,"centerCellHeaders",[]);l(this,"fixedRightCellHeaders",[]);l(this,"renderCenterCellHeaders",[]);l(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Qt(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=te(i),r=_t(i);this.height=t*s,this.width=r.reduce((f,u)=>f+((u==null?void 0:u.width)||100),0),this.visibleHeight=this.height;const o=ei(ee(i,s));this.columnIndex=0,this.resizeNum=0,this.render(o,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const n=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(n.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth-.5+"px",this.visibleWidth=this.ctx.stageWidth-e;const h=this.visibleWidth-this.width;if(this.resizeNum&&h>0){const f=Math.floor(h/this.resizeNum*100)/100;this.resizeAllColumn(f)}const c=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=c.reduce((f,u)=>f+u.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,u)=>f+u.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.ctx.columnResizing=!1,this.clientX=0}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const r=this.resizeTarget.width;let o=e.clientX-this.clientX;o+r<s&&(o=-(r-s)),this.resizeDiff=o,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(e.offsetX<0||e.offsetX>this.visibleWidth){this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");return}this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of r){const{offsetX:n,offsetY:h}=this.ctx.getOffset(e),c=n,d=o.getDrawX();c>d+o.width-5&&c<d+o.width+4&&c<i-4&&o.colspan<=1&&this.ctx.isTarget(e)&&h<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}}))}resizeColumn(t,e){const i=r=>{r.forEach(o=>{if(o.children&&o.children.length>0&&i(o.children),o.key===t.key){const n=o.width||100;o.width=n+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const r=this.visibleWidth-this.width;s=Math.floor(r/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const r of this.allCellHeaders)if(r.widthFillDisable)e.set(r.key,r.width);else{const o=r.width+t*r.colspan;e.set(r.key,o),o<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=r=>{r.forEach(o=>{e.has(o.key)&&(o.width=e.get(o.key)),o.children&&o.children.length>0&&s(o.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:r=0}=this.ctx.config;for(let o=0;o<i;o++){const n=t[o],h=r*(n.rowspan||0),c=r*(n.level||0);let d=n.width||100;n.children&&(d=_t(n.children).reduce((g,m)=>g+((m==null?void 0:m.width)||100),0));const f=new oe(this.ctx,this.columnIndex,s,c,d,h,n);this.ctx.database.setHeader(n.key,f),this.allCellHeaders.push(f),n.children||(this.leafCellHeaders.push(f),f.column.widthFillDisable||this.resizeNum++),n.fixed==="left"?this.fixedLeftCellHeaders.push(f):n.fixed==="right"?this.fixedRightCellHeaders.push(f):this.centerCellHeaders.push(f),!n.children&&this.columnIndex++,n.children&&this.render(n.children,s),s+=d}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,r=i+s+this.resizeDiff-.5,o=[r-.5,0,r-.5,t];this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];if(this.centerCellHeaders.length){const s=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=s.colIndex}this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,r)=>s.x-r.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}drawBottomLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.height,t,this.height];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine(),this.drawBottomLine()}}class ne{constructor(t,e,i=0,s=0,r=0,o=0,n,h="body"){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height");l(this,"cells",[]);l(this,"fixedCells",[]);l(this,"noFixedCells",[]);l(this,"rowIndex",0);l(this,"rowKey","");l(this,"rowType","body");l(this,"data");this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=h,this.data=n,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(r=>{const o=new At(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);o.fixed?i.push(o):s.push(o),e.push(o)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}drawContainer(){this.noFixedCells.forEach(t=>{t.drawContainer()})}drawFixedContainer(){this.fixedCells.forEach(t=>{t.drawContainer()})}}class mi{constructor(t){l(this,"resizeTarget",null);l(this,"isMouseDown",!1);l(this,"resizeDiff",0);l(this,"clientY",0);l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"headIndex",0);l(this,"tailIndex",0);l(this,"isResizing",!1);l(this,"renderRows",[]);l(this,"visibleRows",[]);l(this,"visibleHeight",0);l(this,"visibleWidth",0);l(this,"containerRect");l(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:r,SCROLLER_TRACK_SIZE:o=0,HEIGHT:n,EMPTY_BODY_HEIGHT:h=0,MAX_HEIGHT:c=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:u}}=this.ctx;if(!e.width)return;this.x=0,u==="top"&&r?this.y=e.height+i.height:this.y=e.height;const{data:g,sumHeight:m}=s.getData();this.height=m,this.data=g,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-o;const x=this.ctx.footer.height;!this.data.length&&!n?this.height=h:!this.data.length&&n&&(this.height=n-e.height-x-o);let w=this.height+e.height+o;w+=x;let p=w;const C=window.innerHeight,{top:y}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(C>y&&d&&!n){const T=C-y-f;T>e.height+o?p=T:w>c&&(p=c)}else this.data.length&&n?p=n:this.data.length&&c&&w>c&&(p=c);p>0&&(this.ctx.stageHeight=Math.floor(p),this.ctx.stageElement.style.height=`${this.ctx.stageHeight-.5}px`);let b=this.ctx.stageHeight-e.height-o;r?this.visibleHeight=b-x:this.visibleHeight=b,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=g;const E=window.devicePixelRatio||1,R=this.ctx.stageWidth*E,O=this.ctx.stageHeight*E;t.width=Math.round(R),t.height=Math.round(O);const I=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:I,type:I,headerHeight:e.height,bodyHeight:this.height,footerHeight:x,width:this.width,height:this.data.length?0:h+x});const _=Math.round(t.width/E*1e4)/1e4,v=Math.round(t.height/E*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${v}px;width:${_}px;`),this.ctx.paint.scale(E)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("resize",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("resizeObserver",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0}),this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s,n=e.clientY,{stageHeight:h,scrollY:c,config:{RESIZE_ROW_MIN_HEIGHT:d=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const f=this.resizeTarget.height;let u=n-this.clientY;u+f<d&&(u=-(f-d)),this.resizeDiff=u,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||r<0||r>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");return}if(this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let f=0;f<this.renderRows.length;f++){const u=this.renderRows[f];if(r>u.y-c+u.height-1.5&&r<u.y-c+u.height+1.5&&r<h-4)for(let m=0;m<u.cells.length;m++){const x=u.cells[m];o>x.drawX+10&&o<x.drawX+x.width-10&&x.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=u)}}}}))}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:r,data:o}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:r,row:o,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,r=this.resizeTarget.height,o=s+r+this.resizeDiff-.5,n=[0,o-.5,t,o-.5];this.ctx.paint.drawLine(n,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,r=-1;for(;i<=s;){let o=Math.floor((i+s)/2),n=t[o].bottom;if(n===e)return o;n<e?i=o+1:(r=o,s=o-1)}return r}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,r=i,{data:o,positions:n}=e.getData();this.ctx.maxRowIndex=o.length-1;let h=this.binarySearch(n,r),c=this.binarySearch(n,r+this.visibleHeight);if(c===-1&&(c=this.ctx.maxRowIndex),h===-1&&c===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);h=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,h),this.tailIndex=Math.min(this.ctx.maxRowIndex,c+1),this.visibleRows=o.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const d=[];for(let f=0;f<this.visibleRows.length;f++){const u=this.headIndex+f,g=this.visibleRows[f],{height:m,top:x}=this.ctx.database.getPositionForRowIndex(u),w=new ne(this.ctx,u,0,x+this.y,t.width,m,g);d.push(w)}this.renderRows=d,this.ctx.body.renderRows=d}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class yi{constructor(t){l(this,"ctx");l(this,"renderRows",[]);l(this,"data",[]);l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"visibleWidth",0);l(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r,FOOTER_POSITION:o}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(n=>n+i,0),this.visibleHeight=this.height,s?o==="top"?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-r:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;let h=this.y;if(this.ctx.config.FOOTER_FIXED||(h=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,h,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const c=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(c,h,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,r)=>{const o=new ne(this.ctx,r,0,e,this.width,t,s,"footer");e+=t,i.push(o)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.y,t,this.y];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTopLine()}}class Ei{constructor(t){l(this,"isCut",!1);l(this,"isMultipleRow",!1);l(this,"mousedownHeader",!1);l(this,"ctx");l(this,"adjustPositionX","");l(this,"adjustPositionY","");l(this,"timerX",0);l(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",Qt(t=>{const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=this.ctx.isTarget(t)&&i>0&&i<this.ctx.body.visibleWidth&&e>this.ctx.header.visibleHeight&&e<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(!s&&!this.mousedownHeader?this.startAdjustPosition(t):this.stopAdjustPosition())},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(this.ctx.isTarget(e)&&this.ctx.stageElement.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.stageElement.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}}),this.ctx.on("mouseup",()=>{this.mousedownHeader=!1;const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{this.ctx.stageElement.style.cursor!=="pointer"&&(this.ctx.isPointer||(e.preventDefault(),this.mousedownHeader=!0,this.selectCols(t)))}),this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"||t.shiftKey&&t.code==="Tab"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.stopAdjustPosition()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let r=t,o=e;if(!s){const[n]=o;o=[n,n]}if(!i){const[n]=r;r=[n,n]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(o)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:c,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,g=n,m=h||this.ctx.maxColIndex-f,x=c,w=d||this.ctx.maxRowIndex-u;let[p,C]=r,[y,b]=o;if(p<g||C>m||y<x||b>w)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const R=this.adjustMergeCells(r,o);y=R.yArr[0],b=R.yArr[1],p=R.xArr[0],C=R.xArr[1],this.ctx.onlyMergeCell=R.onlyMergeCell}p===C&&y===b?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,r=[Math.max(g,p),Math.min(m,C)],o=[Math.max(x,y),Math.min(w,b)];const{BEFORE_SET_SELECTOR_METHOD:E}=this.ctx.config;if(typeof E=="function"){const O=E({focusCell:this.ctx.focusCell,xArr:r,yArr:o});if(!O)return;r=O.xArr,o=O.yArr}this.ctx.selector.xArr=r,this.ctx.selector.yArr=o,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var m;const[i,s]=e,[r,o]=t;let n=[],h=[];for(let x=0;x<=e[1]-e[0];x++)for(let w=0;w<=t[1]-t[0];w++){const p=x+e[0],C=w+t[0],y=this.ctx.database.getVirtualBodyCell(p,C);y&&((p===i||p===s)&&n.push(y),(C===r||C===o)&&h.push(y))}const c=n.reduce((x,w)=>{const{yArr:p}=w.getSpanInfo(),[C,y]=p;return x.minY=Math.min(x.minY,C),x.maxY=Math.max(x.maxY,y),x},{minY:i,maxY:s}),d=h.reduce((x,w)=>{const{xArr:p}=w.getSpanInfo(),[C,y]=p;return x.minX=Math.min(x.minX,C),x.maxX=Math.max(x.maxX,y),x},{minX:r,maxX:o}),f=[d.minX,d.maxX],u=[c.minY,c.maxY];let g=!1;if(d.minX!==d.maxX||c.minY!==c.maxY){const x=JSON.stringify(f)+JSON.stringify(u),w=(m=this.ctx.focusCell)==null?void 0:m.getSpanInfo();g=(w&&JSON.stringify(w.xArr)+JSON.stringify(w.yArr))===x}return{xArr:f,yArr:u,onlyMergeCell:g}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,r=e,o=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:n}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=n){const h=[n,t.colIndex+t.colspan-1],c=[r,o];this.setSelector(h,c)}else{const h=[t.colIndex,n],c=[r,o];this.setSelector(h,c)}}else{const n=[t.colIndex,t.colIndex+t.colspan-1],h=[r,o];this.setSelector(n,h)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-n,f=r,u=o||this.ctx.maxRowIndex-h,g=[c,d],m=[f,u];this.setSelector(g,m)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r}=this.ctx.config,o=s||this.ctx.maxColIndex-r,n=i;if(e){this.ctx.setFocusCell(t);const h=[n,o],c=[t.rowIndex,t.rowIndex];this.setSelector(h,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:h}=this.ctx.focusCell;if(t.rowIndex>=h){const c=[n,o],d=[h,t.rowIndex];this.setSelector(c,d)}else{const c=[n,o],d=[t.rowIndex,h];this.setSelector(c,d)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:r}=e,o=Math.min(i.colIndex,r),n=Math.max(i.colIndex,r),h=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),d=[o,n],f=[h,c];this.setSelector(d,f)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE)return;const{colIndex:s,rowIndex:r}=i,{colIndex:o,rowIndex:n}=e,h=Math.min(o,s),c=Math.max(o,s),d=Math.min(n,r),f=Math.max(n,r),u=[h,c],g=[d,f];this.setSelector(u,g)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],r=[e.rowIndex,e.rowIndex];this.setSelector(s,r),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(r=>r.rowIndex===t);return i==null?void 0:i.cells.find(r=>r.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY)return;let{value:t,xArr:e,yArr:i}=this.ctx.getSelectedData();if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(e,i))if(this.ctx.onlyMergeCell&&this.ctx.focusCell){const o=this.ctx.focusCell;t=[[o.getValue()]],e=[o.colIndex,o.colIndex],i=[o.rowIndex,o.rowIndex]}else{const o={code:"ERR_MERGED_CELLS_COPY",message:"Merged cells cannot span copy data"};this.ctx.hasEvent("error")?this.ctx.emit("error",o):alert(o.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const n=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!n)return;t=n.data}const r=ri(t);navigator.clipboard?navigator.clipboard.writeText(r).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(o=>console.error("Copy Failure:",o)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1){let s=[];const r=new Set;for(let n=0;n<=e[1]-e[0];n++)for(let h=0;h<=t[1]-t[0];h++){const c=n+e[0],d=h+t[0],f=this.ctx.database.getItemValueForRowIndexAndColIndex(c,d);if(f){const{rowKey:u,key:g}=f;this.ctx.database.getReadonly(u,g)||(r.add(u),s.push({rowKey:u,key:g,value:null,row:{}}))}}if(!s.length)return[];if(i)return s;this.ctx.database.batchSetItemValue(s,!0);let o=[];return r.forEach(n=>{o.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("clearSelectedDataChange",s,o),s}paste(){if(!navigator.clipboard){console.error("current browser does not support the Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async r=>{let o=si(r);const n=[i,i+o[0].length-1],h=[e,e+o.length-1],[c,d]=h,[f,u]=n,g=d-this.ctx.maxRowIndex,m=u-this.ctx.maxColIndex;(g>0||m>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:u,minY:c,minX:f,overflowRowCount:g,overflowColCount:m,textArr:o});const x=o.length===1&&o[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(n,h)&&!x){const y={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",y):alert(y.message);return}let w=[];for(let y=0;y<=o.length-1;y++){const b=o[y].length;for(let E=0;E<=b-1;E++){const R=y+e,O=E+i,I=o[y][E],_=this.ctx.database.getItemValueForRowIndexAndColIndex(R,O);if(_){const{rowKey:v,key:S}=_;this.ctx.database.getReadonly(v,S)||(s.add(v),w.push({rowKey:v,key:S,value:I,row:{}}))}}}if(this.isCut){const y=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),b=w.map(E=>`${E.rowKey}-${E.key}`);y.forEach(E=>{b.includes(`${E.rowKey}-${E.key}`)||w.unshift(E)}),this.isCut=!1}if(!w.length)return;const{BEFORE_PASTE_DATA_METHOD:p}=this.ctx.config;if(typeof p=="function"){const y=p,b=w.map(E=>({rowKey:E.rowKey,key:E.key,value:E.value,oldValue:this.ctx.database.getItemValue(E.rowKey,E.key),row:this.ctx.database.getRowDataItemForRowKey(E.rowKey)}));if(w=await y(b,n,h,o),w&&!w.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(w,!0);let C=[];s.forEach(y=>{C.push(this.ctx.database.getRowDataItemForRowKey(y))}),this.ctx.emit("pasteChange",w,C)}).catch(r=>{console.error("Failed to get the clipboard content:",r)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const r=0,o=0,n=this.ctx.maxColIndex,h=this.ctx.maxRowIndex;switch(t){case"LEFT":i>r&&i--;break;case"TOP":s>o&&s--;break;case"RIGHT":i<n&&i++;break;case"BOTTOM":s<h&&s++;break}const c=[i,i],d=[s,s],f=this.getCell(s,i);f&&(f.operation||this.isInSettingRange(f.rowIndex,f.colIndex)&&(this.ctx.setFocusCell(f),this.setSelector(c,d),this.adjustBoundaryPosition(),this.ctx.emit("moveFocus",f),this.ctx.emit("draw")))}stopAdjustPosition(){this.adjustPositionX="",this.adjustPositionY="",this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerY&&(clearInterval(this.timerY),this.timerY=0)}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-n,f=r,u=o||this.ctx.maxRowIndex-h;return!(e<c||e>d||t<f||t>u)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",r="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?r="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(r="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let n=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{n*=1.5;const{scrollX:h}=this.ctx,c=h+n;(c<0||c>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(c)},100)}if(r&&this.adjustPositionY!==r){this.adjustPositionY=r;let n=10*(r==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{n*=1.5;const{scrollY:h}=this.ctx,c=h+n;(c<0||c>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(c)},100)}}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:r,header:o,footer:n,body:h,scrollX:c,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:u,FOOTER_POSITION:g,ENABLE_MERGE_CELL_LINK:m}}=this.ctx;if(!i)return;m&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:x,drawY:w,width:p,height:C,fixed:y}=i,b=r-x+1,E=i.drawX+p-(e-s)+1;let R=o.height-w,O=C;O>h.visibleHeight&&(O=h.visibleHeight);let I=0;u&&(g==="top"?R=o.height+n.height-w:I=n.visibleHeight);const _=w+O-(t-I-f);let v=c,S=d;E>0&&!y?v=Math.floor(c+E):b>0&&!y&&(v=Math.floor(c-b)),R>0?S=Math.floor(d-R):_>0&&(S=Math.floor(d+_)),(Math.abs(c-v)>2||Math.abs(d-S)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(v,S),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class Ci{constructor(t){l(this,"ctx");l(this,"maxColRowCell");this.ctx=t,this.init()}init(){this.ctx.on("mousemove",t=>{if(this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t),{colIndex:s,rowIndex:r,drawX:o,drawY:n,width:h,height:c}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||r===this.ctx.maxRowIndex?0:2,u=o+h-d+f,g=n+c-d+f;e>u&&i>g&&e<u+d&&i<g+d&&(this.ctx.stageElement.style.cursor="crosshair")}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],r=i[1],{colIndex:o,rowIndex:n}=t;this.ctx.config.ENABLE_AUTOFILL&&o===s&&n===r&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:r}=this.ctx.config;if(!i)return;let o=t,n=e;if(!r){const[h]=n;n=[h,h]}if(!s){const[h]=o;o=[h,h]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(n)){const{SELECTOR_AREA_MIN_X:h,SELECTOR_AREA_MAX_X:c,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:u,SELECTOR_AREA_MAX_Y_OFFSET:g}=this.ctx.config,m=h,x=c||this.ctx.maxColIndex-u,w=d,p=f||this.ctx.maxRowIndex-g;let[C,y]=o,[b,E]=n;if(C<m||b<w)return;o=[Math.max(m,C),Math.min(x,y)],n=[Math.max(w,b),Math.min(p,E)];const{BEFORE_SET_AUTOFILL_METHOD:R}=this.ctx.config;if(typeof R=="function"){const I=R({focusCell:this.ctx.focusCell,xArr:o,yArr:n});if(!I)return;o=I.xArr,n=I.yArr}this.ctx.autofill.xArr=o,this.ctx.autofill.yArr=n,this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let g=0;g<=e.yArr[1]-e.yArr[0];g++)for(let m=0;m<=e.xArr[1]-e.xArr[0];m++){const x=g+e.yArr[0],w=m+e.xArr[0];i.set(`${x}-${w}`,!0)}const{value:s}=e,r=s[0].length,o=s.length,n=this.ctx.autofill.xArr,h=this.ctx.autofill.yArr,c=r===1&&o===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(n,h)&&!c){const g={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",g):alert(g.message);return}let d=[];for(let g=0;g<=h[1]-h[0];g++)for(let m=0;m<=n[1]-n[0];m++){const x=m+n[0],w=g+h[0],p=s[g%o][m%r],C=this.ctx.database.getItemValueForRowIndexAndColIndex(w,x),y=`${w}-${x}`;if(C&&!i.has(y)){const{rowKey:b,key:E}=C;this.ctx.database.getReadonly(b,E)||(t.add(b),d.push({rowKey:b,key:E,value:p,row:{}}))}}if(!d.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;const{BEFORE_AUTOFILL_DATA_METHOD:f}=this.ctx.config;if(typeof f=="function"){const g=f,m=d.map(x=>({rowKey:x.rowKey,key:x.key,value:x.value,oldValue:this.ctx.database.getItemValue(x.rowKey,x.key),row:this.ctx.database.getRowDataItemForRowKey(x.rowKey)}));if(d=await g(m,n,h),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let u=[];t.forEach(g=>{u.push(this.ctx.database.getRowDataItemForRowKey(g))}),this.ctx.emit("autofillChange",d,u)}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:r}=t,o=e.xArr.slice(),n=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?r>e.xArr[1]?o.splice(1,1,r):r<e.xArr[0]&&o.splice(0,1,r):s>e.yArr[1]?n.splice(1,1,s):s<e.yArr[0]&&n.splice(0,1,s),this.setAutofill(o,n)}}destroy(){}}const rt=Math.min,U=Math.max,ft=Math.round,z=a=>({x:a,y:a}),bi={left:"right",right:"left",bottom:"top",top:"bottom"},vi={start:"end",end:"start"};function It(a,t,e){return U(a,rt(t,e))}function at(a,t){return typeof a=="function"?a(t):a}function G(a){return a.split("-")[0]}function lt(a){return a.split("-")[1]}function ae(a){return a==="x"?"y":"x"}function Mt(a){return a==="y"?"height":"width"}function J(a){return["top","bottom"].includes(G(a))?"y":"x"}function Ht(a){return ae(J(a))}function Ri(a,t,e){e===void 0&&(e=!1);const i=lt(a),s=Ht(a),r=Mt(s);let o=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=ut(o)),[o,ut(o)]}function _i(a){const t=ut(a);return[Ot(a),t,Ot(t)]}function Ot(a){return a.replace(/start|end/g,t=>vi[t])}function Ii(a,t,e){const i=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(a){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?r:o;default:return[]}}function Oi(a,t,e,i){const s=lt(a);let r=Ii(G(a),e==="start",i);return s&&(r=r.map(o=>o+"-"+s),t&&(r=r.concat(r.map(Ot)))),r}function ut(a){return a.replace(/left|right|bottom|top/g,t=>bi[t])}function Li(a){return{top:0,right:0,bottom:0,left:0,...a}}function le(a){return typeof a!="number"?Li(a):{top:a,right:a,bottom:a,left:a}}function xt(a){const{x:t,y:e,width:i,height:s}=a;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function $t(a,t,e){let{reference:i,floating:s}=a;const r=J(t),o=Ht(t),n=Mt(o),h=G(t),c=r==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,u=i[n]/2-s[n]/2;let g;switch(h){case"top":g={x:d,y:i.y-s.height};break;case"bottom":g={x:d,y:i.y+i.height};break;case"right":g={x:i.x+i.width,y:f};break;case"left":g={x:i.x-s.width,y:f};break;default:g={x:i.x,y:i.y}}switch(lt(t)){case"start":g[o]-=u*(e&&c?-1:1);break;case"end":g[o]+=u*(e&&c?-1:1);break}return g}const Si=async(a,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=e,n=r.filter(Boolean),h=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:a,floating:t,strategy:s}),{x:d,y:f}=$t(c,i,h),u=i,g={},m=0;for(let x=0;x<n.length;x++){const{name:w,fn:p}=n[x],{x:C,y,data:b,reset:E}=await p({x:d,y:f,initialPlacement:i,placement:u,strategy:s,middlewareData:g,rects:c,platform:o,elements:{reference:a,floating:t}});d=C??d,f=y??f,g={...g,[w]:{...g[w],...b}},E&&m<=50&&(m++,typeof E=="object"&&(E.placement&&(u=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:a,floating:t,strategy:s}):E.rects),{x:d,y:f}=$t(c,u,h)),x=-1)}return{x:d,y:f,placement:u,strategy:s,middlewareData:g}};async function he(a,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:o,elements:n,strategy:h}=a,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:u=!1,padding:g=0}=at(t,a),m=le(g),w=n[u?f==="floating"?"reference":"floating":f],p=xt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(w)))==null||e?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(n.floating)),boundary:c,rootBoundary:d,strategy:h})),C=f==="floating"?{x:i,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(n.floating)),b=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},E=xt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:n,rect:C,offsetParent:y,strategy:h}):C);return{top:(p.top-E.top+m.top)/b.y,bottom:(E.bottom-p.bottom+m.bottom)/b.y,left:(p.left-E.left+m.left)/b.x,right:(E.right-p.right+m.right)/b.x}}const Ti=a=>({name:"arrow",options:a,async fn(t){const{x:e,y:i,placement:s,rects:r,platform:o,elements:n,middlewareData:h}=t,{element:c,padding:d=0}=at(a,t)||{};if(c==null)return{};const f=le(d),u={x:e,y:i},g=Ht(s),m=Mt(g),x=await o.getDimensions(c),w=g==="y",p=w?"top":"left",C=w?"bottom":"right",y=w?"clientHeight":"clientWidth",b=r.reference[m]+r.reference[g]-u[g]-r.floating[m],E=u[g]-r.reference[g],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let O=R?R[y]:0;(!O||!await(o.isElement==null?void 0:o.isElement(R)))&&(O=n.floating[y]||r.floating[m]);const I=b/2-E/2,_=O/2-x[m]/2-1,v=rt(f[p],_),S=rt(f[C],_),T=v,M=O-x[m]-S,A=O/2-x[m]/2+I,B=It(T,A,M),Y=!h.arrow&&lt(s)!=null&&A!==B&&r.reference[m]/2-(A<T?v:S)-x[m]/2<0,k=Y?A<T?A-T:A-M:0;return{[g]:u[g]+k,data:{[g]:B,centerOffset:A-B-k,...Y&&{alignmentOffset:k}},reset:Y}}}),Ai=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(t){var e,i;const{placement:s,middlewareData:r,rects:o,initialPlacement:n,platform:h,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:u,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...w}=at(a,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const p=G(s),C=J(n),y=G(n)===n,b=await(h.isRTL==null?void 0:h.isRTL(c.floating)),E=u||(y||!x?[ut(n)]:_i(n)),R=m!=="none";!u&&R&&E.push(...Oi(n,x,m,b));const O=[n,...E],I=await he(t,w),_=[];let v=((i=r.flip)==null?void 0:i.overflows)||[];if(d&&_.push(I[p]),f){const A=Ri(s,o,b);_.push(I[A[0]],I[A[1]])}if(v=[...v,{placement:s,overflows:_}],!_.every(A=>A<=0)){var S,T;const A=(((S=r.flip)==null?void 0:S.index)||0)+1,B=O[A];if(B)return{data:{index:A,overflows:v},reset:{placement:B}};let Y=(T=v.filter(k=>k.overflows[0]<=0).sort((k,W)=>k.overflows[1]-W.overflows[1])[0])==null?void 0:T.placement;if(!Y)switch(g){case"bestFit":{var M;const k=(M=v.filter(W=>{if(R){const P=J(W.placement);return P===C||P==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(P=>P>0).reduce((P,Ce)=>P+Ce,0)]).sort((W,P)=>W[1]-P[1])[0])==null?void 0:M[0];k&&(Y=k);break}case"initialPlacement":Y=n;break}if(s!==Y)return{reset:{placement:Y}}}return{}}}};async function Mi(a,t){const{placement:e,platform:i,elements:s}=a,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),o=G(e),n=lt(e),h=J(e)==="y",c=["left","top"].includes(o)?-1:1,d=r&&h?-1:1,f=at(t,a);let{mainAxis:u,crossAxis:g,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return n&&typeof m=="number"&&(g=n==="end"?m*-1:m),h?{x:g*d,y:u*c}:{x:u*c,y:g*d}}const Hi=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(t){var e,i;const{x:s,y:r,placement:o,middlewareData:n}=t,h=await Mi(t,a);return o===((e=n.offset)==null?void 0:e.placement)&&(i=n.arrow)!=null&&i.alignmentOffset?{}:{x:s+h.x,y:r+h.y,data:{...h,placement:o}}}}},Di=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:n={fn:w=>{let{x:p,y:C}=w;return{x:p,y:C}}},...h}=at(a,t),c={x:e,y:i},d=await he(t,h),f=J(G(s)),u=ae(f);let g=c[u],m=c[f];if(r){const w=u==="y"?"top":"left",p=u==="y"?"bottom":"right",C=g+d[w],y=g-d[p];g=It(C,g,y)}if(o){const w=f==="y"?"top":"left",p=f==="y"?"bottom":"right",C=m+d[w],y=m-d[p];m=It(C,m,y)}const x=n.fn({...t,[u]:g,[f]:m});return{...x,data:{x:x.x-e,y:x.y-i,enabled:{[u]:r,[f]:o}}}}}};function gt(){return typeof window<"u"}function tt(a){return ce(a)?(a.nodeName||"").toLowerCase():"#document"}function X(a){var t;return(a==null||(t=a.ownerDocument)==null?void 0:t.defaultView)||window}function V(a){var t;return(t=(ce(a)?a.ownerDocument:a.document)||window.document)==null?void 0:t.documentElement}function ce(a){return gt()?a instanceof Node||a instanceof X(a).Node:!1}function N(a){return gt()?a instanceof Element||a instanceof X(a).Element:!1}function K(a){return gt()?a instanceof HTMLElement||a instanceof X(a).HTMLElement:!1}function qt(a){return!gt()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof X(a).ShadowRoot}function ht(a){const{overflow:t,overflowX:e,overflowY:i,display:s}=F(a);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Xi(a){return["table","td","th"].includes(tt(a))}function wt(a){return[":popover-open",":modal"].some(t=>{try{return a.matches(t)}catch{return!1}})}function Dt(a){const t=Xt(),e=N(a)?F(a):a;return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Ni(a){let t=$(a);for(;K(t)&&!Q(t);){if(Dt(t))return t;if(wt(t))return null;t=$(t)}return null}function Xt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Q(a){return["html","body","#document"].includes(tt(a))}function F(a){return X(a).getComputedStyle(a)}function pt(a){return N(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function $(a){if(tt(a)==="html")return a;const t=a.assignedSlot||a.parentNode||qt(a)&&a.host||V(a);return qt(t)?t.host:t}function de(a){const t=$(a);return Q(t)?a.ownerDocument?a.ownerDocument.body:a.body:K(t)&&ht(t)?t:de(t)}function Lt(a,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=de(a),r=s===((i=a.ownerDocument)==null?void 0:i.body),o=X(s);if(r){const n=St(o);return t.concat(o,o.visualViewport||[],ht(s)?s:[],n&&e?Lt(n):[])}return t.concat(s,Lt(s,[],e))}function St(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function fe(a){const t=F(a);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=K(a),r=s?a.offsetWidth:e,o=s?a.offsetHeight:i,n=ft(e)!==r||ft(i)!==o;return n&&(e=r,i=o),{width:e,height:i,$:n}}function ue(a){return N(a)?a:a.contextElement}function Z(a){const t=ue(a);if(!K(t))return z(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:r}=fe(t);let o=(r?ft(e.width):e.width)/i,n=(r?ft(e.height):e.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!n||!Number.isFinite(n))&&(n=1),{x:o,y:n}}const Fi=z(0);function xe(a){const t=X(a);return!Xt()||!t.visualViewport?Fi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bi(a,t,e){return t===void 0&&(t=!1),!e||t&&e!==X(a)?!1:t}function ot(a,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=a.getBoundingClientRect(),r=ue(a);let o=z(1);t&&(i?N(i)&&(o=Z(i)):o=Z(a));const n=Bi(r,e,i)?xe(r):z(0);let h=(s.left+n.x)/o.x,c=(s.top+n.y)/o.y,d=s.width/o.x,f=s.height/o.y;if(r){const u=X(r),g=i&&N(i)?X(i):i;let m=u,x=St(m);for(;x&&i&&g!==m;){const w=Z(x),p=x.getBoundingClientRect(),C=F(x),y=p.left+(x.clientLeft+parseFloat(C.paddingLeft))*w.x,b=p.top+(x.clientTop+parseFloat(C.paddingTop))*w.y;h*=w.x,c*=w.y,d*=w.x,f*=w.y,h+=y,c+=b,m=X(x),x=St(m)}}return xt({width:d,height:f,x:h,y:c})}function ki(a){let{elements:t,rect:e,offsetParent:i,strategy:s}=a;const r=s==="fixed",o=V(i),n=t?wt(t.floating):!1;if(i===o||n&&r)return e;let h={scrollLeft:0,scrollTop:0},c=z(1);const d=z(0),f=K(i);if((f||!f&&!r)&&((tt(i)!=="body"||ht(o))&&(h=pt(i)),K(i))){const u=ot(i);c=Z(i),d.x=u.x+i.clientLeft,d.y=u.y+i.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-h.scrollLeft*c.x+d.x,y:e.y*c.y-h.scrollTop*c.y+d.y}}function Ki(a){return Array.from(a.getClientRects())}function Tt(a,t){const e=pt(a).scrollLeft;return t?t.left+e:ot(V(a)).left+e}function Yi(a){const t=V(a),e=pt(a),i=a.ownerDocument.body,s=U(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=U(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let o=-e.scrollLeft+Tt(a);const n=-e.scrollTop;return F(i).direction==="rtl"&&(o+=U(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:o,y:n}}function Vi(a,t){const e=X(a),i=V(a),s=e.visualViewport;let r=i.clientWidth,o=i.clientHeight,n=0,h=0;if(s){r=s.width,o=s.height;const c=Xt();(!c||c&&t==="fixed")&&(n=s.offsetLeft,h=s.offsetTop)}return{width:r,height:o,x:n,y:h}}function Wi(a,t){const e=ot(a,!0,t==="fixed"),i=e.top+a.clientTop,s=e.left+a.clientLeft,r=K(a)?Z(a):z(1),o=a.clientWidth*r.x,n=a.clientHeight*r.y,h=s*r.x,c=i*r.y;return{width:o,height:n,x:h,y:c}}function Gt(a,t,e){let i;if(t==="viewport")i=Vi(a,e);else if(t==="document")i=Yi(V(a));else if(N(t))i=Wi(t,e);else{const s=xe(a);i={...t,x:t.x-s.x,y:t.y-s.y}}return xt(i)}function ge(a,t){const e=$(a);return e===t||!N(e)||Q(e)?!1:F(e).position==="fixed"||ge(e,t)}function Pi(a,t){const e=t.get(a);if(e)return e;let i=Lt(a,[],!1).filter(n=>N(n)&&tt(n)!=="body"),s=null;const r=F(a).position==="fixed";let o=r?$(a):a;for(;N(o)&&!Q(o);){const n=F(o),h=Dt(o);!h&&n.position==="fixed"&&(s=null),(r?!h&&!s:!h&&n.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ht(o)&&!h&&ge(a,o))?i=i.filter(d=>d!==o):s=n,o=$(o)}return t.set(a,i),i}function zi(a){let{element:t,boundary:e,rootBoundary:i,strategy:s}=a;const o=[...e==="clippingAncestors"?wt(t)?[]:Pi(t,this._c):[].concat(e),i],n=o[0],h=o.reduce((c,d)=>{const f=Gt(t,d,s);return c.top=U(f.top,c.top),c.right=rt(f.right,c.right),c.bottom=rt(f.bottom,c.bottom),c.left=U(f.left,c.left),c},Gt(t,n,s));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function $i(a){const{width:t,height:e}=fe(a);return{width:t,height:e}}function qi(a,t,e){const i=K(t),s=V(t),r=e==="fixed",o=ot(a,!0,r,t);let n={scrollLeft:0,scrollTop:0};const h=z(0);if(i||!i&&!r)if((tt(t)!=="body"||ht(s))&&(n=pt(t)),i){const g=ot(t,!0,r,t);h.x=g.x+t.clientLeft,h.y=g.y+t.clientTop}else s&&(h.x=Tt(s));let c=0,d=0;if(s&&!i&&!r){const g=s.getBoundingClientRect();d=g.top+n.scrollTop,c=g.left+n.scrollLeft-Tt(s,g)}const f=o.left+n.scrollLeft-h.x-c,u=o.top+n.scrollTop-h.y-d;return{x:f,y:u,width:o.width,height:o.height}}function yt(a){return F(a).position==="static"}function jt(a,t){if(!K(a)||F(a).position==="fixed")return null;if(t)return t(a);let e=a.offsetParent;return V(a)===e&&(e=e.ownerDocument.body),e}function we(a,t){const e=X(a);if(wt(a))return e;if(!K(a)){let s=$(a);for(;s&&!Q(s);){if(N(s)&&!yt(s))return s;s=$(s)}return e}let i=jt(a,t);for(;i&&Xi(i)&&yt(i);)i=jt(i,t);return i&&Q(i)&&yt(i)&&!Dt(i)?e:i||Ni(a)||e}const Gi=async function(a){const t=this.getOffsetParent||we,e=this.getDimensions,i=await e(a.floating);return{reference:qi(a.reference,await t(a.floating),a.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ji(a){return F(a).direction==="rtl"}const Ui={convertOffsetParentRelativeRectToViewportRelativeRect:ki,getDocumentElement:V,getClippingRect:zi,getOffsetParent:we,getElementRects:Gi,getClientRects:Ki,getDimensions:$i,getScale:Z,isElement:N,isRTL:ji},pe=Hi,me=Di,ye=Ai,Zi=Ti,Ee=(a,t,e)=>{const i=new Map,s={platform:Ui,...e},r={...s.platform,_c:i};return Si(a,t,{...s,platform:r})};let Ji=class{constructor(t){l(this,"ctx");l(this,"enable",!1);l(this,"contentEl");l(this,"floatingEl");l(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:r,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;const n={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...r},h={position:"absolute",width:"10px",height:"10px",background:n.background,backgroundColor:n.backgroundColor,transform:"rotate(45deg)",zIndex:n.zIndex};Object.assign(this.arrowEl.style,h),Object.assign(this.floatingEl.style,n),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{if(!this.ctx.isTarget(t))return;const e=this.ctx.containerElement.getBoundingClientRect();e&&(t.clientX<e.x||t.clientX>e.x+e.width||t.clientY<e.y||t.clientY>e.y+e.height)&&this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.minWidth="100px",this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,r=t.drawY+i.y;Ee({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:r,left:s,right:s+t.visibleWidth,top:r,bottom:r+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[me(),ye(),pe(6),Zi({element:this.arrowEl})]}).then(n=>{const{x:h,y:c,placement:d,middlewareData:f}=n;if(Object.assign(this.floatingEl.style,{top:`${c}px`,left:`${h}px`}),f.arrow){const u=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${u.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${u.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class Qi{constructor(t){l(this,"editorEl");l(this,"inputEl");l(this,"enable",!1);l(this,"cellTarget",null);l(this,"selectorArrStr","");l(this,"ctx");l(this,"drawY",0);l(this,"drawX",0);l(this,"cancel",!1);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.cellTarget&&this.cellTarget.editorType==="text"&&this.clearEditor()}),this.ctx.on("moveFocus",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("hoverIconClick",t=>{t.editorType!=="none"&&this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell)return;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:h}=this.ctx;h&&(this.ctx.emit("setSelectorCell",h),this.cellTarget=h),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const h=this.inputEl.selectionStart,c=this.inputEl.value.substring(0,h),d=this.inputEl.value.substring(h);this.inputEl.value=c+`
16
- `+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=h+1,this.autoSize();return}if(t.code==="Tab"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","LEFT");return}this.ctx.emit("setMoveFocus","RIGHT");return}if(t.code==="Enter"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","TOP");return}this.ctx.emit("setMoveFocus","BOTTOM");return}if(t.code==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const e=t.key,i=t.ctrlKey,s=t.altKey,r=t.shiftKey,o=t.metaKey;i||s||r||o||["Enter","Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e)||this.startEdit(!0)}),this.ctx.on("adjustBoundaryPosition",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("cellClick",t=>{if(this.ctx.adjustPositioning||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.selectorArrStr===s&&this.cellTarget){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}if(this.ctx.selectOnlyOne&&t.rowKey===this.cellTarget.rowKey&&t.key===this.cellTarget.key){this.startEdit();return}}if(this.selectorArrStr=s,this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}this.ctx.selectOnlyOne&&this.startEdit()}})}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[n,h]=s;return!(e<r||e>o||t<n||t>h)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:r,config:{SCROLLER_TRACK_SIZE:o}}=this.ctx,n=i-s.height-o;this.editorEl.style.bottom="auto",this.drawY<r.height&&(this.editorEl.style.top=`${r.height-1}px`),this.drawY+t>n&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-n}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:r,width:o,drawY:n,drawX:h}=t;this.drawX=h,this.drawY=n;const{config:{CELL_PADDING:c},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;if(r>f&&(r=f),this.editorEl.style.display="inline-block",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${o-1}px`,this.inputEl.style.minHeight=`${r-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${o-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${c}px`,i!==null&&(this.inputEl.value=i),this.inputEl.focus({preventScroll:!0});const u=this.inputEl.value.length;this.inputEl.setSelectionRange(u,u)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>r||this.drawY<d.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&this.cellTarget.editorType==="text"){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&!this.cancel&&this.ctx.setItemValueByEditor(t,e,s,!0),this.inputEl.value=""}}startEdit(t=!1){this.ctx.emit("draw"),this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i||["index","index-selection","selection"].includes(i.type)||this.enable||!(i.isVerticalVisible()&&i.isHorizontalVisible()))return;const{rowKey:r,key:o,editorType:n}=i;if(n==="none")return;const h=this.ctx.database.getReadonly(r,o);i&&!h&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=i,this.startEditByInput(this.cellTarget,t),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(c=>c.rowIndex===t);if(!i)return;const s=i.cells.find(c=>c.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const r=this.ctx.focusCell;if(!r||["index","index-selection","selection"].includes(r.type)||this.enable)return;const{rowKey:o,key:n}=r,h=this.ctx.database.getReadonly(o,n);r&&!h&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=r,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.ctx.containerElement.focus({preventScroll:!0}),this.editorEl.style.display="none",this.ctx.emit("drawView"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("drawView")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class ts{constructor(t){l(this,"ctx");l(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM_STYLE:i}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=e),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:s,headerHeight:r,bodyHeight:o,footerHeight:n})=>{const h=r+(o+n)/2,c={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${h}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,c)})}destroy(){this.emptyEl.remove()}}class es{constructor(t){l(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:r,FOOTER_POSITION:o}=this.ctx.config;return r?o==="top"?s=[t,i,e]:s=[t,e,i]:s=[t,e],{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:o,renderCellHeaders:n}=this.ctx.header;let h=[],c=[],d=[];n.forEach(w=>{w.render&&(w.fixed==="left"?c.push(w):w.fixed==="right"?d.push(w):h.push(w))});const f=e-i,u={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${o}px`},cells:c},g={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-f+1}px`,height:`${o}px`},cells:h},m={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${o}px`},cells:d};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${r}px`,height:`${o}px`},views:[u,g,m]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(w=>{w.cells.forEach(p=>{p.cellType==="footer"&&(p.render=p.renderFooter),p.render&&(p.fixed==="left"?e.push(p):p.fixed==="right"?i.push(p):t.push(p))})});const{fixedLeftWidth:r,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:n,CSS_PREFIX:h}}=this.ctx,{visibleWidth:c,visibleHeight:d}=this.ctx.body,f=o-n,u={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${r}px`,height:`${d}px`},cells:e},g={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${r-.5}px`,overflow:"hidden",width:`${c-r-f}px`,height:`${d}px`},cells:t},m={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${h}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${d}px`},views:[u,g,m]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(x=>{x.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:n}}=this.ctx,{visibleWidth:h,visibleHeight:c}=this.ctx.footer,d=r-o,f={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${c}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${h-s-d}px`,height:`${c}px`},cells:t},g={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${d}px`,height:`${c}px`},cells:i};return{type:"footer",class:`${n}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${c}px`},views:[f,u,g]}}}class is{constructor(t){l(this,"ctx");l(this,"contextMenuEl");l(this,"custom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.custom=!0,this.contextMenuEl=this.ctx.contextMenuElement):(this.custom=!1,this.contextMenuEl=document.createElement("div")),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[n,h]=s,{rowIndex:c,colIndex:d}=t;c>=n&&c<=h&&d>=r&&d<=o||this.ctx.emit("setSelectorCell",t,e);const u={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};Ee(u,this.contextMenuEl,{placement:"right-start",middleware:[pe(),me(),ye()]}).then(({x:g,y:m})=>{this.show(g,m)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){if(this.contextMenuEl.className="e-virt-table-context-menu",this.ctx.containerElement.appendChild(this.contextMenuEl),this.custom)return;const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){this.contextMenuEl.replaceChildren(),t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class ss{constructor(t,e){l(this,"options");l(this,"scroller");l(this,"header");l(this,"body");l(this,"footer");l(this,"selector");l(this,"autofill");l(this,"tooltip");l(this,"editor");l(this,"empty");l(this,"overlayer");l(this,"contextMenu");l(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:r,contextMenuElement:o}=e,n=this.createContainer(t,i,s,r,o);this.ctx=new gi(n,this.options),this.header=new pi(this.ctx),this.footer=new yi(this.ctx),this.body=new mi(this.ctx),this.scroller=new wi(this.ctx),this.selector=new Ei(this.ctx),this.autofill=new Ci(this.ctx),this.tooltip=new Ji(this.ctx),this.empty=new ts(this.ctx),this.editor=new Qi(this.ctx),this.overlayer=new es(this.ctx),this.contextMenu=new is(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i,s,r){t.className="e-virt-table-container";const o=document.createElement("div"),n=document.createElement("canvas"),h=e||document.createElement("div");o.className="e-virt-table-stage",t.tabIndex=0,n.className="e-virt-table-canvas",h.className="e-virt-table-overlayer";const c=i||document.createElement("div");c.className="e-virt-table-editor";const d=s,f=r;return o.appendChild(n),o.appendChild(h),t.appendChild(o),{containerElement:t,stageElement:o,canvasElement:n,overlayerElement:h,editorElement:c,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw()})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.database.setLoading(t)}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.scrollTo(0,0),this.ctx.database.setFilterMethod(t),this.ctx.database.init(),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,r=!0,o=!1){this.ctx.database.setItemValue(t,e,i,s,r,o)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,r=!0){this.ctx.setItemValueByEditor(t,e,i,s,r),this.editor.doneEdit()}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}validateFields(t,e=!0){return new Promise(async(i,s)=>{let r=[];for(let o=0;o<t.length;o++){const{rowKey:n,key:h}=t[o],c=await this.ctx.database.getValidator(n,h);Array.isArray(c)&&c.length&&r.push(c)}if(r.length){if(s(r),e){const[o]=r;if(Array.isArray(o)&&o.length){const[n]=o,{rowKey:h,key:c}=n;this.scrollToRowkey(h),this.scrollToColkey(c)}}this.ctx.emit("draw")}else i([]),this.ctx.emit("draw")})}async validate(t=!0){return new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[r]=s;if(Array.isArray(r)&&r.length){const[o]=r,{rowKey:n,key:h}=o;this.scrollToRowkey(n),this.scrollToColkey(h)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:r}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,r)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let r=[];for(let o=0;o<i.length;o++)for(let n=0;n<s.length;n++){const h=this.ctx.database.getRowKeyByItem(i[o]),d=s[n].key,f=await this.ctx.database.getValidator(h,d);Array.isArray(f)&&f.length&&r.push(f)}r.length?(e(r),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scroller.setScroll(t,e)}scrollXTo(t){this.scroller.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.scroller.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:ni,mergeRowCell:oi,getSpanArrByRow:ie,getSpanObjByColumn:se}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=ss;
15
+ `)}return r}function ie(l,t,e=[]){let i=0;const s=[];return l.forEach((r,o)=>{if(o===0)s.push(1);else{const n=e.reduce((c,d)=>`${c}${r[d]??""}`,"")||r[t],h=e.reduce((c,d)=>`${c}${l[o-1][d]??""}`,"")||l[o-1][t];n===h?(s[i]+=1,s.push(0)):(s.push(1),i=o)}}),s}function se(l,t){let e="",i="";const s={};return t.forEach((r,o)=>{o===0?(e=r.key,i=r.key,s[r.key]=1):l[r.key]===l[e]?(s[r.key]=0,s[i]+=1):(s[r.key]=1,e=r.key,i=r.key)}),s}function oi(l,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:r}=l,o=ie(i,t,e);return o[s-r]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:o[s-r],colspan:1,relationRowKeys:e,mergeRow:!0}}function ni(l,t=[]){const{column:e,row:i,visibleLeafColumns:s}=l,r=s.filter(o=>t.includes(o.key));if(t.includes(e.key)){const o=se(i,r);return o[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:o[e.key],relationColKeys:t,mergeCol:!0}}}function ai(l,t=document.documentElement){const e=l.startsWith("--")?l:`--${l}`;return getComputedStyle(t).getPropertyValue(e).trim()}class re{constructor(t,e,i,s,r,o,n){a(this,"ctx");a(this,"x",0);a(this,"y",0);a(this,"width",0);a(this,"height",0);a(this,"fixed");a(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=n,this.cellType=o}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,r=t;return!(this.x+this.width-e-i<=0||this.x-i>=r-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class At extends re{constructor(e,i,s,r,o,n,h,c,d,f="body"){super(e,r,o,n,h,f,c.fixed);a(this,"formatter");a(this,"formatterFooter");a(this,"hoverIconName","");a(this,"operation",!1);a(this,"align");a(this,"verticalAlign");a(this,"fixed");a(this,"type");a(this,"editorType");a(this,"editorProps");a(this,"cellType");a(this,"level");a(this,"colspan",1);a(this,"rowspan",1);a(this,"mergeRow",!1);a(this,"mergeCol",!1);a(this,"relationRowKeys",[]);a(this,"relationColKeys",[]);a(this,"key");a(this,"column");a(this,"rowIndex");a(this,"colIndex");a(this,"rowKey");a(this,"row");a(this,"value");a(this,"render");a(this,"renderFooter");a(this,"style",{});a(this,"rules",[]);a(this,"message","");a(this,"text","");a(this,"displayText","");a(this,"visibleWidth",0);a(this,"visibleHeight",0);a(this,"isHasChanged",!1);a(this,"drawX",0);a(this,"drawY",0);a(this,"drawCellBgColor","");a(this,"drawCellSkyBgColor","");a(this,"drawTextColor","");a(this,"drawTextX",0);a(this,"drawTextY",0);a(this,"drawImageX",0);a(this,"drawImageY",0);a(this,"drawImageWidth",0);a(this,"drawImageHeight",0);a(this,"drawImageName","");a(this,"drawImageSource");a(this,"ellipsis",!1);a(this,"rowExpand",!1);a(this,"rowHasChildren",!1);a(this,"overflowTooltipShow",!0);a(this,"overflowTooltipMaxWidth",500);a(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=c.key,this.type=c.type||"",this.editorType=c.editorType||"text",this.editorProps=c.editorProps||{},this.cellType=f,this.align=c.align||"center",this.verticalAlign=c.verticalAlign||"middle",this.fixed=c.fixed,this.level=c.level||0,this.operation=c.operation||!1,this.column=c,this.rules=c.rules||[],this.row=d,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=c.render,this.overflowTooltipShow=c.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=c.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=c.overflowTooltipPlacement||"top",this.renderFooter=c.renderFooter,this.hoverIconName=c.hoverIconName,this.formatter=c.formatter,this.formatterFooter=c.formatterFooter,this.update()}setWidthHeight(e,i){this.width=e,this.height=i}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:r=1,relationRowKeys:o,relationColKeys:n,mergeRow:h=!1,mergeCol:c=!1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};Array.isArray(o)&&o.length>0?this.relationRowKeys=o:this.relationRowKeys=[this.key],Array.isArray(n)&&n.length>0?this.relationColKeys=n:this.relationColKeys=[this.key],this.mergeCol=c,this.mergeRow=h,this.colspan=s,this.rowspan=r,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){const e=this.getSpanInfo();this.height=e.height,this.width=e.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=e.offsetTop,this.drawX-=e.offsetLeft}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditor(){const{BODY_CELL_EDITOR_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(s!==void 0){const{type:r,props:o={}}=s;this.editorType=r,this.editorProps=o}}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let r,o=0,n="";if(this.type==="tree"&&s==="body"){const h=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:d=!1,expandLoading:f=!1,level:x=0}=h||{};if(this.rowExpand=c,this.rowHasChildren=d,f){const u=this.ctx.icons.get("loading");n="loading",r=u,o=x*8}else if(d){const u=this.ctx.icons.get("expand"),w=this.ctx.icons.get("shrink");r=c?w:u,n=c?"shrink":"expand",o=x*8}else o=x*8;let g=20,p=20;if(r){let u=this.drawX+o+e,w=this.drawY+(this.visibleHeight-p)/2;this.ctx.paint.drawImage(r,u,w,g,p),this.drawImageX=u,this.drawImageY=w,this.drawImageWidth=g,this.drawImageHeight=p,this.drawImageName=n,this.drawImageSource=r}this.align="left",this.drawTextX=o+this.drawX+g-.5}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:r,READONLY_TEXT_COLOR:o,BODY_TEXT_COLOR:n,FOOTER_TEXT_COLOR:h,FOOTER_BG_COLOR:c,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:x,HIGHLIGHT_HOVER_ROW_COLOR:g,STRIPE:p,STRIPE_COLOR:u}=this.ctx.config;if(this.cellType==="footer"){let O=c,I=h;if(typeof r=="function"){const _=r,{backgroundColor:v,color:S}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};v&&(O=v),S&&(I=S)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=O,this.drawTextColor=I;return}let w="transparent";const m=this.ctx.hoverCell,b=this.ctx.currentCell;let y=this.rowIndex,C=this.rowIndex;if(this.rowspan!==1&&(x||d)){const O=this.getSpanInfo(),{yArr:I}=O;y=I[0],C=I[1]}x&&m&&(m.rowKey===this.rowKey&&(w=g),m.rowIndex>=y&&m.rowIndex<=C&&(w=g)),d&&b&&(b.rowKey===this.rowKey&&(w=f),b.rowIndex>=y&&b.rowIndex<=C&&(w=f)),this.drawCellSkyBgColor=w;let E=e,R=n;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(E=i,R=o),p&&(this.rowIndex%2?E=u:E=e),typeof s=="function"){const O=s,{backgroundColor:I,color:_}=O({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};I&&(E=I),_&&(R=_)}this.drawCellBgColor=E,this.drawTextColor=R}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:r,cellType:o,type:n,rowIndex:h,rowKey:c}=this;if(!(s===0||r===0)&&o!=="footer"&&["index-selection","selection"].includes(n)){const d=this.ctx.database.getRowSelection(c),f=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:x=0}=this.ctx.config,g=this.drawX+(e-x)/2,p=this.drawY+(i-x)/2;let u=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";d&&f?(u=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):d&&f?(u=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!d&&f?(u=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(u=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),u&&n=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===h||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=g,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=u):u&&n==="selection"&&(this.drawImageX=g,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=u)}}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;const{BODY_CELL_HOVER_ICON_METHOD:i,CELL_HOVER_ICON_SIZE:s,CELL_PADDING:r,ENABLE_MERGE_CELL_LINK:o}=this.ctx.config;if(typeof i=="function"){const c=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});c!==void 0&&(this.hoverIconName=c)}const{hoverCell:n}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&n){let h=0,c=0;if(n.rowKey===this.rowKey&&(h=this.drawX+this.width-s-r,c=this.drawY+(this.height-s)/2),this.rowspan!==1&&o){const f=this.getSpanInfo(),{yArr:x}=f,g=x[0],p=x[1];if(n.rowIndex>=g&&n.rowIndex<=p){const{width:u,height:w,offsetTop:m,offsetLeft:b}=f;h=this.drawX-b+u-s-r,c=this.drawY-m+(w-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawImageX=h,this.drawImageY=c,this.drawImageWidth=s,this.drawImageHeight=s,this.drawImageName=this.hoverIconName,this.drawImageSource=d}}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(e){this.ctx.setItemValueByEditor(this.rowKey,this.key,e)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:r,drawY:o}=this;e.drawRect(r,o,this.visibleWidth,this.visibleHeight,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(r,o,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),s||this.ctx.paint.drawLine([r,o+this.visibleHeight,r+this.visibleWidth,o+this.visibleHeight],{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s,AUTOFILL_POINT_BORDER_COLOR:r}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:o,yArr:n}=this.ctx.selector,h=o[1],c=n[1],{colIndex:d,rowIndex:f,drawX:x,drawY:g}=this;if(d===h&&f===c){const u=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(x+this.width-u,g+this.height-u,6,6,{borderColor:r,fillColor:e})}}draw(){this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let r=e;r<e+i;r++){const o=this.ctx.header.leafCellHeaders[r];s+=o.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s}=this.ctx.config;let r=this.visibleWidth;if(this.type==="tree"){const f=this.drawTextX-this.drawX;r=this.visibleWidth-f}const{ellipsis:o}=this.ctx.paint.handleEllipsis(this.displayText,r,e,i);this.ellipsis=o;const{placeholder:n}=this.column;let h=this.displayText,c=this.drawTextColor;return!this.ctx.database.getReadonly(this.rowKey,this.key)&&n&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(h=n,c=s),this.ctx.paint.drawText(h,this.drawTextX,this.drawTextY,r,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:c})}drawImage(){if(this.drawImageSource){if(this.hoverIconName){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawImageX-2,this.drawImageY-2,this.drawImageWidth+4,this.drawImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e})}this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:r,yArrCopy:o}=this.ctx.selector;this.drawBorder({xArr:r,yArr:o,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});const[n,h]=i,[c,d]=s;!(n===h&&c===d)&&this.colIndex>=n&&this.colIndex<=h&&this.rowIndex>=c&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)"}),this.operation&&this.rowIndex>=c&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.visibleWidth,this.visibleHeight,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawErrorTip(){if(this.cellType==="footer"||!this.message||this.rowspan===0||this.colspan===0)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,r=this.drawX,o=this.drawY,n=[r+s-e-.5,o,r+s-.5,o,r+s-.5,o+e];this.ctx.paint.drawLine(n,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:r,colIndex:o,height:n,width:h}=this;let c=i,d=s;const{xArr:f,yArr:x,lineDash:g=[],borderWidth:p=1,borderColor:u,fillColor:w}=e,m=f[0],b=f[1],y=x[0],C=x[1];if(o>=m&&o<=b&&r===y){const E=o===b?1:0,R=o===m?1:0;this.ctx.paint.drawLine([c+R,d+1,c+h-E,d+1],{borderColor:u,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:g})}if(o===b&&r>=y&&r<=C){const E=r===y?1:0,R=r===C?1:0;this.ctx.paint.drawLine([c+h-1,d+E,c+h-1,d+n-R],{borderColor:u,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:g})}if(o>=m&&o<=b&&r===C){const E=o===b?1:0,R=o===m?1:0;this.ctx.paint.drawLine([c+R,d+n-1,c+h-E,d+n-1],{borderColor:u,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:g})}if(o===m&&r>=y&&r<=C){const E=r===C?1:0,R=r===y?1:0;this.ctx.paint.drawLine([c+1,d+R,c+1,d+n-E],{borderColor:u,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:g})}}}class li{constructor(t,e){a(this,"loading",!1);a(this,"ctx");a(this,"data");a(this,"columns");a(this,"footerData",[]);a(this,"rowKeyMap",new Map);a(this,"colIndexKeyMap",new Map);a(this,"headerMap",new Map);a(this,"rowIndexRowKeyMap",new Map);a(this,"rowKeyRowIndexMap",new Map);a(this,"checkboxKeyMap",new Map);a(this,"selectionMap",new Map);a(this,"expandMap",new Map);a(this,"originalDataMap",new Map);a(this,"changedDataMap",new Map);a(this,"validationErrorMap",new Map);a(this,"itemRowKeyMap",new WeakMap);a(this,"bufferData",[]);a(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});a(this,"sumHeight",0);a(this,"filterMethod");a(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:r=[]}=e;this.data=i,this.footerData=r,this.columns=s,this.setLoading(!0),this.init()}init(){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear(),this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0){t.forEach((i,s)=>{var m,b;let r=!1;Array.isArray(i.children)&&(r=i._hasChildren,i.children.length&&(r=!0,this.initData(i.children,e+1)));const{ROW_KEY:o="",DEFAULT_EXPAND_ALL:n,CELL_HEIGHT:h,SELECTABLE_METHOD:c,CHECKBOX_KEY:d}=this.ctx.config,f=i[o],x=f!=null?`${f}`:Jt();this.itemRowKeyMap.set(i,x);const g=i._height||h,p=i._readonly;let u=!0;if(typeof c=="function"&&(u=c),d){const y=i[d];if(this.checkboxKeyMap.has(y)){const C=this.checkboxKeyMap.get(y)||[];C.push(x),this.checkboxKeyMap.set(y,C)}else this.checkboxKeyMap.set(y,[x])}this.selectionMap.set(x,{key:d?i[d]:x,row:i,check:((m=this.selectionMap.get(x))==null?void 0:m.check)||!1});const w=n||((b=this.expandMap.get(x))==null?void 0:b.expand)||i._expand||!1;this.expandMap.set(x,{key:x,row:i,expand:w}),this.rowKeyMap.set(x,{readonly:p,index:s,rowIndex:s,level:e,height:g,check:!1,selectable:u,expand:w,expandLazy:!1,hasChildren:r,expandLoading:!1,item:i})})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t);if(i===void 0)return;const s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const r={...i};r.children&&Array.isArray(r.children)&&(r.children=this.filterColumns(r.children)),e.push(r)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.columns.length&&this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=r=>{r.forEach(o=>{t.push(o);const n=this.itemRowKeyMap.get(o),{expand:h,hasChildren:c,height:d}=this.rowKeyMap.get(n),f=this.sumHeight;this.sumHeight+=d,this.rowIndexRowKeyMap.set(e,n),this.rowKeyRowIndexMap.set(n,e),this.positions.push({top:f,height:d,bottom:this.sumHeight}),e+=1,h&&c&&i(o.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,{key:t,row:i.item,expand:e}),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,{key:i,row:s.item,expand:e}),s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.rowKeyMap.forEach(e=>{e.expand=t,this.expandMap.set(e.key,{key:e.key,row:e.item,expand:t})}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,this.expandMap.set(t,{key:t,row:i.item,expand:!0}),i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowForRowIndex(t){const e=this.getRowKeyForRowIndex(t);return this.rowKeyMap.get(e)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)||""}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyRowIndexMap.get(t)}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),r=this.colIndexKeyMap.get(e);return s===void 0||r===void 0?null:{rowKey:s,key:r,value:this.getItemValue(s,r)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1){let i=[];const s=new Set;let r=[],o=t.map(d=>{const{rowKey:f,key:x}=d;let g=d.value,p=g;const u=this.getRowDataItemForRowKey(f),w=this.getItemValue(f,x),m=this.getVirtualBodyCellByKey(f,x);return(m==null?void 0:m.type)==="number"&&(["",void 0,null].includes(g)?p=null:/^-?\d+(\.\d+)?$/.test(`${g}`)?p=Number(g):(p=w,r.push({...d,value:p,oldValue:w,row:u}))),{...d,value:p,oldValue:w,row:u}});if(o=o.filter(d=>!r.some(f=>d.rowKey===f.rowKey&&d.key===f.key)),r.length){const d={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:r};this.ctx.emit("error",d)}if(!o.length)return;const{BEFORE_VALUE_CHANGE_METHOD:n}=this.ctx.config;typeof n=="function"&&(o=await n(o)),o.forEach(d=>{const{value:f,rowKey:x,key:g,oldValue:p}=d;s.add(x),this.setItemValue(x,g,f),i.push({rowKey:x,key:g,oldValue:p,newValue:f})});let h=[];s.forEach(d=>{h.push(this.ctx.database.getRowDataItemForRowKey(d))});const c=o.map(({rowKey:d,key:f})=>this.getValidator(d,f));Promise.all(c).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",o,h),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,r=!1,o=!1){if(!this.rowKeyMap.has(t))return{};const{item:n}=this.rowKeyMap.get(t);let h=n[e],c=i;if(this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};n[e]!==null&&typeof n[e]=="object"&&(h=JSON.parse(JSON.stringify(n[e])));const d=`${t}​_${e}`;this.originalDataMap.has(d)||this.originalDataMap.set(d,h);const f=this.originalDataMap.get(d),x=this.getRowDataItemForRowKey(t);if(o){const g=this.getVirtualBodyCellByKey(t,e);if((g==null?void 0:g.type)==="number")if(["",void 0,null].includes(i))c=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))c=Number(i);else{c=h;const w={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:c,oldValue:h,row:x}]};this.ctx.emit("error",w)}if(c===h)return{oldValue:h,newValue:h};const{BEFORE_VALUE_CHANGE_METHOD:p}=this.ctx.config;if(typeof p=="function"){const m=await p([{rowKey:t,key:e,value:c,oldValue:n[e],row:x}]);m&&m.length&&(c=m[0].value)}this.changedDataMap.set(d,c),n[e]=c;const u={rowKey:t,key:e,oldValue:h,value:c,row:x};this.getValidator(t,e).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",[u],[x]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:c,originalValue:f,row:x})}else this.changedDataMap.set(d,c),n[e]=c;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:h,value:c,originalValue:this.originalDataMap.get(d),row:x}),s&&this.ctx.history.pushState({type:"single",scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,changeList:[{rowKey:t,key:e,oldValue:h,newValue:c}]}),r&&this.ctx.emit("draw"),{oldValue:h,newValue:c}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),r=s[i];this.checkboxKeyMap.has(r)&&(this.checkboxKeyMap.get(r)||[]).forEach(n=>{const h=this.selectionMap.get(n);h&&(h.check=e)})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t),i=this.selectionMap.get(t);if(!i)return;i.check=!i.check,this.setRowSelectionByCheckboxKey(t,i.check),this.ctx.emit("toggleRowSelection",e);const s=this.getSelectionRows();this.ctx.emit("selectionChange",s),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}setRowSelection(t,e,i=!0){const s=this.selectionMap.get(t);s&&(s.check=e,this.setRowSelectionByCheckboxKey(t,s.check),this.ctx.emit("setRowSelection",e,s.row),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}getSelectionRows(){let t=[];return this.selectionMap.forEach(e=>{e.check&&t.push(e.row)}),t}getRowSelection(t){const e=this.selectionMap.get(t);return e?e.check:!1}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.rowKeyMap.forEach((e,i)=>{let s=e.selectable;typeof s=="function"&&(s=s({row:e.item,rowIndex:e.rowIndex})),s&&this.setRowSelection(i,!0,!1)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){t?this.rowKeyMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)}):this.selectionMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)});const e=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}getCheckedState(){const{buffer:t,...e}=this.bufferCheckState;if(t)return e;const i=this.rowKeyMap.size;let s=0,r=0;const o=this.selectionMap.size,n=Array.from(this.selectionMap.values()).some(x=>x.check);this.rowKeyMap.forEach((x,g)=>{var u;(u=this.selectionMap.get(g))!=null&&u.check&&(s+=1);let p=x.selectable;typeof p=="function"&&(p=p({row:x.item,rowIndex:x.rowIndex})),p&&(r+=1)});const h=o>i&&s===0&&n,c=r&&r>s&&s>0||h,d=r!==0,f=!!r&&r===s;return this.bufferCheckState={buffer:!0,check:f,indeterminate:c,selectable:d},{check:f,indeterminate:c,selectable:d}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getColumnByColIndex(t){var i;const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return(i=this.headerMap.get(e))==null?void 0:i.column}getColumnByKey(t){const e=this.headerMap.get(t);if(e)return e}getColIndexForKey(t){var e;if(t&&this.headerMap.has(t))return(e=this.headerMap.get(t))==null?void 0:e.colIndex}getColHeaderByIndex(t){const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return this.headerMap.get(e)}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),r=i.split("​_")[0],o=i.split("​_")[1];s!==e&&t.push({rowKey:r,colKey:o,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(r),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const r=this.originalDataMap.get(s),o=s.split("​_")[0];r!==i&&t.add(o)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}​_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),r=this.changedDataMap.get(i);return s!==r}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const{DISABLED:i}=this.ctx.config;if(i)return!0;const s=this.rowKeyMap.get(t),r=this.headerMap.get(e);if(!s||!r)return!0;const o=s.readonly,n=r.readonly,{BODY_CELL_READONLY_METHOD:h}=this.ctx.config;if(typeof h=="function"&&r){const d=h({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:r.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return n||o}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:o}=this.ctx.config;if(r===void 0)return i([]);const n=r.column;let h=n.rules;if(typeof o=="function"){const d=o({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:n,value:this.getItemValue(t,e)});d&&(h=d)}if(h){let c={},d={};if(d[e]=this.getItemValue(t,e),Array.isArray(h)){const x=h.map(g=>({...g,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex}));c[e]=x}else c[e]={...h,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex};new nt(c).validate(d).then(()=>{this.clearValidationError(t,e),i([])}).catch(({errors:x})=>{const g=x.map(p=>({...p,column:n,key:e,row:s.item,rowKey:t}));this.setValidationError(t,e,g),i(g)})}else i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const r=this.positions[t+s];r&&(i+=r.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:r,value:o,colIndex:n,relationRowKeys:h,relationColKeys:c,rowspan:d,height:f,width:x,colspan:g,mergeRow:p,mergeCol:u}=t;if(d===1&&g===1)return{xArr:[n,n],yArr:[e,e],rowspan:d,colspan:g,height:f,width:x,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:r,value:o}]};let w=e,m=e,b=n,y=n,C=[],E=0,R=0,O=0,I=0;if(d!==1&&p){I=x;const _=h.reduce((v,S)=>{const T=this.getItemValue(s,S)??"";return`${v}${T}`},"");for(let v=e-1;v>=0;v--){const S=this.rowIndexRowKeyMap.get(v)||"",T=h.reduce((M,A)=>{const N=this.getItemValue(S,A)??"";return`${M}${N}`},"");if(_===T)w=v;else break}for(let v=e;v<=this.ctx.maxRowIndex;v++){const S=this.rowIndexRowKeyMap.get(v)||"",T=h.reduce((M,A)=>{const N=this.getItemValue(S,A)??"";return`${M}${N}`},"");if(_===T)m=v;else break}for(let v=w;v<e;v++){const{height:S}=this.positions[v];E+=S}for(let v=w;v<=m;v++){const{height:S}=this.positions[v];O+=S;const T=this.rowIndexRowKeyMap.get(v)||"",{item:M}=this.rowKeyMap.get(T),A=this.getItemValue(T,i);C.push({rowKey:T,key:i,value:A,row:M})}}if(g!==1&&u){O=f;for(let _=n-1;_>=0;_--){const v=this.getColumnByColIndex(_);if(!v)break;const S=this.getItemValue(s,i),T=this.getItemValue(s,v.key);if(S===T&&c.includes(v.key))b=_;else break}for(let _=n;_<=this.ctx.maxColIndex;_++){const v=this.getColumnByColIndex(_);if(!v)break;const S=this.getItemValue(s,i),T=this.getItemValue(s,v.key);if(S===T&&c.includes(v.key))y=_;else break}for(let _=b;_<n;_++){const v=this.getColumnByColIndex(_);if(!v)break;R+=v.width||100}for(let _=b;_<=y;_++){const v=this.getColumnByColIndex(_);if(!v)break;I+=v.width||100,C.push({rowKey:s,key:v.key,value:this.getItemValue(s,v.key),row:r})}}return{xArr:[b,y],yArr:[w,m],rowspan:d,colspan:g,height:O,width:I,offsetTop:E,offsetLeft:R,dataList:C}}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const r=`${this.rowIndexRowKeyMap.get(t)}​_${e}`,o=[{message:i}];this.validationErrorMap.set(r,o)}setValidationError(t,e,i){const s=`${t}​_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}​_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}​_${e}`;return this.validationErrorMap.get(i)||[]}getVirtualBodyCell(t,e){const i=this.getColumnByColIndex(e),s=this.getRowForRowIndex(t);return!i||!s?void 0:new At(this.ctx,t,e,0,0,0,0,i,s.item,"body")}getVirtualBodyCellByKey(t,e){const i=this.getRowIndexForRowKey(t),s=this.getColIndexForKey(e);if(!(i===void 0||s===void 0))return this.getVirtualBodyCell(i,s)}hasMergeCell(t,e){let i=!1;for(let s=e[0];s<=e[1];s++)for(let r=t[0];r<=t[1];r++){const o=this.getVirtualBodyCell(s,r);if(o&&(o.rowspan!==1||o.colspan!==1)){i=!0;break}}return i}}class hi{constructor(t){a(this,"ctx");a(this,"history",[]);a(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(r=>({rowKey:r.rowKey,key:r.key,value:r.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1)}}clear(){this.history=[],this.historyIndex=-1}}class ci{constructor(t){a(this,"eventTasks",new Map);a(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"blur",this.handleOutsideMousedown.bind(this)),this.bind(window,"mousedown",this.handleOutsideMousedown.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchstart",this.handleTouchstart.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchend",this.handleTouchend.bind(this)),this.bind(this.ctx.stageElement,"touchmove",this.handleTouchmove.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this)),this.bind(this.ctx.stageElement,"mouseover",this.handleMouseover.bind(this)),this.bind(this.ctx.stageElement,"mouseout",this.handleMouseout.bind(this))}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){t.button===0&&(this.ctx.mousedown=!0),this.ctx.containerElement.focus({preventScroll:!0}),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget(t)&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleTouchstart(t){this.ctx.emit("touchstart",t)}handleTouchend(t){this.ctx.emit("touchend",t)}handleTouchmove(t){this.ctx.emit("touchmove",t)}handleContextMenu(t){t.preventDefault(),this.ctx.emit("contextMenu",t)}handleMouseover(t){this.ctx.isMouseoverTargetContainer=!0,this.ctx.emit("mouseover",t)}handleMouseout(t){this.ctx.isMouseoverTargetContainer=!1,this.ctx.emit("mouseout",t)}handleDblclick(t){this.ctx.emit("dblclick",t)}handleOutsideMousedown(t){this.ctx.selector.enable&&(t.target instanceof Window||t.target instanceof Node&&!this.ctx.containerElement.contains(t.target))&&this.ctx.emit("outsideMousedown",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class di{constructor(){a(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class fi{constructor(t){a(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}scale(t){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,r){const{fillColor:o,side:n,shadowWidth:h,colorStart:c,colorEnd:d}=r;this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s));let f;switch(n){case"left":f=this.ctx.createLinearGradient(t-h,e,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-h,e,h,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+h,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,h,s);break;case"top":f=this.ctx.createLinearGradient(t,e-h,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-h,i,h);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+h),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,h);break;default:console.error("Invalid side specified for shadow");break}}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let r=2;r<t.length;r+=2)this.ctx.lineTo(t[r]-.5,t[r+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=4,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,r){this.ctx.save(),this.ctx.drawImage(t,e,i,s,r),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:r=1,borderColor:o,fillColor:n,radius:h=0}={}){if(this.ctx.save(),this.ctx.beginPath(),n!==void 0&&(this.ctx.fillStyle=n),o!==void 0&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=o),h===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,d,f,x]=typeof h=="number"?[h,h,h,h]:h;this.ctx.moveTo(t+c,e),this.ctx.arcTo(t+i,e,t+i,e+d,d),this.ctx.arcTo(t+i,e+s,t+i-f,e+s,f),this.ctx.arcTo(t,e+s,t,e+s-x,x),this.ctx.arcTo(t,e,t+c,e,c)}n!==void 0&&this.ctx.fill(),o!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,r,o={}){this.ctx.save();const{font:n="12px Arial",align:h="center",color:c="#495060",padding:d=0,verticalAlign:f="middle"}=o;this.ctx.font=n,this.ctx.fillStyle=c,this.ctx.textBaseline=f,this.ctx.textAlign=h;let x=0;f==="top"?x=i+d:f==="bottom"?x=i+r-d:x=i+(r+1)/2;let g=0;h==="left"?g=e+d:h==="right"?g=e+s-d:g=e+s/2;const{_text:p,ellipsis:u}=this.handleEllipsis(t,s,d,n);return this.ctx.fillText(p,g,x),this.ctx.restore(),u}handleEllipsis(t,e,i=0,s="12px Arial"){let r=!1,o=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:r};const n=this.ctx.measureText("...").width,h=this.ctx.measureText(t).width;if(h&&h+n>=e-i*2){r=!0;let c=0;for(let d=0;d<t.length;d++)if(c+=this.ctx.measureText(t[d]).width,c>=e-i*2-n){o=t.slice(0,d)+"...";break}}return{_text:o,ellipsis:r}}}class Wt{constructor(t){a(this,"_config",{});a(this,"CSS_PREFIX","e-virt-table");a(this,"ICONS",[]);a(this,"ROW_KEY","");a(this,"DISABLED",!1);a(this,"HEADER_FONT","12px normal Arial");a(this,"BODY_FONT","12px normal Arial");a(this,"BORDER",!0);a(this,"STRIPE",!1);a(this,"STRIPE_COLOR","#fafafa");a(this,"BORDER_COLOR","#e1e6eb");a(this,"WIDTH",0);a(this,"RESIZE_MIN_WIDTH",40);a(this,"HEIGHT",0);a(this,"PLACEHOLDER_COLOR","#CDD0DC");a(this,"EMPTY_BODY_HEIGHT",120);a(this,"EMPTY_CUSTOM_STYLE",{});a(this,"EMPTY_TEXT","暂无数据");a(this,"MAX_HEIGHT",1e3);a(this,"BORDER_RADIUS",8);a(this,"ENABLE_OFFSET_HEIGHT",!1);a(this,"OFFSET_HEIGHT",0);a(this,"HEADER_HEIGHT",36);a(this,"ENABLE_HEADER_STICKY",!1);a(this,"HEADER_BG_COLOR","#F8FAFF");a(this,"BODY_BG_COLOR","#FFF");a(this,"HEADER_TEXT_COLOR","#1D2129");a(this,"BODY_TEXT_COLOR","#4E5969");a(this,"FOOTER_TEXT_COLOR","#4E5969");a(this,"LOADING_ICON_SVG","");a(this,"LOADING_ICON_COLOR","#4E5969");a(this,"EXPAND_ICON_SVG","");a(this,"SHRINK_ICON_SVG","");a(this,"EXPAND_ICON_COLOR","#4E5969");a(this,"SHRINK_ICON_COLOR","#4E5969");a(this,"ERROR_TIP_ICON_COLOR","red");a(this,"ERROR_TIP_ICON_SIZE",6);a(this,"EXPAND_LAZY",!0);a(this,"DEFAULT_EXPAND_ALL",!1);a(this,"CELL_WIDTH",100);a(this,"CELL_HEIGHT",36);a(this,"CELL_PADDING",8);a(this,"CELL_HOVER_ICON_SIZE",14);a(this,"CELL_HOVER_ICON_BG_COLOR","#fff");a(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");a(this,"SCROLLER_TRACK_SIZE",14);a(this,"SCROLLER_SIZE",8);a(this,"SCROLLER_COLOR","#dee0e3");a(this,"SCROLLER_TRACK_COLOR","#fff");a(this,"SCROLLER_FOCUS_COLOR","#bbbec4");a(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");a(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");a(this,"SELECT_ROW_COL_BG_COLOR","transparent");a(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");a(this,"EDIT_BG_COLOR","#fcf6ed");a(this,"CHECKBOX_KEY","");a(this,"CHECKBOX_COLOR","rgb(82,146,247)");a(this,"CHECKBOX_SIZE",20);a(this,"CHECKBOX_DISABLED_SVG","");a(this,"CHECKBOX_CHECK_SVG","");a(this,"CHECKBOX_UNCHECK_SVG","");a(this,"CHECKBOX_INDETERMINATE_SVG","");a(this,"READONLY_COLOR","#fff");a(this,"READONLY_TEXT_COLOR","#4E5969");a(this,"ERROR_TIP_COLOR","#ED3F14");a(this,"FOOTER_BG_COLOR","#fafafa");a(this,"FOOTER_FIXED",!0);a(this,"FOOTER_POSITION","bottom");a(this,"CELL_FOOTER_HEIGHT",36);a(this,"ENABLE_SELECTOR",!0);a(this,"ENABLE_EDIT_SINGLE_CLICK",!1);a(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);a(this,"SELECTOR_AREA_MIN_X",0);a(this,"SELECTOR_AREA_MAX_X_OFFSET",0);a(this,"SELECTOR_AREA_MAX_X",0);a(this,"SELECTOR_AREA_MIN_Y",0);a(this,"SELECTOR_AREA_MAX_Y",0);a(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);a(this,"ENABLE_AUTO_THEME",!0);a(this,"ENABLE_SELECTOR_SINGLE",!1);a(this,"ENABLE_SELECTOR_SPAN_COL",!0);a(this,"ENABLE_SELECTOR_SPAN_ROW",!0);a(this,"ENABLE_SELECTOR_ALL_ROWS",!0);a(this,"ENABLE_SELECTOR_ALL_COLS",!0);a(this,"ENABLE_MERGE_CELL_LINK",!1);a(this,"ENABLE_AUTOFILL",!1);a(this,"ENABLE_CONTEXT_MENU",!1);a(this,"ENABLE_COPY",!0);a(this,"ENABLE_PASTER",!0);a(this,"ENABLE_RESIZE_ROW",!0);a(this,"ENABLE_RESIZE_COLUMN",!0);a(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");a(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");a(this,"RESIZE_ROW_MIN_HEIGHT",36);a(this,"RESIZE_COLUMN_MIN_WIDTH",40);a(this,"ENABLE_KEYBOARD",!0);a(this,"ENABLE_HISTORY",!1);a(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);a(this,"HISTORY_NUM",50);a(this,"HIGHLIGHT_HOVER_ROW",!1);a(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");a(this,"HIGHLIGHT_SELECTED_ROW",!1);a(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");a(this,"TOOLTIP_BG_COLOR","#303133");a(this,"TOOLTIP_TEXT_COLOR","#fff");a(this,"TOOLTIP_ZINDEX",3e3);a(this,"TOOLTIP_CUSTOM_STYLE",{});a(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);a(this,"HEADER_CELL_STYLE_METHOD");a(this,"BODY_CELL_STYLE_METHOD");a(this,"FOOTER_CELL_STYLE_METHOD");a(this,"BODY_CELL_READONLY_METHOD");a(this,"BODY_CELL_FORMATTER_METHOD");a(this,"BODY_CELL_RULES_METHOD");a(this,"BODY_CELL_TYPE_METHOD");a(this,"BODY_CELL_EDITOR_METHOD");a(this,"BODY_CELL_RENDER_METHOD");a(this,"BODY_CELL_HOVER_ICON_METHOD");a(this,"SPAN_METHOD");a(this,"SELECTABLE_METHOD");a(this,"EXPAND_LAZY_METHOD");a(this,"BEFORE_VALUE_CHANGE_METHOD");a(this,"BEFORE_PASTE_DATA_METHOD");a(this,"BEFORE_AUTOFILL_DATA_METHOD");a(this,"BEFORE_SET_SELECTOR_METHOD");a(this,"BEFORE_SET_AUTOFILL_METHOD");a(this,"BEFORE_COPY_METHOD");this._config=t,this.updateCssVar()}init(t){this._config=t,this.updateCssVar()}updateCssVar(){let t={};Object.keys(this).forEach(e=>{if(e.endsWith("_COLOR")||e.endsWith("_FONT")){const i=`--evt-${e.toLocaleLowerCase().replace(/_/g,"-")}`,s=ai(i);t[e]=s}}),Object.assign(this,t,this._config)}}const Pt='<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>';class xi{constructor(t){a(this,"ctx");a(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Pt,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_SVG",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" fill="#F1F2F4" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:""},{name:"icon-edit",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1744798692576" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6606" width="200" height="200"><path d="M855.296 894.528H168.768v-76.8h686.528v76.8z m38.4-38.4q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.824 4.8-3.2 2.112-6.656 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.52-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.76 4.736 2.752 2.688 4.864 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488z m-686.528 0q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.76 4.8-3.2 2.112-6.72 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.456-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.824 4.736 2.688 2.688 4.8 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488zM652.032 211.2l-369.92 370.368v89.344h90.048l369.664-369.856L652.032 211.2z m-54.4-54.272q22.528-22.528 54.4-22.528 31.808 0 54.336 22.528l89.792 89.856q22.464 22.464 22.464 54.272t-22.464 54.272l-369.664 369.856q-22.464 22.528-54.336 22.528H282.24q-31.808 0-54.336-22.528-22.464-22.464-22.464-54.272V581.568q0-31.808 22.4-54.272l369.92-370.368z" p-id="6607"></path></svg>',color:"#4E5969"},{name:"icon-select",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Pt,color:"#4E5969"}]);a(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color,r=i.svg;if(i.configColorName){const n=this.ctx.config[i.configColorName];n&&(s=n)}if(i.configName){const n=this.ctx.config[i.configName];n&&(r=n)}const o=this.createImageFromSVG(r,s).then(n=>{this.icons.set(i.name,n)});t.push(o)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const r=this.createImageFromSVG(i.svg,s,i.isBlob).then(o=>{this.icons.set(i.name,o)});t.push(r)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&o.querySelectorAll("*").forEach(c=>{c.setAttribute("fill",e)});const n=new Image;let h="";if(i){const c=new Blob([new XMLSerializer().serializeToString(o)],{type:"image/svg+xml"});h=URL.createObjectURL(c)}else h="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(o));return n.src=h,new Promise((c,d)=>{n.onerror=()=>d(new Error("Failed to load image")),n.onload=()=>{c(n)}})}get(t){return this.icons.get(t)}}class oe extends re{constructor(e,i,s,r,o,n,h){super(e,s,r,o,n,"header",h.fixed);a(this,"align");a(this,"verticalAlign","middle");a(this,"fixed");a(this,"minWidth");a(this,"maxWidth");a(this,"widthFillDisable");a(this,"type");a(this,"operation",!1);a(this,"editorType");a(this,"level");a(this,"text");a(this,"displayText","");a(this,"colspan");a(this,"rowspan");a(this,"row");a(this,"key");a(this,"required",!1);a(this,"readonly",!1);a(this,"children",[]);a(this,"column");a(this,"colIndex");a(this,"rowKey");a(this,"rules");a(this,"hasChildren");a(this,"render");a(this,"style",{});a(this,"drawX",0);a(this,"drawY",0);a(this,"drawCellBgColor","");a(this,"drawTextColor","");a(this,"drawImageX",0);a(this,"drawImageY",0);a(this,"drawImageWidth",0);a(this,"drawImageHeight",0);a(this,"drawImageName","");a(this,"drawImageSource");this.ctx=e,this.x=s,this.y=r,this.width=o,this.height=n,this.colIndex=i,this.key=h.key,this.minWidth=h.minWidth,this.maxWidth=h.maxWidth,this.type=h.type||"",this.editorType=h.editorType||"text",this.align=h.align||"center",this.verticalAlign=h.verticalAlign||"middle",this.fixed=h.fixed,this.level=h.level||0,this.operation=h.operation||!1,this.text=h.title,this.column=h,this.colspan=h.colspan||1,this.widthFillDisable=h.widthFillDisable||!1,this.rowspan=h.rowspan||1,this.rules=h.rules,this.readonly=h.readonly||!1,this.required=h.required||!1,this.rowKey=Jt(),this.hasChildren=h.children&&h.children.length>0||!1,this.render=h.renderHeader}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let r=i,o=s;if(typeof e=="function"){const n=e,{backgroundColor:h,color:c}=n({colIndex:this.colIndex,column:this.column})||{};h&&(r=h),c&&(o=c)}this.drawCellBgColor=r,this.drawTextColor=o}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:r,BORDER:o}}=this.ctx,{drawX:n,drawY:h,displayText:c}=this;e.drawRect(n,h,this.width,this.height,{borderColor:o?i:"transparent",fillColor:this.drawCellBgColor}),e.drawText(c,n,h,this.width,this.height,{font:r,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection(),this.drawSelector()}drawSelector(){const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i}=this.ctx.selector,[s,r]=i;this.colIndex>=s&&this.colIndex<=r&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawSelection(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:r,check:o,selectable:n}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:h=0}=this.ctx.config,c=this.drawX+(e-h)/2,d=this.drawY+(i-h)/2;let f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";r?(f=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):o&&n?(f=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):o&&n?(f=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!o&&n?(f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(f=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),f&&(this.drawImageX=c,this.drawImageY=d,this.drawImageWidth=h,this.drawImageHeight=h,this.drawImageName=x,this.drawImageSource=f,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":this.text}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class ui{constructor(t){a(this,"ctx");a(this,"visibleHoverCell");a(this,"resizeObserver");a(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(t=>{for(const e of t)e.type==="attributes"&&e.attributeName==="class"&&(this.ctx.config.updateCssVar(),this.ctx.emit("draw"))}),this.ctx.config.ENABLE_AUTO_THEME&&this.mutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.focusCellHeader=o,this.ctx.emit("cellHeaderMousedown",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.setFocusCell(o),this.ctx.emit("cellMousedown",o,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s),this.hoverIconClick(s)})}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.emit("cellHeaderContextMenuClick",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.emit("cellContextMenuClick",o,t)})}),this.ctx.on("mouseout",t=>{!this.ctx.containerElement.contains(t.relatedTarget)&&this.ctx.hoverCell!==void 0&&(this.ctx.hoverRow=void 0,this.ctx.hoverCell=void 0,this.ctx.emit("draw"))}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default");const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.ctx.emit("cellHeaderHoverChange",s))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.selectionEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var r;this.imageEnterAndLeave(s,t),this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((r=this.ctx.hoverCell)==null?void 0:r.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(o=>o.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}hoverIconClick(t){t.hoverIconName&&this.ctx.isPointer&&this.ctx.emit("hoverIconClick",t)}selectionClick(t){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof oe)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:o}=this.ctx.config;if(r&&o&&!i&&!s)typeof o=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),o({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(h=>{this.ctx.database.setExpandChildren(t.rowKey,h),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(h=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(h)}));else{const n=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!n),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0)}selectionEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight&&t instanceof At&&["selection","index-selection"].includes(t.type)&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;if(!this.ctx.isTarget(t)||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:o}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-o||r>this.ctx.stageWidth-o)}handleBodyEvent(t,e,i,s,r=!1){if(this.isInsideBody(e))for(const o of i){const n=o.fixedCells.concat(o.noFixedCells);for(const h of n){const c=h.getDrawX(),d=h.getDrawY();if(r){if(t>c&&t<c+h.visibleWidth&&e>d&&e<d+h.visibleHeight){s(h);return}}else if(t>c&&t<c+h.width&&e>d&&e<d+h.height){s(h);return}}}}handleHeaderEvent(t,e,i,s){for(const r of i){const o=r.getDrawX(),n=r.getDrawY();if(t>o&&t<o+r.width&&e>n&&e<n+r.height){s(r);return}}}isInsideBody(t){return t>this.ctx.body.y&&t<this.ctx.body.y+this.ctx.body.visibleHeight}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}class gi{constructor(t,e){a(this,"eventBus");a(this,"eventBrowser");a(this,"eventTable");a(this,"containerElement");a(this,"stageElement");a(this,"canvasElement");a(this,"overlayerElement");a(this,"editorElement");a(this,"emptyElement");a(this,"contextMenuElement");a(this,"stageWidth",0);a(this,"stageHeight",0);a(this,"paint");a(this,"icons");a(this,"isMouseoverTargetContainer",!1);a(this,"mousedown",!1);a(this,"isPointer",!1);a(this,"rowResizing",!1);a(this,"columnResizing",!1);a(this,"scrollerMove",!1);a(this,"scrollerFocus",!1);a(this,"autofillMove",!1);a(this,"selectorMove",!1);a(this,"adjustPositioning",!1);a(this,"editing",!1);a(this,"onlyMergeCell",!1);a(this,"selectOnlyOne",!1);a(this,"scrollY",0);a(this,"scrollX",0);a(this,"fixedLeftWidth",0);a(this,"fixedRightWidth",0);a(this,"lastCenterColIndex",0);a(this,"maxColIndex",0);a(this,"maxRowIndex",0);a(this,"hoverRow");a(this,"clickCell");a(this,"focusCell");a(this,"currentCell");a(this,"hoverCell");a(this,"clickCellHeader");a(this,"focusCellHeader");a(this,"hoverCellHeader");a(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});a(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});a(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});a(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});a(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});a(this,"database");a(this,"history");a(this,"config");const{containerElement:i,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:n,emptyElement:h,contextMenuElement:c}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=r,this.overlayerElement=o,this.editorElement=n,this.emptyElement=h,this.contextMenuElement=c,this.config=new Wt(e.config||{}),this.eventBus=new di,this.eventBrowser=new ci(this),this.eventTable=new ui(this),this.paint=new fi(this.canvasElement),this.database=new li(this,e),this.history=new hi(this),this.icons=new xi(this)}setConfig(t){this.config=new Wt(t)}setItemValueByEditor(t,e,i,s=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const o=this.database.getVirtualBodyCellByKey(t,e);if(o&&(o.mergeRow||o.mergeCol)){const{dataList:n}=o.getSpanInfo(),h=n.map(c=>({...c,value:i}));this.database.batchSetItemValue(h,s);return}}this.database.setItemValue(t,e,i,s,r,!0)}batchSetItemValueByEditor(t,e=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const i=[];t.forEach(s=>{const r=this.database.getRowIndexForRowKey(s.rowKey),o=this.database.getColIndexForKey(s.key);if(r===void 0||o===void 0)return;const n=this.database.getVirtualBodyCell(r,o);if(n){const{dataList:h}=n.getSpanInfo(),c=h.map(d=>({...d,value:s.value}));i.push(...c)}}),this.database.batchSetItemValue(i,e)}else this.database.batchSetItemValue(t,e)}setFocusCell(t){var e;if(this.focusCell!==t){if(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey){this.currentCell=t,this.emit("rowFocusChange",t);const i={rowIndex:t.rowIndex,rowKey:t.rowKey,row:t.row};this.emit("currentRowChange",i)}this.focusCell=t,this.emit("cellFocusChange",t)}}clearSelector(){this.selector.enable=!1,this.selector.xArr=[-1,-1],this.selector.yArr=[-1,-1],this.emit("clearSelector")}clearSelectorCopy(){this.selector.xArrCopy=[-1,-1],this.selector.yArrCopy=[-1,-1]}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let r=0;r<=e[1]-e[0];r++){const o=[];for(let n=0;n<=i[1]-i[0];n++){const h=r+e[0],c=n+i[0],d=this.database.getItemValueForRowIndexAndColIndex(h,c);d&&o.push(d.value)}s+=`${o.join(" ")}\r`,t.push(o)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let r=Math.floor(e),o=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(o=this.body.height+this.footer.height-this.body.visibleHeight),r<0?r=0:r>o&&(r=o),this.emit("setScroll",i,r)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class zt{constructor(t,e){a(this,"ctx");a(this,"type");a(this,"isFocus",!1);a(this,"trackX",0);a(this,"trackY",0);a(this,"trackWidth",0);a(this,"trackHeight",0);a(this,"splitPoints",[]);a(this,"barX",0);a(this,"barY",0);a(this,"barWidth",0);a(this,"barHeight",0);a(this,"distance",0);a(this,"visibleDistance",0);a(this,"clientX",0);a(this,"clientY",0);a(this,"dragStart",0);a(this,"isDragging",!1);a(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onTouchmove(t){const{clientY:e,clientX:i}=t.touches[0],s=e-this.clientY,r=i-this.clientX;let o=0;this.type==="vertical"?(o=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(o===0&&s>0||o===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(o=Math.max(0,Math.min(this.dragStart-r,this.distance))),this.scroll=o}onTouchstart(t){const{clientY:e,clientX:i}=t.touches[0];this.clientX=i,this.clientY=e,this.dragStart=this.scroll}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget(t))return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(!(s==this.clientX&&r==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=r,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let o=0;this.type==="vertical"?o=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:o=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(o,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:r,buttons:o}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,o===0||s==this.clientX&&r==this.clientY)return;let n=0;if(this.type==="horizontal"?n=s-this.clientX:n=r-this.clientY,this.isDragging&&n!==0){let h=0;this.type==="vertical"?h=this.dragStart+n/(this.visibleDistance-this.barHeight)*this.distance:h=this.dragStart+n/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(h,this.distance))}}isPointInElement(t,e,i,s,r,o){return t>=i&&t<=i+r&&e>=s&&e<=s+o}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:r=0,SCROLLER_SIZE:o=0,BORDER:n}}=this.ctx,h=s,c=i,d=e.height,f=e.width,x=t.height,g=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=c-r-d,this.distance=x-this.visibleDistance+g,this.trackX=h-r,this.trackY=0,this.splitPoints=[this.trackX,d,this.trackX+r,d],this.trackWidth=r,this.trackHeight=c,this.barX=this.trackX-1+(r-o)/2,this.barWidth=o;const p=this.distance?this.visibleDistance/(x+g):0;let u=Math.floor(p*this.visibleDistance);u<30?u=30:u>this.visibleDistance&&(u=0),this.barHeight=u,this.barY=d+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=h-r,this.distance=f-this.visibleDistance,this.splitPoints=[h-r,c-r,h-r,c];const p=n?0:.5;this.trackX=0,this.trackY=c-r+p,this.trackWidth=h,this.trackHeight=r;const u=this.distance?this.visibleDistance/f:0;let w=Math.floor(u*this.visibleDistance);this.barY=this.trackY-1+(r-o)/2,w<30?w=30:w>=this.visibleDistance&&(w=0),this.barWidth=w,this.barHeight=o,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,BORDER:s,SCROLLER_TRACK_COLOR:r}}=this.ctx;this.updatedSize();let o=i;s||(o="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:o,fillColor:r}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:o,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class wi{constructor(t){a(this,"ctx");a(this,"verticalScrollbar");a(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new zt(t,"vertical"),this.horizontalScrollbar=new zt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("touchmove",e=>this.onTouchmove(e)),this.ctx.on("touchstart",e=>{this.onTouchstart(e)}),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onTouchmove(t){this.verticalScrollbar.onTouchmove(t),this.horizontalScrollbar.onTouchmove(t),this.draw()}onTouchstart(t){this.verticalScrollbar.onTouchstart(t),this.horizontalScrollbar.onTouchstart(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw"),this.ctx.emit("onScroll",t,e)}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:r}=i.getPositionForRowIndex(s);this.setScrollY(r-e.visibleHeight/2)}}class pi{constructor(t){a(this,"ctx");a(this,"x",0);a(this,"y",0);a(this,"width",0);a(this,"height",0);a(this,"resizeTarget",null);a(this,"resizeNum",0);a(this,"isResizing",!1);a(this,"clientX",0);a(this,"resizeDiff",0);a(this,"columnIndex",0);a(this,"isMouseDown",!1);a(this,"columns");a(this,"visibleLeafColumns",[]);a(this,"visibleHeight",0);a(this,"visibleWidth",0);a(this,"allCellHeaders",[]);a(this,"leafCellHeaders",[]);a(this,"renderLeafCellHeaders",[]);a(this,"fixedLeftCellHeaders",[]);a(this,"centerCellHeaders",[]);a(this,"fixedRightCellHeaders",[]);a(this,"renderCenterCellHeaders",[]);a(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Qt(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=te(i),r=_t(i);this.height=t*s,this.width=r.reduce((f,x)=>{const{width:g=100,maxWidth:p,minWidth:u}=x;return p&&g>p?f+p:u&&g<u?f+u:f+g},0),this.visibleHeight=this.height;const o=ei(ee(i,s));this.columnIndex=0,this.resizeNum=0,this.render(o,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const n=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(n.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth+"px",this.visibleWidth=this.ctx.stageWidth-e;const h=this.visibleWidth-this.width;if(this.resizeNum&&h>0){const f=Math.floor(h/this.resizeNum*100)/100;this.resizeAllColumn(f)}const c=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=c.reduce((f,x)=>f+x.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,x)=>f+x.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.isMouseDown=!1,this.ctx.columnResizing=!1,this.clientX=0,this.resizeDiff=0}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const r=this.resizeTarget.width,o=this.resizeTarget.minWidth,n=this.resizeTarget.maxWidth;let h=e.clientX-this.clientX;h+r<s&&(h=-(r-s)),o&&h+r<o&&(h=-(r-o)),n&&h+r>n&&(h=n-r),this.resizeDiff=h,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(e.offsetX<0||e.offsetX>this.visibleWidth){this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");return}this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of r){const{offsetX:n,offsetY:h}=this.ctx.getOffset(e),c=n,d=o.getDrawX();c>d+o.width-5&&c<d+o.width+4&&c<i-4&&o.colspan<=1&&this.ctx.isTarget(e)&&h<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}}))}resizeColumn(t,e){const i=r=>{r.forEach(o=>{if(o.children&&o.children.length>0&&i(o.children),o.key===t.key){const n=o.width||100;o.width=n+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const r=this.visibleWidth-this.width;s=Math.floor(r/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const r of this.allCellHeaders)if(r.widthFillDisable)e.set(r.key,r.width);else{const o=r.width+t*r.colspan;e.set(r.key,o),o<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=r=>{r.forEach(o=>{e.has(o.key)&&(o.width=e.get(o.key)),o.children&&o.children.length>0&&s(o.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:r=0}=this.ctx.config;for(let o=0;o<i;o++){const n=t[o],h=r*(n.rowspan||0),c=r*(n.level||0);let{minWidth:d,maxWidth:f}=n,x=n.width||100;d&&x<d&&(x=d),f&&x>f&&(x=f),n.children&&(x=_t(n.children).reduce((u,w)=>u+((w==null?void 0:w.width)||100),0));const g=new oe(this.ctx,this.columnIndex,s,c,x,h,n);this.ctx.database.setHeader(n.key,g),this.allCellHeaders.push(g),n.children||(this.leafCellHeaders.push(g),g.column.widthFillDisable||this.resizeNum++),n.fixed==="left"?this.fixedLeftCellHeaders.push(g):n.fixed==="right"?this.fixedRightCellHeaders.push(g):this.centerCellHeaders.push(g),!n.children&&this.columnIndex++,n.children&&this.render(n.children,s),s+=x}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,r=i+s+this.resizeDiff-.5,o=[r-.5,0,r-.5,t];this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];if(this.centerCellHeaders.length){const s=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=s.colIndex}this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,r)=>s.x-r.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}drawBottomLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.height,t,this.height];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine(),this.drawBottomLine()}}class ne{constructor(t,e,i=0,s=0,r=0,o=0,n,h="body"){a(this,"ctx");a(this,"x",0);a(this,"y",0);a(this,"width",0);a(this,"height");a(this,"cells",[]);a(this,"fixedCells",[]);a(this,"noFixedCells",[]);a(this,"rowIndex",0);a(this,"rowKey","");a(this,"rowType","body");a(this,"data");this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=h,this.data=n,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(r=>{const o=new At(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);o.fixed?i.push(o):s.push(o),e.push(o)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}drawContainer(){this.noFixedCells.forEach(t=>{t.drawContainer()})}drawFixedContainer(){this.fixedCells.forEach(t=>{t.drawContainer()})}}class mi{constructor(t){a(this,"resizeTarget",null);a(this,"isMouseDown",!1);a(this,"resizeDiff",0);a(this,"clientY",0);a(this,"ctx");a(this,"x",0);a(this,"y",0);a(this,"width",0);a(this,"height",0);a(this,"headIndex",0);a(this,"tailIndex",0);a(this,"isResizing",!1);a(this,"renderRows",[]);a(this,"visibleRows",[]);a(this,"visibleHeight",0);a(this,"visibleWidth",0);a(this,"containerRect");a(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:r,SCROLLER_TRACK_SIZE:o=0,HEIGHT:n,EMPTY_BODY_HEIGHT:h=0,MAX_HEIGHT:c=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:x}}=this.ctx;if(!e.width)return;this.x=0,x==="top"&&r?this.y=e.height+i.height:this.y=e.height;const{data:g,sumHeight:p}=s.getData();this.height=p,this.data=g,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-o;const u=this.ctx.footer.height;!this.data.length&&!n?this.height=h:!this.data.length&&n&&(this.height=n-e.height-u-o);let w=this.height+e.height+o;w+=u;let m=w;const b=window.innerHeight,{top:y}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(b>y&&d&&!n){const T=b-y-f;T>e.height+o?m=T:w>c&&(m=c)}else this.data.length&&n?m=n:this.data.length&&c&&w>c&&(m=c);m>0&&(this.ctx.stageHeight=Math.floor(m),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let C=this.ctx.stageHeight-e.height-o;r?this.visibleHeight=C-u:this.visibleHeight=C,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=g;const E=window.devicePixelRatio||1,R=this.ctx.stageWidth*E,O=this.ctx.stageHeight*E;t.width=Math.round(R),t.height=Math.round(O);const I=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:I,type:I,headerHeight:e.height,bodyHeight:this.height,footerHeight:u,width:this.width,height:this.data.length?0:h+u});const _=Math.round(t.width/E*1e4)/1e4,v=Math.round(t.height/E*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${v}px;width:${_}px;`),this.ctx.paint.scale(E)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("resize",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("resizeObserver",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0}),this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s,n=e.clientY,{stageHeight:h,scrollY:c,config:{RESIZE_ROW_MIN_HEIGHT:d=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const f=this.resizeTarget.height;let x=n-this.clientY;x+f<d&&(x=-(f-d)),this.resizeDiff=x,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||r<0||r>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");return}if(this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let f=0;f<this.renderRows.length;f++){const x=this.renderRows[f];if(r>x.y-c+x.height-1.5&&r<x.y-c+x.height+1.5&&r<h-4)for(let p=0;p<x.cells.length;p++){const u=x.cells[p];o>u.drawX+10&&o<u.drawX+u.width-10&&u.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=x)}}}}))}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:r,data:o}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:r,row:o,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,r=this.resizeTarget.height,o=s+r+this.resizeDiff-.5,n=[0,o-.5,t,o-.5];this.ctx.paint.drawLine(n,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,r=-1;for(;i<=s;){let o=Math.floor((i+s)/2),n=t[o].bottom;if(n===e)return o;n<e?i=o+1:(r=o,s=o-1)}return r}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,r=i,{data:o,positions:n}=e.getData();this.ctx.maxRowIndex=o.length-1;let h=this.binarySearch(n,r),c=this.binarySearch(n,r+this.visibleHeight);if(c===-1&&(c=this.ctx.maxRowIndex),h===-1&&c===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);h=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,h),this.tailIndex=Math.min(this.ctx.maxRowIndex,c+1),this.visibleRows=o.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const d=[];for(let f=0;f<this.visibleRows.length;f++){const x=this.headIndex+f,g=this.visibleRows[f],{height:p,top:u}=this.ctx.database.getPositionForRowIndex(x),w=new ne(this.ctx,x,0,u+this.y,t.width,p,g);d.push(w)}this.renderRows=d,this.ctx.body.renderRows=d}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class yi{constructor(t){a(this,"ctx");a(this,"renderRows",[]);a(this,"data",[]);a(this,"x",0);a(this,"y",0);a(this,"width",0);a(this,"height",0);a(this,"visibleWidth",0);a(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r,FOOTER_POSITION:o}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(n=>n+i,0),this.visibleHeight=this.height,s?o==="top"?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-r:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=this.ctx;let h=this.y;if(this.ctx.config.FOOTER_FIXED||(h=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,h,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==n){const c=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(c,h,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,r)=>{const o=new ne(this.ctx,r,0,e,this.width,t,s,"footer");e+=t,i.push(o)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.y,t,this.y];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTopLine()}}class Ei{constructor(t){a(this,"isCut",!1);a(this,"isMultipleRow",!1);a(this,"mousedownHeader",!1);a(this,"ctx");a(this,"adjustPositionX","");a(this,"adjustPositionY","");a(this,"timerX",0);a(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",Qt(t=>{const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=this.ctx.isTarget(t)&&i>0&&i<this.ctx.body.visibleWidth&&e>this.ctx.header.visibleHeight&&e<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(!s&&!this.mousedownHeader?this.startAdjustPosition(t):this.stopAdjustPosition())},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(this.ctx.isTarget(e)&&this.ctx.stageElement.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.stageElement.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}}),this.ctx.on("mouseup",()=>{this.mousedownHeader=!1;const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{this.ctx.stageElement.style.cursor!=="pointer"&&(this.ctx.isPointer||(e.preventDefault(),this.mousedownHeader=!0,this.selectCols(t)))}),this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"||t.shiftKey&&t.code==="Tab"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.stopAdjustPosition()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let r=t,o=e;if(!s){const[n]=o;o=[n,n]}if(!i){const[n]=r;r=[n,n]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(o)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:c,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,g=n,p=h||this.ctx.maxColIndex-f,u=c,w=d||this.ctx.maxRowIndex-x;let[m,b]=r,[y,C]=o;if(m<g||b>p||y<u||C>w)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const R=this.adjustMergeCells(r,o);y=R.yArr[0],C=R.yArr[1],m=R.xArr[0],b=R.xArr[1],this.ctx.onlyMergeCell=R.onlyMergeCell}m===b&&y===C?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,r=[Math.max(g,m),Math.min(p,b)],o=[Math.max(u,y),Math.min(w,C)];const{BEFORE_SET_SELECTOR_METHOD:E}=this.ctx.config;if(typeof E=="function"){const O=E({focusCell:this.ctx.focusCell,xArr:r,yArr:o});if(!O)return;r=O.xArr,o=O.yArr}this.ctx.selector.xArr=r,this.ctx.selector.yArr=o,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var p;const[i,s]=e,[r,o]=t;let n=[],h=[];for(let u=0;u<=e[1]-e[0];u++)for(let w=0;w<=t[1]-t[0];w++){const m=u+e[0],b=w+t[0],y=this.ctx.database.getVirtualBodyCell(m,b);y&&((m===i||m===s)&&n.push(y),(b===r||b===o)&&h.push(y))}const c=n.reduce((u,w)=>{const{yArr:m}=w.getSpanInfo(),[b,y]=m;return u.minY=Math.min(u.minY,b),u.maxY=Math.max(u.maxY,y),u},{minY:i,maxY:s}),d=h.reduce((u,w)=>{const{xArr:m}=w.getSpanInfo(),[b,y]=m;return u.minX=Math.min(u.minX,b),u.maxX=Math.max(u.maxX,y),u},{minX:r,maxX:o}),f=[d.minX,d.maxX],x=[c.minY,c.maxY];let g=!1;if(d.minX!==d.maxX||c.minY!==c.maxY){const u=JSON.stringify(f)+JSON.stringify(x),w=(p=this.ctx.focusCell)==null?void 0:p.getSpanInfo();g=(w&&JSON.stringify(w.xArr)+JSON.stringify(w.yArr))===u}return{xArr:f,yArr:x,onlyMergeCell:g}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,r=e,o=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:n}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=n){const h=[n,t.colIndex+t.colspan-1],c=[r,o];this.setSelector(h,c)}else{const h=[t.colIndex,n],c=[r,o];this.setSelector(h,c)}}else{const n=[t.colIndex,t.colIndex+t.colspan-1],h=[r,o];this.setSelector(n,h)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-n,f=r,x=o||this.ctx.maxRowIndex-h,g=[c,d],p=[f,x];this.setSelector(g,p)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r}=this.ctx.config,o=s||this.ctx.maxColIndex-r,n=i;if(e){this.ctx.setFocusCell(t);const h=[n,o],c=[t.rowIndex,t.rowIndex];this.setSelector(h,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:h}=this.ctx.focusCell;if(t.rowIndex>=h){const c=[n,o],d=[h,t.rowIndex];this.setSelector(c,d)}else{const c=[n,o],d=[t.rowIndex,h];this.setSelector(c,d)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:r}=e,o=Math.min(i.colIndex,r),n=Math.max(i.colIndex,r),h=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),d=[o,n],f=[h,c];this.setSelector(d,f)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE)return;const{colIndex:s,rowIndex:r}=i,{colIndex:o,rowIndex:n}=e,h=Math.min(o,s),c=Math.max(o,s),d=Math.min(n,r),f=Math.max(n,r),x=[h,c],g=[d,f];this.setSelector(x,g)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],r=[e.rowIndex,e.rowIndex];this.setSelector(s,r),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(r=>r.rowIndex===t);return i==null?void 0:i.cells.find(r=>r.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY)return;let{value:t,xArr:e,yArr:i}=this.ctx.getSelectedData();if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(e,i))if(this.ctx.onlyMergeCell&&this.ctx.focusCell){const o=this.ctx.focusCell;t=[[o.getValue()]],e=[o.colIndex,o.colIndex],i=[o.rowIndex,o.rowIndex]}else{const o={code:"ERR_MERGED_CELLS_COPY",message:"Merged cells cannot span copy data"};this.ctx.hasEvent("error")?this.ctx.emit("error",o):alert(o.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const n=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!n)return;t=n.data}const r=ri(t);navigator.clipboard?navigator.clipboard.writeText(r).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(o=>console.error("Copy Failure:",o)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1){let s=[];const r=new Set;for(let n=0;n<=e[1]-e[0];n++)for(let h=0;h<=t[1]-t[0];h++){const c=n+e[0],d=h+t[0],f=this.ctx.database.getItemValueForRowIndexAndColIndex(c,d);if(f){const{rowKey:x,key:g}=f;this.ctx.database.getReadonly(x,g)||(r.add(x),s.push({rowKey:x,key:g,value:null,row:{}}))}}if(!s.length)return[];if(i)return s;this.ctx.database.batchSetItemValue(s,!0);let o=[];return r.forEach(n=>{o.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("clearSelectedDataChange",s,o),s}paste(){if(!navigator.clipboard){console.error("current browser does not support the Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async r=>{let o=si(r);const n=[i,i+o[0].length-1],h=[e,e+o.length-1],[c,d]=h,[f,x]=n,g=d-this.ctx.maxRowIndex,p=x-this.ctx.maxColIndex;(g>0||p>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:x,minY:c,minX:f,overflowRowCount:g,overflowColCount:p,textArr:o});const u=o.length===1&&o[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(n,h)&&!u){const y={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",y):alert(y.message);return}let w=[];for(let y=0;y<=o.length-1;y++){const C=o[y].length;for(let E=0;E<=C-1;E++){const R=y+e,O=E+i,I=o[y][E],_=this.ctx.database.getItemValueForRowIndexAndColIndex(R,O);if(_){const{rowKey:v,key:S}=_;this.ctx.database.getReadonly(v,S)||(s.add(v),w.push({rowKey:v,key:S,value:I,row:{}}))}}}if(this.isCut){const y=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),C=w.map(E=>`${E.rowKey}-${E.key}`);y.forEach(E=>{C.includes(`${E.rowKey}-${E.key}`)||w.unshift(E)}),this.isCut=!1}if(!w.length)return;const{BEFORE_PASTE_DATA_METHOD:m}=this.ctx.config;if(typeof m=="function"){const y=m,C=w.map(E=>({rowKey:E.rowKey,key:E.key,value:E.value,oldValue:this.ctx.database.getItemValue(E.rowKey,E.key),row:this.ctx.database.getRowDataItemForRowKey(E.rowKey)}));if(w=await y(C,n,h,o),w&&!w.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(w,!0);let b=[];s.forEach(y=>{b.push(this.ctx.database.getRowDataItemForRowKey(y))}),this.ctx.emit("pasteChange",w,b)}).catch(r=>{console.error("Failed to get the clipboard content:",r)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const r=0,o=0,n=this.ctx.maxColIndex,h=this.ctx.maxRowIndex;switch(t){case"LEFT":i>r&&i--;break;case"TOP":s>o&&s--;break;case"RIGHT":i<n&&i++;break;case"BOTTOM":s<h&&s++;break}const c=[i,i],d=[s,s],f=this.getCell(s,i);f&&(f.operation||this.isInSettingRange(f.rowIndex,f.colIndex)&&(this.ctx.setFocusCell(f),this.setSelector(c,d),this.adjustBoundaryPosition(),this.ctx.emit("moveFocus",f),this.ctx.emit("draw")))}stopAdjustPosition(){this.adjustPositionX="",this.adjustPositionY="",this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerY&&(clearInterval(this.timerY),this.timerY=0)}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-n,f=r,x=o||this.ctx.maxRowIndex-h;return!(e<c||e>d||t<f||t>x)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",r="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?r="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(r="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let n=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{n*=1.5;const{scrollX:h}=this.ctx,c=h+n;(c<0||c>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(c)},100)}if(r&&this.adjustPositionY!==r){this.adjustPositionY=r;let n=10*(r==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{n*=1.5;const{scrollY:h}=this.ctx,c=h+n;(c<0||c>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(c)},100)}}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:r,header:o,footer:n,body:h,scrollX:c,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:x,FOOTER_POSITION:g,ENABLE_MERGE_CELL_LINK:p}}=this.ctx;if(!i)return;p&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:u,drawY:w,width:m,height:b,fixed:y}=i,C=r-u+1,E=i.drawX+m-(e-s)+1;let R=o.height-w,O=b;O>h.visibleHeight&&(O=h.visibleHeight);let I=0;x&&(g==="top"?R=o.height+n.height-w:I=n.visibleHeight);const _=w+O-(t-I-f);let v=c,S=d;E>0&&!y?v=Math.floor(c+E):C>0&&!y&&(v=Math.floor(c-C)),R>0?S=Math.floor(d-R):_>0&&(S=Math.floor(d+_)),(Math.abs(c-v)>2||Math.abs(d-S)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(v,S),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class Ci{constructor(t){a(this,"ctx");a(this,"maxColRowCell");this.ctx=t,this.init()}init(){this.ctx.on("mousemove",t=>{if(this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t),{colIndex:s,rowIndex:r,drawX:o,drawY:n,width:h,height:c}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||r===this.ctx.maxRowIndex?0:2,x=o+h-d+f,g=n+c-d+f;e>x&&i>g&&e<x+d&&i<g+d&&(this.ctx.stageElement.style.cursor="crosshair")}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],r=i[1],{colIndex:o,rowIndex:n}=t;this.ctx.config.ENABLE_AUTOFILL&&o===s&&n===r&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:r}=this.ctx.config;if(!i)return;let o=t,n=e;if(!r){const[h]=n;n=[h,h]}if(!s){const[h]=o;o=[h,h]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(n)){const{SELECTOR_AREA_MIN_X:h,SELECTOR_AREA_MAX_X:c,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:x,SELECTOR_AREA_MAX_Y_OFFSET:g}=this.ctx.config,p=h,u=c||this.ctx.maxColIndex-x,w=d,m=f||this.ctx.maxRowIndex-g;let[b,y]=o,[C,E]=n;if(b<p||C<w)return;o=[Math.max(p,b),Math.min(u,y)],n=[Math.max(w,C),Math.min(m,E)];const{BEFORE_SET_AUTOFILL_METHOD:R}=this.ctx.config;if(typeof R=="function"){const I=R({focusCell:this.ctx.focusCell,xArr:o,yArr:n});if(!I)return;o=I.xArr,n=I.yArr}this.ctx.autofill.xArr=o,this.ctx.autofill.yArr=n,this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let g=0;g<=e.yArr[1]-e.yArr[0];g++)for(let p=0;p<=e.xArr[1]-e.xArr[0];p++){const u=g+e.yArr[0],w=p+e.xArr[0];i.set(`${u}-${w}`,!0)}const{value:s}=e,r=s[0].length,o=s.length,n=this.ctx.autofill.xArr,h=this.ctx.autofill.yArr,c=r===1&&o===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(n,h)&&!c){const g={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",g):alert(g.message);return}let d=[];for(let g=0;g<=h[1]-h[0];g++)for(let p=0;p<=n[1]-n[0];p++){const u=p+n[0],w=g+h[0],m=s[g%o][p%r],b=this.ctx.database.getItemValueForRowIndexAndColIndex(w,u),y=`${w}-${u}`;if(b&&!i.has(y)){const{rowKey:C,key:E}=b;this.ctx.database.getReadonly(C,E)||(t.add(C),d.push({rowKey:C,key:E,value:m,row:{}}))}}if(!d.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;const{BEFORE_AUTOFILL_DATA_METHOD:f}=this.ctx.config;if(typeof f=="function"){const g=f,p=d.map(u=>({rowKey:u.rowKey,key:u.key,value:u.value,oldValue:this.ctx.database.getItemValue(u.rowKey,u.key),row:this.ctx.database.getRowDataItemForRowKey(u.rowKey)}));if(d=await g(p,n,h),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let x=[];t.forEach(g=>{x.push(this.ctx.database.getRowDataItemForRowKey(g))}),this.ctx.emit("autofillChange",d,x)}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:r}=t,o=e.xArr.slice(),n=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?r>e.xArr[1]?o.splice(1,1,r):r<e.xArr[0]&&o.splice(0,1,r):s>e.yArr[1]?n.splice(1,1,s):s<e.yArr[0]&&n.splice(0,1,s),this.setAutofill(o,n)}}destroy(){}}const rt=Math.min,U=Math.max,ft=Math.round,z=l=>({x:l,y:l}),bi={left:"right",right:"left",bottom:"top",top:"bottom"},vi={start:"end",end:"start"};function It(l,t,e){return U(l,rt(t,e))}function at(l,t){return typeof l=="function"?l(t):l}function G(l){return l.split("-")[0]}function lt(l){return l.split("-")[1]}function ae(l){return l==="x"?"y":"x"}function Mt(l){return l==="y"?"height":"width"}function J(l){return["top","bottom"].includes(G(l))?"y":"x"}function Ht(l){return ae(J(l))}function Ri(l,t,e){e===void 0&&(e=!1);const i=lt(l),s=Ht(l),r=Mt(s);let o=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=xt(o)),[o,xt(o)]}function _i(l){const t=xt(l);return[Ot(l),t,Ot(t)]}function Ot(l){return l.replace(/start|end/g,t=>vi[t])}function Ii(l,t,e){const i=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(l){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?r:o;default:return[]}}function Oi(l,t,e,i){const s=lt(l);let r=Ii(G(l),e==="start",i);return s&&(r=r.map(o=>o+"-"+s),t&&(r=r.concat(r.map(Ot)))),r}function xt(l){return l.replace(/left|right|bottom|top/g,t=>bi[t])}function Li(l){return{top:0,right:0,bottom:0,left:0,...l}}function le(l){return typeof l!="number"?Li(l):{top:l,right:l,bottom:l,left:l}}function ut(l){const{x:t,y:e,width:i,height:s}=l;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function $t(l,t,e){let{reference:i,floating:s}=l;const r=J(t),o=Ht(t),n=Mt(o),h=G(t),c=r==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,x=i[n]/2-s[n]/2;let g;switch(h){case"top":g={x:d,y:i.y-s.height};break;case"bottom":g={x:d,y:i.y+i.height};break;case"right":g={x:i.x+i.width,y:f};break;case"left":g={x:i.x-s.width,y:f};break;default:g={x:i.x,y:i.y}}switch(lt(t)){case"start":g[o]-=x*(e&&c?-1:1);break;case"end":g[o]+=x*(e&&c?-1:1);break}return g}const Si=async(l,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=e,n=r.filter(Boolean),h=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:l,floating:t,strategy:s}),{x:d,y:f}=$t(c,i,h),x=i,g={},p=0;for(let u=0;u<n.length;u++){const{name:w,fn:m}=n[u],{x:b,y,data:C,reset:E}=await m({x:d,y:f,initialPlacement:i,placement:x,strategy:s,middlewareData:g,rects:c,platform:o,elements:{reference:l,floating:t}});d=b??d,f=y??f,g={...g,[w]:{...g[w],...C}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(x=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:l,floating:t,strategy:s}):E.rects),{x:d,y:f}=$t(c,x,h)),u=-1)}return{x:d,y:f,placement:x,strategy:s,middlewareData:g}};async function he(l,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:o,elements:n,strategy:h}=l,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:x=!1,padding:g=0}=at(t,l),p=le(g),w=n[x?f==="floating"?"reference":"floating":f],m=ut(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(w)))==null||e?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(n.floating)),boundary:c,rootBoundary:d,strategy:h})),b=f==="floating"?{x:i,y:s,width:o.floating.width,height:o.floating.height}:o.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(n.floating)),C=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},E=ut(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:n,rect:b,offsetParent:y,strategy:h}):b);return{top:(m.top-E.top+p.top)/C.y,bottom:(E.bottom-m.bottom+p.bottom)/C.y,left:(m.left-E.left+p.left)/C.x,right:(E.right-m.right+p.right)/C.x}}const Ti=l=>({name:"arrow",options:l,async fn(t){const{x:e,y:i,placement:s,rects:r,platform:o,elements:n,middlewareData:h}=t,{element:c,padding:d=0}=at(l,t)||{};if(c==null)return{};const f=le(d),x={x:e,y:i},g=Ht(s),p=Mt(g),u=await o.getDimensions(c),w=g==="y",m=w?"top":"left",b=w?"bottom":"right",y=w?"clientHeight":"clientWidth",C=r.reference[p]+r.reference[g]-x[g]-r.floating[p],E=x[g]-r.reference[g],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let O=R?R[y]:0;(!O||!await(o.isElement==null?void 0:o.isElement(R)))&&(O=n.floating[y]||r.floating[p]);const I=C/2-E/2,_=O/2-u[p]/2-1,v=rt(f[m],_),S=rt(f[b],_),T=v,M=O-u[p]-S,A=O/2-u[p]/2+I,N=It(T,A,M),Y=!h.arrow&&lt(s)!=null&&A!==N&&r.reference[p]/2-(A<T?v:S)-u[p]/2<0,k=Y?A<T?A-T:A-M:0;return{[g]:x[g]+k,data:{[g]:N,centerOffset:A-N-k,...Y&&{alignmentOffset:k}},reset:Y}}}),Ai=function(l){return l===void 0&&(l={}),{name:"flip",options:l,async fn(t){var e,i;const{placement:s,middlewareData:r,rects:o,initialPlacement:n,platform:h,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:x,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:u=!0,...w}=at(l,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const m=G(s),b=J(n),y=G(n)===n,C=await(h.isRTL==null?void 0:h.isRTL(c.floating)),E=x||(y||!u?[xt(n)]:_i(n)),R=p!=="none";!x&&R&&E.push(...Oi(n,u,p,C));const O=[n,...E],I=await he(t,w),_=[];let v=((i=r.flip)==null?void 0:i.overflows)||[];if(d&&_.push(I[m]),f){const A=Ri(s,o,C);_.push(I[A[0]],I[A[1]])}if(v=[...v,{placement:s,overflows:_}],!_.every(A=>A<=0)){var S,T;const A=(((S=r.flip)==null?void 0:S.index)||0)+1,N=O[A];if(N)return{data:{index:A,overflows:v},reset:{placement:N}};let Y=(T=v.filter(k=>k.overflows[0]<=0).sort((k,W)=>k.overflows[1]-W.overflows[1])[0])==null?void 0:T.placement;if(!Y)switch(g){case"bestFit":{var M;const k=(M=v.filter(W=>{if(R){const P=J(W.placement);return P===b||P==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(P=>P>0).reduce((P,Ce)=>P+Ce,0)]).sort((W,P)=>W[1]-P[1])[0])==null?void 0:M[0];k&&(Y=k);break}case"initialPlacement":Y=n;break}if(s!==Y)return{reset:{placement:Y}}}return{}}}};async function Mi(l,t){const{placement:e,platform:i,elements:s}=l,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),o=G(e),n=lt(e),h=J(e)==="y",c=["left","top"].includes(o)?-1:1,d=r&&h?-1:1,f=at(t,l);let{mainAxis:x,crossAxis:g,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return n&&typeof p=="number"&&(g=n==="end"?p*-1:p),h?{x:g*d,y:x*c}:{x:x*c,y:g*d}}const Hi=function(l){return l===void 0&&(l=0),{name:"offset",options:l,async fn(t){var e,i;const{x:s,y:r,placement:o,middlewareData:n}=t,h=await Mi(t,l);return o===((e=n.offset)==null?void 0:e.placement)&&(i=n.arrow)!=null&&i.alignmentOffset?{}:{x:s+h.x,y:r+h.y,data:{...h,placement:o}}}}},Di=function(l){return l===void 0&&(l={}),{name:"shift",options:l,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:n={fn:w=>{let{x:m,y:b}=w;return{x:m,y:b}}},...h}=at(l,t),c={x:e,y:i},d=await he(t,h),f=J(G(s)),x=ae(f);let g=c[x],p=c[f];if(r){const w=x==="y"?"top":"left",m=x==="y"?"bottom":"right",b=g+d[w],y=g-d[m];g=It(b,g,y)}if(o){const w=f==="y"?"top":"left",m=f==="y"?"bottom":"right",b=p+d[w],y=p-d[m];p=It(b,p,y)}const u=n.fn({...t,[x]:g,[f]:p});return{...u,data:{x:u.x-e,y:u.y-i,enabled:{[x]:r,[f]:o}}}}}};function gt(){return typeof window<"u"}function tt(l){return ce(l)?(l.nodeName||"").toLowerCase():"#document"}function X(l){var t;return(l==null||(t=l.ownerDocument)==null?void 0:t.defaultView)||window}function V(l){var t;return(t=(ce(l)?l.ownerDocument:l.document)||window.document)==null?void 0:t.documentElement}function ce(l){return gt()?l instanceof Node||l instanceof X(l).Node:!1}function B(l){return gt()?l instanceof Element||l instanceof X(l).Element:!1}function K(l){return gt()?l instanceof HTMLElement||l instanceof X(l).HTMLElement:!1}function qt(l){return!gt()||typeof ShadowRoot>"u"?!1:l instanceof ShadowRoot||l instanceof X(l).ShadowRoot}function ht(l){const{overflow:t,overflowX:e,overflowY:i,display:s}=F(l);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Xi(l){return["table","td","th"].includes(tt(l))}function wt(l){return[":popover-open",":modal"].some(t=>{try{return l.matches(t)}catch{return!1}})}function Dt(l){const t=Xt(),e=B(l)?F(l):l;return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Bi(l){let t=$(l);for(;K(t)&&!Q(t);){if(Dt(t))return t;if(wt(t))return null;t=$(t)}return null}function Xt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Q(l){return["html","body","#document"].includes(tt(l))}function F(l){return X(l).getComputedStyle(l)}function pt(l){return B(l)?{scrollLeft:l.scrollLeft,scrollTop:l.scrollTop}:{scrollLeft:l.scrollX,scrollTop:l.scrollY}}function $(l){if(tt(l)==="html")return l;const t=l.assignedSlot||l.parentNode||qt(l)&&l.host||V(l);return qt(t)?t.host:t}function de(l){const t=$(l);return Q(t)?l.ownerDocument?l.ownerDocument.body:l.body:K(t)&&ht(t)?t:de(t)}function Lt(l,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=de(l),r=s===((i=l.ownerDocument)==null?void 0:i.body),o=X(s);if(r){const n=St(o);return t.concat(o,o.visualViewport||[],ht(s)?s:[],n&&e?Lt(n):[])}return t.concat(s,Lt(s,[],e))}function St(l){return l.parent&&Object.getPrototypeOf(l.parent)?l.frameElement:null}function fe(l){const t=F(l);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=K(l),r=s?l.offsetWidth:e,o=s?l.offsetHeight:i,n=ft(e)!==r||ft(i)!==o;return n&&(e=r,i=o),{width:e,height:i,$:n}}function xe(l){return B(l)?l:l.contextElement}function Z(l){const t=xe(l);if(!K(t))return z(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:r}=fe(t);let o=(r?ft(e.width):e.width)/i,n=(r?ft(e.height):e.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!n||!Number.isFinite(n))&&(n=1),{x:o,y:n}}const Fi=z(0);function ue(l){const t=X(l);return!Xt()||!t.visualViewport?Fi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ni(l,t,e){return t===void 0&&(t=!1),!e||t&&e!==X(l)?!1:t}function ot(l,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=l.getBoundingClientRect(),r=xe(l);let o=z(1);t&&(i?B(i)&&(o=Z(i)):o=Z(l));const n=Ni(r,e,i)?ue(r):z(0);let h=(s.left+n.x)/o.x,c=(s.top+n.y)/o.y,d=s.width/o.x,f=s.height/o.y;if(r){const x=X(r),g=i&&B(i)?X(i):i;let p=x,u=St(p);for(;u&&i&&g!==p;){const w=Z(u),m=u.getBoundingClientRect(),b=F(u),y=m.left+(u.clientLeft+parseFloat(b.paddingLeft))*w.x,C=m.top+(u.clientTop+parseFloat(b.paddingTop))*w.y;h*=w.x,c*=w.y,d*=w.x,f*=w.y,h+=y,c+=C,p=X(u),u=St(p)}}return ut({width:d,height:f,x:h,y:c})}function ki(l){let{elements:t,rect:e,offsetParent:i,strategy:s}=l;const r=s==="fixed",o=V(i),n=t?wt(t.floating):!1;if(i===o||n&&r)return e;let h={scrollLeft:0,scrollTop:0},c=z(1);const d=z(0),f=K(i);if((f||!f&&!r)&&((tt(i)!=="body"||ht(o))&&(h=pt(i)),K(i))){const x=ot(i);c=Z(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-h.scrollLeft*c.x+d.x,y:e.y*c.y-h.scrollTop*c.y+d.y}}function Ki(l){return Array.from(l.getClientRects())}function Tt(l,t){const e=pt(l).scrollLeft;return t?t.left+e:ot(V(l)).left+e}function Yi(l){const t=V(l),e=pt(l),i=l.ownerDocument.body,s=U(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=U(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let o=-e.scrollLeft+Tt(l);const n=-e.scrollTop;return F(i).direction==="rtl"&&(o+=U(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:o,y:n}}function Vi(l,t){const e=X(l),i=V(l),s=e.visualViewport;let r=i.clientWidth,o=i.clientHeight,n=0,h=0;if(s){r=s.width,o=s.height;const c=Xt();(!c||c&&t==="fixed")&&(n=s.offsetLeft,h=s.offsetTop)}return{width:r,height:o,x:n,y:h}}function Wi(l,t){const e=ot(l,!0,t==="fixed"),i=e.top+l.clientTop,s=e.left+l.clientLeft,r=K(l)?Z(l):z(1),o=l.clientWidth*r.x,n=l.clientHeight*r.y,h=s*r.x,c=i*r.y;return{width:o,height:n,x:h,y:c}}function Gt(l,t,e){let i;if(t==="viewport")i=Vi(l,e);else if(t==="document")i=Yi(V(l));else if(B(t))i=Wi(t,e);else{const s=ue(l);i={...t,x:t.x-s.x,y:t.y-s.y}}return ut(i)}function ge(l,t){const e=$(l);return e===t||!B(e)||Q(e)?!1:F(e).position==="fixed"||ge(e,t)}function Pi(l,t){const e=t.get(l);if(e)return e;let i=Lt(l,[],!1).filter(n=>B(n)&&tt(n)!=="body"),s=null;const r=F(l).position==="fixed";let o=r?$(l):l;for(;B(o)&&!Q(o);){const n=F(o),h=Dt(o);!h&&n.position==="fixed"&&(s=null),(r?!h&&!s:!h&&n.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ht(o)&&!h&&ge(l,o))?i=i.filter(d=>d!==o):s=n,o=$(o)}return t.set(l,i),i}function zi(l){let{element:t,boundary:e,rootBoundary:i,strategy:s}=l;const o=[...e==="clippingAncestors"?wt(t)?[]:Pi(t,this._c):[].concat(e),i],n=o[0],h=o.reduce((c,d)=>{const f=Gt(t,d,s);return c.top=U(f.top,c.top),c.right=rt(f.right,c.right),c.bottom=rt(f.bottom,c.bottom),c.left=U(f.left,c.left),c},Gt(t,n,s));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function $i(l){const{width:t,height:e}=fe(l);return{width:t,height:e}}function qi(l,t,e){const i=K(t),s=V(t),r=e==="fixed",o=ot(l,!0,r,t);let n={scrollLeft:0,scrollTop:0};const h=z(0);if(i||!i&&!r)if((tt(t)!=="body"||ht(s))&&(n=pt(t)),i){const g=ot(t,!0,r,t);h.x=g.x+t.clientLeft,h.y=g.y+t.clientTop}else s&&(h.x=Tt(s));let c=0,d=0;if(s&&!i&&!r){const g=s.getBoundingClientRect();d=g.top+n.scrollTop,c=g.left+n.scrollLeft-Tt(s,g)}const f=o.left+n.scrollLeft-h.x-c,x=o.top+n.scrollTop-h.y-d;return{x:f,y:x,width:o.width,height:o.height}}function yt(l){return F(l).position==="static"}function jt(l,t){if(!K(l)||F(l).position==="fixed")return null;if(t)return t(l);let e=l.offsetParent;return V(l)===e&&(e=e.ownerDocument.body),e}function we(l,t){const e=X(l);if(wt(l))return e;if(!K(l)){let s=$(l);for(;s&&!Q(s);){if(B(s)&&!yt(s))return s;s=$(s)}return e}let i=jt(l,t);for(;i&&Xi(i)&&yt(i);)i=jt(i,t);return i&&Q(i)&&yt(i)&&!Dt(i)?e:i||Bi(l)||e}const Gi=async function(l){const t=this.getOffsetParent||we,e=this.getDimensions,i=await e(l.floating);return{reference:qi(l.reference,await t(l.floating),l.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ji(l){return F(l).direction==="rtl"}const Ui={convertOffsetParentRelativeRectToViewportRelativeRect:ki,getDocumentElement:V,getClippingRect:zi,getOffsetParent:we,getElementRects:Gi,getClientRects:Ki,getDimensions:$i,getScale:Z,isElement:B,isRTL:ji},pe=Hi,me=Di,ye=Ai,Zi=Ti,Ee=(l,t,e)=>{const i=new Map,s={platform:Ui,...e},r={...s.platform,_c:i};return Si(l,t,{...s,platform:r})};let Ji=class{constructor(t){a(this,"ctx");a(this,"enable",!1);a(this,"contentEl");a(this,"floatingEl");a(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:r,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;const n={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...r},h={position:"absolute",width:"10px",height:"10px",background:n.background,backgroundColor:n.backgroundColor,transform:"rotate(45deg)",zIndex:n.zIndex};Object.assign(this.arrowEl.style,h),Object.assign(this.floatingEl.style,n),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{if(!this.ctx.isTarget(t))return;const e=this.ctx.containerElement.getBoundingClientRect();e&&(t.clientX<e.x||t.clientX>e.x+e.width||t.clientY<e.y||t.clientY>e.y+e.height)&&this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.minWidth="100px",this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,r=t.drawY+i.y;Ee({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:r,left:s,right:s+t.visibleWidth,top:r,bottom:r+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[me(),ye(),pe(6),Zi({element:this.arrowEl})]}).then(n=>{const{x:h,y:c,placement:d,middlewareData:f}=n;if(Object.assign(this.floatingEl.style,{top:`${c}px`,left:`${h}px`}),f.arrow){const x=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${x.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class Qi{constructor(t){a(this,"editorEl");a(this,"inputEl");a(this,"enable",!1);a(this,"cellTarget",null);a(this,"selectorArrStr","");a(this,"ctx");a(this,"drawY",0);a(this,"drawX",0);a(this,"cancel",!1);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.cellTarget&&this.cellTarget.editorType==="text"&&this.clearEditor()}),this.ctx.on("moveFocus",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("hoverIconClick",t=>{t.editorType!=="none"&&this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell)return;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:h}=this.ctx;h&&(this.ctx.emit("setSelectorCell",h),this.cellTarget=h),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const h=this.inputEl.selectionStart,c=this.inputEl.value.substring(0,h),d=this.inputEl.value.substring(h);this.inputEl.value=c+`
16
+ `+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=h+1,this.autoSize();return}if(t.code==="Tab"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","LEFT");return}this.ctx.emit("setMoveFocus","RIGHT");return}if(t.code==="Enter"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","TOP");return}this.ctx.emit("setMoveFocus","BOTTOM");return}if(t.code==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const e=t.key,i=t.ctrlKey,s=t.altKey,r=t.shiftKey,o=t.metaKey;i||s||r||o||["Enter","Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e)||this.startEdit(!0)}),this.ctx.on("adjustBoundaryPosition",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("cellClick",t=>{if(this.ctx.adjustPositioning||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.selectorArrStr===s&&this.cellTarget){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}if(this.ctx.selectOnlyOne&&t.rowKey===this.cellTarget.rowKey&&t.key===this.cellTarget.key){this.startEdit();return}}if(this.selectorArrStr=s,this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}this.ctx.selectOnlyOne&&this.startEdit()}})}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[n,h]=s;return!(e<r||e>o||t<n||t>h)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:r,config:{SCROLLER_TRACK_SIZE:o}}=this.ctx,n=i-s.height-o;this.editorEl.style.bottom="auto",this.drawY<r.height&&(this.editorEl.style.top=`${r.height-1}px`),this.drawY+t>n&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-n}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:r,width:o,drawY:n,drawX:h}=t;this.drawX=h,this.drawY=n;const{config:{CELL_PADDING:c},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;if(r>f&&(r=f),this.editorEl.style.display="inline-block",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${o-1}px`,this.inputEl.style.minHeight=`${r-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${o-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${c}px`,i!==null&&(this.inputEl.value=i),this.inputEl.focus({preventScroll:!0});const x=this.inputEl.value.length;this.inputEl.setSelectionRange(x,x)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>r||this.drawY<d.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&this.cellTarget.editorType==="text"){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&!this.cancel&&this.ctx.setItemValueByEditor(t,e,s,!0),this.inputEl.value=""}}startEdit(t=!1){this.ctx.emit("draw"),this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i||["index","index-selection","selection"].includes(i.type)||this.enable||!(i.isVerticalVisible()&&i.isHorizontalVisible()))return;const{rowKey:r,key:o,editorType:n}=i;if(n==="none")return;const h=this.ctx.database.getReadonly(r,o);i&&!h&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=i,this.startEditByInput(this.cellTarget,t),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(c=>c.rowIndex===t);if(!i)return;const s=i.cells.find(c=>c.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const r=this.ctx.focusCell;if(!r||["index","index-selection","selection"].includes(r.type)||this.enable)return;const{rowKey:o,key:n}=r,h=this.ctx.database.getReadonly(o,n);r&&!h&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=r,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.ctx.containerElement.focus({preventScroll:!0}),this.editorEl.style.display="none",this.ctx.emit("drawView"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("drawView")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class ts{constructor(t){a(this,"ctx");a(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM_STYLE:i}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=e),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:s,headerHeight:r,bodyHeight:o,footerHeight:n})=>{const h=r+(o+n)/2,c={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${h}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,c)})}destroy(){this.emptyEl.remove()}}class es{constructor(t){a(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:r,FOOTER_POSITION:o}=this.ctx.config;return r?o==="top"?s=[t,i,e]:s=[t,e,i]:s=[t,e],{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:o,renderCellHeaders:n}=this.ctx.header;let h=[],c=[],d=[];n.forEach(w=>{w.render&&(w.fixed==="left"?c.push(w):w.fixed==="right"?d.push(w):h.push(w))});const f=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${o}px`},cells:c},g={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-f+1}px`,height:`${o}px`},cells:h},p={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${o}px`},cells:d};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${r}px`,height:`${o}px`},views:[x,g,p]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(w=>{w.cells.forEach(m=>{m.cellType==="footer"&&(m.render=m.renderFooter),m.render&&(m.fixed==="left"?e.push(m):m.fixed==="right"?i.push(m):t.push(m))})});const{fixedLeftWidth:r,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:n,CSS_PREFIX:h}}=this.ctx,{visibleWidth:c,visibleHeight:d}=this.ctx.body,f=o-n,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${r}px`,height:`${d}px`},cells:e},g={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${r-.5}px`,overflow:"hidden",width:`${c-r-f}px`,height:`${d}px`},cells:t},p={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${h}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${d}px`},views:[x,g,p]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(u=>{u.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:n}}=this.ctx,{visibleWidth:h,visibleHeight:c}=this.ctx.footer,d=r-o,f={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${c}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${h-s-d}px`,height:`${c}px`},cells:t},g={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${d}px`,height:`${c}px`},cells:i};return{type:"footer",class:`${n}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${c}px`},views:[f,x,g]}}}class is{constructor(t){a(this,"ctx");a(this,"contextMenuEl");a(this,"custom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.custom=!0,this.contextMenuEl=this.ctx.contextMenuElement):(this.custom=!1,this.contextMenuEl=document.createElement("div")),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[n,h]=s,{rowIndex:c,colIndex:d}=t;c>=n&&c<=h&&d>=r&&d<=o||this.ctx.emit("setSelectorCell",t,e);const x={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};Ee(x,this.contextMenuEl,{placement:"right-start",middleware:[pe(),me(),ye()]}).then(({x:g,y:p})=>{this.show(g,p)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){if(this.contextMenuEl.className="e-virt-table-context-menu",this.contextMenuEl.addEventListener("contextmenu",function(e){e.preventDefault()}),this.ctx.containerElement.appendChild(this.contextMenuEl),this.custom)return;const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){this.contextMenuEl.replaceChildren(),t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class ss{constructor(t,e){a(this,"options");a(this,"scroller");a(this,"header");a(this,"body");a(this,"footer");a(this,"selector");a(this,"autofill");a(this,"tooltip");a(this,"editor");a(this,"empty");a(this,"overlayer");a(this,"contextMenu");a(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:r,contextMenuElement:o}=e,n=this.createContainer(t,i,s,r,o);this.ctx=new gi(n,this.options),this.header=new pi(this.ctx),this.footer=new yi(this.ctx),this.body=new mi(this.ctx),this.scroller=new wi(this.ctx),this.selector=new Ei(this.ctx),this.autofill=new Ci(this.ctx),this.tooltip=new Ji(this.ctx),this.empty=new ts(this.ctx),this.editor=new Qi(this.ctx),this.overlayer=new es(this.ctx),this.contextMenu=new is(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i,s,r){t.className="e-virt-table-container";const o=document.createElement("div"),n=document.createElement("canvas"),h=e||document.createElement("div");o.className="e-virt-table-stage",t.tabIndex=0,n.className="e-virt-table-canvas",h.className="e-virt-table-overlayer";const c=i||document.createElement("div");c.className="e-virt-table-editor";const d=s,f=r;return o.appendChild(n),o.appendChild(h),t.appendChild(o),{containerElement:t,stageElement:o,canvasElement:n,overlayerElement:h,editorElement:c,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw()})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.database.setLoading(t)}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.scrollTo(0,0),this.ctx.database.setFilterMethod(t),this.ctx.database.init(),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,r=!0,o=!1){this.ctx.database.setItemValue(t,e,i,s,r,o)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,r=!0){this.ctx.setItemValueByEditor(t,e,i,s,r),this.editor.doneEdit()}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}setCurrentRowByRowIndex(t){this.ctx.currentCell=this.ctx.database.getVirtualBodyCell(t,0),this.ctx.emit("draw")}setCurrentRow(t){const e=this.ctx.database.getColumnByColIndex(0);e&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(t,e.key),this.ctx.emit("draw"))}getCurrentRow(){const t=this.ctx.currentCell;return t?{row:t.row,rowIndex:t.rowIndex,rowKey:t.rowKey}:void 0}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}validateFields(t,e=!0){return new Promise(async(i,s)=>{let r=[];for(let o=0;o<t.length;o++){const{rowKey:n,key:h}=t[o],c=await this.ctx.database.getValidator(n,h);Array.isArray(c)&&c.length&&r.push(c)}if(r.length){if(s(r),e){const[o]=r;if(Array.isArray(o)&&o.length){const[n]=o,{rowKey:h,key:c}=n;this.scrollToRowkey(h),this.scrollToColkey(c)}}this.ctx.emit("draw")}else i([]),this.ctx.emit("draw")})}async validate(t=!0){return new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[r]=s;if(Array.isArray(r)&&r.length){const[o]=r,{rowKey:n,key:h}=o;this.scrollToRowkey(n),this.scrollToColkey(h)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:r}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,r)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let r=[];for(let o=0;o<i.length;o++)for(let n=0;n<s.length;n++){const h=this.ctx.database.getRowKeyByItem(i[o]),d=s[n].key,f=await this.ctx.database.getValidator(h,d);Array.isArray(f)&&f.length&&r.push(f)}r.length?(e(r),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scroller.setScroll(t,e)}scrollXTo(t){this.scroller.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.scroller.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}getExpandRowKeys(){return this.ctx.database.getExpandRowKeys()}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:ni,mergeRowCell:oi,getSpanArrByRow:ie,getSpanObjByColumn:se}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=ss;
17
17
  //# sourceMappingURL=index.cjs.js.map