UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

15 lines 184 kB
(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)}})(); (function(D,X){typeof exports=="object"&&typeof module<"u"?module.exports=X():typeof define=="function"&&define.amd?define(X):(D=typeof globalThis<"u"?globalThis:D||self,D.EVirtTable=X())})(this,function(){"use strict";var is=Object.defineProperty;var ss=(D,X,z)=>X in D?is(D,X,{enumerable:!0,configurable:!0,writable:!0,value:z}):D[X]=z;var a=(D,X,z)=>ss(D,typeof X!="symbol"?X+"":X,z);function D(){return D=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},D.apply(this,arguments)}function X(l,t){l.prototype=Object.create(t.prototype),l.prototype.constructor=l,st(l,t)}function z(l){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},z(l)}function st(l,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(l,t)}function be(){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 ft(l,t,e){return be()?ft=Reflect.construct.bind():ft=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},ft.apply(null,arguments)}function ve(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function Et(l){var t=typeof Map=="function"?new Map:void 0;return Et=function(i){if(i===null||!ve(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 ft(i,arguments,z(this).constructor)}return s.prototype=Object.create(i.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),st(s,i)},Et(l)}var Re=/%[sdj%]/g,Ft=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(Ft=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 Ct(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 N(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(Re,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 _e(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||_e(t)&&typeof l=="string"&&!l)}function Ie(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 Oe(l){var t=[];return Object.keys(l).forEach(function(e){t.push.apply(t,l[e]||[])}),t}var kt=function(l){X(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}(Et(Error));function Le(l,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 kt(p,Ct(p))):u(s)},x=Oe(l);Bt(x,e,m)});return r.catch(function(u){return u}),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(u,g){var m=function(w){if(d.push.apply(d,w),c++,c===h)return i(d),d.length?g(new kt(d,Ct(d))):u(s)};n.length||(i(d),u(s)),n.forEach(function(x){var w=l[x];o.indexOf(x)!==-1?Bt(w,e,m):Ie(w,e,m)})});return f.catch(function(u){return u}),f}function Se(l){return!!(l&&l.message!==void 0)}function Te(l,t){for(var e=l,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Kt(l,t){return function(e){var i;return l.fullFields?i=Te(t,l.fullFields):i=t[e.field||l.fullField],Se(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 Yt(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]=D({},l[e],i):l[e]=i}}return l}var Vt=function(t,e,i,s,r,o){t.required&&(!i.hasOwnProperty(t.field)||H(e,o||t.type))&&s.push(N(r.messages.required,t.fullField))},Ae=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(N(r.messages.whitespace,t.fullField))},ut,Me=function(){if(ut)return ut;var l="[a-fA-F\\d:]",t=function(b){return b&&b.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=(` (?: (?:`+i+":){7}(?:"+i+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 (?:`+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 (?:`+i+":){5}(?::"+e+"|(?::"+i+`){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4 (?:`+i+":){4}(?:(?::"+i+"){0,1}:"+e+"|(?::"+i+`){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4 (?:`+i+":){3}(?:(?::"+i+"){0,2}:"+e+"|(?::"+i+`){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4 (?:`+i+":){2}(?:(?::"+i+"){0,3}:"+e+"|(?::"+i+`){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4 (?:`+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 (?::(?:(?::`+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 )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1 `).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 ut=new RegExp("(?:^"+C+"$)","i"),ut},Wt={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},rt={integer:function(t){return rt.number(t)&&parseInt(t,10)===t},float:function(t){return rt.number(t)&&!rt.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"&&!rt.array(t)},method:function(t){return typeof t=="function"},email:function(t){return typeof t=="string"&&t.length<=320&&!!t.match(Wt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Me())},hex:function(t){return typeof t=="string"&&!!t.match(Wt.hex)}},He=function(t,e,i,s,r){if(t.required&&e===void 0){Vt(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?rt[n](e)||s.push(N(r.messages.types[n],t.fullField,t.type)):n&&typeof e!==t.type&&s.push(N(r.messages.types[n],t.fullField,t.type))},De=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(N(r.messages[f].len,t.fullField,t.len)):n&&!h&&d<t.min?s.push(N(r.messages[f].min,t.fullField,t.min)):h&&!n&&d>t.max?s.push(N(r.messages[f].max,t.fullField,t.max)):n&&h&&(d<t.min||d>t.max)&&s.push(N(r.messages[f].range,t.fullField,t.min,t.max))},Z="enum",Xe=function(t,e,i,s,r){t[Z]=Array.isArray(t[Z])?t[Z]:[],t[Z].indexOf(e)===-1&&s.push(N(r.messages[Z],t.fullField,t[Z].join(", ")))},Ne=function(t,e,i,s,r){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(N(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(N(r.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},L={required:Vt,whitespace:Ae,type:He,range:De,enum:Xe,pattern:Ne},Fe=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)},Be=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)},ke=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)},Ke=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)},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),H(e)||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(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),L.range(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(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)},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)}i(o)},$e="enum",qe=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[$e](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,"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)},Ue=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)},bt=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)},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)}i(o)},ot={string:Fe,method:Be,number:ke,boolean:Ke,regexp:Ye,integer:Ve,float:We,array:Pe,object:ze,enum:qe,pattern:Ge,date:je,url:bt,hex:bt,email:bt,required:Ue,any:Ze};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=Yt(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=Ct(w),c(w,p)):c(null,n)}if(h.messages){var f=this.messages();f===Rt&&(f=vt()),Yt(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=D({},n)),p=n[x]=y.transform(p)),typeof y=="function"?y={validator:y}:y=D({},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 Le(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 D({},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&&l.warning("async-validator:",O),O.length&&p.message!==void 0&&(O=[].concat(p.message));var I=O.map(Kt(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(Kt(p,n)):h.error&&(I=[h.error(p,N(h.messages.required,p.field))]),w(I);var _={};p.defaultField&&Object.keys(x.value).map(function(T){_[T]=p.defaultField}),_=D({},_,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 l(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&&!ot.hasOwnProperty(i.type))throw new Error(N("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"?ot.required:ot[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");ot[t]=e},nt.warning=Ft,nt.messages=Rt,nt.validators=ot;function Pt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(l){const t=Math.random()*16|0;return(l==="x"?t:t&3|8).toString(16)})}function zt(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 $t(l=[]){return l.length?l.map(t=>$t(t.children)+1).sort((t,e)=>e-t)[0]:0}function Je(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 qt(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=qt(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 Gt=/^(\r\n|\n\r|\r|\n)/,Qe=/^[^\t\r\n]+/,jt=/^\t/;function ti(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(jt))l=l.replace(jt,""),e+=1,t[i][e]="";else if(l.match(Gt))l=l.replace(Gt,""),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(Qe);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 ei(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(` `)>-1?r+=`"${o.replace(/"/g,'""')}"`:r+=o:o==null?r+="":r+=o;t!==e-1&&(r+=` `)}return r}function Ut(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 Zt(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 ii(l,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:r}=l,o=Ut(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 si(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=Zt(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 ri(l,t=document.documentElement){const e=l.startsWith("--")?l:`--${l}`;return getComputedStyle(t).getPropertyValue(e).trim()}class Jt{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 It extends Jt{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: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 oi{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,"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;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}`:Pt();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.g